diff options
Diffstat (limited to '')
-rw-r--r-- | src/lindafactory.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/lindafactory.cpp b/src/lindafactory.cpp index 0ec5a0a..16c653f 100644 --- a/src/lindafactory.cpp +++ b/src/lindafactory.cpp | |||
@@ -68,25 +68,25 @@ void LindaFactory::createMetatable(lua_State* L_) const | |||
68 | 68 | ||
69 | void LindaFactory::deleteDeepObjectInternal(lua_State* L_, DeepPrelude* o_) const | 69 | void LindaFactory::deleteDeepObjectInternal(lua_State* L_, DeepPrelude* o_) const |
70 | { | 70 | { |
71 | Linda* const linda{ static_cast<Linda*>(o_) }; | 71 | Linda* const _linda{ static_cast<Linda*>(o_) }; |
72 | LUA_ASSERT(L_, linda); | 72 | LUA_ASSERT(L_, _linda); |
73 | Keeper* const myK{ linda->whichKeeper() }; | 73 | Keeper* const _myK{ _linda->whichKeeper() }; |
74 | // if collected after the universe, keepers are already destroyed, and there is nothing to clear | 74 | // if collected after the universe, keepers are already destroyed, and there is nothing to clear |
75 | if (myK) { | 75 | if (_myK) { |
76 | // if collected from my own keeper, we can't acquire/release it | 76 | // if collected from my own keeper, we can't acquire/release it |
77 | // because we are already inside a protected area, and trying to do so would deadlock! | 77 | // because we are already inside a protected area, and trying to do so would deadlock! |
78 | bool const need_acquire_release{ myK->L != L_ }; | 78 | bool const _need_acquire_release{ _myK->L != L_ }; |
79 | // Clean associated structures in the keeper state. | 79 | // Clean associated structures in the keeper state. |
80 | Keeper* const K{ need_acquire_release ? linda->acquireKeeper() : myK }; | 80 | Keeper* const _K{ _need_acquire_release ? _linda->acquireKeeper() : _myK }; |
81 | // hopefully this won't ever raise an error as we would jump to the closest pcall site while forgetting to release the keeper mutex... | 81 | // hopefully this won't ever raise an error as we would jump to the closest pcall site while forgetting to release the keeper mutex... |
82 | [[maybe_unused]] KeeperCallResult const result{ keeper_call(linda->U, K->L, KEEPER_API(clear), L_, linda, 0) }; | 82 | [[maybe_unused]] KeeperCallResult const result{ keeper_call(_K->L, KEEPER_API(clear), L_, _linda, 0) }; |
83 | LUA_ASSERT(L_, result.has_value() && result.value() == 0); | 83 | LUA_ASSERT(L_, result.has_value() && result.value() == 0); |
84 | if (need_acquire_release) { | 84 | if (_need_acquire_release) { |
85 | linda->releaseKeeper(K); | 85 | _linda->releaseKeeper(_K); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | delete linda; // operator delete overload ensures things go as expected | 89 | delete _linda; // operator delete overload ensures things go as expected |
90 | } | 90 | } |
91 | 91 | ||
92 | // ################################################################################################# | 92 | // ################################################################################################# |
@@ -103,9 +103,9 @@ char const* LindaFactory::moduleName() const | |||
103 | 103 | ||
104 | DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* L_) const | 104 | DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* L_) const |
105 | { | 105 | { |
106 | size_t name_len{ 0 }; | 106 | size_t _name_len{ 0 }; |
107 | char const* linda_name{ nullptr }; | 107 | char const* _linda_name{ nullptr }; |
108 | LindaGroup linda_group{ 0 }; | 108 | LindaGroup _linda_group{ 0 }; |
109 | // should have a string and/or a number of the stack as parameters (name and group) | 109 | // should have a string and/or a number of the stack as parameters (name and group) |
110 | switch (lua_gettop(L_)) { | 110 | switch (lua_gettop(L_)) { |
111 | default: // 0 | 111 | default: // 0 |
@@ -113,21 +113,21 @@ DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* L_) const | |||
113 | 113 | ||
114 | case 1: // 1 parameter, either a name or a group | 114 | case 1: // 1 parameter, either a name or a group |
115 | if (lua_type(L_, -1) == LUA_TSTRING) { | 115 | if (lua_type(L_, -1) == LUA_TSTRING) { |
116 | linda_name = lua_tolstring(L_, -1, &name_len); | 116 | _linda_name = lua_tolstring(L_, -1, &_name_len); |
117 | } else { | 117 | } else { |
118 | linda_group = LindaGroup{ static_cast<int>(lua_tointeger(L_, -1)) }; | 118 | _linda_group = LindaGroup{ static_cast<int>(lua_tointeger(L_, -1)) }; |
119 | } | 119 | } |
120 | break; | 120 | break; |
121 | 121 | ||
122 | case 2: // 2 parameters, a name and group, in that order | 122 | case 2: // 2 parameters, a name and group, in that order |
123 | linda_name = lua_tolstring(L_, -2, &name_len); | 123 | _linda_name = lua_tolstring(L_, -2, &_name_len); |
124 | linda_group = LindaGroup{ static_cast<int>(lua_tointeger(L_, -1)) }; | 124 | _linda_group = LindaGroup{ static_cast<int>(lua_tointeger(L_, -1)) }; |
125 | break; | 125 | break; |
126 | } | 126 | } |
127 | 127 | ||
128 | // The deep data is allocated separately of Lua stack; we might no longer be around when last reference to it is being released. | 128 | // The deep data is allocated separately of Lua stack; we might no longer be around when last reference to it is being released. |
129 | // 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 | 129 | // 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 |
130 | Universe* const U{ universe_get(L_) }; | 130 | Universe* const _U{ universe_get(L_) }; |
131 | Linda* const linda{ new (U) Linda{ U, linda_group, linda_name, name_len } }; | 131 | Linda* const _linda{ new (_U) Linda{ _U, _linda_group, _linda_name, _name_len } }; |
132 | return linda; | 132 | return _linda; |
133 | } | 133 | } |