You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using wasmer on the web (wasmer itself is compiled to WASM and then loads another WASM module) with the js feature, you cannot pass u32 and u64 as arguments from / to functions, because those types do not implement NativeWasmTypeInto.
Proposed solution
Implement NativeWasmTypeInto for u32 and u64.
Alternatives
You can, of course, cast your unsigned integers to signed integers, but it is kind of annoying. Example:
// Plugin:#[no_mangle]pubfnadd_ten(value:u32) -> u32{
value + 10}// Host, current workaround:letmut value:u32 = 50;let add_ten = instance
.exports.get_typed_function::<i32,i32>(&store,"add_ten").unwrap();
value = take_u32.call(&mut store, value asi32).unwrap()asu32;// Host, with proposed change:letmut value:u32 = 50;let add_ten = instance
.exports.get_typed_function::<u32,u32>(&store,"add_ten").unwrap();
value = take_u32.call(&mut store, value).unwrap();
Additional context
Not sure if implementing NativeWasmTypeInto for u8 / u16 / i8 / i16 makes sense in the same way, but that can be another feature request.
The text was updated successfully, but these errors were encountered:
Motivation
When using wasmer on the web (wasmer itself is compiled to WASM and then loads another WASM module) with the
js
feature, you cannot passu32
andu64
as arguments from / to functions, because those types do not implementNativeWasmTypeInto
.Proposed solution
Implement
NativeWasmTypeInto
foru32
andu64
.Alternatives
You can, of course, cast your unsigned integers to signed integers, but it is kind of annoying. Example:
Additional context
Not sure if implementing
NativeWasmTypeInto
foru8
/u16
/i8
/i16
makes sense in the same way, but that can be another feature request.The text was updated successfully, but these errors were encountered: