annotate qt/d2/qt/Signal.d @ 288:f9559a957be9 signals

new signals and slots implementation
author eldar
date Sun, 08 Nov 2009 19:28:01 +0000
parents 1f6923c8cba0
children c9d1aac290e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
e78566595089 initial import
mandel
parents:
diff changeset
1 /**
e78566595089 initial import
mandel
parents:
diff changeset
2 *
e78566595089 initial import
mandel
parents:
diff changeset
3 * Copyright: Copyright QtD Team, 2008-2009
e78566595089 initial import
mandel
parents:
diff changeset
4 * Authors: Max Samukha, Eldar Insafutdinov
e78566595089 initial import
mandel
parents:
diff changeset
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>
e78566595089 initial import
mandel
parents:
diff changeset
6 *
e78566595089 initial import
mandel
parents:
diff changeset
7 * Copyright QtD Team, 2008-2009
e78566595089 initial import
mandel
parents:
diff changeset
8 * Distributed under the Boost Software License, Version 1.0.
e78566595089 initial import
mandel
parents:
diff changeset
9 * (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
e78566595089 initial import
mandel
parents:
diff changeset
10 *
e78566595089 initial import
mandel
parents:
diff changeset
11 */
16
6faf3d3cb95e CMake: implement install and package targets.
SokoL_SD
parents: 1
diff changeset
12 module qt.Signal;
1
e78566595089 initial import
mandel
parents:
diff changeset
13
e78566595089 initial import
mandel
parents:
diff changeset
14 public import qt.QGlobal;
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
15 import qt.qtd.MetaMarshall;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
16
1
e78566595089 initial import
mandel
parents:
diff changeset
17 import core.stdc.stdlib : crealloc = realloc, cfree = free;
e78566595089 initial import
mandel
parents:
diff changeset
18 import core.stdc.string : memmove;
e78566595089 initial import
mandel
parents:
diff changeset
19 import
188
7dd099050621 initial commit for D2 support
eldar
parents: 16
diff changeset
20 core.thread,
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
21 core.exception,
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
22 std.algorithm;
1
e78566595089 initial import
mandel
parents:
diff changeset
23
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
24 public import
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
25 std.typetuple,
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
26 std.traits,
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
27 std.conv,
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
28 std.string,
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
29 std.metastrings;
276
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
30
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
31
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
32 // returns name, arguments or tuple of the function depending on type parameter
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
33 enum {_Name, _Tuple, _Args}
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
34 string getFunc(int type)(string fullName)
276
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
35 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
36 int pos = 0;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
37 foreach(i, c; fullName)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
38 if (c == '(')
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
39 static if (type == _Tuple)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
40 return fullName[i..$];
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
41 else if (type == _Name)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
42 return fullName[0..i];
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
43 else if (type == _Args)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
44 for(int j = fullName.length-1;; j--)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
45 if(fullName[j] == ')')
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
46 return fullName[i+1 .. j];
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
47 return null;
253
073b9153ed8a Rev. 264 done right.
maxter
parents: 246
diff changeset
48 }
1
e78566595089 initial import
mandel
parents:
diff changeset
49
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
50 /** The beast that takes string representation of function arguments
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
51 * and returns an array of default values it doesn't check if arguments
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
52 * without default values follow the arguments with default values for
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
53 * simplicity. It is done by mixing in an delegate alias.
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
54 */
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
55 string[] defaultValues(string signature)
1
e78566595089 initial import
mandel
parents:
diff changeset
56 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
57 int braces = 0;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
58 bool inDefaultValue = false;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
59 bool inStringLiteral = false;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
60 string[] res;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
61 int startValue = 0;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
62
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
63 if(strip(signature).length == 0)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
64 return res;
1
e78566595089 initial import
mandel
parents:
diff changeset
65
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
66 foreach (i,c; signature)
1
e78566595089 initial import
mandel
parents:
diff changeset
67 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
68 if(!inStringLiteral)
1
e78566595089 initial import
mandel
parents:
diff changeset
69 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
70 if(c == '{' || c =='(')
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
71 braces++;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
72 else if(c == '}' || c ==')')
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
73 braces--;
276
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
74 }
1
e78566595089 initial import
mandel
parents:
diff changeset
75
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
76 if(c == '\"' || c == '\'')
276
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
77 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
78 if (inStringLiteral)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
79 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
80 if(signature[i-1] != '\\')
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
81 inStringLiteral = false;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
82 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
83 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
84 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
85 inStringLiteral = true;
276
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
86 }
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
87 }
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
88
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
89 if (!inStringLiteral && braces == 0)
276
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
90 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
91 if(c == '=') // found default value
276
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
92 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
93 inDefaultValue = true;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
94 startValue = i+1;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
95 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
96 else if(c == ',') // next function argument
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
97 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
98 if (inDefaultValue)
276
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
99 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
100 res ~= signature[startValue..i];
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
101 inDefaultValue = false;
276
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
102 }
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
103 }
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
104 }
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
105 }
501128ac7a2c signals cleaned up correctly on receiver destruction
maxter
parents: 268
diff changeset
106
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
107 if (inDefaultValue)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
108 res ~= signature[startValue..$];
1
e78566595089 initial import
mandel
parents:
diff changeset
109
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
110 return res;
1
e78566595089 initial import
mandel
parents:
diff changeset
111 }
e78566595089 initial import
mandel
parents:
diff changeset
112
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
113 int defaultValuesLength(string[] defVals)
1
e78566595089 initial import
mandel
parents:
diff changeset
114 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
115 return defVals.length;
1
e78566595089 initial import
mandel
parents:
diff changeset
116 }
e78566595089 initial import
mandel
parents:
diff changeset
117
e78566595089 initial import
mandel
parents:
diff changeset
118 /**
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
119 New implementation.
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
120 */
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
121
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
122
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
123 // need this to mark static metamethods-info whether it's generated by presence of default args
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
124 enum DefaultArgs
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
125 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
126 None, Start, Continue
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
127 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
128
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
129 // templates for extracting data from static meta-information of signals, slots or properties
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
130 // public alias TypeTuple!("name", index, OwnerClass, DefaultArgs.Start, ArgTypes) __signal
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
131 template MetaEntryName(source...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
132 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
133 enum MetaEntryName = source[0]; // name of the metaentry is the first element
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
134 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
135
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
136 template MetaEntryOwner(source...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
137 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
138 alias TupleWrapper!(source[2]).at[0] MetaEntryOwner; // class that owns the property is the third
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
139 // Compiler #BUG 3092 - evaluates MetaEntryOwner as a Tuple with one element
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
140 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
141
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
142 template MetaEntryArgs(source...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
143 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
144 alias source[4 .. $] MetaEntryArgs; // arguments-tuple starts from the fourth position
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
145 }
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
146
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
147 template TupleWrapper(A...) { alias A at; }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
148
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
149 template isDg(Dg)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
150 {
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
151 enum isDg = is(Dg == delegate);
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
152 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
153
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
154 template isFn(Fn)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
155 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
156 enum isFn = is(typeof(*Fn.init) == function);
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
157 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
158
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
159 template isFnOrDg(Dg)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
160 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
161 enum isFnOrDg = isFn!(Dg) || isDg!(Dg);
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
162 }
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
163
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
164 string joinArgs(A...)()
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
165 {
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
166 string res = "";
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
167 static if(A.length)
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
168 {
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
169 res = A[0].stringof;
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
170 foreach(k; A[1..$])
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
171 res ~= "," ~ k.stringof;
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
172 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
173 return res;
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
174 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
175
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
176 template SlotPred(T1, T2)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
177 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
178 enum SlotPred = is(T1 : T2);
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
179 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
180
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
181 template CheckSlot(alias Needle, alias Source)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
182 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
183 static if(Needle.at.length <= Source.at.length)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
184 enum CheckSlot = CheckArgs!(Needle, Source, SlotPred, 0).value;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
185 else
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
186 enum CheckSlot = false;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
187 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
188
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
189 template SignalPred(T1, T2)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
190 {
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
191 enum SignalPred = is(T1 == T2);
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
192 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
193
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
194 template CheckSignal(alias Needle, alias Source)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
195 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
196 static if(Needle.at.length == Source.at.length)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
197 enum CheckSignal = CheckArgs!(Needle, Source, SignalPred, 0).value;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
198 else
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
199 enum CheckSignal = false;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
200 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
201
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
202 template CheckArgs(alias Needle, alias Source, alias pred, int i)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
203 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
204 static if (i < Needle.at.length)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
205 {
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
206 static if (pred!(Needle.at[i], Source.at[i]))
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
207 enum value = CheckArgs!(Needle, Source, pred, i + 1).value;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
208 else
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
209 enum value = false;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
210 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
211 else
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
212 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
213 enum value = true;
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
214 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
215 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
216
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
217 template SigByNamePred(string name, SlotArgs...)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
218 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
219 template SigByNamePred(source...)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
220 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
221 static if (source[0] == name) // only instantiate CheckSlot if names match
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
222 enum SigByNamePred = CheckSlot!(TupleWrapper!(SlotArgs), TupleWrapper!(source[2 .. $]));
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
223 else
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
224 enum SigByNamePred = false;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
225 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
226 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
227
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
228 template SigBySignPred(string name, SigArgs...)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
229 {
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
230 template SigBySignPred(source...)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
231 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
232 static if (source[0] == name) // only instantiate CheckSignal if names match
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
233 enum SigBySignPred = CheckSignal!(TupleWrapper!(SigArgs), TupleWrapper!(source[2 .. $]));
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
234 else
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
235 enum SigBySignPred = false;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
236 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
237 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
238
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
239 template ByOwner(Owner)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
240 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
241 template ByOwner(source...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
242 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
243 enum ByOwner = is(MetaEntryOwner!source == Owner);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
244 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
245 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
246
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
247 template staticSymbolName(string prefix, int id)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
248 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
249 const string staticSymbolName = prefix ~ ToString!(id);
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
250 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
251
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
252 template signatureString(string name, A...)
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
253 {
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
254 const string signatureString = name ~ "(" ~ joinArgs!(A) ~ ")";
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
255 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
256
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
257 // recursive search in the static meta-information
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
258 template findSymbolImpl(string prefix, C, int id, alias pred)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
259 {
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
260 static if ( is(typeof(mixin("C." ~ staticSymbolName!(prefix, id)))) )
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
261 {
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
262 mixin ("alias C." ~ staticSymbolName!(prefix, id) ~ " current;");
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
263 static if (pred!current)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
264 alias current result;
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
265 else
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
266 alias findSymbolImpl!(prefix, C, id + 1, pred).result result;
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
267 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
268 else
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
269 {
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
270 alias void result;
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
271 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
272 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
273
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
274 template findSymbol(string prefix, C, alias pred)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
275 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
276 alias findSymbolImpl!(prefix, C, 0, pred).result findSymbol;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
277 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
278
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
279 template findSignal(C, string name, Receiver, SigArgs...)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
280 {
282
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
281 alias TupleWrapper!(ParameterTypeTuple!Receiver) SlotArgsWr;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
282 static if (SigArgs.length > 0)
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
283 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
284 alias findSymbol!(signalPrefix, C, SigBySignPred!(name, SigArgs)) result;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
285 static if (is(result == void))
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
286 static assert(0, "Signal " ~ name ~ "(" ~ joinArgs!SigArgs() ~ ") was not found.");
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
287 else
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
288 static if (!CheckSlot!(SlotArgsWr, TupleWrapper!(result[2 .. $])))
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
289 static assert(0, "Signature of slot is incompatible with signal " ~ name ~ ".");
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
290 }
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
291 else
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
292 {
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
293 alias findSymbol!(signalPrefix, C, SigByNamePred!(name, SlotArgsWr.at)) result;
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
294 static if (is(result == void))
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
295 static assert(0, "Signal " ~ name ~ " was not found.");
256ab6cb8e85 Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
eldar
parents: 279
diff changeset
296 }
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
297 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
298
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
299 // recursive search in the static meta-information
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
300 template findSymbolsImpl(string prefix, C, int id, alias pred)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
301 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
302 static if ( is(typeof(mixin("C." ~ staticSymbolName!(prefix, id)))) )
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
303 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
304 mixin ("alias C." ~ staticSymbolName!(prefix, id) ~ " current;");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
305 static if (pred!current) {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
306 alias TupleWrapper!current subres;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
307 // pragma(msg, toStringNow!id ~ " " ~ subres.stringof);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
308 } else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
309 alias TypeTuple!() subres;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
310 alias TypeTuple!(subres, findSymbolsImpl!(prefix, C, id + 1, pred).result) result;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
311 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
312 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
313 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
314 alias TypeTuple!() result;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
315 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
316 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
317
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
318 template findSymbols(string prefix, C, alias pred)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
319 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
320 alias findSymbolsImpl!(prefix, C, 0, pred).result findSymbols;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
321 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
322
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
323 string __toString(long v)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
324 {
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
325 if (v == 0)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
326 return "0";
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
327
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
328 string ret;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
329
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
330 bool neg;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
331 if (v < 0)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
332 {
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
333 neg = true;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
334 v = -v;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
335 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
336
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
337 while (v != 0)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
338 {
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
339 ret = cast(char)(v % 10 + '0') ~ ret;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
340 v = cast(long)(v / 10);
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
341 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
342
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
343 if (neg)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
344 ret = "-" ~ ret;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
345
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
346 return ret;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
347 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
348
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
349 string convertSignalArguments(Args...)()
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
350 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
351 // void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
352
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
353 string res = "void*[" ~ __toString(Args.length+1) ~ "] _a = [null";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
354 foreach(i, _; Args)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
355 res ~= ", " ~ "cast(void*) &" ~ convertSignalArgument!(Args[i])("_t" ~ __toString(i));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
356 res ~= "];\n";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
357 return res;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
358 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
359
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
360 public string SignalEmitter(A...)(SignalType signalType, string name, string[] defVals, int localIndex)
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
361 {
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
362 string fullArgs, args;
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
363 int defValsLength = defVals.length;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
364 string argsConversion = "";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
365 string argsPtr = "null";
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
366 static if (A.length)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
367 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
368 while(A.length != defVals.length)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
369 defVals = "" ~ defVals;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
370
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
371 fullArgs = A[0].stringof ~ " _t0";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
372 if (defVals[0].length)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
373 fullArgs ~= " = " ~ defVals[0];
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
374 args = "_t0";
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
375 foreach(i, _; A[1..$])
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
376 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
377 fullArgs ~= ", " ~ A[i+1].stringof ~ " _t" ~ __toString(i+1);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
378 if (defVals[i+1].length)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
379 fullArgs ~= " = " ~ defVals[i+1];
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
380 args ~= ", _t" ~ __toString(i+1);
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
381 }
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
382 // build up conversion of signal args from D to C++
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
383 argsPtr = "_a.ptr";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
384 argsConversion = convertSignalArguments!(A)();
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
385 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
386 string attribute;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
387 string sigName = name;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
388 if (signalType == SignalType.BindQtSignal)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
389 name ~= "_emit";
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
390 else
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
391 attribute = "protected ";
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
392
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
393 string indexArgs = __toString(localIndex);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
394 if(defValsLength > 0)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
395 indexArgs ~= ", " ~ __toString(localIndex+defValsLength);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
396 string str = attribute ~ "final void " ~ name ~ "(" ~ fullArgs ~ ") {\n" ~ argsConversion ~ "\n"
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
397 ~ " QMetaObject.activate(this, typeof(this).staticMetaObject, " ~ indexArgs ~ ", " ~ argsPtr ~ ");\n"
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
398 ~ "}\n"; // ~
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
399 return str;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
400 }
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
401 /** ---------------- */
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
402
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
403
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
404 const string signalPrefix = "__signal";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
405 const string slotPrefix = "__slot";
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
406
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
407 enum SignalType
1
e78566595089 initial import
mandel
parents:
diff changeset
408 {
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
409 BindQtSignal,
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
410 NewSignal,
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
411 NewSlot
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
412 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
413
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
414 template BindQtSignal(string fullName)
1
e78566595089 initial import
mandel
parents:
diff changeset
415 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
416 mixin MetaMethodImpl!(signalPrefix, 0, fullName, SignalType.BindQtSignal);
1
e78566595089 initial import
mandel
parents:
diff changeset
417 }
e78566595089 initial import
mandel
parents:
diff changeset
418
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
419 template Signal(string fullName)
1
e78566595089 initial import
mandel
parents:
diff changeset
420 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
421 mixin MetaMethodImpl!(signalPrefix, 0, fullName, SignalType.NewSignal);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
422 }
1
e78566595089 initial import
mandel
parents:
diff changeset
423
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
424 template Slot(string fullName)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
425 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
426 mixin MetaMethodImpl!(slotPrefix, 0, fullName, SignalType.NewSlot);
1
e78566595089 initial import
mandel
parents:
diff changeset
427 }
e78566595089 initial import
mandel
parents:
diff changeset
428
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
429 template SignalImpl(int index, string fullName, SignalType signalType)
1
e78566595089 initial import
mandel
parents:
diff changeset
430 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
431 static if (is(typeof(mixin(typeof(this).stringof ~ "." ~ signalPrefix ~ ToString!(index)))))
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
432 mixin SignalImpl!(index + 1, fullName, signalType);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
433 else
1
e78566595089 initial import
mandel
parents:
diff changeset
434 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
435 // pragma(msg, "alias void delegate" ~ getFunc!_Tuple(fullName) ~ " Dg;");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
436 mixin("alias void delegate" ~ getFunc!_Tuple(fullName) ~ " Dg;");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
437 alias ParameterTypeTuple!(Dg) ArgTypes;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
438 enum args = getFunc!_Args(fullName);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
439 enum defVals = defaultValues(args);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
440 enum defValsLength = defaultValuesLength(defVals);
1
e78566595089 initial import
mandel
parents:
diff changeset
441
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
442 // pragma (msg, SignalEmitter!(ArgTypes)(SignalType.NewSignal, getFunc!_Name(fullName), defVals, index));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
443 mixin InsertMetaSignal!(fullName, index, defValsLength, ArgTypes);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
444 // pragma (msg, ctfe_meta_signal!(ArgTypes)(fullName, index, defValsLength));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
445 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
446 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
447 template MetaMethodImpl(string metaPrefix, int index, string fullName, SignalType signalType)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
448 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
449 static if (is(typeof(mixin(typeof(this).stringof ~ "." ~ metaPrefix ~ toStringNow!(index)))))
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
450 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
451 mixin MetaMethodImpl!(metaPrefix, index + 1, fullName, signalType);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
452 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
453 else
1
e78566595089 initial import
mandel
parents:
diff changeset
454 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
455 mixin("alias void delegate" ~ getFunc!_Tuple(fullName) ~ " Dg;");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
456 alias ParameterTypeTuple!(Dg) ArgTypes;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
457 enum args = getFunc!_Args(fullName);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
458 enum defVals = defaultValues(args);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
459 enum defValsLength = defaultValuesLength(defVals);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
460
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
461 static if (metaPrefix == signalPrefix)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
462 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
463 // calculating local index of the signal
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
464 static if (typeof(this).stringof == "QObject")
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
465 enum localIndex = index;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
466 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
467 mixin ("enum localIndex = index - 1 - lastSignalIndex_" ~ (typeof(super)).stringof ~ ";");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
468
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
469 static if (signalType == SignalType.NewSignal)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
470 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
471 pragma (msg, SignalEmitter!(ArgTypes)(SignalType.NewSignal, getFunc!_Name(fullName), defVals, localIndex));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
472 mixin (SignalEmitter!(ArgTypes)(SignalType.NewSignal, getFunc!_Name(fullName), defVals, localIndex));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
473 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
474 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
475 mixin InsertMetaMethod!(fullName, metaPrefix, index, defValsLength, DefaultArgs.Start, ArgTypes);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
476 // pragma (msg, ctfe_meta_signal!(ArgTypes)(fullName, index, defValsLength));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
477 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
478 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
479 template InsertMetaMethod(string fullName, string metaPrefix, int index, int defValsCount, DefaultArgs defArgsInitFlag, ArgTypes...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
480 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
481 // this identifies if metamethod is was generated by the presence of default args or not
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
482 static if(defValsCount > 0)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
483 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
484 static if (defArgsInitFlag == DefaultArgs.Start)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
485 enum defValsFlag = DefaultArgs.Start;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
486 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
487 enum defValsFlag = DefaultArgs.Continue;
1
e78566595089 initial import
mandel
parents:
diff changeset
488 }
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
489 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
490 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
491 static if (defArgsInitFlag == DefaultArgs.Start)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
492 enum defValsFlag = DefaultArgs.None;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
493 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
494 enum defValsFlag = DefaultArgs.Continue;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
495 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
496 static if(defValsCount >= 0)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
497 mixin("public alias TypeTuple!(\"" ~ getFunc!_Name(fullName) ~ "\", index, typeof(this), defValsFlag, ArgTypes) " ~ metaPrefix ~ toStringNow!(index) ~ ";");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
498 static if(defValsCount > 0)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
499 mixin InsertMetaMethod!(fullName, metaPrefix, index+1, defValsCount-1, DefaultArgs.Continue, ArgTypes[0..$-1]);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
500 }
1
e78566595089 initial import
mandel
parents:
diff changeset
501
e78566595089 initial import
mandel
parents:
diff changeset
502
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
503 string signature_impl(T...)(string name)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
504 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
505 string res = name ~ "(";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
506 foreach(i, _; T)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
507 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
508 if(i > 0)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
509 res ~= ",";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
510 res ~= T[i].stringof;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
511 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
512 res ~= ")";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
513 return res;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
514 }
1
e78566595089 initial import
mandel
parents:
diff changeset
515
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
516 template signature(string name, T...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
517 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
518 enum signature = signature_impl!(T)(name);
1
e78566595089 initial import
mandel
parents:
diff changeset
519 }
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
520
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
521 template lastSignalIndex(T)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
522 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
523 static if (T.stringof == "QObject")
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
524 enum lastSignalIndex = lastSignalIndexImpl!(T, 0);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
525 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
526 mixin ("enum lastSignalIndex = lastSignalIndexImpl!(T, " ~ "T.lastSignalIndex_" ~ (BaseClassesTuple!(T)[0]).stringof ~ ");");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
527 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
528
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
529 template lastSignalIndexImpl(T, int index)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
530 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
531 static if (is(typeof(mixin("T." ~ signalPrefix ~ toStringNow!(index)))))
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
532 enum lastSignalIndexImpl = lastSignalIndexImpl!(T, index + 1);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
533 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
534 enum lastSignalIndexImpl = index - 1;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
535 }