13
0

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 ();
/* 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;

View 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) {
;