MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fx_ArrayBuffer

Function fx_ArrayBuffer

xs/sources/xsDataView.c:498–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496}
497
498void fx_ArrayBuffer(txMachine* the)
499{
500 txSlot* instance;
501 txS8 byteLength;
502 txS8 maxByteLength = -1;
503 txSlot* property;
504 if (!mxHasTarget)
505 mxTypeError("call: ArrayBuffer");
506 byteLength = fxArgToSafeByteLength(the, 0, 0);
507 if ((mxArgc > 1) && mxIsReference(mxArgv(1))) {
508 mxPushSlot(mxArgv(1));
509 mxGetID(mxID(_maxByteLength));
510 mxPullSlot(mxArgv(1));
511 maxByteLength = fxArgToSafeByteLength(the, 1, -1);
512 }
513 if (maxByteLength >= 0) {
514 if (byteLength > maxByteLength)
515 mxRangeError("byteLength > maxByteLength");
516 }
517 mxPushSlot(mxTarget);
518 fxGetPrototypeFromConstructor(the, &mxArrayBufferPrototype);
519 instance = fxNewArrayBufferInstance(the);
520 mxPullSlot(mxResult);
521 if (byteLength > 0x7FFFFFFF)
522 mxRangeError("byteLength too big");
523 if (maxByteLength > 0x7FFFFFFF)
524 mxRangeError("maxByteLength too big");
525 property = instance->next;
526 property->value.arrayBuffer.address = fxNewChunk(the, (txSize)byteLength);
527 c_memset(property->value.arrayBuffer.address, 0, (txSize)byteLength);
528 property = property->next;
529 property->value.bufferInfo.length = (txSize)byteLength;
530 property->value.bufferInfo.maxLength = (txSize)maxByteLength;
531}
532
533void fx_ArrayBuffer_fromBigInt(txMachine* the)
534{

Callers

nothing calls this directly

Calls 4

fxArgToSafeByteLengthFunction · 0.85
fxNewArrayBufferInstanceFunction · 0.85
fxNewChunkFunction · 0.85

Tested by

no test coverage detected