diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-03 15:53:34 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-03 15:53:34 +0200 |
commit | 44c617f7b756052c7cd059c96f89b85f0f5ec96c (patch) | |
tree | a9ac504d7ffa09500c9ea17bab963f1016f6fe79 /src/deep.cpp | |
parent | 420e50697cd036a0d8ea1601961bd6974703ade1 (diff) | |
download | lanes-44c617f7b756052c7cd059c96f89b85f0f5ec96c.tar.gz lanes-44c617f7b756052c7cd059c96f89b85f0f5ec96c.tar.bz2 lanes-44c617f7b756052c7cd059c96f89b85f0f5ec96c.zip |
Moved lanes.sleep implementation to the C-side
Diffstat (limited to 'src/deep.cpp')
-rw-r--r-- | src/deep.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/deep.cpp b/src/deep.cpp index 34cc4b4..76397ae 100644 --- a/src/deep.cpp +++ b/src/deep.cpp | |||
@@ -191,7 +191,7 @@ void DeepFactory::PushDeepProxy(DestState const L_, DeepPrelude* const prelude_, | |||
191 | STACK_GROW(L_, 7); | 191 | STACK_GROW(L_, 7); |
192 | 192 | ||
193 | // a new full userdata, fitted with the specified number of uservalue slots (always 1 for Lua < 5.4) | 193 | // a new full userdata, fitted with the specified number of uservalue slots (always 1 for Lua < 5.4) |
194 | DeepPrelude** const _proxy{ lua_newuserdatauv<DeepPrelude*>(L_, nuv_) }; // L_: DPC proxy | 194 | DeepPrelude** const _proxy{ lua_newuserdatauv<DeepPrelude*>(L_, nuv_) }; // L_: DPC proxy |
195 | LUA_ASSERT(L_, _proxy); | 195 | LUA_ASSERT(L_, _proxy); |
196 | *_proxy = prelude_; | 196 | *_proxy = prelude_; |
197 | prelude_->refcount.fetch_add(1, std::memory_order_relaxed); // one more proxy pointing to this deep data | 197 | prelude_->refcount.fetch_add(1, std::memory_order_relaxed); // one more proxy pointing to this deep data |
@@ -268,10 +268,10 @@ void DeepFactory::PushDeepProxy(DestState const L_, DeepPrelude* const prelude_, | |||
268 | } | 268 | } |
269 | } | 269 | } |
270 | } | 270 | } |
271 | STACK_CHECK(L_, 3); // DPC proxy metatable | 271 | STACK_CHECK(L_, 3); // L_: DPC proxy metatable |
272 | LUA_ASSERT(L_, lua_type_as_enum(L_, -2) == LuaType::USERDATA); | 272 | LUA_ASSERT(L_, lua_type_as_enum(L_, -2) == LuaType::USERDATA); |
273 | LUA_ASSERT(L_, lua_istable(L_, -1)); | 273 | LUA_ASSERT(L_, lua_istable(L_, -1)); |
274 | lua_setmetatable(L_, -2); // DPC proxy | 274 | lua_setmetatable(L_, -2); // L_: DPC proxy |
275 | 275 | ||
276 | // If we're here, we obviously had to create a new proxy, so cache it. | 276 | // If we're here, we obviously had to create a new proxy, so cache it. |
277 | lua_pushlightuserdata(L_, prelude_); // L_: DPC proxy deep | 277 | lua_pushlightuserdata(L_, prelude_); // L_: DPC proxy deep |
@@ -375,3 +375,15 @@ DeepPrelude* DeepFactory::toDeep(lua_State* const L_, int const index_) const | |||
375 | DeepPrelude** const _proxy{ lua_tofulluserdata<DeepPrelude*>(L_, index_) }; | 375 | DeepPrelude** const _proxy{ lua_tofulluserdata<DeepPrelude*>(L_, index_) }; |
376 | return *_proxy; | 376 | return *_proxy; |
377 | } | 377 | } |
378 | |||
379 | // ################################################################################################# | ||
380 | |||
381 | void DeepPrelude::push(lua_State* L_) const | ||
382 | { | ||
383 | STACK_CHECK_START_REL(L_, 0); | ||
384 | kDeepProxyCacheRegKey.getSubTableMode(L_, "v"); // L_: DPC | ||
385 | lua_pushlightuserdata(L_, const_cast<DeepPrelude*>(this)); // L_: DPC this | ||
386 | lua_rawget(L_, -2); // L_: DPC deep | ||
387 | lua_remove(L_, -2); // L_: deep | ||
388 | STACK_CHECK(L_, 1); | ||
389 | } | ||