Skip to content

Define JS API #13

Open
Open
@wingo

Description

@wingo

The MVP should probably define a JS API. AFAIU the work needed is to define a mapping between globals, tables, and function parameters and results of type stringref, stringview_wtf8, stringview_wtf16, and stringview_iter.

Current sloppily specified strawperson:

  1. You cannot convert stringview_wtf8, stringview_wtf16, or stringview_iter values to JS. Attempting to access the value of such an exported global throws. There is no value you can pass to a WebAssembly.Global constructor that would succeed. Same for tables. Calling a function that takes a stringview parameter or returns a stringview result throws before the function is called; like it used to be for i64.
  2. The set of JS representations of stringref values is the set of JS strings, plus JS null.
  3. There is no default value for a stringref. If a stringref argument is not supplied, that's an error.
  4. There are no implicitly/automatically applied conversions: no ToString on numeric values passed as stringref arguments, for example.

Regarding (3), perhaps we should default to null when a JS value isn't given, as ref.null string is the default value on the wasm side, because stringref is nullable. Not sure!

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