Add method to look up Lua script by name

This commit is contained in:
Robin Gareus 2019-12-12 20:34:50 +01:00
parent bf8c256771
commit 3208535c20
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 14 additions and 0 deletions

View File

@ -117,6 +117,8 @@ public:
void refresh (bool run_scan = false);
PBD::Signal0<void> scripts_changed;
LuaScriptInfoPtr by_name (const std::string&, LuaScriptInfo::ScriptType);
static LuaScriptInfoPtr script_info (const std::string &script);
static bool try_compile (const std::string&, const LuaScriptParamList&);
static std::string get_factory_bytecode (const std::string&, const std::string& ffn = "factory", const std::string& fp = "f");

View File

@ -337,6 +337,18 @@ LuaScripting::scripts (LuaScriptInfo::ScriptType type) {
return _empty_script_info; // make some compilers happy
}
LuaScriptInfoPtr
LuaScripting::by_name (const std::string& name, LuaScriptInfo::ScriptType type)
{
LuaScriptList lsl (scripts (type));
printf ("CHECKING %d scripts\n", lsl.size());
for (LuaScriptList::const_iterator s = lsl.begin(); s != lsl.end(); ++s) {
if ((*s)->name == name) {
return (*s);
}
}
return LuaScriptInfoPtr();
}
std::string
LuaScriptInfo::type2str (const ScriptType t) {