Add a simple callback native function
This commit is contained in:
parent
bdbc1568ba
commit
05bf984212
|
@ -44,6 +44,12 @@ struct hb_wasm_face_data_t {
|
||||||
wasm_module_t wasm_module;
|
wasm_module_t wasm_module;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
static void debugprint(wasm_exec_env_t exec_env, char *the_string, uint8_t len) {
|
||||||
|
printf("%*s", len, the_string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
init_wasm ()
|
init_wasm ()
|
||||||
{
|
{
|
||||||
|
@ -61,21 +67,12 @@ init_wasm ()
|
||||||
// https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/export_native_api.md
|
// https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/export_native_api.md
|
||||||
|
|
||||||
static NativeSymbol native_symbols[] = {
|
static NativeSymbol native_symbols[] = {
|
||||||
#if 0
|
{
|
||||||
{
|
"debugprint",
|
||||||
"intToStr", // the name of WASM function name
|
(void *)debugprint,
|
||||||
intToStr, // the native function pointer
|
"($i)",
|
||||||
"(i*~i)i", // the function prototype signature, avoid to use i32
|
NULL
|
||||||
NULL // attachment is NULL
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"get_pow", // the name of WASM function name
|
|
||||||
get_pow, // the native function pointer
|
|
||||||
"(ii)i", // the function prototype signature, avoid to use i32
|
|
||||||
NULL // attachment is NULL
|
|
||||||
},
|
|
||||||
{ "calculate_native", calculate_native, "(iii)i", NULL }
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
init_args.mem_alloc_type = Alloc_With_Allocator;
|
init_args.mem_alloc_type = Alloc_With_Allocator;
|
||||||
|
|
Loading…
Reference in New Issue