dart-archive / wasm

Utilities for loading and running WASM modules from Dart code
https://pub.dev/packages/wasm
BSD 3-Clause "New" or "Revised" License
312 stars 24 forks source link

[bindgen] functions starting with an underscore #118

Closed modulovalue closed 1 year ago

modulovalue commented 1 year ago

Consider the following set of exports (from tree-sitter in this case):

...
export function: int32 towupper(int32)
export function: int32 __errno_location()
export function: int32 memchr(int32, int32, int32)
export function: int32 strlen(int32)
export function: int32 stackSave()
export function: void stackRestore(int32)
export function: int32 stackAlloc(int32)
export function: void setThrew(int32, int32)
export function: int32 _ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev(int32)
export function: void _ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm(int32, int32, int32, int32, int32, int32, int32)
...

Notice that there are functions starting with an underscore. I guess this is a convention to signal that a function is private and not meant to be used? Should we generate bindings for them? (I'm wondering if there are already some established expectations here)

modulovalue commented 1 year ago

120 prepends a $ to generated bindings (to avoid clashes) and exposes private WASM functions.