-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get multi.c
working in the Wasm C API
#1953
Conversation
lib/c-api/src/wasm_c_api/macros.rs
Outdated
pub unsafe extern "C" fn [<wasm_ $name _vec_delete>](ptr: Option<&mut[<wasm_ $name _vec_t>]>) { | ||
if let Some(vec) = ptr { | ||
if !vec.data.is_null() { | ||
let ptr: *mut Option<Box<[<wasm_ $name _t>]>> = vec.data as _; | ||
let data: Vec<Option<Box<[<wasm_ $name _t>]>>> = Vec::from_raw_parts(ptr, vec.size, vec.size); | ||
|
||
vec.data = ::std::ptr::null_mut(); | ||
vec.size = 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conflicts with #1949.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
bors r+ |
@@ -121,7 +121,7 @@ int main(int argc, const char* argv[]) { | |||
// Call. | |||
printf("Calling export...\n"); | |||
wasm_val_t vals[4] = { | |||
WASM_I32_VAL(1), WASM_I32_VAL(2), WASM_I32_VAL(3), WASM_I32_VAL(4) | |||
WASM_I32_VAL(1), WASM_I64_VAL(2), WASM_I64_VAL(3), WASM_I32_VAL(4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended? Did the code was updated in the wasm-c-api side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I linked to the PR on the Wasm C API above
Gets the
multi.c
example working.This PR has significant overlap with #1949 due to changes in vec / boxed vec.
Changes in this PR:
Clone
more often, implement*_copy
functions in terms ofClone
*_vec_copy
functions for boxed and unboxed versionswasm-c-api/examples/multi.c
; fixed in the upstream Wasm C API here: Fix typo inmulti.c
: args should be i32, i64, i64, i32 WebAssembly/wasm-c-api#163Review