MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / HackObjectVTable

Method HackObjectVTable

Source/Engine/Scripting/BinaryModule.cpp:546–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544}
545
546void 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
591String ScriptingType::ToString() const
592{

Callers 3

loadMethod · 0.80
ManagedObjectSpawnMethod · 0.80

Calls 3

LockMethod · 0.80
UnlockMethod · 0.80
GetTypeMethod · 0.45

Tested by

no test coverage detected