Save Lua script origin (for later updates) -- DSP plugin

This commit is contained in:
Robin Gareus 2017-02-24 14:11:56 +01:00
parent 81a0bdcc40
commit 24f070610c
2 changed files with 15 additions and 1 deletions

View file

@ -132,8 +132,13 @@ private:
void find_presets (); void find_presets ();
/* END Plugin interface */ /* END Plugin interface */
public:
void set_origin (std::string& path) { _origin = path; }
protected: protected:
const std::string& script() const { return _script; } const std::string& script() const { return _script; }
const std::string& origin() const { return _origin; }
private: private:
#ifdef USE_TLSF #ifdef USE_TLSF
@ -144,6 +149,7 @@ private:
LuaState lua; LuaState lua;
luabridge::LuaRef * _lua_dsp; luabridge::LuaRef * _lua_dsp;
std::string _script; std::string _script;
std::string _origin;
std::string _docs; std::string _docs;
bool _lua_does_channelmapping; bool _lua_does_channelmapping;
bool _lua_has_inline_display; bool _lua_has_inline_display;

View file

@ -87,6 +87,7 @@ LuaProc::LuaProc (const LuaProc &other)
#endif #endif
, _lua_dsp (0) , _lua_dsp (0)
, _script (other.script ()) , _script (other.script ())
, _origin (other._origin)
, _lua_does_channelmapping (false) , _lua_does_channelmapping (false)
, _lua_has_inline_display (false) , _lua_has_inline_display (false)
, _designated_bypass_port (UINT32_MAX) , _designated_bypass_port (UINT32_MAX)
@ -763,6 +764,7 @@ LuaProc::add_state (XMLNode* root) const
g_free (b64); g_free (b64);
XMLNode* script_node = new XMLNode (X_("script")); XMLNode* script_node = new XMLNode (X_("script"));
script_node->add_property (X_("lua"), LUA_VERSION); script_node->add_property (X_("lua"), LUA_VERSION);
script_node->add_property (X_("origin"), _origin);
script_node->add_content (b64s); script_node->add_content (b64s);
root->add_child_nocopy (*script_node); 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) { 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) { for (XMLNodeList::const_iterator n = child->children ().begin (); n != child->children ().end (); ++n) {
if (!(*n)->is_content ()) { continue; } if (!(*n)->is_content ()) { continue; }
gsize size; gsize size;
@ -1242,7 +1248,9 @@ LuaPluginInfo::load (Session& session)
} }
try { 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; return plugin;
} catch (failed_constructor& err) { } catch (failed_constructor& err) {
; ;