, _sl_hook (0)
, _sl_action (0)
, _sl_snippet (0)
+ , _sl_setup (0)
+ , _sl_tracks (0)
{
;
}
delete _sl_hook;
delete _sl_action;
delete _sl_snippet;
+ delete _sl_setup;
+ delete _sl_tracks;
}
}
delete _sl_hook;
delete _sl_action;
delete _sl_snippet;
+ delete _sl_setup;
+ delete _sl_tracks;
_sl_dsp = 0;
_sl_session = 0;
_sl_hook = 0;
_sl_action = 0;
_sl_snippet = 0;
+ _sl_setup = 0;
+ _sl_tracks = 0;
if (run_scan) {
lm.release ();
CLEAR_OR_NEW (_sl_hook)
CLEAR_OR_NEW (_sl_action)
CLEAR_OR_NEW (_sl_snippet)
+ CLEAR_OR_NEW (_sl_setup)
+ CLEAR_OR_NEW (_sl_tracks)
#undef CLEAR_OR_NEW
case LuaScriptInfo::Snippet:
_sl_snippet->push_back(lsi);
break;
+ case LuaScriptInfo::SessionInit:
+ _sl_setup->push_back(lsi);
+ break;
default:
break;
}
std::sort (_sl_hook->begin(), _sl_hook->end(), ScriptSorter());
std::sort (_sl_action->begin(), _sl_action->end(), ScriptSorter());
std::sort (_sl_snippet->begin(), _sl_snippet->end(), ScriptSorter());
+ std::sort (_sl_setup->begin(), _sl_setup->end(), ScriptSorter());
+ std::sort (_sl_tracks->begin(), _sl_tracks->end(), ScriptSorter());
scripts_changed (); /* EMIT SIGNAL */
}
lua_State* L = lua.getState();
lua.Print.connect (&LuaScripting::lua_print);
-
- lua.do_command ("io = nil;");
+ lua.sandbox (true);
lua.do_command (
"ardourluainfo = {}"
if (key == "description") { lsi->description = val; }
if (key == "category") { lsi->category = val; }
}
+
+
+ if (type == LuaScriptInfo::EditorAction) {
+
+ luabridge::LuaRef lua_rs = luabridge::getGlobal (L, "route_setup");
+ if (lua_rs.isFunction ()) {
+ lsi->subtype |= LuaScriptInfo::RouteSetup;
+ }
+
+ luabridge::LuaRef lua_ss = luabridge::getGlobal (L, "session_setup");
+ if (lua_ss.isFunction ()) {
+ try {
+ if (lua_ss () == true) {
+ lsi->subtype |= LuaScriptInfo::SessionSetup;
+ }
+ } catch (...) { }
+ }
+
+ }
+
return lsi;
}
LuaScriptList &
LuaScripting::scripts (LuaScriptInfo::ScriptType type) {
- if (!_sl_dsp || !_sl_session || !_sl_hook || !_sl_action || !_sl_snippet) {
+ if (!_sl_dsp || !_sl_session || !_sl_hook || !_sl_action || !_sl_snippet || ! _sl_setup || ! _sl_tracks) {
scan ();
}
case LuaScriptInfo::Snippet:
return *_sl_snippet;
break;
+ case LuaScriptInfo::SessionInit:
+ return *_sl_setup;
+ break;
default:
break;
}
case LuaScriptInfo::EditorHook: return "EditorHook";
case LuaScriptInfo::EditorAction: return "EditorAction";
case LuaScriptInfo::Snippet: return "Snippet";
+ case LuaScriptInfo::SessionInit: return "SessionInit";
default: return "Invalid";
}
}
if (!strcasecmp (type, "EditorHook")) {return LuaScriptInfo::EditorHook;}
if (!strcasecmp (type, "EditorAction")) {return LuaScriptInfo::EditorAction;}
if (!strcasecmp (type, "Snippet")) {return LuaScriptInfo::Snippet;}
+ if (!strcasecmp (type, "SessionInit")) {return LuaScriptInfo::SessionInit;}
return LuaScriptInfo::Invalid;
}
LuaState lua;
lua_State* L = lua.getState();
- lua.do_command ("io = nil;");
+ lua.sandbox (true);
lua.do_command ("function ardour () end");
try {
} else {
lua.do_command (s);
}
- } catch (luabridge::LuaException const& e) {
+ } catch (...) {
return rv;
}
}
LuaState l;
l.Print.connect (&LuaScripting::lua_print);
+ l.sandbox (true);
lua_State* L = l.getState();
l.do_command (""
" assert(type(f) == 'string', 'Assigned ByteCode must be string')"
" local factory = load(f)"
" assert(type(factory) == 'function', 'Factory is a not a function')"
- " local env = _ENV; env.f = nil env.debug = nil os.exit = nil"
+ " local env = _ENV; env.f = nil env.os = nil env.io = nil"
" load (string.dump(factory, true), nil, nil, env)(a)"
" end"
);
cerr << e.what() << "\n";
#endif
lua_print (e.what());
- }
+ } catch (...) { }
return false;
}
std::string
-LuaScripting::get_factory_bytecode (const std::string& script)
+LuaScripting::get_factory_bytecode (const std::string& script, const std::string& ffn, const std::string& fp)
{
LuaState l;
l.Print.connect (&LuaScripting::lua_print);
+ l.sandbox (true);
lua_State* L = l.getState();
l.do_command (
""
" function dump_function (f)"
" assert(type(f) == 'function', 'Factory is a not a function')"
- " return string.format(\"f = %q\", string.dump(f, true))"
+ " return string.format(\"" + fp + " = %q\", string.dump(f, true))"
" end"
);
luabridge::LuaRef lua_dump = luabridge::getGlobal (L, "dump_function");
l.do_command ("dump_function = nil"); // hide it
l.do_command (script); // register "factory"
- luabridge::LuaRef lua_factory = luabridge::getGlobal (L, "factory");
+ luabridge::LuaRef lua_factory = luabridge::getGlobal (L, ffn.c_str());
if (lua_factory.isFunction()) {
return (lua_dump(lua_factory)).cast<std::string> ();
}
- } catch (luabridge::LuaException const& e) { }
+ } catch (...) { }
return "";
}