@@ -217,37 +217,52 @@ function postInstantiate(baseModule, instance) {
217
217
218
218
baseModule . __getArrayBuffer = __getArrayBuffer ;
219
219
220
- function getTypedArrayImpl ( Type , alignLog2 , ptr ) {
220
+ function getTypedArrayView ( Type , alignLog2 , ptr ) {
221
221
const buffer = memory . buffer ;
222
222
const U32 = new Uint32Array ( buffer ) ;
223
223
const bufPtr = U32 [ ptr + ARRAYBUFFERVIEW_DATASTART_OFFSET >>> 2 ] ;
224
224
return new Type ( buffer , bufPtr , U32 [ bufPtr + SIZE_OFFSET >>> 2 ] >>> alignLog2 ) ;
225
225
}
226
226
227
+ function getTypedArray ( Type , alignLog2 , ptr ) {
228
+ return new Type ( getTypedArrayView ( Type , alignLog2 , ptr ) ) ;
229
+ }
230
+
227
231
/** Gets a view on the values of a known-to-be Int8Array in the module's memory. */
228
- baseModule . __getInt8Array = getTypedArrayImpl . bind ( null , Int8Array , 0 ) ;
232
+ baseModule . __getInt8Array = getTypedArray . bind ( null , Int8Array , 0 ) ;
233
+ baseModule . __getInt8ArrayView = getTypedArrayView . bind ( null , Int8Array , 0 ) ;
229
234
/** Gets a view on the values of a known-to-be Uint8Array in the module's memory. */
230
- baseModule . __getUint8Array = getTypedArrayImpl . bind ( null , Uint8Array , 0 ) ;
235
+ baseModule . __getUint8Array = getTypedArray . bind ( null , Uint8Array , 0 ) ;
236
+ baseModule . __getUint8ArrayView = getTypedArrayView . bind ( null , Uint8Array , 0 ) ;
231
237
/** Gets a view on the values of a known-to-be Uint8ClampedArray in the module's memory. */
232
- baseModule . __getUint8ClampedArray = getTypedArrayImpl . bind ( null , Uint8ClampedArray , 0 ) ;
238
+ baseModule . __getUint8ClampedArray = getTypedArray . bind ( null , Uint8ClampedArray , 0 ) ;
239
+ baseModule . __getUint8ClampedArrayView = getTypedArrayView . bind ( null , Uint8ClampedArray , 0 ) ;
233
240
/** Gets a view on the values of a known-to-be Int16Array in the module's memory. */
234
- baseModule . __getInt16Array = getTypedArrayImpl . bind ( null , Int16Array , 1 ) ;
241
+ baseModule . __getInt16Array = getTypedArray . bind ( null , Int16Array , 1 ) ;
242
+ baseModule . __getInt16ArrayView = getTypedArrayView . bind ( null , Int16Array , 1 ) ;
235
243
/** Gets a view on the values of a known-to-be Uint16Array in the module's memory. */
236
- baseModule . __getUint16Array = getTypedArrayImpl . bind ( null , Uint16Array , 1 ) ;
244
+ baseModule . __getUint16Array = getTypedArray . bind ( null , Uint16Array , 1 ) ;
245
+ baseModule . __getUint16ArrayView = getTypedArrayView . bind ( null , Uint16Array , 1 ) ;
237
246
/** Gets a view on the values of a known-to-be Int32Array in the module's memory. */
238
- baseModule . __getInt32Array = getTypedArrayImpl . bind ( null , Int32Array , 2 ) ;
247
+ baseModule . __getInt32Array = getTypedArray . bind ( null , Int32Array , 2 ) ;
248
+ baseModule . __getInt32ArrayView = getTypedArrayView . bind ( null , Int32Array , 2 ) ;
239
249
/** Gets a view on the values of a known-to-be Uint32Array in the module's memory. */
240
- baseModule . __getUint32Array = getTypedArrayImpl . bind ( null , Uint32Array , 2 ) ;
250
+ baseModule . __getUint32Array = getTypedArray . bind ( null , Uint32Array , 2 ) ;
251
+ baseModule . __getUint32ArrayView = getTypedArrayView . bind ( null , Uint32Array , 2 ) ;
241
252
if ( BIGINT ) {
242
253
/** Gets a view on the values of a known-to-be-Int64Array in the module's memory. */
243
- baseModule . __getInt64Array = getTypedArrayImpl . bind ( null , BigInt64Array , 3 ) ;
254
+ baseModule . __getInt64Array = getTypedArray . bind ( null , BigInt64Array , 3 ) ;
255
+ baseModule . __getInt64ArrayView = getTypedArrayView . bind ( null , BigInt64Array , 3 ) ;
244
256
/** Gets a view on the values of a known-to-be-Uint64Array in the module's memory. */
245
- baseModule . __getUint64Array = getTypedArrayImpl . bind ( null , BigUint64Array , 3 ) ;
257
+ baseModule . __getUint64Array = getTypedArray . bind ( null , BigUint64Array , 3 ) ;
258
+ baseModule . __getUint64ArrayView = getTypedArrayView . bind ( null , BigUint64Array , 3 ) ;
246
259
}
247
260
/** Gets a view on the values of a known-to-be Float32Array in the module's memory. */
248
- baseModule . __getFloat32Array = getTypedArrayImpl . bind ( null , Float32Array , 2 ) ;
261
+ baseModule . __getFloat32Array = getTypedArray . bind ( null , Float32Array , 2 ) ;
262
+ baseModule . __getFloat32ArrayView = getTypedArrayView . bind ( null , Float32Array , 2 ) ;
249
263
/** Gets a view on the values of a known-to-be Float64Array in the module's memory. */
250
- baseModule . __getFloat64Array = getTypedArrayImpl . bind ( null , Float64Array , 3 ) ;
264
+ baseModule . __getFloat64Array = getTypedArray . bind ( null , Float64Array , 3 ) ;
265
+ baseModule . __getFloat64ArrayView = getTypedArrayView . bind ( null , Float64Array , 3 ) ;
251
266
252
267
/** Tests whether an object is an instance of the class represented by the specified base id. */
253
268
function __instanceof ( ptr , baseId ) {
0 commit comments