summaryrefslogtreecommitdiff
path: root/wasm2c/examples/callback
diff options
context:
space:
mode:
Diffstat (limited to 'wasm2c/examples/callback')
-rw-r--r--wasm2c/examples/callback/callback.wat2
-rw-r--r--wasm2c/examples/callback/main.c17
2 files changed, 10 insertions, 9 deletions
diff --git a/wasm2c/examples/callback/callback.wat b/wasm2c/examples/callback/callback.wat
index 6a8ab233..9786209a 100644
--- a/wasm2c/examples/callback/callback.wat
+++ b/wasm2c/examples/callback/callback.wat
@@ -1,7 +1,7 @@
;; Module demonstrating use of a host-installed callback function.
;; The type of the callback function. The type ID can be looked up outside the module by calling
-;; Z_[modname]_get_func_type(1, 0, WASM_RT_I32) (indicating 1 param, 0 results, param type is i32).
+;; wasm2c_[modname]_get_func_type(1, 0, WASM_RT_I32) (indicating 1 param, 0 results, param type is i32).
(type $print_type (func (param i32)))
;; An indirect function table to hold the callback function
diff --git a/wasm2c/examples/callback/main.c b/wasm2c/examples/callback/main.c
index b0b37d46..8c6f9db0 100644
--- a/wasm2c/examples/callback/main.c
+++ b/wasm2c/examples/callback/main.c
@@ -6,8 +6,8 @@
* The callback function. Prints the null-terminated string at the given
* location in the instance's exported memory.
*/
-void print(Z_callback_instance_t* instance, uint32_t ptr) {
- puts(Z_callbackZ_memory(instance)->data + ptr);
+void print(w2c_callback* instance, uint32_t ptr) {
+ puts(w2c_callback_memory(instance)->data + ptr);
}
int main(int argc, char** argv) {
@@ -15,8 +15,8 @@ int main(int argc, char** argv) {
wasm_rt_init();
/* Instantiate the callback module. */
- Z_callback_instance_t inst;
- Z_callback_instantiate(&inst);
+ w2c_callback inst;
+ wasm2c_callback_instantiate(&inst);
/*
* Call the module's "set_print_function" function, which takes a funcref to
@@ -24,15 +24,16 @@ int main(int argc, char** argv) {
* looked up with "Z_callback_get_func_type"), a pointer to the function, and
* a module instance pointer that will be passed to the function when called.
*/
- wasm_rt_func_type_t fn_type = Z_callback_get_func_type(1, 0, WASM_RT_I32);
+ wasm_rt_func_type_t fn_type =
+ wasm2c_callback_get_func_type(1, 0, WASM_RT_I32);
wasm_rt_funcref_t fn_ref = {fn_type, (wasm_rt_function_ptr_t)print, &inst};
- Z_callbackZ_set_print_function(&inst, fn_ref);
+ w2c_callback_set_print_function(&inst, fn_ref);
/* "say_hello" uses the previously installed callback. */
- Z_callbackZ_say_hello(&inst);
+ w2c_callback_say_hello(&inst);
/* Free the module instance and the Wasm runtime state. */
- Z_callback_free(&inst);
+ wasm2c_callback_free(&inst);
wasm_rt_free();
return 0;