Skip to content

Commit

Permalink
feat(wasm-api-bindgen): add WasmType.instanceArray() impl
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jan 29, 2023
1 parent 2adf65f commit f69d46e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/wasm-api-bindgen/src/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ export const TYPESCRIPT = (opts: Partial<TSOpts> = {}) => {
`get size() {`,
`return ${struct.__size};`,
`},`,
`instanceArray(base, num) {`,
`const items: ${struct.name}[] = [];`,
`for (; num --> 0; base += ${struct.__size}) items.push(this.instance(base));`,
`return items;`,
`},`,
`instance: (base) => {`,
...pointerDecls,
...stringDecls,
Expand Down

0 comments on commit f69d46e

Please sign in to comment.