aboutsummaryrefslogtreecommitdiff
path: root/src/lindafactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lindafactory.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lindafactory.cpp b/src/lindafactory.cpp
index 42d0984..4eab0c1 100644
--- a/src/lindafactory.cpp
+++ b/src/lindafactory.cpp
@@ -108,9 +108,11 @@ std::string_view LindaFactory::moduleName() const
108 108
109DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* const L_) const 109DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* const L_) const
110{ 110{
111 // we always expect name and group at the bottom of the stack (either can be nil). any extra stuff we ignore and keep unmodified 111 STACK_CHECK_START_REL(L_, 0);
112 // we always expect name, wake_period, group at the bottom of the stack (either can be nil). any extra stuff we ignore and keep unmodified
112 std::string_view _linda_name{ luaG_tostring(L_, StackIndex{ 1 }) }; 113 std::string_view _linda_name{ luaG_tostring(L_, StackIndex{ 1 }) };
113 LindaGroup _linda_group{ static_cast<int>(lua_tointeger(L_, 2)) }; 114 auto const _wake_period{ static_cast<lua_Duration>(lua_tonumber(L_, 2)) };
115 LindaGroup const _linda_group{ static_cast<int>(lua_tointeger(L_, 3)) };
114 116
115 // store in the linda the location of the script that created it 117 // store in the linda the location of the script that created it
116 if (_linda_name == "auto") { 118 if (_linda_name == "auto") {
@@ -129,6 +131,7 @@ DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* const L_) const
129 // The deep data is allocated separately of Lua stack; we might no longer be around when last reference to it is being released. 131 // The deep data is allocated separately of Lua stack; we might no longer be around when last reference to it is being released.
130 // One can use any memory allocation scheme. Just don't use L's allocF because we don't know which state will get the honor of GCing the linda 132 // One can use any memory allocation scheme. Just don't use L's allocF because we don't know which state will get the honor of GCing the linda
131 Universe* const _U{ Universe::Get(L_) }; 133 Universe* const _U{ Universe::Get(L_) };
132 Linda* const _linda{ new (_U) Linda{ _U, _linda_group, _linda_name } }; 134 Linda* const _linda{ new (_U) Linda{ _U, _linda_name, _wake_period, _linda_group } };
135 STACK_CHECK(L_, 0);
133 return _linda; 136 return _linda;
134} 137}