Save Lua script origin (for later updates) -- DSP plugin
authorRobin Gareus <robin@gareus.org>
Fri, 24 Feb 2017 13:11:56 +0000 (14:11 +0100)
committerRobin Gareus <robin@gareus.org>
Fri, 24 Feb 2017 15:10:14 +0000 (16:10 +0100)
libs/ardour/ardour/luaproc.h
libs/ardour/luaproc.cc

index 423a960feb22336af6f6ece25175aa7b09cb0ce9..2c4f7989455db1c76c4659f65bbf71673c804204 100644 (file)
@@ -132,8 +132,13 @@ private:
        void find_presets ();
 
        /* END Plugin interface */
+
+public:
+       void set_origin (std::string& path) { _origin = path; }
+
 protected:
        const std::string& script() const { return _script; }
+       const std::string& origin() const { return _origin; }
 
 private:
 #ifdef USE_TLSF
@@ -144,6 +149,7 @@ private:
        LuaState lua;
        luabridge::LuaRef * _lua_dsp;
        std::string _script;
+       std::string _origin;
        std::string _docs;
        bool _lua_does_channelmapping;
        bool _lua_has_inline_display;
index 9b51565b9ca15a83664bc17cf80430427e1a6920..bae1bd6d3dd2435a141b85d7e9bbf9f53fbce908 100644 (file)
@@ -87,6 +87,7 @@ LuaProc::LuaProc (const LuaProc &other)
 #endif
        , _lua_dsp (0)
        , _script (other.script ())
+       , _origin (other._origin)
        , _lua_does_channelmapping (false)
        , _lua_has_inline_display (false)
        , _designated_bypass_port (UINT32_MAX)
@@ -763,6 +764,7 @@ LuaProc::add_state (XMLNode* root) const
        g_free (b64);
        XMLNode* script_node = new XMLNode (X_("script"));
        script_node->add_property (X_("lua"), LUA_VERSION);
+       script_node->add_property (X_("origin"), _origin);
        script_node->add_content (b64s);
        root->add_child_nocopy (*script_node);
 
@@ -787,6 +789,10 @@ LuaProc::set_script_from_state (const XMLNode& node)
        }
 
        if ((child = node.child (X_("script"))) != 0) {
+               XMLProperty const* prop;
+               if ((prop = node.property ("origin")) != 0) {
+                       _origin = prop->value();
+               }
                for (XMLNodeList::const_iterator n = child->children ().begin (); n != child->children ().end (); ++n) {
                        if (!(*n)->is_content ()) { continue; }
                        gsize size;
@@ -1242,7 +1248,9 @@ LuaPluginInfo::load (Session& session)
        }
 
        try {
-               PluginPtr plugin (new LuaProc (session.engine (), session, script));
+               LuaProc* lp = new LuaProc (session.engine (), session, script);
+               lp->set_origin (path);
+               PluginPtr plugin (lp);
                return plugin;
        } catch (failed_constructor& err) {
                ;