diff options
Diffstat (limited to '')
-rw-r--r-- | src/lindafactory.cpp | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/src/lindafactory.cpp b/src/lindafactory.cpp index 8622c12..863f16e 100644 --- a/src/lindafactory.cpp +++ b/src/lindafactory.cpp | |||
@@ -105,26 +105,9 @@ std::string_view LindaFactory::moduleName() const | |||
105 | 105 | ||
106 | DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* const L_) const | 106 | DeepPrelude* LindaFactory::newDeepObjectInternal(lua_State* const L_) const |
107 | { | 107 | { |
108 | std::string_view _linda_name{}; | 108 | // we always expect name and group at the bottom of the stack (either can be nil). any extra stuff we ignore and keep unmodified |
109 | LindaGroup _linda_group{ 0 }; | 109 | std::string_view _linda_name{ luaG_tostring(L_, 1) }; |
110 | // should have a string and/or a number of the stack as parameters (name and group) | 110 | LindaGroup _linda_group{ static_cast<int>(lua_tointeger(L_, 2)) }; |
111 | switch (lua_gettop(L_)) { | ||
112 | default: // 0 | ||
113 | break; | ||
114 | |||
115 | case 1: // 1 parameter, either a name or a group | ||
116 | if (luaG_type(L_, -1) == LuaType::STRING) { | ||
117 | _linda_name = luaG_tostring(L_, -1); | ||
118 | } else { | ||
119 | _linda_group = LindaGroup{ static_cast<int>(lua_tointeger(L_, -1)) }; | ||
120 | } | ||
121 | break; | ||
122 | |||
123 | case 2: // 2 parameters, a name and group, in that order | ||
124 | _linda_name = luaG_tostring(L_, -2); | ||
125 | _linda_group = LindaGroup{ static_cast<int>(lua_tointeger(L_, -1)) }; | ||
126 | break; | ||
127 | } | ||
128 | 111 | ||
129 | // store in the linda the location of the script that created it | 112 | // store in the linda the location of the script that created it |
130 | if (_linda_name == "auto") { | 113 | if (_linda_name == "auto") { |