ashtonmeuser / godot-wasm

Interact with WebAssembly modules from Godot
https://github.com/ashtonmeuser/godot-wasm/wiki
MIT License
197 stars 12 forks source link

Provide access to table exports and registering extra functions. #72

Open basicer opened 3 months ago

basicer commented 3 months ago

This would allow calling function that expect to be passed a c function pointer argument.

ashtonmeuser commented 3 months ago

This is a great next step. I'm imagining starting with supporting only exported WebAssembly tables via the following API. Please let me know your thoughts.

New class WasmTable with the following structure.

class WasmTable:
  bool import;
  func get(index: int);
  func set(index: int, func: Callable);

Tables accessible via Wasm.table(table_name).

In the future, this could support import tables via an import dictionary as follows.

imports = {
  functions: { ... },
  memory: ...,
  tables: {
    "my_table": my_table,
  },
}