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

SCRIPT: The get module/function/job methods in LuaContext now aborts the lua interpreter on errors

parent 26bbe15f
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
......@@ -201,8 +201,11 @@ LuaContext::getModule(const std::string_view name) const noexcept
const int r = modules.at(name);
lua_rawgeti(L, LUA_REGISTRYINDEX, r);
return ModuleDeclaration::CHECK(L, -1);
} else {
lua_pushnil(L);
}
else {
const std::string moduleName(name);
luaL_error(L, "Module %s not found", moduleName.c_str());
return nullptr;
}
}
......@@ -214,8 +217,12 @@ LuaContext::getFunction(const std::string_view module, const std::string_view na
const int r = functions.at({ module, name });
lua_rawgeti(L, LUA_REGISTRYINDEX, r);
return FunctionDeclaration::CHECK(L, -1);
} else {
lua_pushnil(L);
}
else {
const std::string moduleName(module);
const std::string functionName(name);
luaL_error(L, "Function %s::%s not found", moduleName.c_str(), functionName.c_str());
return nullptr;
}
}
......@@ -223,13 +230,17 @@ LuaContext::getFunction(const std::string_view module, const std::string_view na
JobDeclaration *
LuaContext::getJob(const std::string_view module, const std::string_view name) const noexcept
{
if (moduleExists(module)) {
if (moduleExists(module) && jobs.count({ module, name }) >= 1) {
const int r = jobs.at({ module, name });
lua_rawgeti(L, LUA_REGISTRYINDEX, r);
return JobDeclaration::CHECK(L, -1);
} else {
lua_pushnil(L);
return nullptr;
}
else {
const std::string moduleName(module);
const std::string jobName(name);
luaL_error(L, "Job %s::%s not found", moduleName.c_str(), jobName.c_str());
return nullptr; // Unreachable
}
}
......
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