From 2552888693cdd75a6c29cfb169b47bc8a7e0b8d1 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Sat, 22 Apr 2017 20:40:21 +0200 Subject: [PATCH] return tuple should be treated as multiple returns --- source/ddbus/router.d | 9 +++++++-- source/ddbus/util.d | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/source/ddbus/router.d b/source/ddbus/router.d index 49744ba..ec25eea 100644 --- a/source/ddbus/router.d +++ b/source/ddbus/router.d @@ -110,7 +110,7 @@ class MessageRouter { static if(is(Ret==void)) { static string[] ret = []; } else { - static string[] ret = [typeSig!Ret]; + static string[] ret = typeSigReturn!Ret; } MessageHandler handleStruct = {func: &handlerWrapper, argSig: args, retSig: ret}; callTable[patt] = handleStruct; @@ -199,12 +199,17 @@ unittest{ router.setHandler!(void,int,string)(patt,(int p, string p2) {}); patt = MessagePattern("/root/wat","ca.thume.tester","lolwut"); router.setHandler!(int,int)(patt,(int p) {return 6;}); + patt = MessagePattern("/root/foo","ca.thume.tester","lolwut"); + router.setHandler!(Tuple!(string,string,int),int)(patt,(int p) {Tuple!(string,string,int) ret; ret[0] = "a"; ret[1] = "b"; ret[2] = p; return ret;}); patt = MessagePattern("/troll","ca.thume.tester","wow"); router.setHandler!(void)(patt,{return;}); // TODO: these tests rely on nondeterministic hash map ordering static string introspectResult = ` -`; +`; router.introspectXML("/root").assertEqual(introspectResult); + static string introspectResult2 = ` +`; + router.introspectXML("/root/foo").assertEqual(introspectResult2); router.introspectXML("/").assertEndsWith(``); } diff --git a/source/ddbus/util.d b/source/ddbus/util.d index c2b0065..6a77432 100644 --- a/source/ddbus/util.d +++ b/source/ddbus/util.d @@ -98,6 +98,13 @@ string typeSig(T)() if(canDBus!T) { } } +string[] typeSigReturn(T)() if(canDBus!T) { + static if(is(T == Tuple!TS, TS...)) + return typeSigArr!TS; + else + return [typeSig!T]; +} + string typeSigAll(TS...)() if(allCanDBus!TS) { string sig = ""; foreach(i,T; TS) {