| 544 | } |
| 545 | |
| 546 | void ScriptingType::HackObjectVTable(void* object, ScriptingTypeHandle baseTypeHandle, int32 wrapperIndex) |
| 547 | { |
| 548 | if (!Script.ScriptVTable) |
| 549 | return; |
| 550 | if (!Script.VTable) |
| 551 | { |
| 552 | // Ensure to have valid Script VTable hacked |
| 553 | BinaryModule::Locker.Lock(); |
| 554 | if (!Script.VTable) |
| 555 | { |
| 556 | SetupScriptObjectVTable(object, baseTypeHandle, wrapperIndex); |
| 557 | } |
| 558 | BinaryModule::Locker.Unlock(); |
| 559 | } |
| 560 | |
| 561 | // Override object vtable with hacked one that has calls to overriden scripting functions |
| 562 | *(void**)object = Script.VTable; |
| 563 | |
| 564 | if (Script.InterfacesOffsets) |
| 565 | { |
| 566 | // Override vtables for interfaces |
| 567 | int32 interfacesCount = 0; |
| 568 | for (ScriptingTypeHandle e = baseTypeHandle; e;) |
| 569 | { |
| 570 | const ScriptingType& eType = e.GetType(); |
| 571 | auto interfaces = eType.Interfaces; |
| 572 | if (interfaces) |
| 573 | { |
| 574 | while (interfaces->InterfaceType) |
| 575 | { |
| 576 | auto& interfaceType = interfaces->InterfaceType->GetType(); |
| 577 | if (interfaceType.Interface.SetupScriptObjectVTable) |
| 578 | { |
| 579 | void** interfaceVTable = (void**)((byte*)Script.VTable + Script.InterfacesOffsets[interfacesCount++]); |
| 580 | *(void**)((byte*)object + interfaces->VTableOffset) = interfaceVTable; |
| 581 | interfacesCount++; |
| 582 | } |
| 583 | interfaces++; |
| 584 | } |
| 585 | } |
| 586 | e = eType.GetBaseType(); |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | String ScriptingType::ToString() const |
| 592 | { |
no test coverage detected