externToDart function
Turns a filled wasmtime_extern_t into the matching wrapper and consumes it.
Implementation
Object? externToDart(WasmStore store, ffi.Pointer<c.wasmtime_extern_t> item) {
final value = item.ref;
final kind = WasmExternKind.fromC(value.kind);
try {
switch (kind) {
case WasmExternKind.func:
return WasmFunc.fromHandle(store, readFuncHandle(value.of.func));
case WasmExternKind.memory:
case WasmExternKind.sharedMemory:
return WasmMemory._(store, readMemoryHandle(value.of.memory));
case WasmExternKind.global:
return WasmGlobal._(store, readGlobalHandle(value.of.global));
case WasmExternKind.table:
return WasmTable._(store, readTableHandle(value.of.table));
case WasmExternKind.tag:
throw UnsupportedError('Exception tags are not supported.');
}
} finally {
c.wasmtime_extern_delete(item);
}
}