diff options
Diffstat (limited to 'src/deep.cpp')
-rw-r--r-- | src/deep.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/deep.cpp b/src/deep.cpp index 6358745..a824f72 100644 --- a/src/deep.cpp +++ b/src/deep.cpp | |||
@@ -111,7 +111,7 @@ static void LookupDeep(lua_State* L_) | |||
111 | if (mode_ == LookupMode::FromKeeper) { | 111 | if (mode_ == LookupMode::FromKeeper) { |
112 | DeepPrelude* const proxy{ *lua_tofulluserdata<DeepPrelude*>(L_, index_) }; | 112 | DeepPrelude* const proxy{ *lua_tofulluserdata<DeepPrelude*>(L_, index_) }; |
113 | // we can (and must) cast and fetch the internally stored factory | 113 | // we can (and must) cast and fetch the internally stored factory |
114 | return &proxy->m_factory; | 114 | return &proxy->factory; |
115 | } else { | 115 | } else { |
116 | // essentially we are making sure that the metatable of the object we want to copy is stored in our metatable/factory database | 116 | // essentially we are making sure that the metatable of the object we want to copy is stored in our metatable/factory database |
117 | // it is the only way to ensure that the userdata is indeed a deep userdata! | 117 | // it is the only way to ensure that the userdata is indeed a deep userdata! |
@@ -138,7 +138,7 @@ static void LookupDeep(lua_State* L_) | |||
138 | void DeepFactory::DeleteDeepObject(lua_State* L_, DeepPrelude* o_) | 138 | void DeepFactory::DeleteDeepObject(lua_State* L_, DeepPrelude* o_) |
139 | { | 139 | { |
140 | STACK_CHECK_START_REL(L_, 0); | 140 | STACK_CHECK_START_REL(L_, 0); |
141 | o_->m_factory.deleteDeepObjectInternal(L_, o_); | 141 | o_->factory.deleteDeepObjectInternal(L_, o_); |
142 | STACK_CHECK(L_, 0); | 142 | STACK_CHECK(L_, 0); |
143 | } | 143 | } |
144 | 144 | ||
@@ -157,7 +157,7 @@ void DeepFactory::DeleteDeepObject(lua_State* L_, DeepPrelude* o_) | |||
157 | 157 | ||
158 | // can work without a universe if creating a deep userdata from some external C module when Lanes isn't loaded | 158 | // can work without a universe if creating a deep userdata from some external C module when Lanes isn't loaded |
159 | // in that case, we are not multithreaded and locking isn't necessary anyway | 159 | // in that case, we are not multithreaded and locking isn't necessary anyway |
160 | bool const isLastRef{ p->m_refcount.fetch_sub(1, std::memory_order_relaxed) == 1 }; | 160 | bool const isLastRef{ p->refcount.fetch_sub(1, std::memory_order_relaxed) == 1 }; |
161 | 161 | ||
162 | if (isLastRef) { | 162 | if (isLastRef) { |
163 | // retrieve wrapped __gc | 163 | // retrieve wrapped __gc |
@@ -205,10 +205,10 @@ char const* DeepFactory::PushDeepProxy(DestState L_, DeepPrelude* prelude_, int | |||
205 | DeepPrelude** const proxy{ lua_newuserdatauv<DeepPrelude*>(L_, nuv_) }; // L_: DPC proxy | 205 | DeepPrelude** const proxy{ lua_newuserdatauv<DeepPrelude*>(L_, nuv_) }; // L_: DPC proxy |
206 | LUA_ASSERT(L_, proxy); | 206 | LUA_ASSERT(L_, proxy); |
207 | *proxy = prelude_; | 207 | *proxy = prelude_; |
208 | prelude_->m_refcount.fetch_add(1, std::memory_order_relaxed); // one more proxy pointing to this deep data | 208 | prelude_->refcount.fetch_add(1, std::memory_order_relaxed); // one more proxy pointing to this deep data |
209 | 209 | ||
210 | // Get/create metatable for 'factory' (in this state) | 210 | // Get/create metatable for 'factory' (in this state) |
211 | DeepFactory& factory = prelude_->m_factory; | 211 | DeepFactory& factory = prelude_->factory; |
212 | lua_pushlightuserdata(L_, std::bit_cast<void*>(&factory)); // L_: DPC proxy factory | 212 | lua_pushlightuserdata(L_, std::bit_cast<void*>(&factory)); // L_: DPC proxy factory |
213 | LookupDeep(L_); // L_: DPC proxy metatable|nil | 213 | LookupDeep(L_); // L_: DPC proxy metatable|nil |
214 | 214 | ||
@@ -323,14 +323,14 @@ int DeepFactory::pushDeepUserdata(DestState L_, int nuv_) const | |||
323 | raise_luaL_error(L_, "DeepFactory::newDeepObjectInternal failed to create deep userdata (out of memory)"); | 323 | raise_luaL_error(L_, "DeepFactory::newDeepObjectInternal failed to create deep userdata (out of memory)"); |
324 | } | 324 | } |
325 | 325 | ||
326 | if (prelude->m_magic != kDeepVersion) { | 326 | if (prelude->magic != kDeepVersion) { |
327 | // just in case, don't leak the newly allocated deep userdata object | 327 | // just in case, don't leak the newly allocated deep userdata object |
328 | deleteDeepObjectInternal(L_, prelude); | 328 | deleteDeepObjectInternal(L_, prelude); |
329 | raise_luaL_error(L_, "Bad Deep Factory: kDeepVersion is incorrect, rebuild your implementation with the latest deep implementation"); | 329 | raise_luaL_error(L_, "Bad Deep Factory: kDeepVersion is incorrect, rebuild your implementation with the latest deep implementation"); |
330 | } | 330 | } |
331 | 331 | ||
332 | LUA_ASSERT(L_, prelude->m_refcount.load(std::memory_order_relaxed) == 0); // 'DeepFactory::PushDeepProxy' will lift it to 1 | 332 | LUA_ASSERT(L_, prelude->refcount.load(std::memory_order_relaxed) == 0); // 'DeepFactory::PushDeepProxy' will lift it to 1 |
333 | LUA_ASSERT(L_, &prelude->m_factory == this); | 333 | LUA_ASSERT(L_, &prelude->factory == this); |
334 | 334 | ||
335 | if (lua_gettop(L_) - oldtop != 0) { | 335 | if (lua_gettop(L_) - oldtop != 0) { |
336 | // just in case, don't leak the newly allocated deep userdata object | 336 | // just in case, don't leak the newly allocated deep userdata object |