| 589 | } |
| 590 | |
| 591 | txSlot* fxNewHostFunction(txMachine* the, txCallback theCallback, txInteger theLength, txInteger name, txInteger profileID) |
| 592 | { |
| 593 | txSlot* instance; |
| 594 | txSlot* property; |
| 595 | |
| 596 | mxPushUndefined(); |
| 597 | instance = fxNewSlot(the); |
| 598 | instance->flag |= XS_CAN_CALL_FLAG; |
| 599 | instance->kind = XS_INSTANCE_KIND; |
| 600 | instance->value.instance.garbage = C_NULL; |
| 601 | instance->value.instance.prototype = mxFunctionPrototype.value.reference; |
| 602 | the->stack->value.reference = instance; |
| 603 | the->stack->kind = XS_REFERENCE_KIND; |
| 604 | |
| 605 | /* CALLBACK */ |
| 606 | property = instance->next = fxNewSlot(the); |
| 607 | property->flag = XS_INTERNAL_FLAG; |
| 608 | property->kind = XS_CALLBACK_KIND; |
| 609 | property->value.callback.address = theCallback; |
| 610 | property->value.callback.closures = C_NULL; |
| 611 | |
| 612 | /* HOME */ |
| 613 | property = property->next = fxNewSlot(the); |
| 614 | if (profileID != XS_NO_ID) |
| 615 | property->ID = profileID; |
| 616 | else |
| 617 | property->ID = fxGenerateProfileID(the); |
| 618 | property->flag = XS_INTERNAL_FLAG; |
| 619 | property->kind = XS_HOME_KIND; |
| 620 | property->value.home.object = C_NULL; |
| 621 | if (the->frame && (mxFunction->kind == XS_REFERENCE_KIND) && (mxIsFunction(mxFunction->value.reference))) { |
| 622 | txSlot* slot = mxFunctionInstanceHome(mxFunction->value.reference); |
| 623 | property->value.home.module = slot->value.home.module; |
| 624 | } |
| 625 | else |
| 626 | property->value.home.module = C_NULL; |
| 627 | |
| 628 | /* LENGTH */ |
| 629 | if (gxDefaults.newFunctionLength) |
| 630 | gxDefaults.newFunctionLength(the, instance, theLength); |
| 631 | |
| 632 | /* NAME */ |
| 633 | fxRenameFunction(the, instance, name, 0, XS_NO_ID, C_NULL); |
| 634 | |
| 635 | return instance; |
| 636 | } |
| 637 | |
| 638 | txSlot* fxNewHostInstance(txMachine* the) |
| 639 | { |
no test coverage detected