NitroWasmModule class final

A loaded nitro WASM module: the Emscripten Module object plus typed heap I/O and the module-allocator entry points generated bridges rely on.

All heap access is bulk (set/slice) — per-element access from Dart is a JS call per byte under dart2wasm, and cached views detach on memory growth.

Constructors

NitroWasmModule(String libName, EmscriptenModule module)

Properties

hashCode int
The hash code for this object.
no setterinherited
libName String
The nitro library name this module was registered under (@NitroModule.lib).
final
module EmscriptenModule
The raw Emscripten Module object.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addFunction(JSFunction<Function> f, String signature) int
Adds f to the module function table; the returned index is a C function pointer. signature uses Emscripten sig letters (v=void, i=i32, j=i64/BigInt, d=f64), return type first.
call(String cSymbol, List<JSAny?> args) JSAny?
Calls the exported C symbol cSymbol (without the leading underscore) with pre-converted JS arguments.
free(int ptr) → void
Frees a malloc allocation.
malloc(int byteCount) int
Dart-owned scratch memory (Emscripten malloc). Pair with free.
nitroAlloc(int byteCount) int
The module's <lib>_nitro_alloc — for buffers whose ownership transfers to native code (the C side frees them with its own free). size_t/void* are i32 on wasm32 — plain JS numbers, never BigInt.
nitroAllocBytes(Uint8List bytes) int
Copies bytes into a <lib>_nitro_alloc'd buffer — for framed payloads whose ownership transfers to native, such as a @HybridRecord returned from a Dart callback. The C side frees it with its own free.
nitroAllocCString(String s) int
Copies s into a <lib>_nitro_alloc'd NUL-terminated buffer — for values whose ownership transfers to native (e.g. callback string returns, which the bridge frees with its own free).
nitroFree(int ptr) → void
The module's <lib>_nitro_free — frees native-owned returns (strings, framed buffers) that crossed with ownership transfer to Dart.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
providesSymbol(String cSymbol) bool
True when the module exports cSymbol.
readBytes(int ptr, int len) Uint8List
Copies len bytes at ptr out of the module heap.
readCString(int ptr) String
Decodes a NUL-terminated C string at ptr (chunked scan — avoids a JS call per byte). Preserves a leading BOM, tolerates malformed UTF-8.
readF64(int ptr) double
readFramed(int ptr) Uint8List
Reads a framed buffer ([4B len][payload]) at ptr — the standard record/variant/map envelope — as one bulk copy of the whole frame.
readI32(int ptr) int
readI64(int ptr) int
readU32(int ptr) int
readU8(int ptr) int
removeFunction(int fnPtr) → void
Releases a function-table entry created by addFunction.
toString() String
A string representation of this object.
inherited
writeBytes(int ptr, Uint8List bytes) → void
Copies bytes into the module heap at ptr in one bulk write.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

encodeCString(String s) Uint8List
Encodes s as NUL-terminated UTF-8 bytes (not yet in the heap — copy in via a WasmArena or writeBytes).