Skip to content

On exclusively using names in the C-API #1273

@dcodeIO

Description

@dcodeIO

As a follow-up to @kripken's comment in #1261:

For iteration, perhaps another option is something like a JS API that returns an array of the names, and a C API underneath that does something similar (mallocs a list that must later be freed, and returns it)? Just a suggestion, I'm not sure what is best, but overall I'd like to avoid using indexes (as we have names intentionally, and also, the indexes are internal and do not necessarily match the wasm binary indexes, which could be confusing).

There are two things that bother me about using names exclusively in the C-API:

  • Not everything might have a (useful) name, especially when loading binaries without debug info
  • In binaryen.js, decoding and encoding UTF8 strings for each invocation comes with quite some overhead

The logical way to avoid any issues there would be to use references / arrays of references (avoiding calling with indexes) instead, while the API could still expose GetXYByName methods for convenience. In turn, BinaryenRemoveExport and BinaryenRemoveImport would have to be renamed to BinaryenRemoveExportByName and BInaryenRemoveImportByName in favor of the reference versions without such a suffix.

wdyt?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions