Skip to content

Commit 3c02161

Browse files
編集( ArrayBuffer 作成アルゴリズムを汎用化
1 parent ccd1b4c commit 3c02161

9 files changed

+94
-111
lines changed

Encoding-ja.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@
687687
BS.~byte長さ:~WEBIDLjs#buffersource-byte-length
688688
配列~buffer~viewの中へ~byte列を書込む:~WEBIDLjs#arraybufferview-write
689689
:~WEBIDLjs#arraybufferview-write-startingoffset
690-
~buffer~sourceを~byte列から作成する:~WEBIDLjs#_buffersource-create
690+
~buffer~sourceを作成する:~WEBIDLjs#_buffersource-create
691691

692692
~chunk:~STREAMS#chunk
693693
可読~stream:~STREAMS#readable-stream
@@ -4645,7 +4645,7 @@ <h3 title="Interface TextEncoder">7.4. ~interface `TextEncoder^I</h3>
46454645
%出力 ~SET %出力 を~byte列に`変換する$
46464646
</li>
46474647
<li>
4648-
~RET `~buffer~sourceを~byte列から作成する$( `Uint8Array$I, %出力, コレに`関連な~realm$ )
4648+
~RET `~buffer~sourceを作成する$( `Uint8Array$I, %出力, コレに`関連な~realm$ )
46494649
</li>
46504650
</ol>
46514651
@@ -5416,7 +5416,7 @@ <h3 title="Interface TextEncoderStream">7.6. ~interface `TextEncoderStream^I</h3
54165416
</p>
54175417
<ol>
54185418
<li>
5419-
%~chunk ~LET `~buffer~sourceを~byte列から作成する$( `Uint8Array$I, %出力, %符号化器 に`関連な~realm$ )
5419+
%~chunk ~LET `~buffer~sourceを作成する$( `Uint8Array$I, %出力, %符号化器 に`関連な~realm$ )
54205420
54215421
Let chunk be a Uint8Array object wrapping an ArrayBuffer containing output.
54225422
</li>
@@ -5578,7 +5578,7 @@ <h3 title="Interface TextEncoderStream">7.6. ~interface `TextEncoderStream^I</h3
55785578
</li>
55795579
<li>
55805580
<p>
5581-
%~chunk ~LET `~buffer~sourceを~byte列から作成する$( `Uint8Array$I, %~byte列, %符号化器 に`関連な~realm$ )
5581+
%~chunk ~LET `~buffer~sourceを作成する$( `Uint8Array$I, %~byte列, %符号化器 に`関連な~realm$ )
55825582
55835583
</li>
55845584
<li>

Fetch-ja.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@
13081308
反復される値~pair群:~WEBIDL#dfn-value-pairs-to-iterate-over
13091309

13101310
保持された~byte列の複製を取得する:~WEBIDLjs#dfn-get-buffer-source-copy
1311-
~buffer~sourceを~byte列から作成する:~WEBIDLjs#_buffersource-create
1311+
~buffer~sourceを作成する:~WEBIDLjs#_buffersource-create
13121312
~WEBIDLjs#arraybufferview-create → ~WEBIDLjs#_buffersource-create
13131313
~WEBIDLjs#arraybuffer-create → ~WEBIDLjs#_buffersource-create
13141314

@@ -18862,7 +18862,7 @@ <h3 title="BodyInit unions">5.2. `BodyInit^I 共用体</h3>
1886218862
</p>
1886318863
<ol>
1886418864
<li>
18865-
%~chunk ~LET `~buffer~sourceを~byte列から作成する$( `Uint8Array$I, %~byte列【, ここに必要な~realm引数はまだ指定されていない】 )
18865+
%~chunk ~LET `~buffer~sourceを作成する$( `Uint8Array$I, %~byte列【, ここに必要な~realm引数はまだ指定されていない】 )
1886618866
</li>
1886718867
<li>
1886818868
%~stream に`~chunkを~enqueueする$RS( %~chunk )
@@ -19227,7 +19227,7 @@ <h3 title="Body mixin">5.3. `Body^I ~mixin</h3>
1922719227
( `~byte列$ %~byte列 )
1922819228
に対し
1922919229
19230-
~RET `~buffer~sourceを~byte列から作成する$( `ArrayBuffer$I, %~byte列, コレに`関連な~realm$ )
19230+
~RET `~buffer~sourceを作成する$( `ArrayBuffer$I, %~byte列, コレに`関連な~realm$ )
1923119231
1923219232
given a byte sequence bytes: return the result of creating an ArrayBuffer from bytes in this’s relevant realm.
1923319233
</p>
@@ -19285,7 +19285,7 @@ <h3 title="Body mixin">5.3. `Body^I ~mixin</h3>
1928519285
( `~byte列$ %~byte列 )
1928619286
に対し
1928719287
19288-
~RET `~buffer~sourceを~byte列から作成する$( `Uint8Array$I, %~byte列, コレに`関連な~realm$ )
19288+
~RET `~buffer~sourceを作成する$( `Uint8Array$I, %~byte列, コレに`関連な~realm$ )
1928919289
1929019290
given a byte sequence bytes:\
1929119291
return the result of creating a Uint8Array from bytes in this’s relevant realm.

File_API-ja.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@
539539
~supportする~prop~index:~WEBIDL#dfn-supported-property-indices
540540
投出-:~WEBIDL#dfn-throw
541541
保持された~byte列の複製を取得する:~WEBIDLjs#dfn-get-buffer-source-copy
542-
~buffer~sourceを~byte列から作成する:~WEBIDLjs#_buffersource-create
542+
~buffer~sourceを作成する:~WEBIDLjs#_buffersource-create
543543
新たな~obj:~WEBIDLjs#new
544544
新たな~promise:~WEBIDLjs#a-new-promise
545545
却下される~promise:~WEBIDLjs#a-promise-rejected-with
@@ -1736,7 +1736,7 @@ <h2 title="The Blob Interface and Binary Data">3. `Blob^I ~interfaceと~binary~d
17361736
If bytes is failure, then error stream with a failure reason and abort these steps.
17371737
</li>
17381738
<li>
1739-
%~chunk ~LET `~buffer~sourceを~byte列から作成する$( `Uint8Array$I, %~byte列, %~blob に`関連な~realm$ )
1739+
%~chunk ~LET `~buffer~sourceを作成する$( `Uint8Array$I, %~byte列, %~blob に`関連な~realm$ )
17401740
17411741
例外 %e が投出されたときは
17421742
⇒#
@@ -2438,7 +2438,7 @@ <h3 title="Methods and Parameters">3.3. ~method</h3>
24382438
手続きは、
24392439
所与の ( %入力 ) に対し
24402440
2441-
~RET `~buffer~sourceを~byte列から作成する$( `ArrayBuffer$I, %入力, コレに`関連な~realm$ )
2441+
~RET `~buffer~sourceを作成する$( `ArrayBuffer$I, %入力, コレに`関連な~realm$ )
24422442
24432443
that returns a new ArrayBuffer whose contents are its first argument.
24442444
</div>
@@ -2487,7 +2487,7 @@ <h3 title="Methods and Parameters">3.3. ~method</h3>
24872487
手続きは、
24882488
所与の ( %入力 ) に対し
24892489
2490-
~RET `~buffer~sourceを~byte列から作成する$( `ArrayBuffer$I, %入力, コレに`関連な~realm$ )
2490+
~RET `~buffer~sourceを作成する$( `ArrayBuffer$I, %入力, コレに`関連な~realm$ )
24912491
24922492
that returns a new Uint8Array wrapping an ArrayBuffer containing its first argument.
24932493
</div>
@@ -4028,7 +4028,7 @@ <h3 title="Packaging data">6.3. ~dataの梱包-法</h3>
40284028

40294029
<dt>`ArrayBuffer^i</dt>
40304030
<dd>
4031-
~RET `~buffer~sourceを~byte列から作成する$( `ArrayBuffer$I, %~byte列, %~blob に`関連な~realm$ )
4031+
~RET `~buffer~sourceを作成する$( `ArrayBuffer$I, %~byte列, %~blob に`関連な~realm$ )
40324032
40334033
Return a new ArrayBuffer whose contents are bytes.
40344034
</dd>

HTML-canvas-ja.html

+8-34
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@
10111011
~JS値に変換する:~WEBIDLjs#js-type-mapping
10121012
~callback関数を呼出す:~WEBIDLjs#invoke-a-callback-function
10131013
BS.~byte長さ:~WEBIDLjs#buffersource-byte-length
1014-
~buffer~sourceを~byte列から作成する:~WEBIDLjs#_buffersource-create
1014+
~buffer~sourceを作成する:~WEBIDLjs#_buffersource-create
10151015

10161016
算出d値:~CASCADE#computed-value
10171017
~fontに相対的な長さ:~CSSVAL#font-relative-length
@@ -11944,36 +11944,12 @@ <h6 title="Pixel manipulation">4.12.5.1.16. 画素~操作</h6>
1194411944
<ol>
1194511945
<li>
1194611946
<p>
11947-
%画素~形式 に応じて:
11948-
</p>
11949-
<ul class="switch">
11950-
<li>
11951-
<p>
11952-
`rgba-unorm8$l:
11953-
</p>
11954-
<ol>
11955-
<li>
11956-
%~byte列 ~LET 長さ ( 4 ~MUL %縦幅 ~MUL %横幅 ), すべて 0 からなる~byte列
11957-
</li>
11958-
<li>
11959-
%~source ~SET `~buffer~sourceを~byte列から作成する$( `Uint8ClampedArray$I, %~byte列 )
11960-
</li>
11961-
</ol>
11962-
</li>
11963-
<li>
11964-
<p>
11965-
`rgba-float16$l:
11947+
%~source ~SET %画素~形式 に応じて
11948+
⇒#
11949+
`rgba-unorm8$l ならば `~buffer~sourceを作成する$( `Uint8ClampedArray$I, 4 ~MUL %縦幅 ~MUL %横幅 ) /
11950+
`rgba-float16$l ならば `~buffer~sourceを作成する$( `Float16Array$I, 8 ~MUL %縦幅 ~MUL %横幅 )
1196611951
</p>
11967-
<ol>
11968-
<li>
11969-
%~byte列 ~LET 長さ ( 8 ~MUL %縦幅 ~MUL %横幅 ), すべて 0 からなる~byte列
11970-
</li>
11971-
<li>
11972-
%~source ~SET `~buffer~sourceを~byte列から作成する$( `Float16Array$I, %~byte列 )
11973-
</li>
11974-
</ol>
11975-
</li>
11976-
</ul>
11952+
1197711953
<p>
1197811954
この段は、
1197911955
~buffer~source用の配列~bufferを割振れなかった場合には,
@@ -11982,10 +11958,8 @@ <h6 title="Pixel manipulation">4.12.5.1.16. 画素~操作</h6>
1198211958

1198311959
<p class="trans-note">
1198411960
この訳では、
11985-
“~buffer~sourceを~byte列から作成する” ~algoを利用して,
11986-
この段の内容を簡素化する
11987-
( “すべて 0 からなる” は、
11988-
原文には無いが,形式的に必要になる)。
11961+
“~buffer~sourceを作成する” ~algoを利用して,
11962+
この段の内容を簡素化する。
1198911963
</p>
1199011964
1199111965
If settings["pixelFormat"] is "rgba-unorm8", then initialize the data attribute of imageData to a new Uint8ClampedArray object. The Uint8ClampedArray object must use a new ArrayBuffer for its storage, and must have a zero byte offset and byte length equal to the length of its storage, in bytes. The storage ArrayBuffer must have a length of 4 × rows × pixelsPerRow bytes.

Streams-ja.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@
952952
BS.~byte長さ:~WEBIDLjs#buffersource-byte-length
953953
保持された~byte列の複製を取得する:~WEBIDLjs#dfn-get-buffer-source-copy
954954
配列~buffer~viewの中へ~byte列を書込む:~WEBIDLjs#arraybufferview-write
955-
~buffer~sourceを~byte列から作成する:~WEBIDLjs#_buffersource-create
955+
~buffer~sourceを作成する:~WEBIDLjs#_buffersource-create
956956
配列~buffer~viewを~byte列から作成する:~WEBIDLjs#arraybufferview-create
957957

958958
新たな~obj:~WEBIDLjs#new
@@ -24156,7 +24156,7 @@ <h4 title="Creation and manipulation">9.1.1. 作成と操作</h4>
2415624156
</p>
2415724157
<ol>
2415824158
<li>
24159-
%~view ~SET `~buffer~sourceを~byte列から作成する$( `Uint8Array$I, %~pullした~byte列, %~stream に`関連な~realm$ )
24159+
%~view ~SET `~buffer~sourceを作成する$( `Uint8Array$I, %~pullした~byte列, %~stream に`関連な~realm$ )
2416024160
2416124161
Set view to the result of creating a Uint8Array from pulled in stream’s relevant Realm.
2416224162
</li>

WebIDL-JS-ja.html

+55-47
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@
905905
可反復から凍結d配列を作成する:#create-frozen-array-from-iterable
906906
凍結d配列を作成する:#dfn-create-frozen-array
907907

908-
~buffer~sourceを~byte列から作成する:#_buffersource-create
908+
~buffer~sourceを作成する:#_buffersource-create
909909
配列~bufferを~byte列から作成する:#arraybuffer-create
910910
配列~buffer~viewを~byte列から作成する:#arraybufferview-create
911911
共用~配列~bufferを~byte列から作成する:#sharedarraybuffer-create
@@ -7163,23 +7163,25 @@ <h4 title="Buffer source types">3.2.26. ~buffer~source型</h4>
71637163

71647164
<div class="algo">
71657165
<p>
7166-
`~buffer~sourceを~byte列から作成する@
7166+
`~buffer~sourceを作成する@
71677167
~algoは、
71687168
所与の
7169-
( `~buffer~source型$ %T, `~byte列$ %~byte列, `~realm$ %~realm )
7169+
( `~buffer~source型$ %T, `~byte列$/負でない整数 ] %~byte列または長さ, `~realm$ %~realm )
71707170
に対し:
7171-
7172-
To create an ArrayBuffer from a byte sequence bytes in a realm realm:
7173-
7174-
↓↓</p>
7171+
</p>
71757172
<ol>
71767173
<li>
71777174
%~buffer型 ~LET %T に応じて
71787175
⇒#
71797176
`SharedArrayBuffer$T ならば %T /
71807177
~ELSE_ `ArrayBuffer$T
7181-
7182-
↓↓</li>
7178+
</li>
7179+
<li>
7180+
%長さ ~LET %~byte列または長さ に応じて
7181+
⇒#
7182+
`~byte列$であるならば`~byte列$の`長さ$byte /
7183+
整数であるならば %~byte列または長さ
7184+
</li>
71837185
<li>
71847186
<p>
71857187
%~js配列~buffer ~LET %~buffer型 に応じて:
@@ -7188,84 +7190,64 @@ <h4 title="Buffer source types">3.2.26. ~buffer~source型</h4>
71887190
<li>
71897191
`SharedArrayBuffer$T
71907192
7191-
~ABRUPT `AllocateSharedArrayBuffer$A( %~realm.`SharedArrayBuffer$jIsl,
7192-
%~byte列 の`長さ$byte )
7193+
~ABRUPT `AllocateSharedArrayBuffer$A( %~realm.`SharedArrayBuffer$jIsl, %長さ )
71937194
</li>
71947195
<li>
71957196
`ArrayBuffer$T
71967197
7197-
~ABRUPT `AllocateArrayBuffer$A( %~realm.`ArrayBuffer$jIsl,
7198-
%~byte列 の`長さ$byte )
7198+
~ABRUPT `AllocateArrayBuffer$A( %~realm.`ArrayBuffer$jIsl, %長さ )
71997199
</li>
72007200
</ul>
7201-
7202-
↓↓
7203-
7204-
Let jsArrayBuffer be ? AllocateArrayBuffer(realm.[[Intrinsics]].[[%ArrayBuffer%]], bytes’s length).
7205-
</li>
7201+
7202+
<p class="trans-note">【
7203+
~JS仕様に則って、
7204+
ここで割振られた~bufferを成す各~byteは,
7205+
すべて 0 に初期化される。
7206+
~bufferを割振ることに失敗した場合、
7207+
`RangeError$jE が投出される。
7208+
】</p>
7209+
</li>
72067210
<li>
72077211
%配列~buffer ~LET `~IDL値に変換する$( %~js配列~buffer, %~buffer型 )
7208-
7209-
Let arrayBuffer be the result of converting jsArrayBuffer to an IDL value of type ArrayBuffer.
72107212
</li>
72117213
<li>
7212-
`配列~bufferの中へ~byte列を書込む$( %配列~buffer, %~byte列 )
7213-
7214-
Write bytes into arrayBuffer.
7214+
~IF[
7215+
%~byte列または長さ は`~byte列$である
7216+
7217+
7218+
`配列~bufferの中へ~byte列を書込む$( %配列~buffer, %~byte列または長さ )
72157219
</li>
72167220
<li>
72177221
~IF[
72187222
%T は`~buffer型$である
72197223
72207224
72217225
~RET %配列~buffer
7222-
7223-
Return arrayBuffer.
7224-
7225-
↑↑ To create a SharedArrayBuffer from a byte sequence bytes in a realm realm:
7226-
• Let jsSharedArrayBuffer be ? AllocateSharedArrayBuffer(realm.[[Intrinsics]].[[%SharedArrayBuffer%]], bytes’s length).
7227-
• Let sharedArrayBuffer be the result of converting jsSharedArrayBuffer to an IDL value of type SharedArrayBuffer.
7228-
• Write bytes into sharedArrayBuffer.
7229-
• Return sharedArrayBuffer.
72307226
</li>
72317227
<li>
72327228
~Assert:
72337229
%T は`~buffer~view型$である
7234-
7235-
↑↑To create one of the ArrayBufferView types from a byte sequence bytes in a realm realm:
72367230
</li>
72377231
<li>
72387232
~Assert:
72397233
72407234
%T ~EQ `DataView$T
72417235
]~OR[
7242-
( %~byte列 の`長さ$byte ) `modulo$op ( %T の`要素~size$eS )
7236+
%長さ `modulo$op ( %T の`要素~size$eS )
72437237
~EQ 0
72447238
7245-
7246-
Assert: if the type is not DataView, then bytes’s length modulo the element size of that type is 0.
72477239
</li>
72487240
<li>
72497241
%構築子 ~LET %~realm.`Intrinsics^sl からの[
72507242
%T 用の適切な構築子
72517243
7252-
7253-
↑↑Let arrayBuffer be the result of creating an ArrayBuffer from bytes in realm.
7254-
7255-
↑↑Let jsArrayBuffer be the result of converting arrayBuffer to a JavaScript value.
7256-
7257-
Let constructor be the appropriate constructor from realm.[[Intrinsics]] for the type of ArrayBufferView being created.
72587244
</li>
72597245
<li>
72607246
%~js~view ~LET
72617247
~NOABRUPT `Construct$A( %構築子, « %~js配列~buffer » )
7262-
7263-
Let jsView be ! Construct(constructor, « jsArrayBuffer »).
72647248
</li>
72657249
<li>
72667250
~RET `~IDL値に変換する$( %~js~view, %T )
7267-
7268-
Return the result of converting jsView into the given type.
72697251
</li>
72707252
</ol>
72717253

@@ -7279,7 +7261,33 @@ <h4 title="Buffer source types">3.2.26. ~buffer~source型</h4>
72797261
<dfn id="arraybufferview-create">`ArrayBufferView$T の場合</dfn>
72807262
]の 3 つに分けて定義されているが,
72817263
この訳では 1 つに統合することにする。
7264+
】【
7265+
%~byte列または長さ は、
7266+
原文では,~byte列しかとらない %~byte列 として定義されるが、
7267+
この訳では,[
7268+
~byte列を書込むことなく~buffer~sourceを作成する事例
7269+
]にも利用できるよう拡張する。
72827270
】</p>
7271+
7272+
To create an ArrayBuffer from a byte sequence bytes in a realm realm:
7273+
• Let jsArrayBuffer be ? AllocateArrayBuffer(realm.[[Intrinsics]].[[%ArrayBuffer%]], bytes’s length).
7274+
• Let arrayBuffer be the result of converting jsArrayBuffer to an IDL value of type ArrayBuffer.
7275+
• Write bytes into arrayBuffer.
7276+
• Return arrayBuffer.
7277+
7278+
To create a SharedArrayBuffer from a byte sequence bytes in a realm realm:
7279+
• Let jsSharedArrayBuffer be ? AllocateSharedArrayBuffer(realm.[[Intrinsics]].[[%SharedArrayBuffer%]], bytes’s length).
7280+
• Let sharedArrayBuffer be the result of converting jsSharedArrayBuffer to an IDL value of type SharedArrayBuffer.
7281+
• Write bytes into sharedArrayBuffer.
7282+
• Return sharedArrayBuffer.
7283+
7284+
To create one of the ArrayBufferView types from a byte sequence bytes in a realm realm:
7285+
• Assert: if the type is not DataView, then bytes’s length modulo the element size of that type is 0.
7286+
• Let arrayBuffer be the result of creating an ArrayBuffer from bytes in realm.
7287+
• Let jsArrayBuffer be the result of converting arrayBuffer to a JavaScript value.
7288+
• Let constructor be the appropriate constructor from realm.[[Intrinsics]] for the type of ArrayBufferView being created.
7289+
• Let jsView be ! Construct(constructor, « jsArrayBuffer »).
7290+
• Return the result of converting jsView into the given type.
72837291
</div>
72847292

72857293
<div class="algo">
@@ -7594,7 +7602,7 @@ <h4 title="Buffer source types">3.2.26. ~buffer~source型</h4>
75947602
代替として,次を行うこともできる
75957603
⇒#
75967604
まず,~buffer~sourceに`保持された~byte列の複製を取得する$;
7597-
その~byte列を改変してから,`~buffer~sourceを~byte列から作成する$;
7605+
その~byte列を改変してから,`~buffer~sourceを作成する$;
75987606
結果の新たな`~buffer型$の~obj【! ArrayBuffer or ArrayBufferView】を作者~codeに与える。
75997607
76007608
Alternately, you can get a copy of the bytes held by the buffer source, modify those bytes, and then use them to create a new ArrayBuffer or ArrayBufferView to give back to author code.

0 commit comments

Comments
 (0)