Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 5b2963e1 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

SCRIPT: Get ride of the unregister functions in the LuaContext because...

SCRIPT: Get ride of the unregister functions in the LuaContext because everything will be wiped out when closing the lua_State
parent 9ee25193
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!16Add a way to execute a Lua file with Vivy in a click-click way
......@@ -126,11 +126,11 @@ LuaContext::getLastLuaError() noexcept
{
const int type = lua_type(L, -1);
if (type != LUA_TSTRING) {
return QString("No lua error detected...");
return QStringLiteral("No lua error detected...");
}
const char *error = lua_tostring(L, -1);
QString ret = QString("%1").arg(error);
QString ret = QStringLiteral("%1").arg(error);
lua_pop(L, 1);
return ret;
}
......@@ -208,49 +208,6 @@ LuaContext::getModule(const std::string_view name) const noexcept
}
}
LuaContext::Code
LuaContext::unregisterFunctionDeclaration(const std::string_view module,
const std::string_view name) noexcept
{
return unregisterFromMapTuple(module, name, &functions);
}
LuaContext::Code
LuaContext::unregisterJobDeclaration(const std::string_view module,
const std::string_view name) noexcept
{
return unregisterFromMapTuple(module, name, &jobs);
}
LuaContext::Code
LuaContext::unregisterFromMapTuple(
string_view module, string_view name,
std::map<std::tuple<string_view, string_view>, const int> *const map) noexcept
{
if (!moduleExists(module))
return Error;
if (map->count({ module, name }) >= 1) {
const int r = map->at({ module, name });
luaL_unref(L, LUA_REGISTRYINDEX, r);
return Success;
} else {
return Error;
}
}
LuaContext::Code
LuaContext::unregisterModuleDeclaration(const std::string_view name) noexcept
{
if (moduleExists(name)) {
const int r = modules.at(name);
luaL_unref(L, LUA_REGISTRYINDEX, r);
return Code::Success;
} else {
return Code::Error;
}
}
const std::vector<std::string_view>
LuaContext::getAllModuleName() const noexcept
{
......
......@@ -67,9 +67,6 @@ public:
Code registerDeclaration(const ModuleDeclaration *const) noexcept;
Code registerDeclaration(const FunctionDeclaration *const) noexcept;
Code registerDeclaration(const JobDeclaration *const) noexcept;
Code unregisterModuleDeclaration(string_view) noexcept;
Code unregisterFunctionDeclaration(string_view, string_view) noexcept;
Code unregisterJobDeclaration(string_view, string_view) noexcept;
// Returns the module or `nullptr` if not found.
const ModuleDeclaration *getModule(const std::string_view) const noexcept;
......@@ -93,9 +90,6 @@ private:
Code loadFile(const char *) noexcept;
void loadPackagedFile(const QString &) noexcept;
Code unregisterFromMapTuple(
const std::string_view module, const std::string_view name,
std::map<std::tuple<string_view, string_view>, const int> *const mapPtr) noexcept;
Code registerToMapTuple(
const std::string_view module, const std::string_view name,
std::map<std::tuple<string_view, string_view>, const int> *const mapPtr) noexcept;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter