Skip to content

Commit 029434b

Browse files
committed
feat: Add wasm_module_name and wasm_module_set_name.
This patch proposes 2 new functions to handle module's name: * `wasm_module_name` that writes the module's name in a `wasm_name_t` if any, * `wasm_module_set_name` that sets the module's name if possible. `wasm_module_set_name` returns `true` if the module's name has been updated succesfully, `false` otherwise, e.g. if the name is invalid, or if it's not possible to update it (e.g. if the module is already instantiated).
1 parent 3a31b7e commit 029434b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

include/wasm.h

+3
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ WASM_API_EXTERN own wasm_module_t* wasm_module_new(
402402

403403
WASM_API_EXTERN bool wasm_module_validate(wasm_store_t*, const wasm_byte_vec_t* binary);
404404

405+
WASM_API_EXTERN void wasm_module_name(const wasm_module_t*, own wasm_name_t* out);
406+
WASM_API_EXTERN bool wasm_module_set_name(const wasm_module_t*, const wasm_name_t* name);
407+
405408
WASM_API_EXTERN void wasm_module_imports(const wasm_module_t*, own wasm_importtype_vec_t* out);
406409
WASM_API_EXTERN void wasm_module_exports(const wasm_module_t*, own wasm_exporttype_vec_t* out);
407410

include/wasm.hh

+3
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ public:
595595
static auto make(Store*, const vec<byte_t>& binary) -> own<Module>;
596596
auto copy() const -> own<Module>;
597597

598+
auto name() const -> vec<byte_t>;
599+
auto set_name(const vec<byte_t>&) -> bool;
600+
598601
auto imports() const -> ownvec<ImportType>;
599602
auto exports() const -> ownvec<ExportType>;
600603

0 commit comments

Comments
 (0)