annotate qt/d2/qt/Signal.d @ 293:8627891e4556 signals

QList updates
author eldar
date Fri, 13 Nov 2009 19:09:28 +0000
parents c9d1aac290e9
children 55ee4603365d
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
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
124 // templates for extracting data from static meta-information of signals, slots or properties
289
c9d1aac290e9 clean up of unneeded functionality
eldar
parents: 288
diff changeset
125 // public alias TypeTuple!("name", index, OwnerClass, ArgTypes) __signal
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
126 template MetaEntryName(source...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
127 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
128 enum MetaEntryName = source[0]; // name of the metaentry is the first element
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
129 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
130
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
131 template MetaEntryOwner(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 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
134 // Compiler #BUG 3092 - evaluates MetaEntryOwner as a Tuple with one element
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
135 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
136
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
137 template MetaEntryArgs(source...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
138 {
289
c9d1aac290e9 clean up of unneeded functionality
eldar
parents: 288
diff changeset
139 alias source[3 .. $] MetaEntryArgs; // arguments-tuple starts from the fourth position
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
140 }
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
141
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
142 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
143
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
144 template isDg(Dg)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
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 enum isDg = is(Dg == delegate);
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
147 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
148
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
149 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
150 {
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 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
152 }
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
153
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 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
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 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
157 }
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
158
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
159 string joinArgs(A...)()
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
160 {
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
161 string res = "";
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
162 static if(A.length)
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 res = A[0].stringof;
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
165 foreach(k; A[1..$])
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
166 res ~= "," ~ k.stringof;
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
167 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
168 return res;
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
169 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
170
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
171 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
172 {
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
173 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
174 }
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
175
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 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
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 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
179 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
180 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
181 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
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
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 template SignalPred(T1, T2)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
185 {
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
186 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
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 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
190 {
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 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
192 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
193 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
194 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
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
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 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
198 {
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 static if (i < Needle.at.length)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
200 {
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
201 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
202 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
203 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
204 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
205 }
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 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
207 {
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 enum value = true;
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
209 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
210 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
211
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
212 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
213 {
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
214 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
215 {
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
216 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
217 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
218 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
219 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
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 }
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
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 template SigBySignPred(string name, SigArgs...)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
224 {
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
225 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
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 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
228 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
229 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
230 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
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 }
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
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
234 template ByOwner(Owner)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
235 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
236 template ByOwner(source...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
237 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
238 enum ByOwner = is(MetaEntryOwner!source == Owner);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
239 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
240 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
241
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
242 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
243 {
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
244 const string staticSymbolName = prefix ~ ToString!(id);
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
245 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
246
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
247 template signatureString(string name, A...)
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
248 {
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
249 const string signatureString = name ~ "(" ~ joinArgs!(A) ~ ")";
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
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
252 // 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
253 template findSymbolImpl(string prefix, C, int id, alias pred)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
254 {
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
255 static if ( is(typeof(mixin("C." ~ staticSymbolName!(prefix, id)))) )
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
256 {
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
257 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
258 static if (pred!current)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
259 alias current result;
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
260 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
261 alias findSymbolImpl!(prefix, C, id + 1, pred).result result;
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
262 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
263 else
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
264 {
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
265 alias void result;
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
266 }
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
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
269 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
270 {
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
271 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
272 }
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
273
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 findSignal(C, string name, Receiver, SigArgs...)
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
275 {
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
276 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
277 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
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 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
280 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
281 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
282 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
283 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
284 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
285 }
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 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
287 {
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 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
289 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
290 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
291 }
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
292 }
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
293
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
294 // recursive search in the static meta-information
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
295 template findSymbolsImpl(string prefix, C, int id, alias pred)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
296 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
297 static if ( is(typeof(mixin("C." ~ staticSymbolName!(prefix, id)))) )
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
298 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
299 mixin ("alias C." ~ staticSymbolName!(prefix, id) ~ " current;");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
300 static if (pred!current) {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
301 alias TupleWrapper!current subres;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
302 // pragma(msg, toStringNow!id ~ " " ~ subres.stringof);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
303 } else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
304 alias TypeTuple!() subres;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
305 alias TypeTuple!(subres, findSymbolsImpl!(prefix, C, id + 1, pred).result) result;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
306 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
307 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
308 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
309 alias TypeTuple!() result;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
310 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
311 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
312
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
313 template findSymbols(string prefix, C, alias pred)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
314 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
315 alias findSymbolsImpl!(prefix, C, 0, pred).result findSymbols;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
316 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
317
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
318 string __toString(long v)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
319 {
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
320 if (v == 0)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
321 return "0";
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
322
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
323 string ret;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
324
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
325 bool neg;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
326 if (v < 0)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
327 {
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
328 neg = true;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
329 v = -v;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
330 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
331
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
332 while (v != 0)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
333 {
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
334 ret = cast(char)(v % 10 + '0') ~ ret;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
335 v = cast(long)(v / 10);
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
336 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
337
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
338 if (neg)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
339 ret = "-" ~ ret;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
340
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
341 return ret;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
342 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
343
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
344 string convertSignalArguments(Args...)()
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
345 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
346 // void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
347
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
348 string res = "void*[" ~ __toString(Args.length+1) ~ "] _a = [null";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
349 foreach(i, _; Args)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
350 res ~= ", " ~ "cast(void*) &" ~ convertSignalArgument!(Args[i])("_t" ~ __toString(i));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
351 res ~= "];\n";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
352 return res;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
353 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
354
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
355 public string SignalEmitter(A...)(SignalType signalType, string name, string[] defVals, int localIndex)
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
356 {
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
357 string fullArgs, args;
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
358 int defValsLength = defVals.length;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
359 string argsConversion = "";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
360 string argsPtr = "null";
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
361 static if (A.length)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
362 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
363 while(A.length != defVals.length)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
364 defVals = "" ~ defVals;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
365
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
366 fullArgs = A[0].stringof ~ " _t0";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
367 if (defVals[0].length)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
368 fullArgs ~= " = " ~ defVals[0];
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
369 args = "_t0";
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
370 foreach(i, _; A[1..$])
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
371 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
372 fullArgs ~= ", " ~ A[i+1].stringof ~ " _t" ~ __toString(i+1);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
373 if (defVals[i+1].length)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
374 fullArgs ~= " = " ~ defVals[i+1];
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
375 args ~= ", _t" ~ __toString(i+1);
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
376 }
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
377 // build up conversion of signal args from D to C++
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
378 argsPtr = "_a.ptr";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
379 argsConversion = convertSignalArguments!(A)();
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
380 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
381 string attribute;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
382 string sigName = name;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
383 if (signalType == SignalType.BindQtSignal)
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
384 name ~= "_emit";
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
385 else
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
386 attribute = "protected ";
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
387
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
388 string indexArgs = __toString(localIndex);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
389 if(defValsLength > 0)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
390 indexArgs ~= ", " ~ __toString(localIndex+defValsLength);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
391 string str = attribute ~ "final void " ~ name ~ "(" ~ fullArgs ~ ") {\n" ~ argsConversion ~ "\n"
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
392 ~ " QMetaObject.activate(this, typeof(this).staticMetaObject, " ~ indexArgs ~ ", " ~ argsPtr ~ ");\n"
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
393 ~ "}\n"; // ~
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
394 return str;
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
395 }
278
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
396 /** ---------------- */
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
397
5df570e79cfc new syntax for connecting using static information
eldar
parents: 276
diff changeset
398
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
399 const string signalPrefix = "__signal";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
400 const string slotPrefix = "__slot";
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
401
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
402 enum SignalType
1
e78566595089 initial import
mandel
parents:
diff changeset
403 {
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
404 BindQtSignal,
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
405 NewSignal,
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
406 NewSlot
284
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
407 }
1f6923c8cba0 consistent emit syntax.
eldar
parents: 282
diff changeset
408
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
409 template BindQtSignal(string fullName)
1
e78566595089 initial import
mandel
parents:
diff changeset
410 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
411 mixin MetaMethodImpl!(signalPrefix, 0, fullName, SignalType.BindQtSignal);
1
e78566595089 initial import
mandel
parents:
diff changeset
412 }
e78566595089 initial import
mandel
parents:
diff changeset
413
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
414 template Signal(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.NewSignal);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
417 }
1
e78566595089 initial import
mandel
parents:
diff changeset
418
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
419 template Slot(string fullName)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
420 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
421 mixin MetaMethodImpl!(slotPrefix, 0, fullName, SignalType.NewSlot);
1
e78566595089 initial import
mandel
parents:
diff changeset
422 }
e78566595089 initial import
mandel
parents:
diff changeset
423
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
424 template SignalImpl(int index, string fullName, SignalType signalType)
1
e78566595089 initial import
mandel
parents:
diff changeset
425 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
426 static if (is(typeof(mixin(typeof(this).stringof ~ "." ~ signalPrefix ~ ToString!(index)))))
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
427 mixin SignalImpl!(index + 1, fullName, signalType);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
428 else
1
e78566595089 initial import
mandel
parents:
diff changeset
429 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
430 // pragma(msg, "alias void delegate" ~ getFunc!_Tuple(fullName) ~ " Dg;");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
431 mixin("alias void delegate" ~ getFunc!_Tuple(fullName) ~ " Dg;");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
432 alias ParameterTypeTuple!(Dg) ArgTypes;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
433 enum args = getFunc!_Args(fullName);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
434 enum defVals = defaultValues(args);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
435 enum defValsLength = defaultValuesLength(defVals);
1
e78566595089 initial import
mandel
parents:
diff changeset
436
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
437 // pragma (msg, SignalEmitter!(ArgTypes)(SignalType.NewSignal, getFunc!_Name(fullName), defVals, index));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
438 mixin InsertMetaSignal!(fullName, index, defValsLength, ArgTypes);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
439 // pragma (msg, ctfe_meta_signal!(ArgTypes)(fullName, index, defValsLength));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
440 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
441 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
442 template MetaMethodImpl(string metaPrefix, int index, string fullName, SignalType signalType)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
443 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
444 static if (is(typeof(mixin(typeof(this).stringof ~ "." ~ metaPrefix ~ toStringNow!(index)))))
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
445 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
446 mixin MetaMethodImpl!(metaPrefix, index + 1, fullName, signalType);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
447 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
448 else
1
e78566595089 initial import
mandel
parents:
diff changeset
449 {
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
450 mixin("alias void delegate" ~ getFunc!_Tuple(fullName) ~ " Dg;");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
451 alias ParameterTypeTuple!(Dg) ArgTypes;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
452 enum args = getFunc!_Args(fullName);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
453 enum defVals = defaultValues(args);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
454 enum defValsLength = defaultValuesLength(defVals);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
455
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
456 static if (metaPrefix == signalPrefix)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
457 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
458 // calculating local index of the signal
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
459 static if (typeof(this).stringof == "QObject")
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
460 enum localIndex = index;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
461 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
462 mixin ("enum localIndex = index - 1 - lastSignalIndex_" ~ (typeof(super)).stringof ~ ";");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
463
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
464 static if (signalType == SignalType.NewSignal)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
465 {
293
8627891e4556 QList updates
eldar
parents: 289
diff changeset
466 // pragma (msg, SignalEmitter!(ArgTypes)(SignalType.NewSignal, getFunc!_Name(fullName), defVals, localIndex));
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
467 mixin (SignalEmitter!(ArgTypes)(SignalType.NewSignal, getFunc!_Name(fullName), defVals, localIndex));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
468 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
469 }
289
c9d1aac290e9 clean up of unneeded functionality
eldar
parents: 288
diff changeset
470 mixin InsertMetaMethod!(fullName, metaPrefix, index, defValsLength, ArgTypes);
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
471 // pragma (msg, ctfe_meta_signal!(ArgTypes)(fullName, index, defValsLength));
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
472 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
473 }
289
c9d1aac290e9 clean up of unneeded functionality
eldar
parents: 288
diff changeset
474 template InsertMetaMethod(string fullName, string metaPrefix, int index, int defValsCount, ArgTypes...)
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
475 {
289
c9d1aac290e9 clean up of unneeded functionality
eldar
parents: 288
diff changeset
476 static if(defValsCount >= 0)
c9d1aac290e9 clean up of unneeded functionality
eldar
parents: 288
diff changeset
477 mixin("public alias TypeTuple!(\"" ~ getFunc!_Name(fullName) ~ "\", index, typeof(this), ArgTypes) " ~ metaPrefix ~ toStringNow!(index) ~ ";");
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
478 static if(defValsCount > 0)
289
c9d1aac290e9 clean up of unneeded functionality
eldar
parents: 288
diff changeset
479 mixin InsertMetaMethod!(fullName, metaPrefix, index+1, defValsCount-1, ArgTypes[0..$-1]);
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
480 }
1
e78566595089 initial import
mandel
parents:
diff changeset
481
e78566595089 initial import
mandel
parents:
diff changeset
482
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
483 string signature_impl(T...)(string name)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
484 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
485 string res = name ~ "(";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
486 foreach(i, _; T)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
487 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
488 if(i > 0)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
489 res ~= ",";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
490 res ~= T[i].stringof;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
491 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
492 res ~= ")";
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
493 return res;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
494 }
1
e78566595089 initial import
mandel
parents:
diff changeset
495
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
496 template signature(string name, T...)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
497 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
498 enum signature = signature_impl!(T)(name);
1
e78566595089 initial import
mandel
parents:
diff changeset
499 }
288
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
500
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
501 template lastSignalIndex(T)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
502 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
503 static if (T.stringof == "QObject")
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
504 enum lastSignalIndex = lastSignalIndexImpl!(T, 0);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
505 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
506 mixin ("enum lastSignalIndex = lastSignalIndexImpl!(T, " ~ "T.lastSignalIndex_" ~ (BaseClassesTuple!(T)[0]).stringof ~ ");");
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
507 }
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
508
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
509 template lastSignalIndexImpl(T, int index)
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
510 {
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
511 static if (is(typeof(mixin("T." ~ signalPrefix ~ toStringNow!(index)))))
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
512 enum lastSignalIndexImpl = lastSignalIndexImpl!(T, index + 1);
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
513 else
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
514 enum lastSignalIndexImpl = index - 1;
f9559a957be9 new signals and slots implementation
eldar
parents: 284
diff changeset
515 }