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

Function GetContextValue

engine/script/src/script.cpp:1042–1070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1040 }
1041
1042 void GetContextValue(HContext context)
1043 {
1044 assert(context != 0x0);
1045 lua_State* L = context->m_LuaState;
1046
1047 DM_LUA_STACK_CHECK(L, 0);
1048
1049 lua_rawgeti(L, LUA_REGISTRYINDEX, context->m_ContextTableRef);
1050 // [-2] key
1051 // [-1] context table
1052
1053 if (lua_type(L, -1) != LUA_TTABLE)
1054 {
1055 lua_pop(L, 2);
1056 lua_pushnil(L);
1057 // [-1] LUA_NIL
1058 return;
1059 }
1060
1061 lua_insert(L, -2);
1062 // [-2] context table
1063 // [-1] key
1064 lua_gettable(L, -2);
1065 // [-2] context table
1066 // [-1] value
1067
1068 lua_remove(L, -2);
1069 // [-1] value
1070 }
1071
1072 static void GetInstanceContextTable(lua_State* L)
1073 {

Callers 1

GetTestScriptExtensionFunction · 0.85

Calls 7

lua_rawgetiFunction · 0.85
lua_typeFunction · 0.85
lua_pushnilFunction · 0.85
lua_insertFunction · 0.85
lua_gettableFunction · 0.85
lua_removeFunction · 0.85
assertFunction · 0.50

Tested by 1

GetTestScriptExtensionFunction · 0.68