init static method

void init([
  1. int pointerSizeBytes = 4
])

Must be called before working with web_ffi to initalize all type sizes.

The optional parameter pointerSizeBytes can be used to adjust the size of pointers. It defaults to 4 since WebAssembly usually uses 32 bit pointers. If you want to use wasm64, set pointerSizeBytes to 8 to denote 64 bit pointers.

Implementation

static void init([int pointerSizeBytes = 4]) {
  _registerType<Float>(4);
  _registerType<Double>(8);
  _registerType<Int8>(1);
  _registerType<Uint8>(1);
  _registerType<Int16>(2);
  _registerType<Uint16>(2);
  _registerType<Int32>(4);
  _registerType<Uint32>(4);
  _registerType<Int64>(8);
  _registerType<Uint64>(8);
  _registerType<IntPtr>(pointerSizeBytes);
  _registerType<Opaque>(pointerSizeBytes);
  registerNativeMarshallerType<Void>();
  registerNativeMarshallerType<NativeFunction<dynamic>>();
}