feat: some shit
This commit is contained in:
10
nodes/add/.vscode/settings.json
vendored
Normal file
10
nodes/add/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"rust-analyzer.check.overrideCommand": [
|
||||
"cargo",
|
||||
"component",
|
||||
"check",
|
||||
"--workspace",
|
||||
"--all-targets",
|
||||
"--message-format=json"
|
||||
],
|
||||
}
|
||||
17
nodes/add/Cargo.toml
Normal file
17
nodes/add/Cargo.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "add"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
wit-bindgen = { version = "0.19.2", default-features = false, features = [
|
||||
"realloc",
|
||||
] }
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[package.metadata.component]
|
||||
package = "component:add"
|
||||
|
||||
[package.metadata.component.dependencies]
|
||||
95
nodes/add/src/bindings.rs
Normal file
95
nodes/add/src/bindings.rs
Normal file
@@ -0,0 +1,95 @@
|
||||
// Generated by `wit-bindgen` 0.18.0. DO NOT EDIT!
|
||||
const _: () = {
|
||||
|
||||
#[doc(hidden)]
|
||||
#[export_name = "execute"]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn __export_execute(arg0: i32,arg1: i32,) -> i32 {
|
||||
#[allow(unused_imports)]
|
||||
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||
|
||||
// Before executing any other code, use this function to run all static
|
||||
// constructors, if they have not yet been run. This is a hack required
|
||||
// to work around wasi-libc ctors calling import functions to initialize
|
||||
// the environment.
|
||||
//
|
||||
// This functionality will be removed once rust 1.69.0 is stable, at which
|
||||
// point wasi-libc will no longer have this behavior.
|
||||
//
|
||||
// See
|
||||
// https://github.com/bytecodealliance/preview2-prototyping/issues/99
|
||||
// for more details.
|
||||
#[cfg(target_arch="wasm32")]
|
||||
wit_bindgen::rt::run_ctors_once();
|
||||
|
||||
let result0 = <_GuestImpl as Guest>::execute(arg0, arg1);
|
||||
wit_bindgen::rt::as_i32(result0)
|
||||
}
|
||||
};
|
||||
const _: () = {
|
||||
|
||||
#[doc(hidden)]
|
||||
#[export_name = "get-definition"]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn __export_get_definition() -> i32 {
|
||||
#[allow(unused_imports)]
|
||||
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||
|
||||
// Before executing any other code, use this function to run all static
|
||||
// constructors, if they have not yet been run. This is a hack required
|
||||
// to work around wasi-libc ctors calling import functions to initialize
|
||||
// the environment.
|
||||
//
|
||||
// This functionality will be removed once rust 1.69.0 is stable, at which
|
||||
// point wasi-libc will no longer have this behavior.
|
||||
//
|
||||
// See
|
||||
// https://github.com/bytecodealliance/preview2-prototyping/issues/99
|
||||
// for more details.
|
||||
#[cfg(target_arch="wasm32")]
|
||||
wit_bindgen::rt::run_ctors_once();
|
||||
|
||||
let result0 = <_GuestImpl as Guest>::get_definition();
|
||||
let ptr1 = _RET_AREA.0.as_mut_ptr() as i32;
|
||||
let vec2 = (result0.into_bytes()).into_boxed_slice();
|
||||
let ptr2 = vec2.as_ptr() as i32;
|
||||
let len2 = vec2.len() as i32;
|
||||
::core::mem::forget(vec2);
|
||||
*((ptr1 + 4) as *mut i32) = len2;
|
||||
*((ptr1 + 0) as *mut i32) = ptr2;
|
||||
ptr1
|
||||
}
|
||||
|
||||
const _: () = {
|
||||
#[doc(hidden)]
|
||||
#[export_name = "cabi_post_get-definition"]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn __post_return_get_definition(arg0: i32,) {
|
||||
let l0 = *((arg0 + 0) as *const i32);
|
||||
let l1 = *((arg0 + 4) as *const i32);
|
||||
wit_bindgen::rt::dealloc(l0, (l1) as usize, 1);
|
||||
}
|
||||
};
|
||||
};
|
||||
use super::Component as _GuestImpl;
|
||||
pub trait Guest {
|
||||
fn execute(left: i32,right: i32,) -> i32;
|
||||
fn get_definition() -> wit_bindgen::rt::string::String;
|
||||
}
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||
|
||||
#[repr(align(4))]
|
||||
struct _RetArea([u8; 8]);
|
||||
static mut _RET_AREA: _RetArea = _RetArea([0; 8]);
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[link_section = "component-type:example"]
|
||||
#[doc(hidden)]
|
||||
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 210] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 86, 1, 65, 2, 1, 65, 4, 1, 64, 2, 4, 108, 101, 102, 116, 122, 5, 114, 105, 103, 104, 116, 122, 0, 122, 4, 0, 7, 101, 120, 101, 99, 117, 116, 101, 1, 0, 1, 64, 0, 0, 115, 4, 0, 14, 103, 101, 116, 45, 100, 101, 102, 105, 110, 105, 116, 105, 111, 110, 1, 1, 4, 1, 21, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 97, 100, 100, 47, 101, 120, 97, 109, 112, 108, 101, 4, 0, 11, 13, 1, 0, 7, 101, 120, 97, 109, 112, 108, 101, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48];
|
||||
|
||||
#[inline(never)]
|
||||
#[doc(hidden)]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn __link_section() {}
|
||||
16
nodes/add/src/lib.rs
Normal file
16
nodes/add/src/lib.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
mod bindings;
|
||||
|
||||
use bindings::Guest;
|
||||
|
||||
struct Component;
|
||||
|
||||
impl Guest for Component {
|
||||
/// Say hello!
|
||||
fn execute(left: i32, right: i32) -> i32 {
|
||||
left + right
|
||||
}
|
||||
fn get_definition() -> String {
|
||||
let definition = include_str!("./node.json");
|
||||
definition.to_string()
|
||||
}
|
||||
}
|
||||
17
nodes/add/src/node.json
Normal file
17
nodes/add/src/node.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"inputs": {
|
||||
"left": {
|
||||
"type": "integer",
|
||||
"default": 50,
|
||||
"min": 0,
|
||||
"max": 255
|
||||
},
|
||||
"right": {
|
||||
"type": "integer",
|
||||
"default": 50,
|
||||
"min": 0,
|
||||
"max": 255
|
||||
}
|
||||
},
|
||||
"outputs": ["integer"]
|
||||
}
|
||||
7
nodes/add/wit/world.wit
Normal file
7
nodes/add/wit/world.wit
Normal file
@@ -0,0 +1,7 @@
|
||||
package component:add;
|
||||
|
||||
/// An example world for the component to target.
|
||||
world example {
|
||||
export execute: func(left: s32, right: s32) -> s32;
|
||||
export get-definition: func() -> string;
|
||||
}
|
||||
11
nodes/multiply/Cargo.toml
Normal file
11
nodes/multiply/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "multiply"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = "0.2.91"
|
||||
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
10
nodes/multiply/src/lib.rs
Normal file
10
nodes/multiply/src/lib.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
#[no_mangle]
|
||||
pub extern "C" fn execute(a: u32, b: u32) -> u32 {
|
||||
a + b
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn get_definition() -> String {
|
||||
let bytes = include_str!("./node.json");
|
||||
bytes.to_string()
|
||||
}
|
||||
17
nodes/multiply/src/node.json
Normal file
17
nodes/multiply/src/node.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"inputs": {
|
||||
"left": {
|
||||
"type": "integer",
|
||||
"default": 50,
|
||||
"min": 0,
|
||||
"max": 255
|
||||
},
|
||||
"right": {
|
||||
"type": "integer",
|
||||
"default": 50,
|
||||
"min": 0,
|
||||
"max": 255
|
||||
}
|
||||
},
|
||||
"outputs": ["integer"]
|
||||
}
|
||||
10
nodes/subtract/.vscode/settings.json
vendored
Normal file
10
nodes/subtract/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"rust-analyzer.check.overrideCommand": [
|
||||
"cargo",
|
||||
"component",
|
||||
"check",
|
||||
"--workspace",
|
||||
"--all-targets",
|
||||
"--message-format=json"
|
||||
],
|
||||
}
|
||||
17
nodes/subtract/Cargo.toml
Normal file
17
nodes/subtract/Cargo.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "subtract"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
wit-bindgen = { version = "0.19.2", default-features = false, features = [
|
||||
"realloc",
|
||||
] }
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[package.metadata.component]
|
||||
package = "component:subtract"
|
||||
|
||||
[package.metadata.component.dependencies]
|
||||
95
nodes/subtract/src/bindings.rs
Normal file
95
nodes/subtract/src/bindings.rs
Normal file
@@ -0,0 +1,95 @@
|
||||
// Generated by `wit-bindgen` 0.18.0. DO NOT EDIT!
|
||||
const _: () = {
|
||||
|
||||
#[doc(hidden)]
|
||||
#[export_name = "execute"]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn __export_execute(arg0: i32,arg1: i32,) -> i32 {
|
||||
#[allow(unused_imports)]
|
||||
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||
|
||||
// Before executing any other code, use this function to run all static
|
||||
// constructors, if they have not yet been run. This is a hack required
|
||||
// to work around wasi-libc ctors calling import functions to initialize
|
||||
// the environment.
|
||||
//
|
||||
// This functionality will be removed once rust 1.69.0 is stable, at which
|
||||
// point wasi-libc will no longer have this behavior.
|
||||
//
|
||||
// See
|
||||
// https://github.com/bytecodealliance/preview2-prototyping/issues/99
|
||||
// for more details.
|
||||
#[cfg(target_arch="wasm32")]
|
||||
wit_bindgen::rt::run_ctors_once();
|
||||
|
||||
let result0 = <_GuestImpl as Guest>::execute(arg0, arg1);
|
||||
wit_bindgen::rt::as_i32(result0)
|
||||
}
|
||||
};
|
||||
const _: () = {
|
||||
|
||||
#[doc(hidden)]
|
||||
#[export_name = "get-definition"]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn __export_get_definition() -> i32 {
|
||||
#[allow(unused_imports)]
|
||||
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||
|
||||
// Before executing any other code, use this function to run all static
|
||||
// constructors, if they have not yet been run. This is a hack required
|
||||
// to work around wasi-libc ctors calling import functions to initialize
|
||||
// the environment.
|
||||
//
|
||||
// This functionality will be removed once rust 1.69.0 is stable, at which
|
||||
// point wasi-libc will no longer have this behavior.
|
||||
//
|
||||
// See
|
||||
// https://github.com/bytecodealliance/preview2-prototyping/issues/99
|
||||
// for more details.
|
||||
#[cfg(target_arch="wasm32")]
|
||||
wit_bindgen::rt::run_ctors_once();
|
||||
|
||||
let result0 = <_GuestImpl as Guest>::get_definition();
|
||||
let ptr1 = _RET_AREA.0.as_mut_ptr() as i32;
|
||||
let vec2 = (result0.into_bytes()).into_boxed_slice();
|
||||
let ptr2 = vec2.as_ptr() as i32;
|
||||
let len2 = vec2.len() as i32;
|
||||
::core::mem::forget(vec2);
|
||||
*((ptr1 + 4) as *mut i32) = len2;
|
||||
*((ptr1 + 0) as *mut i32) = ptr2;
|
||||
ptr1
|
||||
}
|
||||
|
||||
const _: () = {
|
||||
#[doc(hidden)]
|
||||
#[export_name = "cabi_post_get-definition"]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn __post_return_get_definition(arg0: i32,) {
|
||||
let l0 = *((arg0 + 0) as *const i32);
|
||||
let l1 = *((arg0 + 4) as *const i32);
|
||||
wit_bindgen::rt::dealloc(l0, (l1) as usize, 1);
|
||||
}
|
||||
};
|
||||
};
|
||||
use super::Component as _GuestImpl;
|
||||
pub trait Guest {
|
||||
fn execute(left: i32,right: i32,) -> i32;
|
||||
fn get_definition() -> wit_bindgen::rt::string::String;
|
||||
}
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||
|
||||
#[repr(align(4))]
|
||||
struct _RetArea([u8; 8]);
|
||||
static mut _RET_AREA: _RetArea = _RetArea([0; 8]);
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[link_section = "component-type:example"]
|
||||
#[doc(hidden)]
|
||||
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 215] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 91, 1, 65, 2, 1, 65, 4, 1, 64, 2, 4, 108, 101, 102, 116, 122, 5, 114, 105, 103, 104, 116, 122, 0, 122, 4, 0, 7, 101, 120, 101, 99, 117, 116, 101, 1, 0, 1, 64, 0, 0, 115, 4, 0, 14, 103, 101, 116, 45, 100, 101, 102, 105, 110, 105, 116, 105, 111, 110, 1, 1, 4, 1, 26, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 115, 117, 98, 116, 114, 97, 99, 116, 47, 101, 120, 97, 109, 112, 108, 101, 4, 0, 11, 13, 1, 0, 7, 101, 120, 97, 109, 112, 108, 101, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48];
|
||||
|
||||
#[inline(never)]
|
||||
#[doc(hidden)]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn __link_section() {}
|
||||
16
nodes/subtract/src/lib.rs
Normal file
16
nodes/subtract/src/lib.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
mod bindings;
|
||||
|
||||
use bindings::Guest;
|
||||
|
||||
struct Component;
|
||||
|
||||
impl Guest for Component {
|
||||
/// Say hello!
|
||||
fn execute(left: i32, right: i32) -> i32 {
|
||||
left - right
|
||||
}
|
||||
fn get_definition() -> String {
|
||||
let definition = include_str!("./node.json");
|
||||
definition.to_string()
|
||||
}
|
||||
}
|
||||
17
nodes/subtract/src/node.json
Normal file
17
nodes/subtract/src/node.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"inputs": {
|
||||
"left": {
|
||||
"type": "integer",
|
||||
"default": 50,
|
||||
"min": 0,
|
||||
"max": 255
|
||||
},
|
||||
"right": {
|
||||
"type": "integer",
|
||||
"default": 50,
|
||||
"min": 0,
|
||||
"max": 255
|
||||
}
|
||||
},
|
||||
"outputs": ["integer"]
|
||||
}
|
||||
7
nodes/subtract/wit/world.wit
Normal file
7
nodes/subtract/wit/world.wit
Normal file
@@ -0,0 +1,7 @@
|
||||
package component:subtract;
|
||||
|
||||
/// An example world for the component to target.
|
||||
world example {
|
||||
export execute: func(left: s32, right: s32) -> s32;
|
||||
export get-definition: func() -> string;
|
||||
}
|
||||
Reference in New Issue
Block a user