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

Function fxLinkerScriptCallback

xs/tools/xslSlot.c:457–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455}
456
457void fxLinkerScriptCallback(txMachine* the)
458{
459 txLinker* linker = xsGetContext(the);
460 txSlot* slot = mxModuleInternal(mxThis);
461 txSlot* key = fxGetKey(the, slot->value.module.id);
462 txString path = key->value.key.string;
463 txLinkerScript* linkerScript = linker->firstScript;
464 mxPush(mxArrayPrototype);
465 fxNewArrayInstance(the);
466 fxArrayCacheBegin(the, the->stack);
467 while (linkerScript) {
468 if (!c_strcmp(linkerScript->path, path)) {
469 txByte* p = linkerScript->hostsBuffer;
470 if (p) {
471 txID c, i, id;
472 mxDecode2(p, c);
473 linkerScript->builders = fxNewLinkerChunk(linker, c * sizeof(txHostFunctionBuilder));
474 linkerScript->callbackNames = fxNewLinkerChunk(linker, c * sizeof(txCallbackName));
475 linkerScript->hostsCount = c;
476 for (i = 0; i < c; i++) {
477 txCallback callback = the->fakeCallback;
478 txHostFunctionBuilder* builder = &linkerScript->builders[i];
479 txCallbackName* callbackName = &linkerScript->callbackNames[i];
480 txS1 length = *p++;
481 the->fakeCallback = (txCallback)(((txU1*)the->fakeCallback) + 1);
482 mxDecode2(p, id);
483 builder->callback = callback;
484 builder->length = length;
485 builder->id = id;
486 callbackName->callback = callback;
487 callbackName->name = (char*)p;
488 if (length < 0) {
489 fxNewHostObject(the, (txDestructor)callback);
490 }
491 else {
492 mxPushUndefined();
493 the->stack->kind = XS_HOST_FUNCTION_KIND;
494 the->stack->value.hostFunction.builder = builder;
495 the->stack->value.hostFunction.profileID = fxGenerateProfileID(the);
496 }
497 fxArrayCacheItem(the, the->stack + 1, the->stack);
498 mxPop();
499 p += mxStringLength((char*)p) + 1;
500 }
501 }
502 break;
503 }
504 linkerScript = linkerScript->nextScript;
505 }
506 fxArrayCacheEnd(the, the->stack);
507 mxPullSlot(mxResult);
508 mxPop();
509}
510
511txSlot* fxNewFunctionLength(txMachine* the, txSlot* instance, txNumber length)
512{

Callers

nothing calls this directly

Calls 8

fxGetKeyFunction · 0.85
fxNewArrayInstanceFunction · 0.85
fxArrayCacheBeginFunction · 0.85
fxNewLinkerChunkFunction · 0.85
fxNewHostObjectFunction · 0.85
fxArrayCacheItemFunction · 0.85
fxArrayCacheEndFunction · 0.85
fxGenerateProfileIDFunction · 0.70

Tested by

no test coverage detected