-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: handle ref/non-ref case with rigor (#608)
Match numeric runtime vals on ref/non-ref.
- Loading branch information
Zeeshan Lakhani
authored
Mar 8, 2024
1 parent
b44d0d5
commit 422cca1
Showing
16 changed files
with
13,896 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "homestar-functions-subtract" | ||
publish = false | ||
version = "0.1.0" | ||
edition = { workspace = true } | ||
rust-version = { workspace = true } | ||
|
||
[dependencies] | ||
wit-bindgen-rt = "0.20.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[package.metadata.component] | ||
package = "component:homestar-functions-subtract" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Generated by `wit-bindgen` 0.20.0. DO NOT EDIT! | ||
// Options used: | ||
|
||
#[doc(hidden)] | ||
#[allow(non_snake_case)] | ||
pub unsafe fn _export_subtract_cabi<T: Guest>(arg0: f64, arg1: f64) -> f64 { | ||
let result0 = T::subtract(arg0, arg1); | ||
_rt::as_f64(result0) | ||
} | ||
pub trait Guest { | ||
fn subtract(a: f64, b: f64) -> f64; | ||
} | ||
#[doc(hidden)] | ||
|
||
macro_rules! __export_world_subtract_cabi{ | ||
($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { | ||
|
||
|
||
#[export_name = "subtract"] | ||
unsafe extern "C" fn export_subtract(arg0: f64,arg1: f64,) -> f64 { | ||
$($path_to_types)*::_export_subtract_cabi::<$ty>(arg0, arg1) | ||
} | ||
};); | ||
} | ||
#[doc(hidden)] | ||
pub(crate) use __export_world_subtract_cabi; | ||
mod _rt { | ||
|
||
pub fn as_f64<T: AsF64>(t: T) -> f64 { | ||
t.as_f64() | ||
} | ||
|
||
pub trait AsF64 { | ||
fn as_f64(self) -> f64; | ||
} | ||
|
||
impl<'a, T: Copy + AsF64> AsF64 for &'a T { | ||
fn as_f64(self) -> f64 { | ||
(*self).as_f64() | ||
} | ||
} | ||
|
||
impl AsF64 for f64 { | ||
#[inline] | ||
fn as_f64(self) -> f64 { | ||
self as f64 | ||
} | ||
} | ||
} | ||
|
||
/// Generates `#[no_mangle]` functions to export the specified type as the | ||
/// root implementation of all generated traits. | ||
/// | ||
/// For more information see the documentation of `wit_bindgen::generate!`. | ||
/// | ||
/// ```rust | ||
/// # macro_rules! export{ ($($t:tt)*) => (); } | ||
/// # trait Guest {} | ||
/// struct MyType; | ||
/// | ||
/// impl Guest for MyType { | ||
/// // ... | ||
/// } | ||
/// | ||
/// export!(MyType); | ||
/// ``` | ||
#[allow(unused_macros)] | ||
#[doc(hidden)] | ||
|
||
macro_rules! __export_subtract_impl { | ||
($ty:ident) => (self::export!($ty with_types_in self);); | ||
($ty:ident with_types_in $($path_to_types_root:tt)*) => ( | ||
$($path_to_types_root)*::__export_world_subtract_cabi!($ty with_types_in $($path_to_types_root)*); | ||
) | ||
} | ||
#[doc(inline)] | ||
pub(crate) use __export_subtract_impl as export; | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
#[link_section = "component-type:wit-bindgen:0.20.0:subtract:encoded world"] | ||
#[doc(hidden)] | ||
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 197] = *b"\ | ||
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07G\x01A\x02\x01A\x02\x01\ | ||
@\x02\x01au\x01bu\0u\x04\0\x08subtract\x01\0\x04\x01$homestar-functions:subtract\ | ||
/subtract\x04\0\x0b\x0e\x01\0\x08subtract\x03\0\0\0G\x09producers\x01\x0cprocess\ | ||
ed-by\x02\x0dwit-component\x070.201.0\x10wit-bindgen-rust\x060.20.0"; | ||
|
||
#[inline(never)] | ||
#[doc(hidden)] | ||
#[cfg(target_arch = "wasm32")] | ||
pub fn __link_custom_section_describing_imports() { | ||
wit_bindgen_rt::maybe_link_cabi_realloc(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#[allow(clippy::all)] | ||
#[rustfmt::skip] | ||
mod bindings; | ||
|
||
use bindings::Guest; | ||
|
||
struct Component; | ||
|
||
impl Guest for Component { | ||
fn subtract(a: f64, b: f64) -> f64 { | ||
a - b | ||
} | ||
} | ||
|
||
bindings::export!(Component with_types_in bindings); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package homestar-functions:subtract; | ||
|
||
world subtract { | ||
export subtract: func(a: float64, b: float64) -> float64; | ||
} |
Binary file not shown.
Oops, something went wrong.