13
0

LuaInstance: prepare for 3 argument signal/slot callbacks

This commit is contained in:
Robin Gareus 2018-01-29 22:21:59 +01:00
parent e3c6a41c11
commit 0772513499
2 changed files with 25 additions and 0 deletions

View File

@ -2125,6 +2125,14 @@ LuaCallback::connect_2 (enum LuaSignal::LuaSignal ls, T ref, PBD::Signal2<void,
gui_context()); 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> void template <typename T> void
LuaCallback::proxy_0 (enum LuaSignal::LuaSignal ls, T ref) { LuaCallback::proxy_0 (enum LuaSignal::LuaSignal ls, T ref) {
bool ok = true; bool ok = true;
@ -2167,3 +2175,17 @@ LuaCallback::proxy_2 (enum LuaSignal::LuaSignal ls, T ref, C1 a1, C2 a2) {
drop_callback (); /* EMIT SIGNAL */ 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 */
}
}

View File

@ -70,6 +70,9 @@ private:
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 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> 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);
}; };
typedef boost::shared_ptr<LuaCallback> LuaCallbackPtr; typedef boost::shared_ptr<LuaCallback> LuaCallbackPtr;