Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ urlPrefix: https://tc39.es/ecma262/; spec: ecmascript
url: sec-object-type
text: is an Object
text: is not an Object
urlPrefix: https://tc39.es/proposal-immutable-arraybuffer/; spec: PROPOSAL-IMMUTABLE-ARRAYBUFFER
type: abstract-op
text: AllocateImmutableArrayBuffer; url: sec-allocateimmutablearraybuffer
</pre>

<pre class=biblio>
Expand All @@ -99,6 +102,11 @@ urlPrefix: https://tc39.es/ecma262/; spec: ecmascript
"publisher": "Ecma",
"href": "https://tc39.es/proposal-float16array/",
"title": "Proposal to add float16 TypedArrays to JavaScript"
},
"PROPOSAL-IMMUTABLE-ARRAYBUFFER": {
"publisher": "Ecma",
"href": "https://tc39.es/proposal-immutable-arraybuffer/",
"title": "Immutable ArrayBuffers"
}
}
</pre>
Expand Down Expand Up @@ -9266,16 +9274,25 @@ a reference to the same object that the IDL value represents.

<hr>

<div algorithm>
<div algorithm="ArrayBuffer/create">
To <dfn export for="ArrayBuffer">create</dfn> an {{ArrayBuffer}} from a [=byte sequence=]
|bytes| in a [=realm=] |realm|:
|bytes| in a [=realm=] |realm|, optionally given an
<dfn export for="ArrayBuffer/create">|immutable|</dfn> boolean (default
<emu-val>false</emu-val>):

1. Let |jsArrayBuffer| be [=?=]
[$AllocateArrayBuffer$](|realm|.\[[Intrinsics]].\[[{{%ArrayBuffer%}}]], |bytes|'s
[=byte sequence/length=]).
1. Let |arrayBuffer| be the result of [=converted to an IDL value|converting=] |jsArrayBuffer|
to an IDL value of type {{ArrayBuffer}}.
1. [=ArrayBuffer/Write=] |bytes| into |arrayBuffer|.
1. If |immutable| is <emu-val>true</emu-val>, then:
1. Set |jsArrayBuffer| to [=?=]
[$AllocateImmutableArrayBuffer$](|realm|.\[[Intrinsics]].\[[{{%ArrayBuffer%}}]],
|bytes|'s [=byte sequence/length=], |jsArrayBuffer|.\[[ArrayBufferData]], 0,
|bytes|'s [=byte sequence/length=]).
1. Set |arrayBuffer| to the result of [=converted to an IDL value|converting=]
|jsArrayBuffer| to an IDL value of type {{ArrayBuffer}}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the immutable branch ends up doing a bunch of work twice. I think this can be structured a bit better.

1. Return |arrayBuffer|.
</div>

Expand Down