Skip to content

Commit

Permalink
feat(wasm-api): add WasmType.instanceArray(), add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jan 29, 2023
1 parent abecf5d commit 2adf65f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/wasm-api/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,29 @@ export interface WasmTypeBase {
}

export interface WasmType<T> {
/**
* Type alignment (in bytes)
*/
readonly align: number;
/**
* Type size (in bytes)
*/
readonly size: number;
instance: Fn<number, T>;
/**
* Takes a start address and number of items. Returns an array of memory
* mapped type instances (see {@link WasmType.instance}).
*
* @param base
* @param num
* @returns
*/
instanceArray: (base: number, num: number) => T[];
/**
* Returns a memory-mapped type instance for given start address.
*
* @param base
*/
instance: (base: number) => T;
}

export type WasmTypeConstructor<T> = Fn<IWasmMemoryAccess, WasmType<T>>;
Expand Down

0 comments on commit 2adf65f

Please sign in to comment.