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

Function GetDelegateInfo

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

* Get target UObject and Lua function pointer for a delegate */

Source from the content-addressed store, hash-verified

831 * Get target UObject and Lua function pointer for a delegate
832 */
833int32 GetDelegateInfo(lua_State *L, int32 Index, UObject* &Object, const void* &Function)
834{
835 int32 Type = lua_type(L, Index);
836 if (Type != LUA_TTABLE)
837 {
838 return INDEX_NONE;
839 }
840
841 Object = nullptr;
842 Function = nullptr;
843 int32 FuncIdxInTable = INDEX_NONE;
844 for (int32 i = 1; i <= 2; ++i)
845 {
846 Type = lua_rawgeti(L, Index, i);
847 if (Type == LUA_TFUNCTION)
848 {
849 Function = lua_topointer(L, -1); // Lua function pointer
850 FuncIdxInTable = i;
851 }
852 else
853 {
854 Object = UnLua::GetUObject(L, -1); // target UObject
855 }
856 lua_pop(L, 1);
857 }
858 return !Object || !Function ? INDEX_NONE : FuncIdxInTable;
859}
860
861/**
862 * Get Lua instance for a UObject

Callers 2

SetValueInternalMethod · 0.85
SetValueInternalMethod · 0.85

Calls 4

lua_typeFunction · 0.85
lua_rawgetiFunction · 0.85
lua_topointerFunction · 0.85
GetUObjectFunction · 0.85

Tested by

no test coverage detected