Add method to look up Lua script by name
authorRobin Gareus <robin@gareus.org>
Thu, 12 Dec 2019 19:34:50 +0000 (20:34 +0100)
committerRobin Gareus <robin@gareus.org>
Thu, 12 Dec 2019 19:53:17 +0000 (20:53 +0100)
libs/ardour/ardour/luascripting.h
libs/ardour/luascripting.cc

index 76c49c1788d951bf22cc96966ce58b6ac7c6b20d..283c68df8df6bfa2771754a568f2079a7eb4db4a 100644 (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");
index 3f1ec81e422f72616da3ffa3ba5b577bd0173214..c1bd777f0fc81da6119902f2c76fec48d3cc4e9b 100644 (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) {