withNative<T> method

T withNative<T>(
  1. T body(
    1. Pointer<wasm_functype_t> type
    )
)

Calls body with a freshly allocated wasm_functype_t.

The native type - and the value type vectors it owns - are released when body returns.

Implementation

T withNative<T>(T Function(ffi.Pointer<c.wasm_functype_t> type) body) =>
    scoped((arena) {
      final type = c.wasm_functype_new(
        _writeValTypes(arena, parameters),
        _writeValTypes(arena, results),
      );
      try {
        return body(type);
      } finally {
        c.wasm_functype_delete(type);
      }
    });