Skip to content

Commit f277b2c

Browse files
committed
capi: find_exported_function
1 parent b375946 commit f277b2c

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

include/fizzy/fizzy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ struct FizzyModule* fizzy_parse(const uint8_t* wasm_binary, size_t wasm_binary_s
7171
/// Should be called unless @p module was passed to fizzy_instantiate.
7272
void fizzy_free_module(struct FizzyModule* module);
7373

74+
bool fizzy_find_exported_function(
75+
const struct FizzyModule* module, const char* name, uint32_t* out_func_idx);
76+
7477
/// Instantiate a module.
7578
/// Takes ownership of module, i.e. @p module is invalidated after this call.
7679
///

lib/fizzy/capi.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ void fizzy_free_module(FizzyModule* module)
109109
delete module;
110110
}
111111

112+
bool fizzy_find_exported_function(
113+
const struct FizzyModule* module, const char* name, uint32_t* out_func_idx)
114+
{
115+
const auto optional_func_idx = fizzy::find_exported_function(module->module, name);
116+
if (!optional_func_idx)
117+
return false;
118+
119+
*out_func_idx = *optional_func_idx;
120+
return true;
121+
}
122+
112123
FizzyInstance* fizzy_instantiate(FizzyModule* module,
113124
const FizzyExternalFunction* imported_functions, size_t imported_functions_size)
114125
{

0 commit comments

Comments
 (0)