Adapt LuaCallback to new template variadic Signal
This commit is contained in:
parent
16dd8528c8
commit
6e19813c9b
@ -357,9 +357,9 @@ class PangoLayout {
|
||||
|
||||
namespace LuaSignal {
|
||||
|
||||
#define STATIC(name,c,p) else if (!strcmp(type, #name)) {return name;}
|
||||
#define SESSION(name,c,p) else if (!strcmp(type, #name)) {return name;}
|
||||
#define ENGINE(name,c,p) else if (!strcmp(type, #name)) {return name;}
|
||||
#define STATIC(name,c) else if (!strcmp(type, #name)) {return name;}
|
||||
#define SESSION(name,c) else if (!strcmp(type, #name)) {return name;}
|
||||
#define ENGINE(name,c) else if (!strcmp(type, #name)) {return name;}
|
||||
|
||||
LuaSignal
|
||||
str2luasignal (const std::string &str) {
|
||||
@ -375,9 +375,9 @@ str2luasignal (const std::string &str) {
|
||||
#undef SESSION
|
||||
#undef ENGINE
|
||||
|
||||
#define STATIC(name,c,p) N_(#name),
|
||||
#define SESSION(name,c,p) N_(#name),
|
||||
#define ENGINE(name,c,p) N_(#name),
|
||||
#define STATIC(name,c) N_(#name),
|
||||
#define SESSION(name,c) N_(#name),
|
||||
#define ENGINE(name,c) N_(#name),
|
||||
const char *luasignalstr[] = {
|
||||
# include "luasignal_syms.h"
|
||||
0
|
||||
@ -546,9 +546,9 @@ void
|
||||
LuaInstance::register_hooks (lua_State* L)
|
||||
{
|
||||
|
||||
#define ENGINE(name,c,p) .addConst (stringify(name), (LuaSignal::LuaSignal)LuaSignal::name)
|
||||
#define STATIC(name,c,p) .addConst (stringify(name), (LuaSignal::LuaSignal)LuaSignal::name)
|
||||
#define SESSION(name,c,p) .addConst (stringify(name), (LuaSignal::LuaSignal)LuaSignal::name)
|
||||
#define ENGINE(name,c) .addConst (stringify(name), (LuaSignal::LuaSignal)LuaSignal::name)
|
||||
#define STATIC(name,c) .addConst (stringify(name), (LuaSignal::LuaSignal)LuaSignal::name)
|
||||
#define SESSION(name,c) .addConst (stringify(name), (LuaSignal::LuaSignal)LuaSignal::name)
|
||||
luabridge::getGlobalNamespace (L)
|
||||
.beginNamespace ("LuaSignal")
|
||||
# include "luasignal_syms.h"
|
||||
@ -2375,9 +2375,9 @@ LuaCallback::reconnect_object (T obj)
|
||||
{
|
||||
for (uint32_t i = 0; i < LuaSignal::LAST_SIGNAL; ++i) {
|
||||
if (_signals[i]) {
|
||||
#define ENGINE(n,c,p) else if (i == LuaSignal::n) { connect_ ## p (LuaSignal::n, AudioEngine::instance(), &(AudioEngine::instance()->c)); }
|
||||
#define SESSION(n,c,p) else if (i == LuaSignal::n) { if (_session) { connect_ ## p (LuaSignal::n, _session, &(_session->c)); } }
|
||||
#define STATIC(n,c,p) else if (i == LuaSignal::n) { connect_ ## p (LuaSignal::n, obj, c); }
|
||||
#define ENGINE(n,c) else if (i == LuaSignal::n) { connect (LuaSignal::n, AudioEngine::instance(), &(AudioEngine::instance()->c)); }
|
||||
#define SESSION(n,c) else if (i == LuaSignal::n) { if (_session) { connect (LuaSignal::n, _session, &(_session->c)); } }
|
||||
#define STATIC(n,c) else if (i == LuaSignal::n) { connect (LuaSignal::n, obj, c); }
|
||||
if (0) {}
|
||||
# include "luasignal_syms.h"
|
||||
else {
|
||||
@ -2391,51 +2391,20 @@ LuaCallback::reconnect_object (T obj)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename S> void
|
||||
LuaCallback::connect_0 (enum LuaSignal::LuaSignal ls, T ref, S *signal) {
|
||||
template <typename T, typename... C> void
|
||||
LuaCallback::connect (enum LuaSignal::LuaSignal ls, T ref, PBD::Signal<void(C...)> *signal) {
|
||||
signal->connect (
|
||||
_connections, invalidator (*this),
|
||||
boost::bind (&LuaCallback::proxy_0<T>, this, ls, ref),
|
||||
gui_context());
|
||||
_connections,
|
||||
invalidator (*this),
|
||||
[=] (C... a) { return proxy(ls, ref, a...); },
|
||||
gui_context());
|
||||
}
|
||||
|
||||
template <typename T, typename C1> void
|
||||
LuaCallback::connect_1 (enum LuaSignal::LuaSignal ls, T ref, PBD::Signal1<void, C1> *signal) {
|
||||
signal->connect (
|
||||
_connections, invalidator (*this),
|
||||
boost::bind (&LuaCallback::proxy_1<T, C1>, this, ls, ref, _1),
|
||||
gui_context());
|
||||
}
|
||||
|
||||
template <typename T, typename C1, typename C2> void
|
||||
LuaCallback::connect_2 (enum LuaSignal::LuaSignal ls, T ref, PBD::Signal2<void, C1, C2> *signal) {
|
||||
signal->connect (
|
||||
_connections, invalidator (*this),
|
||||
boost::bind (&LuaCallback::proxy_2<T, C1, C2>, this, ls, ref, _1, _2),
|
||||
gui_context());
|
||||
}
|
||||
|
||||
template <typename T, typename C1, typename C2, typename C3> void
|
||||
LuaCallback::connect_3 (enum LuaSignal::LuaSignal ls, T ref, PBD::Signal3<void, C1, C2, C3> *signal) {
|
||||
signal->connect (
|
||||
_connections, invalidator (*this),
|
||||
boost::bind (&LuaCallback::proxy_3<T, C1, C2, C3>, this, ls, ref, _1, _2, _3),
|
||||
gui_context());
|
||||
}
|
||||
|
||||
template <typename T, typename C1, typename C2, typename C3, typename C4> void
|
||||
LuaCallback::connect_4 (enum LuaSignal::LuaSignal ls, T ref, PBD::Signal4<void, C1, C2, C3, C4> *signal) {
|
||||
signal->connect (
|
||||
_connections, invalidator (*this),
|
||||
boost::bind (&LuaCallback::proxy_4<T, C1, C2, C3, C4>, this, ls, ref, _1, _2, _3, _4),
|
||||
gui_context());
|
||||
}
|
||||
|
||||
template <typename T> void
|
||||
LuaCallback::proxy_0 (enum LuaSignal::LuaSignal ls, T ref) {
|
||||
template <typename T, typename... C> void
|
||||
LuaCallback::proxy (enum LuaSignal::LuaSignal ls, T ref, C... a) {
|
||||
bool ok = true;
|
||||
{
|
||||
const luabridge::LuaRef& rv ((*_lua_call)((int)ls, ref));
|
||||
const luabridge::LuaRef& rv ((*_lua_call)((int)ls, ref, a...));
|
||||
if (! rv.cast<bool> ()) {
|
||||
ok = false;
|
||||
}
|
||||
@ -2445,59 +2414,3 @@ LuaCallback::proxy_0 (enum LuaSignal::LuaSignal ls, T ref) {
|
||||
drop_callback (); /* EMIT SIGNAL */
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename C1> void
|
||||
LuaCallback::proxy_1 (enum LuaSignal::LuaSignal ls, T ref, C1 a1) {
|
||||
bool ok = true;
|
||||
{
|
||||
const luabridge::LuaRef& rv ((*_lua_call)((int)ls, ref, a1));
|
||||
if (! rv.cast<bool> ()) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
drop_callback (); /* EMIT SIGNAL */
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename C1, typename C2> void
|
||||
LuaCallback::proxy_2 (enum LuaSignal::LuaSignal ls, T ref, C1 a1, C2 a2) {
|
||||
bool ok = true;
|
||||
{
|
||||
const luabridge::LuaRef& rv ((*_lua_call)((int)ls, ref, a1, a2));
|
||||
if (! rv.cast<bool> ()) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
drop_callback (); /* EMIT SIGNAL */
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename C1, typename C2, typename C3> void
|
||||
LuaCallback::proxy_3 (enum LuaSignal::LuaSignal ls, T ref, C1 a1, C2 a2, C3 a3) {
|
||||
bool ok = true;
|
||||
{
|
||||
const luabridge::LuaRef& rv ((*_lua_call)((int)ls, ref, a1, a2, a3));
|
||||
if (! rv.cast<bool> ()) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
drop_callback (); /* EMIT SIGNAL */
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename C1, typename C2, typename C3, typename C4> void
|
||||
LuaCallback::proxy_4 (enum LuaSignal::LuaSignal ls, T ref, C1 a1, C2 a2, C3 a3, C4 a4) {
|
||||
bool ok = true;
|
||||
{
|
||||
const luabridge::LuaRef& rv ((*_lua_call)((int)ls, ref, a1, a2, a3, a4));
|
||||
if (! rv.cast<bool> ()) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
drop_callback (); /* EMIT SIGNAL */
|
||||
}
|
||||
}
|
||||
|
@ -83,20 +83,8 @@ private:
|
||||
|
||||
PBD::ScopedConnectionList _connections;
|
||||
|
||||
template <typename T, typename S> void connect_0 (enum LuaSignal::LuaSignal, T, S*);
|
||||
template <typename T> void proxy_0 (enum LuaSignal::LuaSignal, T);
|
||||
|
||||
template <typename T, typename C1> void connect_1 (enum LuaSignal::LuaSignal, T, PBD::Signal1<void, C1>*);
|
||||
template <typename T, typename C1> void proxy_1 (enum LuaSignal::LuaSignal, T, C1);
|
||||
|
||||
template <typename T, typename C1, typename C2> void connect_2 (enum LuaSignal::LuaSignal, T, PBD::Signal2<void, C1, C2>*);
|
||||
template <typename T, typename C1, typename C2> void proxy_2 (enum LuaSignal::LuaSignal, T, C1, C2);
|
||||
|
||||
template <typename T, typename C1, typename C2, typename C3> void connect_3 (enum LuaSignal::LuaSignal, T, PBD::Signal3<void, C1, C2, C3>*);
|
||||
template <typename T, typename C1, typename C2, typename C3> void proxy_3 (enum LuaSignal::LuaSignal, T, C1, C2, C3);
|
||||
|
||||
template <typename T, typename C1, typename C2, typename C3, typename C4> void connect_4 (enum LuaSignal::LuaSignal, T, PBD::Signal4<void, C1, C2, C3, C4>*);
|
||||
template <typename T, typename C1, typename C2, typename C3, typename C4> void proxy_4 (enum LuaSignal::LuaSignal, T, C1, C2, C3, C4);
|
||||
template <typename T, typename... C> void connect (enum LuaSignal::LuaSignal, T, PBD::Signal<void(C...)>*);
|
||||
template <typename T, typename... C> void proxy (enum LuaSignal::LuaSignal, T, C...);
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<LuaCallback> LuaCallbackPtr;
|
||||
|
@ -19,9 +19,9 @@
|
||||
#define _luasignal_h_
|
||||
namespace LuaSignal {
|
||||
|
||||
#define ENGINE(name,c,p) name,
|
||||
#define STATIC(name,c,p) name,
|
||||
#define SESSION(name,c,p) name,
|
||||
#define ENGINE(name,c) name,
|
||||
#define STATIC(name,c) name,
|
||||
#define SESSION(name,c) name,
|
||||
|
||||
enum LuaSignal {
|
||||
# include "luasignal_syms.h"
|
||||
|
@ -19,80 +19,80 @@
|
||||
|
||||
// editor
|
||||
#if 0
|
||||
STATIC(SessionLoad, &, 0)
|
||||
STATIC(SessionClose, &, 0)
|
||||
STATIC(SessionLoad, &)
|
||||
STATIC(SessionClose, &)
|
||||
#endif
|
||||
STATIC(ConfigChanged, &ARDOUR::Config->ParameterChanged, 1)
|
||||
STATIC(ConfigChanged, &ARDOUR::Config->ParameterChanged)
|
||||
|
||||
// engine instance
|
||||
ENGINE(EngineRunning, Running, 0)
|
||||
ENGINE(EngineStopped, Stopped, 0)
|
||||
ENGINE(EngineHalted, Halted, 1)
|
||||
ENGINE(EngineDeviceListChanged, DeviceListChanged, 0)
|
||||
ENGINE(BufferSizeChanged, BufferSizeChanged, 1)
|
||||
ENGINE(SampleRateChanged, SampleRateChanged, 1)
|
||||
ENGINE(EngineRunning, Running)
|
||||
ENGINE(EngineStopped, Stopped)
|
||||
ENGINE(EngineHalted, Halted)
|
||||
ENGINE(EngineDeviceListChanged, DeviceListChanged)
|
||||
ENGINE(BufferSizeChanged, BufferSizeChanged)
|
||||
ENGINE(SampleRateChanged, SampleRateChanged)
|
||||
|
||||
// session static
|
||||
STATIC(FeedbackDetected, &ARDOUR::Session::FeedbackDetected, 0)
|
||||
STATIC(SuccessfulGraphSort, &ARDOUR::Session::SuccessfulGraphSort, 0)
|
||||
STATIC(StartTimeChanged, &ARDOUR::Session::StartTimeChanged, 1)
|
||||
STATIC(EndTimeChanged, &ARDOUR::Session::EndTimeChanged, 1)
|
||||
STATIC(Exported, &ARDOUR::Session::Exported, 4)
|
||||
STATIC(FeedbackDetected, &ARDOUR::Session::FeedbackDetected)
|
||||
STATIC(SuccessfulGraphSort, &ARDOUR::Session::SuccessfulGraphSort)
|
||||
STATIC(StartTimeChanged, &ARDOUR::Session::StartTimeChanged)
|
||||
STATIC(EndTimeChanged, &ARDOUR::Session::EndTimeChanged)
|
||||
STATIC(Exported, &ARDOUR::Session::Exported)
|
||||
|
||||
// stripable static globals
|
||||
STATIC(Change, &PresentationInfo::Change, 0)
|
||||
STATIC(Change, &PresentationInfo::Change)
|
||||
|
||||
// session specific (re-subscribe when session changes)
|
||||
SESSION(SessionConfigChanged, config.ParameterChanged, 1)
|
||||
SESSION(TransportStateChange, TransportStateChange, 0)
|
||||
SESSION(DirtyChanged, DirtyChanged, 0)
|
||||
SESSION(StateSaved, StateSaved, 1)
|
||||
SESSION(Xrun, Xrun, 1)
|
||||
SESSION(TransportLooped, TransportLooped, 0)
|
||||
SESSION(SoloActive, SoloActive, 1)
|
||||
SESSION(SoloChanged, SoloChanged, 0)
|
||||
SESSION(IsolatedChanged, IsolatedChanged, 0)
|
||||
SESSION(MonitorChanged, MonitorChanged, 0)
|
||||
SESSION(RecordStateChanged, RecordStateChanged, 0)
|
||||
SESSION(RecordArmStateChanged, RecordArmStateChanged, 0)
|
||||
SESSION(AudioLoopLocationChanged, auto_loop_location_changed, 1)
|
||||
SESSION(AudioPunchLocationChanged, auto_punch_location_changed, 1)
|
||||
SESSION(LocationsModified, locations_modified, 0)
|
||||
SESSION(AuditionActive, AuditionActive, 1)
|
||||
SESSION(BundleAddedOrRemoved, BundleAddedOrRemoved, 0)
|
||||
SESSION(PositionChanged, PositionChanged, 1)
|
||||
SESSION(Located, Located, 0)
|
||||
SESSION(RoutesReconnected, session_routes_reconnected, 0)
|
||||
SESSION(RouteAdded, RouteAdded, 1)
|
||||
SESSION(RouteGroupPropertyChanged, RouteGroupPropertyChanged, 1)
|
||||
SESSION(RouteAddedToRouteGroup, RouteAddedToRouteGroup, 2)
|
||||
SESSION(RouteRemovedFromRouteGroup, RouteRemovedFromRouteGroup, 2)
|
||||
SESSION(StepEditStatusChange, StepEditStatusChange, 1)
|
||||
SESSION(RouteGroupAdded, route_group_added, 1)
|
||||
SESSION(RouteGroupRemoved, route_group_removed, 0)
|
||||
SESSION(RouteGroupsReordered, route_groups_reordered, 0)
|
||||
SESSION(SessionConfigChanged, config.ParameterChanged)
|
||||
SESSION(TransportStateChange, TransportStateChange)
|
||||
SESSION(DirtyChanged, DirtyChanged)
|
||||
SESSION(StateSaved, StateSaved)
|
||||
SESSION(Xrun, Xrun)
|
||||
SESSION(TransportLooped, TransportLooped)
|
||||
SESSION(SoloActive, SoloActive)
|
||||
SESSION(SoloChanged, SoloChanged)
|
||||
SESSION(IsolatedChanged, IsolatedChanged)
|
||||
SESSION(MonitorChanged, MonitorChanged)
|
||||
SESSION(RecordStateChanged, RecordStateChanged)
|
||||
SESSION(RecordArmStateChanged, RecordArmStateChanged)
|
||||
SESSION(AudioLoopLocationChanged, auto_loop_location_changed)
|
||||
SESSION(AudioPunchLocationChanged, auto_punch_location_changed)
|
||||
SESSION(LocationsModified, locations_modified)
|
||||
SESSION(AuditionActive, AuditionActive)
|
||||
SESSION(BundleAddedOrRemoved, BundleAddedOrRemoved)
|
||||
SESSION(PositionChanged, PositionChanged)
|
||||
SESSION(Located, Located)
|
||||
SESSION(RoutesReconnected, session_routes_reconnected)
|
||||
SESSION(RouteAdded, RouteAdded)
|
||||
SESSION(RouteGroupPropertyChanged, RouteGroupPropertyChanged)
|
||||
SESSION(RouteAddedToRouteGroup, RouteAddedToRouteGroup)
|
||||
SESSION(RouteRemovedFromRouteGroup, RouteRemovedFromRouteGroup)
|
||||
SESSION(StepEditStatusChange, StepEditStatusChange)
|
||||
SESSION(RouteGroupAdded, route_group_added)
|
||||
SESSION(RouteGroupRemoved, route_group_removed)
|
||||
SESSION(RouteGroupsReordered, route_groups_reordered)
|
||||
|
||||
// plugin manager instance
|
||||
STATIC(PluginListChanged, &(PluginManager::instance().PluginListChanged), 0)
|
||||
STATIC(PluginStatusChanged, &(PluginManager::instance().PluginStatusChanged), 3)
|
||||
//STATIC(PluginStatusesChanged, &(PluginManager::instance().PluginTagsChanged), 3)
|
||||
STATIC(PluginListChanged, &(PluginManager::instance().PluginListChanged))
|
||||
STATIC(PluginStatusChanged, &(PluginManager::instance().PluginStatusChanged))
|
||||
//STATIC(PluginStatusesChanged, &(PluginManager::instance().PluginTagsChanged))
|
||||
|
||||
// Diskstream static global
|
||||
STATIC(DiskOverrun, &ARDOUR::DiskWriter::Overrun, 0)
|
||||
STATIC(DiskUnderrun, &ARDOUR::DiskReader::Underrun, 0)
|
||||
STATIC(DiskOverrun, &ARDOUR::DiskWriter::Overrun)
|
||||
STATIC(DiskUnderrun, &ARDOUR::DiskReader::Underrun)
|
||||
|
||||
// Region static
|
||||
STATIC(RegionsPropertyChanged, &ARDOUR::Region::RegionsPropertyChanged, 2)
|
||||
STATIC(RegionsPropertyChanged, &ARDOUR::Region::RegionsPropertyChanged)
|
||||
|
||||
// Timers
|
||||
STATIC(LuaTimerS, &LuaInstance::LuaTimerS, 0)
|
||||
STATIC(LuaTimerDS, &LuaInstance::LuaTimerDS, 0)
|
||||
STATIC(LuaTimerS, &LuaInstance::LuaTimerS)
|
||||
STATIC(LuaTimerDS, &LuaInstance::LuaTimerDS)
|
||||
|
||||
// Session load
|
||||
STATIC(SetSession, &LuaInstance::SetSession, 0)
|
||||
STATIC(SetSession, &LuaInstance::SetSession)
|
||||
|
||||
// Editor Selection Changed
|
||||
STATIC(SelectionChanged, &LuaInstance::SelectionChanged, 0)
|
||||
STATIC(SelectionChanged, &LuaInstance::SelectionChanged)
|
||||
|
||||
// TODO per track/route signals,
|
||||
// TODO per plugin actions / controllables
|
||||
|
Loading…
Reference in New Issue
Block a user