@@ -243,6 +243,9 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
243
243
text: ResolvedBinding Record; url: resolvedbinding-record
244
244
text: running execution context; url: running-execution-context
245
245
text: element size; url: table-the-typedarray-constructors
246
+ urlPrefix: https://tc39.es/proposal-resizablearraybuffer/; spec: RESIZABLE-BUFFERS-PROPOSAL
247
+ type: abstract-op
248
+ text: IsResizableArrayBuffer; url: sec-isresizablearraybuffer
246
249
</pre>
247
250
248
251
<style>
@@ -6610,6 +6613,7 @@ annotate are called <dfn export for="annotated types" lt="inner type">inner type
6610
6613
</div>
6611
6614
6612
6615
The following extended attributes are <dfn for="extended attributes">applicable to types</dfn>:
6616
+ [{{AllowResizable}}],
6613
6617
[{{AllowShared}}],
6614
6618
[{{Clamp}}],
6615
6619
[{{EnforceRange}}], and
@@ -8856,10 +8860,34 @@ that correspond to the union’s [=member types=].
8856
8860
<h4 id="es-buffer-source-types">Buffer source types</h4>
8857
8861
8858
8862
Values of the IDL [=buffer source types=]
8859
- are represented by objects of the corresponding ECMAScript class, with the additional restriction
8860
- that unless the type is [=extended attributes associated with|associated with=] the
8861
- [{{AllowShared}}] extended attribute, they can only be backed by ECMAScript
8862
- {{ECMAScript/ArrayBuffer}} objects, and not {{ECMAScript/SharedArrayBuffer}} objects.
8863
+ are represented by objects of the corresponding ECMAScript class, with the following additional restrictions on those objects.
8864
+
8865
+ <ul>
8866
+ <li>
8867
+ If the type is not [=extended attributes associated with|associated with=] either the
8868
+ [{{AllowResizable}}] or [{{AllowShared}}] [=extended attribute=], they can only be backed by
8869
+ ECMAScript {{ECMAScript/ArrayBuffer}} objects |V| for which <a
8870
+ abstract-op>IsResizableArrayBuffer</a>(|V|) is false.
8871
+ </li>
8872
+ <li>
8873
+ If the type is [=extended attributes associated with|associated with=] the
8874
+ [{{AllowResizable}}] [=extended attribute=] but not with the [{{AllowShared}}] [=extended
8875
+ attribute=], they can only be backed by ECMAScript {{ECMAScript/ArrayBuffer}} objects.
8876
+ </li>
8877
+ <li>
8878
+ If the type is [=extended attributes associated with|associated with=] the [{{AllowShared}}]
8879
+ [=extended attribute=] but not with the [{{AllowResizable}}] [=extended attribute=], they
8880
+ can only be backed by ECMAScript {{ECMAScript/ArrayBuffer}} and ECMAScript
8881
+ {{ECMAScript/SharedArrayBuffer}} objects |V| for which <a
8882
+ abstract-op>IsResizableArrayBuffer</a>(|V|) is false.
8883
+ </li>
8884
+ <li>
8885
+ If the type is [=extended attributes associated with|associated with=] both the
8886
+ [{{AllowResizable}}] and the [{{AllowShared}}] [=extended attribute|extended attributes=],
8887
+ they can be backed by any ECMAScript {{ECMAScript/ArrayBuffer}} or
8888
+ {{ECMAScript/SharedArrayBuffer}} object.
8889
+ </li>
8890
+ </ul>
8863
8891
8864
8892
<div id="es-to-buffer-source" algorithm="convert an ECMAScript value to IDL ArrayBuffer">
8865
8893
@@ -8873,6 +8901,10 @@ that unless the type is [=extended attributes associated with|associated with=]
8873
8901
[=extended attributes associated with|associated with=] the [{{AllowShared}}]
8874
8902
[=extended attribute=], and <a abstract-op>IsSharedArrayBuffer</a>(|V|) is true, then [=ECMAScript/throw=]
8875
8903
a {{ECMAScript/TypeError}}.
8904
+ 1. If the conversion is not to an IDL type
8905
+ [=extended attributes associated with|associated with=] the [{{AllowResizable}}]
8906
+ [=extended attribute=], and <a abstract-op>IsResizableArrayBuffer</a>(|V|) is true,
8907
+ then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
8876
8908
1. Return the IDL {{ArrayBuffer}} value that is a reference
8877
8909
to the same object as |V|.
8878
8910
</div>
@@ -8889,6 +8921,10 @@ that unless the type is [=extended attributes associated with|associated with=]
8889
8921
[=extended attributes associated with|associated with=] the [{{AllowShared}}]
8890
8922
[=extended attribute=], and <a abstract-op>IsSharedArrayBuffer</a>(|V|.\[[ViewedArrayBuffer]]) is true,
8891
8923
then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
8924
+ 1. If the conversion is not to an IDL type
8925
+ [=extended attributes associated with|associated with=] the [{{AllowResizable}}]
8926
+ [=extended attribute=], and <a abstract-op>IsResizableArrayBuffer</a>(|V|.\[[ViewedArrayBuffer]]) is true,
8927
+ then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
8892
8928
1. Return the IDL {{DataView}} value that is a reference
8893
8929
to the same object as |V|.
8894
8930
</div>
@@ -8921,6 +8957,10 @@ that unless the type is [=extended attributes associated with|associated with=]
8921
8957
[=extended attributes associated with|associated with=] the [{{AllowShared}}]
8922
8958
[=extended attribute=], and <a abstract-op>IsSharedArrayBuffer</a>(|V|.\[[ViewedArrayBuffer]]) is true,
8923
8959
then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
8960
+ 1. If the conversion is not to an IDL type
8961
+ [=extended attributes associated with|associated with=] the [{{AllowResizable}}]
8962
+ [=extended attribute=], and <a abstract-op>IsResizableArrayBuffer</a>(|V|.\[[ViewedArrayBuffer]]) is true,
8963
+ then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
8924
8964
1. Return the IDL value of type |T| that is a reference to the same object as |V|.
8925
8965
</div>
8926
8966
@@ -9181,6 +9221,27 @@ This section defines a number of
9181
9221
whose presence affects the ECMAScript binding.
9182
9222
9183
9223
9224
+ <h4 id="AllowResizable" extended-attribute lt="AllowResizable">[AllowResizable]</h4>
9225
+
9226
+ If the [{{AllowResizable}}] [=extended attribute=] appears on one of the [=buffer source types=] without the presence of the [{{AllowShared}}] [=extended attribute=], it
9227
+ creates a new IDL type that allows the buffer source type to be backed by an ECMAScript
9228
+ {{ECMAScript/ArrayBuffer}} that is resizable, instead of only by a fixed-length {{ECMAScript/ArrayBuffer}}.
9229
+
9230
+ If the [{{AllowResizable}}] [=extended attribute=] and the [{{AllowShared}}] [=extended attribute=] both appear on one of the [=buffer source types=], it
9231
+ creates a new IDL type that allows the buffer source type to be additionally backed by an ECMAScript
9232
+ {{ECMAScript/SharedArrayBuffer}} that is growable.
9233
+
9234
+ The [{{AllowResizable}}] extended attribute must [=takes no arguments|take no arguments=].
9235
+
9236
+ A type that is not a [=buffer source type=] must not be
9237
+ [=extended attributes associated with|associated with=] the [{{AllowResizable}}] extended attribute.
9238
+
9239
+ See the rules for converting ECMAScript values to IDL [=buffer source types=] in
9240
+ [[#es-buffer-source-types]] for the specific requirements that the use of [{{AllowResizable}}] entails.
9241
+
9242
+ See the <a href="#example-allowresizable-allowshared">example</a> in [[#AllowShared]] for example usage of both [{{AllowResizable}}] and [{{AllowShared}}].
9243
+
9244
+
9184
9245
<h4 id="AllowShared" extended-attribute lt="AllowShared">[AllowShared]</h4>
9185
9246
9186
9247
If the [{{AllowShared}}] [=extended attribute=] appears on one of the [=buffer source types=], it
@@ -9195,22 +9256,43 @@ A type that is not a [=buffer source type=] must not be
9195
9256
See the rules for converting ECMAScript values to IDL [=buffer source types=] in
9196
9257
[[#es-buffer-source-types]] for the specific requirements that the use of [{{AllowShared}}] entails.
9197
9258
9198
- <div class="example">
9199
- In the following [=IDL fragment=], one operation's argument uses the [{{AllowShared }}] extended
9259
+ <div class="example" id="example-allowresizable-allowshared" >
9260
+ In the following [=IDL fragment=], one operation's argument uses the [{{AllowResizable }}] extended
9200
9261
attribute, while the other does not:
9201
9262
9202
9263
<pre highlight="webidl">
9203
9264
[Exposed=Window]
9204
- interface RenderingContext {
9205
- undefined readPixels(long width, long height, BufferSource pixels);
9206
- undefined readPixelsShared(long width, long height, [AllowShared] BufferSource pixels);
9207
- };
9208
- </pre>
9209
-
9210
- With this definition, a call to <code>readPixels</code> with an {{ECMAScript/SharedArrayBuffer}}
9211
- instance, or any typed array or {{ECMAScript/DataView}} backed by one, will throw a
9212
- {{ECMAScript/TypeError}} exception. In contrast, a call to <code>readPixelsShared</code> will allow such
9213
- objects as input.
9265
+ interface ExampleBufferFeature {
9266
+ undefined writeInto(BufferSource dest);
9267
+ undefined writeIntoResizable([AllowResizable] BufferSource dest);
9268
+ undefined writeIntoShared([AllowShared] BufferSource dest);
9269
+ undefined writeIntoSharedResizable([AllowResizable, AllowShared] BufferSource dest);
9270
+ };
9271
+ </pre>
9272
+
9273
+ With this definition,
9274
+ <ul>
9275
+ <li>
9276
+ A call to <code>writeInto</code> with a resizable {{ECMAScript/ArrayBuffer}} instance, a
9277
+ {{ECMAScript/SharedArrayBuffer}} instance, or any typed array or {{ECMAScript/DataView}}
9278
+ backed by either, will throw a {{ECMAScript/TypeError}} exception.
9279
+ </li>
9280
+ <li>
9281
+ A call to <code>writeIntoResizable</code> with a {{ECMAScript/SharedArrayBuffer}}
9282
+ instance, or any typed array or {{ECMAScript/DataView}} backed by one, will throw a
9283
+ {{ECMAScript/TypeError}} exception.
9284
+ </li>
9285
+ <li>
9286
+ A call to <code>writeIntoShared</code> with a resizable {{ECMAScript/ArrayBuffer}}
9287
+ instance, a growable {{ECMAScript/SharedArrayBuffer}} instance, or any typed array or
9288
+ {{ECMAScript/DataView}} backed by one, will throw a {{ECMAScript/TypeError}} exception.
9289
+ </li>
9290
+ <li>
9291
+ A call to <code>writeIntoSharedResizable</code> will accept an
9292
+ {{ECMAScript/ArrayBuffer}} instance, a {{ECMAScript/SharedArrayBuffer}} instance, or any
9293
+ typed array or {{ECMAScript/DataView}} backed by either.
9294
+ </li>
9295
+ </ul>
9214
9296
</div>
9215
9297
9216
9298
0 commit comments