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

Function fx_Uint8Array_fromHex

xs/sources/xsDataView.c:3640–3666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3638}
3639
3640void fx_Uint8Array_fromHex(txMachine* the)
3641{
3642 txSize srcSize;
3643 txSize dstSize;
3644 txU1* src;
3645 txU1* dst;
3646 if ((mxArgc < 1) || !mxIsStringPrimitive(mxArgv(0)))
3647 mxTypeError("string: not a string");
3648 srcSize = (txSize)c_strlen(mxArgv(0)->value.string);
3649 if (srcSize & 1)
3650 mxSyntaxError("string: odd length");
3651 dstSize = srcSize >> 1;
3652 mxPush(mxUint8ArrayConstructor);
3653 mxNew();
3654 mxPushInteger(dstSize);
3655 mxRunCount(1);
3656 mxPullSlot(mxResult);
3657 {
3658 txSlot* resultInstance = fxCheckTypedArrayInstance(the, mxResult); \
3659 txSlot* resultDispatch = resultInstance->next; \
3660 txSlot* resultView = resultDispatch->next; \
3661 txSlot* resultBuffer = resultView->next; \
3662 src = (txU1*)(mxArgv(0)->value.string);
3663 dst = (txU1*)(resultBuffer->value.reference->next->value.arrayBuffer.address + resultView->value.dataView.offset);
3664 fxUint8ArrayFromHex(the, src, dst, &srcSize, &dstSize);
3665 }
3666}
3667
3668void fx_Uint8Array_prototype_setFromBase64(txMachine* the)
3669{

Callers

nothing calls this directly

Calls 2

fxUint8ArrayFromHexFunction · 0.85

Tested by

no test coverage detected