Add option to limit automatable control parmaters
[ardour.git] / libs / ardour / luascripting.cc
index a63dc9ea489f91ed80a34b279335d55b13e18627..e748fb656e792752bbb0792bb0f7eca2b2fd3ee0 100644 (file)
@@ -262,7 +262,7 @@ LuaScripting::scan_script (const std::string &fn, const std::string &sc)
                try {
                        std::string script = Glib::file_get_contents (fn);
                        sha1_write (&s, (const uint8_t *) script.c_str(), script.size ());
-               } catch (Glib::FileError err) {
+               } catch (Glib::FileError const& err) {
                        return LuaScriptInfoPtr();
                }
        }
@@ -294,9 +294,11 @@ LuaScripting::scan_script (const std::string &fn, const std::string &sc)
 
                luabridge::LuaRef lua_ss = luabridge::getGlobal (L, "session_setup");
                if (lua_ss.isFunction ()) {
-                       if (lua_ss () == true) {
-                               lsi->subtype |= LuaScriptInfo::SessionSetup;
-                       }
+                       try {
+                               if (lua_ss () == true) {
+                                       lsi->subtype |= LuaScriptInfo::SessionSetup;
+                               }
+                       } catch (...) { }
                }
 
        }
@@ -371,10 +373,16 @@ LuaScriptParams::script_params (const LuaScriptInfoPtr& lsi, const std::string &
 
 LuaScriptParamList
 LuaScriptParams::script_params (const std::string& s, const std::string &pname, bool file)
+{
+       LuaState lua;
+       return LuaScriptParams::script_params (lua, s, pname, file);
+}
+
+LuaScriptParamList
+LuaScriptParams::script_params (LuaState& lua, const std::string& s, const std::string &pname, bool file)
 {
        LuaScriptParamList rv;
 
-       LuaState lua;
        lua_State* L = lua.getState();
        lua.sandbox (true);
        lua.do_command ("function ardour () end");
@@ -402,6 +410,7 @@ LuaScriptParams::script_params (const std::string& s, const std::string &pname,
                                std::string title = i.value ()["title"].cast<std::string> ();
                                std::string dflt;
                                bool optional = false;
+                               bool preseeded = false;
 
                                if (i.value ()["default"].isString ()) {
                                        dflt = i.value ()["default"].cast<std::string> ();
@@ -409,7 +418,10 @@ LuaScriptParams::script_params (const std::string& s, const std::string &pname,
                                if (i.value ()["optional"].isBoolean ()) {
                                        optional = i.value ()["optional"].cast<bool> ();
                                }
-                               LuaScriptParamPtr lsspp (new LuaScriptParam(name, title, dflt, optional));
+                               if (i.value ()["preseeded"].isBoolean ()) {
+                                       preseeded = i.value ()["preseeded"].cast<bool> ();
+                               }
+                               LuaScriptParamPtr lsspp (new LuaScriptParam(name, title, dflt, optional, preseeded));
                                rv.push_back (lsspp);
                        }
                }