refactor: merge get_outputs macros into define_node and include_definition

This commit is contained in:
2024-04-16 13:58:10 +02:00
parent 097b99ef55
commit 8f594aebe3
19 changed files with 130 additions and 149 deletions

View File

@@ -1,10 +1,15 @@
{
"value": {
"type": "float",
"value": 4.2
},
"amount": {
"type": "integer",
"value": 2
"outputs": [
"float"
],
"inputs": {
"value": {
"type": "float",
"value": 4.2
},
"amount": {
"type": "integer",
"value": 2
}
}
}

View File

@@ -1,11 +1,8 @@
use macros::generate_input_types_file;
use utils::{evaluate_args, generate_outputs, get_args};
use macros::include_definition_file;
use utils::{evaluate_args, get_args};
use wasm_bindgen::prelude::*;
// use web_sys::console;
generate_outputs!(["float"]);
generate_input_types_file!("src/input.json");
include_definition_file!("src/input.json");
#[wasm_bindgen]
pub fn execute(input: &[i32]) -> Vec<i32> {

View File

@@ -1,7 +1,12 @@
{
"value": {
"type": "float",
"value": 0.1,
"internal": true
"outputs": [
"float"
],
"inputs": {
"value": {
"type": "float",
"value": 0.1,
"internal": true
}
}
}

View File

@@ -1,9 +1,7 @@
use macros::generate_input_types_file;
use utils::generate_outputs;
use macros::include_definition_file;
use wasm_bindgen::prelude::*;
generate_outputs!(["float"]);
generate_input_types_file!("src/input.json");
include_definition_file!("src/input.json");
#[wasm_bindgen]
pub fn execute(args: &[i32]) -> Vec<i32> {

View File

@@ -1,27 +1,32 @@
{
"op_type": {
"label": "type",
"type": "select",
"labels": [
"add",
"subtract",
"multiply",
"divide"
],
"internal": true,
"value": 0
},
"a": {
"type": "float",
"value": 2
},
"b": {
"type": "float",
"value": 2
},
"clip": {
"type": "boolean",
"value": 0,
"setting": "math.clipping"
"outputs": [
"float"
],
"inputs": {
"op_type": {
"label": "type",
"type": "select",
"labels": [
"add",
"subtract",
"multiply",
"divide"
],
"internal": true,
"value": 0
},
"a": {
"type": "float",
"value": 2
},
"b": {
"type": "float",
"value": 2
},
"clip": {
"type": "boolean",
"value": 0,
"setting": "math.clipping"
}
}
}

View File

@@ -1,10 +1,7 @@
use macros::generate_input_types_file;
use utils::generate_outputs;
use macros::include_definition_file;
use wasm_bindgen::prelude::*;
generate_outputs!(["float"]);
generate_input_types_file!("src/input.json");
include_definition_file!("src/input.json");
#[wasm_bindgen]
pub fn execute(args: &[i32]) -> Vec<i32> {

View File

@@ -1,6 +1,9 @@
{
"input": {
"type": "plant",
"external": true
"outputs": [],
"inputs": {
"input": {
"type": "plant",
"external": true
}
}
}

View File

@@ -1,8 +1,8 @@
use macros::generate_input_types_file;
use macros::include_definition_file;
use utils::evaluate_args;
use wasm_bindgen::prelude::*;
generate_input_types_file!("src/inputs.json");
include_definition_file!("src/inputs.json");
#[wasm_bindgen]
pub fn execute(args: &[i32]) -> Vec<i32> {

View File

@@ -1,26 +1,16 @@
use macros::define_node;
use wasm_bindgen::prelude::*;
// lifted from the `console_log` example
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
fn log(s: &str);
}
#[wasm_bindgen]
pub fn get_outputs() -> Vec<String> {
vec!["float".to_string()]
}
#[wasm_bindgen]
pub fn get_input_types() -> String {
define_node!(
r#"{
"min": { "type": "float", "value": 2 },
"max": { "type": "float", "value": 2 },
"seed": { "type": "seed" }
"outputs": ["float"],
"inputs": {
"min": { "type": "float", "value": 2 },
"max": { "type": "float", "value": 2 },
"seed": { "type": "seed" }
}
}"#
.to_string()
}
);
#[wasm_bindgen]
pub fn execute(args: &[i32]) -> Vec<i32> {

View File

@@ -1,15 +1,20 @@
{
"length": {
"type": "float",
"value": 2
},
"thickness": {
"type": "float",
"value": 2
},
"resolution": {
"type": "integer",
"value": 32,
"setting": "resolution.stem"
"outputs": [
"plant"
],
"inputs": {
"length": {
"type": "float",
"value": 2
},
"thickness": {
"type": "float",
"value": 2
},
"resolution": {
"type": "integer",
"value": 32,
"setting": "resolution.stem"
}
}
}

View File

@@ -1,10 +1,9 @@
use macros::generate_input_types_file;
use utils::{evaluate_args, generate_outputs, get_args};
use macros::include_definition_file;
use utils::{evaluate_args, get_args};
use wasm_bindgen::prelude::*;
use web_sys::console;
generate_outputs!(["plant"]);
generate_input_types_file!("src/input.json");
include_definition_file!("src/input.json");
#[wasm_bindgen]
pub fn execute(input: &[i32]) -> Vec<i32> {

View File

@@ -1,7 +1,12 @@
{
"array": {
"type": "float",
"value": 2,
"external": true
"outputs": [
"float"
],
"inputs": {
"array": {
"type": "float",
"value": 2,
"external": true
}
}
}

View File

@@ -1,10 +1,8 @@
use macros::generate_input_types_file;
use utils::{decode_float, encode_float, generate_outputs};
use macros::include_definition_file;
use utils::{decode_float, encode_float};
use wasm_bindgen::prelude::*;
generate_outputs!(["float"]);
generate_input_types_file!("src/input.json");
include_definition_file!("src/input.json");
#[wasm_bindgen]
pub fn execute(input: &[i32]) -> Vec<i32> {