aboutsummaryrefslogtreecommitdiff
path: root/src/deep.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/deep.cpp')
-rw-r--r--src/deep.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/deep.cpp b/src/deep.cpp
index 735a14c..6570e55 100644
--- a/src/deep.cpp
+++ b/src/deep.cpp
@@ -71,7 +71,7 @@ void DeepFactory::storeDeepLookup(lua_State* L_) const
71 // the deep metatable is at the top of the stack // L_: mt 71 // the deep metatable is at the top of the stack // L_: mt
72 STACK_GROW(L_, 3); 72 STACK_GROW(L_, 3);
73 STACK_CHECK_START_REL(L_, 0); // L_: mt 73 STACK_CHECK_START_REL(L_, 0); // L_: mt
74 push_registry_subtable(L_, kDeepLookupRegKey); // L_: mt {} 74 std::ignore = kDeepLookupRegKey.getSubTable(L_, 0, 0); // L_: mt {}
75 lua_pushvalue(L_, -2); // L_: mt {} mt 75 lua_pushvalue(L_, -2); // L_: mt {} mt
76 lua_pushlightuserdata(L_, std::bit_cast<void*>(this)); // L_: mt {} mt factory 76 lua_pushlightuserdata(L_, std::bit_cast<void*>(this)); // L_: mt {} mt factory
77 lua_rawset(L_, -3); // L_: mt {} 77 lua_rawset(L_, -3); // L_: mt {}
@@ -176,6 +176,26 @@ void DeepFactory::DeleteDeepObject(lua_State* L_, DeepPrelude* o_)
176 176
177// ################################################################################################# 177// #################################################################################################
178 178
179// TODO: convert to UniqueKey::getSubTableMode
180static void push_registry_subtable_mode(lua_State* L_, RegistryUniqueKey key_, const char* mode_)
181{
182 STACK_GROW(L_, 4);
183 STACK_CHECK_START_REL(L_, 0);
184 if (!key_.getSubTable(L_, 0, 0)) { // L_: {}
185 // Set its metatable if requested
186 if (mode_) {
187 lua_createtable(L_, 0, 1); // L_: {} mt
188 lua_pushliteral(L_, "__mode"); // L_: {} mt "__mode"
189 lua_pushstring(L_, mode_); // L_: {} mt "__mode" mode
190 lua_rawset(L_, -3); // L_: {} mt
191 lua_setmetatable(L_, -2); // L_: {}
192 }
193 }
194 STACK_CHECK(L_, 1);
195}
196
197// #################################################################################################
198
179/* 199/*
180 * Push a proxy userdata on the stack. 200 * Push a proxy userdata on the stack.
181 * returns nullptr if ok, else some error string related to bad factory behavior or module require problem 201 * returns nullptr if ok, else some error string related to bad factory behavior or module require problem
@@ -228,7 +248,7 @@ char const* DeepFactory::PushDeepProxy(DestState L_, DeepPrelude* prelude_, int
228 lua_getfield(L_, -1, "__gc"); // L_: DPC proxy metatable __gc 248 lua_getfield(L_, -1, "__gc"); // L_: DPC proxy metatable __gc
229 } else { 249 } else {
230 // keepers need a minimal metatable that only contains our own __gc 250 // keepers need a minimal metatable that only contains our own __gc
231 lua_newtable(L_); // L_: DPC proxy metatable 251 lua_createtable(L_, 0, 1); // L_: DPC proxy metatable
232 lua_pushnil(L_); // L_: DPC proxy metatable nil 252 lua_pushnil(L_); // L_: DPC proxy metatable nil
233 } 253 }
234 if (lua_isnil(L_, -1)) { 254 if (lua_isnil(L_, -1)) {