MCPcopy Create free account
hub / github.com/Tencent/UnLua / PushObjectCore

Function PushObjectCore

Plugins/UnLua/Source/UnLua/Private/LuaCore.cpp:575–594  ·  view source on GitHub ↗

* Push a UObject to Lua stack */

Source from the content-addressed store, hash-verified

573 * Push a UObject to Lua stack
574 */
575void PushObjectCore(lua_State *L, UObjectBaseUtility *Object)
576{
577 FString MetatableName = UnLua::LowLevel::GetMetatableName((UObject*)Object);
578 if (MetatableName.IsEmpty())
579 {
580 lua_pushnil(L);
581 return;
582 }
583
584#if UNLUA_ENABLE_DEBUG != 0
585 UE_LOG(LogUnLua, Log, TEXT("%s : %p,%s,%s"), ANSI_TO_TCHAR(__FUNCTION__), Object,*Object->GetName(), *MetatableName);
586#endif
587
588 NewUserdataWithTwoLvPtrTag(L, sizeof(void*), Object); // create a userdata and store the UObject address
589 bool bSuccess = TryToSetMetatable(L, TCHAR_TO_UTF8(*MetatableName), (UObject*)Object);
590 if (!bSuccess)
591 {
592 UNLUA_LOGERROR(L, LogUnLua, Warning, TEXT("%s, Invalid metatable,Name %s, Object %s,%p!"), ANSI_TO_TCHAR(__FUNCTION__), *MetatableName, *Object->GetName(), Object);
593 }
594}
595
596
597/**

Callers 4

PushObjectElementFunction · 0.85
PushInterfaceElementFunction · 0.85
PushMethod · 0.85
BindMethod · 0.85

Calls 5

GetMetatableNameFunction · 0.85
lua_pushnilFunction · 0.85
TryToSetMetatableFunction · 0.85
GetNameMethod · 0.45

Tested by

no test coverage detected