MCPcopy Create free account
hub / github.com/defold/defold / GetInstanceContextTable

Function GetInstanceContextTable

engine/script/src/script.cpp:1072–1108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1070 }
1071
1072 static void GetInstanceContextTable(lua_State* L)
1073 {
1074 DM_LUA_STACK_CHECK(L, 1);
1075
1076 GetInstance(L);
1077 // [-1] instance
1078
1079 if (!GetMetaFunction(L, -1, META_GET_INSTANCE_CONTEXT_TABLE_REF, sizeof(META_GET_INSTANCE_CONTEXT_TABLE_REF) - 1))
1080 {
1081 lua_pop(L, 1);
1082 lua_pushnil(L);
1083 return;
1084 }
1085 // [-2] instance
1086 // [-1] META_GET_INSTANCE_CONTEXT_TABLE_REF()
1087
1088 lua_insert(L, -2);
1089 // [-2] META_GET_INSTANCE_CONTEXT_TABLE_REF()
1090 // [-1] instance
1091
1092 lua_call(L, 1, 1);
1093 // [-1] instance context table ref or LUA_NOREF
1094 assert(lua_type(L, -1) == LUA_TNUMBER);
1095
1096 int context_table_ref = lua_tonumber(L, -1);
1097 lua_pop(L, 1);
1098
1099 if (context_table_ref == LUA_NOREF)
1100 {
1101 lua_pushnil(L);
1102 // [-1] LUA_NIL
1103 return;
1104 }
1105
1106 lua_rawgeti(L, LUA_REGISTRYINDEX, context_table_ref);
1107 // [-1] instance context table
1108 }
1109
1110 uintptr_t GetInstanceId(lua_State* L)
1111 {

Callers 5

SetInstanceContextValueFunction · 0.85
GetInstanceContextValueFunction · 0.85
RefInInstanceFunction · 0.85
UnrefInInstanceFunction · 0.85
ResolveInInstanceFunction · 0.85

Calls 9

GetMetaFunctionFunction · 0.85
lua_pushnilFunction · 0.85
lua_insertFunction · 0.85
lua_callFunction · 0.85
lua_typeFunction · 0.85
lua_tonumberFunction · 0.85
lua_rawgetiFunction · 0.85
GetInstanceFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected