Update wasm_c_api to use vector types (#751)
The WASM C API now requires the use of vector types in certain apis. Switching WAMR to use the new call signatures improves "drop in" compilation compatibility between WAMR and other implementations from a C-api embedding program's perspective. * wasm_func_callback_t type has been updated to use wasm_val_vec_t * wasm_func_callback_with_env_t type has been updated to use wasm_val_vec_t * wasm_func_call() has been updated to use wasm_val_vec_t * wasm_instance_new() has been updated to use wasm_extern_vec_t* * wasm_instance_new_with_args() has been updated to use wasm_extern_vec_t* * wasm_runtime_invoke_c_api_native() has been updated to support vector types in native callbacks without modifying the contract with the interpreter code. * All users of the modified functions (including samples/wasm-c-api/src/*.c) have been appropriately updated.
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
|
||||
// A function to be called from Wasm code.
|
||||
own wasm_trap_t* fail_callback(
|
||||
void* env, const wasm_val_t args[], wasm_val_t results[]
|
||||
void* env, const wasm_val_vec_t* args, wasm_val_vec_t* results
|
||||
) {
|
||||
printf("Calling back...\n");
|
||||
own wasm_name_t message;
|
||||
@ -80,9 +80,10 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
// Instantiate.
|
||||
printf("Instantiating module...\n");
|
||||
const wasm_extern_t* imports[] = { wasm_func_as_extern(fail_func) };
|
||||
wasm_extern_vec_t imports;
|
||||
wasm_extern_vec_new(&imports, 1, (wasm_extern_t* []) { wasm_func_as_extern(fail_func) });
|
||||
own wasm_instance_t* instance =
|
||||
wasm_instance_new(store, module, imports, NULL);
|
||||
wasm_instance_new(store, module, &imports, NULL);
|
||||
if (!instance) {
|
||||
printf("> Error instantiating module!\n");
|
||||
return 1;
|
||||
@ -111,8 +112,10 @@ int main(int argc, const char* argv[]) {
|
||||
}
|
||||
|
||||
printf("Calling export %d...\n", i);
|
||||
wasm_val_t results[1]; \
|
||||
own wasm_trap_t* trap = wasm_func_call(func, NULL, results);
|
||||
|
||||
wasm_val_vec_t results;
|
||||
wasm_val_vec_new_uninitialized(&results, 1);
|
||||
own wasm_trap_t* trap = wasm_func_call(func, NULL, &results);
|
||||
if (!trap) {
|
||||
printf("> Error calling function, expected trap!\n");
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user