| 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 | { |
no test coverage detected