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

Function fx_Object_defineProperties

xs/sources/xsObject.c:558–588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556}
557
558void fx_Object_defineProperties(txMachine* the)
559{
560 txSlot* instance;
561 txSlot* properties;
562 txSlot* at;
563 txSlot* property;
564 txFlag mask;
565 if ((mxArgc < 1) || (mxArgv(0)->kind != XS_REFERENCE_KIND))
566 mxTypeError("invalid object");
567 if ((mxArgc < 2) || (mxArgv(1)->kind == XS_UNDEFINED_KIND))
568 mxTypeError("invalid properties");
569 instance = fxGetInstance(the, mxArgv(0));
570 properties = fxToInstance(the, mxArgv(1));
571 at = fxNewInstance(the);
572 mxBehaviorOwnKeys(the, properties, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
573 mxPushUndefined();
574 property = the->stack;
575 while ((at = at->next)) {
576 if (mxBehaviorGetOwnProperty(the, properties, at->value.at.id, at->value.at.index, property) && !(property->flag & XS_DONT_ENUM_FLAG)) {
577 mxPushReference(properties);
578 mxGetAll(at->value.at.id, at->value.at.index);
579 mask = fxDescriptorToSlot(the, the->stack);
580 if (!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, the->stack, mask))
581 mxTypeError("invalid descriptor");
582 mxPop();
583 }
584 }
585 mxPop();
586 mxPop();
587 *mxResult = *mxArgv(0);
588}
589
590void fx_Object_defineProperty(txMachine* the)
591{

Callers

nothing calls this directly

Calls 4

fxGetInstanceFunction · 0.85
fxToInstanceFunction · 0.85
fxNewInstanceFunction · 0.85
fxDescriptorToSlotFunction · 0.85

Tested by

no test coverage detected