Support for signals in registerMethods generator
This commit is contained in:
parent
21d36af507
commit
aa9ecc5004
|
@ -44,6 +44,8 @@ unittest {
|
||||||
obj.call!string("GetNameOwner","org.freedesktop.DBus").assertEqual("org.freedesktop.DBus");
|
obj.call!string("GetNameOwner","org.freedesktop.DBus").assertEqual("org.freedesktop.DBus");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum SignalMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Registers all *possible* methods of an object in a router.
|
Registers all *possible* methods of an object in a router.
|
||||||
It will not register methods that use types that ddbus can't handle.
|
It will not register methods that use types that ddbus can't handle.
|
||||||
|
@ -63,6 +65,7 @@ void registerMethods(T : Object)(MessageRouter router, string path, string iface
|
||||||
&& __traits(getOverloads, obj, member).length > 0
|
&& __traits(getOverloads, obj, member).length > 0
|
||||||
&& __traits(compiles, router.setHandler(patt, &__traits(getOverloads,obj,member)[0]))) {
|
&& __traits(compiles, router.setHandler(patt, &__traits(getOverloads,obj,member)[0]))) {
|
||||||
patt.method = member;
|
patt.method = member;
|
||||||
|
patt.signal = hasUDA!(__traits(getOverloads,obj,member)[0], SignalMethod);
|
||||||
router.setHandler(patt, &__traits(getOverloads,obj,member)[0]);
|
router.setHandler(patt, &__traits(getOverloads,obj,member)[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,13 +76,19 @@ unittest {
|
||||||
class Tester {
|
class Tester {
|
||||||
int lol(int x, string s) {return 5;}
|
int lol(int x, string s) {return 5;}
|
||||||
void wat() {}
|
void wat() {}
|
||||||
|
@SignalMethod
|
||||||
|
void signalRecv() {}
|
||||||
}
|
}
|
||||||
auto o = new Tester;
|
auto o = new Tester;
|
||||||
auto router = new MessageRouter;
|
auto router = new MessageRouter;
|
||||||
registerMethods(router, "/","ca.thume.test",o);
|
registerMethods(router, "/","ca.thume.test",o);
|
||||||
MessagePattern patt = MessagePattern("/","ca.thume.test","wat");
|
MessagePattern patt = MessagePattern("/","ca.thume.test","wat");
|
||||||
router.callTable.assertHasKey(patt);
|
router.callTable.assertHasKey(patt);
|
||||||
|
patt.method = "signalRecv";
|
||||||
|
patt.signal = true;
|
||||||
|
router.callTable.assertHasKey(patt);
|
||||||
patt.method = "lol";
|
patt.method = "lol";
|
||||||
|
patt.signal = false;
|
||||||
router.callTable.assertHasKey(patt);
|
router.callTable.assertHasKey(patt);
|
||||||
auto res = router.callTable[patt];
|
auto res = router.callTable[patt];
|
||||||
res.argSig.assertEqual(["i","s"]);
|
res.argSig.assertEqual(["i","s"]);
|
||||||
|
|
Loading…
Reference in a new issue