You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Editorial: Use USVString rather than DOMString to explain encoding
WebAssembly names are in the AST as strings of Unicode code points,
rather than UTF-8-encoded byte sequences. This patch uses WebIDL's
USVString type to encode this--the type is sequences of code points
in IDL-land, which is then converted to an ECMAScript value by
encoding in UTF-16. The place where this is inapplicable is custom
sections, which don't have a decoded name, but whose name is still
validated as UTF-8.
Thanks to @lukewagner for pointing this out in
WebAssembly#591 (comment)
Copy file name to clipboardexpand all lines: document/js-api/index.bs
+8-13
Original file line number
Diff line number
Diff line change
@@ -365,9 +365,7 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
365
365
1. If |ret| is [=error=], throw an exception. This exception should be a WebAssembly {{RuntimeError}} exception, unless otherwise indicated by <a href="#errors">the WebAssembly error mapping</a>.
366
366
1. Assert: |ret| is empty.
367
367
1. Let |exportsObject| be ! [=ObjectCreate=](null).
368
-
1. For each pair (|nameBytes|, |externtype|) in [=module_exports=](|module|),
369
-
1. Let |name| be |nameBytes| [=UTF-8 decode without BOM or fail|decoded as UTF-8=].
370
-
1. Assert: |name| is not failure (|module| is [=valid=]).
368
+
1. For each pair (|name|, |externtype|) in [=module_exports=](|module|),
371
369
1. Let |externval| be [=get_export=](|instance|, |name|).
372
370
1. If |externtype| is of the form [=𝖿𝗎𝗇𝖼=] |functype|,
373
371
1. If |funcs| contains an entry |func| where 𝖿𝗎𝗇𝖼 |func|.\[[FunctionAddress]] is |externval|, let |value| be |func|
@@ -442,22 +440,22 @@ enum ImportExportKind {
442
440
};
443
441
444
442
dictionary ModuleExportDescriptor {
445
-
required DOMString name;
443
+
required USVString name;
446
444
required ImportExportKind kind;
447
445
// Note: Other fields such as signature may be added in the future.
The <dfn method for="Module">exports(moduleObject)</dfn> method, when invoked, performs the following steps:
474
472
1. Let |module| be |moduleObject|.\[[Module]].
475
473
1. Let |exports| be an empty [=list=].
476
-
1. For each (|nameBytes|, |type|) in [=module_exports=](|module|)
477
-
1. Let |name| be |nameBytes| [=UTF-8 decode without BOM or fail|decoded as UTF-8=].
474
+
1. For each (|name|, |type|) in [=module_exports=](|module|)
475
+
1. Let |nameString| be String value consisting of the [=UTF16Encoding=] of each code point of |name|.
478
476
1. Assert: |name| is not failure (|module| is [=valid=]).
479
477
1. Let |kind| be the [=string value of the extern type=] |type|.
480
478
1. Let |obj| be a new {{ModuleExportDescriptor}} dictionary with {{ModuleExportDescriptor/name}} |name| and {{ModuleExportDescriptor/kind}} |kind|.
@@ -486,10 +484,7 @@ interface Module {
486
484
The <dfn method for="Module">imports(moduleObject)</dfn> method, when invoked, performs the following steps:
487
485
1. Let |module| be |moduleObject|.\[[Module]].
488
486
1. Let |imports| be an empty [=list=].
489
-
1. For each (|moduleBytes|, |nameBytes|, |type|) in [=module_imports=](|module|),
490
-
1. Let |moduleName| be |moduleBytes| [=UTF-8 decode without BOM or fail|decoded as UTF-8=].
491
-
1. Let |name| be |nameBytes| [=UTF-8 decode without BOM or fail|decoded as UTF-8=].
492
-
1. Assert: The previous operations are not failure, as |module| is [=valid=].
487
+
1. For each (|moduleName|, |name|, |type|) in [=module_imports=](|module|),
493
488
1. Let |kind| be the [=string value of the extern type=] |type|.
494
489
1. Let |obj| be a new {{ModuleImportDescriptor}} dictionary with {{ModuleImportDescriptor/module}} |moduleName|, {{ModuleImportDescriptor/name}} |name| and {{ModuleImportDescriptor/kind}} |kind|.
0 commit comments