* Get target UObject and Lua function pointer for a delegate */
| 831 | * Get target UObject and Lua function pointer for a delegate |
| 832 | */ |
| 833 | int32 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 |
no test coverage detected