Mercurial > projects > qtd
annotate qt/qtd/MOC.d @ 322:7c2cf27391c4 signals
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
author | eldar_ins@eldar-laptop |
---|---|
date | Sun, 27 Dec 2009 21:13:38 +0500 |
parents | 5c6455c4889b |
children | 7a3c43424dca |
rev | line source |
---|---|
288 | 1 module qt.qtd.MOC; |
2 | |
3 import qt.qtd.ctfe.Format; | |
4 | |
5 import std.typetuple; | |
6 | |
7 import qt.Signal; | |
8 import qt.qtd.MetaMarshall; | |
319
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
9 import qt.qtd.Meta; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
10 |
302 | 11 public import qt.core.QString; |
288 | 12 |
13 public import std.traits; | |
14 /** | |
15 Utils. | |
16 */ | |
17 | |
18 T qMin(T)(T a,T b) { if (a < b) return a; return b; } | |
19 T qMax(T)(T a, T b) { if (a < b) return b; return a; } | |
20 T qBound(T)(T min, T val,T max) { return qMax(min, qMin(max, val)); } | |
21 | |
22 bool is_digit_char(const char s) | |
23 { | |
24 return (s >= '0' && s <= '9'); | |
25 } | |
26 | |
27 bool is_octal_char(const char s) | |
28 { | |
29 return (s >= '0' && s <= '7'); | |
30 } | |
31 | |
32 bool is_hex_char(const char s) | |
33 { | |
34 return ((s >= 'a' && s <= 'f') | |
35 || (s >= 'A' && s <= 'F') | |
36 || (s >= '0' && s <= '9') | |
37 ); | |
38 } | |
39 | |
40 int lastIndexOf(T)(T[] haystack, T[] needle, int from = -1) | |
41 { | |
42 auto l = haystack.length; | |
43 auto ol = needle.length; | |
44 int delta = l - ol; | |
45 if (from < 0) | |
46 from = delta; | |
47 if (from < 0 || from > l) | |
48 return -1; | |
49 if (from > delta) | |
50 from = delta; | |
51 | |
52 while(from >= 0) | |
53 { | |
54 if (haystack[from..from+ol] == needle) | |
55 return from; | |
56 from--; | |
57 } | |
58 return -1; | |
59 } | |
60 | |
61 | |
62 T[] newArray(T)(size_t len, T[] from = []) | |
63 { | |
64 if (len == from.length) | |
65 return from; | |
66 | |
67 if (!from.length) | |
68 from = [T.init]; | |
69 | |
70 if (from.length < len) | |
71 return newArray!T(len, from ~ from); | |
72 | |
73 return from[0..len]; | |
74 } | |
75 | |
76 string replicate(int n, char value) | |
77 { | |
78 char[] ret = "".dup; | |
79 if (n > 0) | |
80 { | |
81 // ret = newArray!char(n); | |
82 for(int i = 0; i < n; i++) | |
83 ret ~= value; | |
84 } | |
85 return cast(string)ret; | |
86 } | |
87 | |
88 /** | |
89 CTFE MOC port. | |
90 */ | |
91 | |
92 enum MethodFlags { | |
93 AccessPrivate = 0x00, | |
94 AccessProtected = 0x01, | |
95 AccessPublic = 0x02, | |
96 MethodMethod = 0x00, | |
97 MethodSignal = 0x04, | |
98 MethodSlot = 0x08, | |
99 MethodConstructor = 0x0c, | |
100 MethodCompatibility = 0x10, | |
101 MethodCloned = 0x20, | |
102 MethodScriptable = 0x40 | |
103 } | |
104 | |
105 enum Access { Private, Protected, Public } | |
106 | |
107 struct FunctionDef | |
108 { | |
109 /* FunctionDef(): returnTypeIsVolatile(false), access(Private), isConst(false), isVirtual(false), | |
110 inlineCode(false), wasCloned(false), isCompat(false), isInvokable(false), | |
111 isScriptable(false), isSlot(false), isSignal(false), | |
112 isConstructor(false), isDestructor(false), isAbstract(false) {} | |
113 */ | |
114 // Type type; | |
115 // string normalizedType; | |
116 // string tag; | |
117 // string name; | |
118 string sig; | |
119 string arguments; | |
120 Access access; | |
121 /* bool returnTypeIsVolatile; | |
122 | |
123 QList<ArgumentDef> arguments; | |
124 | |
125 enum Access { Private, Protected, Public }; | |
126 bool isConst; | |
127 bool isVirtual; | |
128 bool inlineCode; | |
129 bool wasCloned; | |
130 | |
131 QByteArray inPrivateClass; | |
132 bool isCompat; | |
133 bool isInvokable; | |
134 bool isScriptable; | |
135 bool isSlot; | |
136 bool isSignal; | |
137 bool isConstructor; | |
138 bool isDestructor; | |
139 bool isAbstract; | |
140 */ | |
141 } | |
142 | |
143 FunctionDef newSlot(string sig, string args) | |
144 { | |
145 return FunctionDef(sig, args, Access.Public); | |
146 } | |
147 | |
148 FunctionDef newSignal(string sig, string args) | |
149 { | |
150 return FunctionDef(sig, args, Access.Protected); | |
151 } | |
152 | |
153 struct Generator | |
154 { | |
155 string output; | |
156 string[] strings; | |
157 // QByteArray purestSuperClass; | |
158 // QList<QByteArray> metaTypes; | |
159 } | |
160 | |
161 int lengthOfEscapeSequence(string s, uint i) | |
162 { | |
163 if (s[i] != '\\' || i >= s.length - 1) | |
164 return 1; | |
165 const int startPos = i; | |
166 ++i; | |
167 auto ch = s[i]; | |
168 if (ch == 'x') { | |
169 ++i; | |
170 while (i < s.length && is_hex_char(s[i])) | |
171 ++i; | |
172 } else if (is_octal_char(ch)) { | |
173 while (i < startPos + 4 | |
174 && i < s.length | |
175 && is_octal_char(s[i])) { | |
176 ++i; | |
177 } | |
178 } else { // single character escape sequence | |
179 i = qMin(i + 1, s.length); | |
180 } | |
181 return i - startPos; | |
182 } | |
183 | |
184 int strreg(ref Generator gen, string s) | |
185 { | |
186 int idx = 0; | |
187 foreach (str; gen.strings) { | |
188 if (str == s) | |
189 return idx; | |
190 idx += str.length + 1; | |
191 foreach (i, c; str) { | |
192 if (c == '\\') { | |
193 int cnt = lengthOfEscapeSequence(str, i) - 1; | |
194 idx -= cnt; | |
195 i += cnt; | |
196 } | |
197 } | |
198 } | |
199 gen.strings ~= s; | |
200 return idx; | |
201 } | |
202 | |
203 void generateFunctions(ref Generator gen, FunctionDef[] list, string functype, byte type) | |
204 { | |
205 if (!list.length) | |
206 return; | |
207 gen.output ~= format_ctfe("\n // ${}s: signature, parameters, type, tag, flags\n", functype); | |
208 | |
209 foreach (i, f; list) { | |
210 byte flags = type; | |
211 | |
212 if (f.access == Access.Private) | |
213 flags |= MethodFlags.AccessPrivate; | |
214 else if (f.access == Access.Public) | |
215 flags |= MethodFlags.AccessPublic; | |
216 else if (f.access == Access.Protected) | |
217 flags |= MethodFlags.AccessProtected; | |
218 | |
219 gen.output ~= format_ctfe(" ${}, ${}, ${}, ${}, 0x${:x},\n", strreg(gen, f.sig), | |
220 strreg(gen, f.arguments), strreg(gen, ""/*f.normalizedType*/), strreg(gen, ""/*f.tag*/), flags); | |
221 } | |
222 } | |
223 | |
224 string generateCode(string className, FunctionDef[] signalList, FunctionDef[] slotList) | |
225 { | |
226 auto gen = Generator("", []); | |
227 | |
228 /* bool isQt = (cdef->classname == "Qt"); | |
229 bool isQObject = (cdef->classname == "QObject"); | |
230 bool isConstructible = !cdef->constructorList.isEmpty(); | |
231 | |
232 // | |
233 // build the data array | |
234 // | |
235 int i = 0; | |
236 | |
237 | |
238 // filter out undeclared enumerators and sets | |
239 { | |
240 QList<EnumDef> enumList; | |
241 for (i = 0; i < cdef->enumList.count(); ++i) { | |
242 EnumDef def = cdef->enumList.at(i); | |
243 if (cdef->enumDeclarations.contains(def.name)) { | |
244 enumList += def; | |
245 } | |
246 QByteArray alias = cdef->flagAliases.value(def.name); | |
247 if (cdef->enumDeclarations.contains(alias)) { | |
248 def.name = alias; | |
249 enumList += def; | |
250 } | |
251 } | |
252 cdef->enumList = enumList; | |
253 } | |
254 | |
255 | |
256 QByteArray qualifiedClassNameIdentifier = cdef->qualified; | |
257 qualifiedClassNameIdentifier.replace(':', '_'); | |
258 */ | |
259 bool isConstructible = false; | |
260 | |
261 FunctionDef[] propertyList, enumList, constructorList; | |
262 int index = 12; | |
263 gen.output ~= format_ctfe("static const uint[] qt_meta_data_${} = [\n", className); | |
264 gen.output ~= format_ctfe("\n // content:\n"); | |
265 gen.output ~= format_ctfe(" ${}, // revision\n", 2); | |
266 gen.output ~= format_ctfe(" ${}, // classname\n", strreg(gen, className)); | |
267 gen.output ~= format_ctfe(" ${}, ${}, // classinfo\n", 0, 0); | |
268 // index += cdef->classInfoList.count() * 2; | |
269 | |
270 int methodCount = signalList.length + slotList.length;// + cdef->methodList.count(); | |
271 gen.output ~= format_ctfe(" ${}, ${}, // methods\n", methodCount, methodCount ? index : 0); | |
272 index += methodCount * 5; | |
273 gen.output ~= format_ctfe(" ${}, ${}, // properties\n", propertyList.length, propertyList.length ? index : 0); | |
274 index += propertyList.length * 3; | |
275 // if(cdef->notifyableProperties) | |
276 // index += cdef->propertyList.count(); | |
277 gen.output ~= format_ctfe(" ${}, ${}, // enums/sets\n", enumList.length, enumList.length ? index : 0); | |
278 | |
279 // int enumsIndex = index; | |
280 // for (i = 0; i < cdef->enumList.count(); ++i) | |
281 // index += 4 + (cdef->enumList.at(i).values.count() * 2); | |
282 gen.output ~= format_ctfe(" ${}, ${}, // constructors\n", isConstructible ? constructorList.length : 0, | |
283 isConstructible ? index : 0); | |
284 | |
285 // | |
286 // Build classinfo array | |
287 // | |
288 // generateClassInfos(); | |
289 | |
290 // | |
291 // Build signals array first, otherwise the signal indices would be wrong | |
292 // | |
293 generateFunctions(gen, signalList, "signal", MethodFlags.MethodSignal); | |
294 | |
295 // | |
296 // Build slots array | |
297 // | |
298 generateFunctions(gen, slotList, "slot", MethodFlags.MethodSlot); | |
299 | |
300 // | |
301 // Build method array | |
302 // | |
303 // generateFunctions(cdef->methodList, "method", MethodMethod); | |
304 | |
305 | |
306 // | |
307 // Build property array | |
308 // | |
309 // generateProperties(); | |
310 | |
311 // | |
312 // Build enums array | |
313 // | |
314 // generateEnums(enumsIndex); | |
315 | |
316 // | |
317 // Build constructors array | |
318 // | |
319 // if (isConstructible) | |
320 // generateFunctions(cdef->constructorList, "constructor", MethodConstructor); | |
321 | |
322 // | |
323 // Terminate data array | |
324 // | |
325 gen.output ~= format_ctfe("\n 0 // eod\n];\n\n"); | |
326 | |
327 // | |
328 // Build stringdata array | |
329 // | |
330 gen.output ~= format_ctfe("static const string qt_meta_stringdata_${} = \n", className); | |
331 gen.output ~= format_ctfe(" \""); | |
332 int col = 0; | |
333 int len = 0; | |
334 foreach (i, s; gen.strings) { | |
335 len = s.length; | |
336 if (col && col + len >= 72) { | |
337 gen.output ~= format_ctfe("\"\n \""); | |
338 col = 0; | |
339 } else if (len && s[0] >= '0' && s[0] <= '9') { | |
340 gen.output ~= format_ctfe("\"\""); | |
341 len += 2; | |
342 } | |
343 int idx = 0; | |
344 while (idx < s.length) { | |
345 if (idx > 0) { | |
346 col = 0; | |
347 gen.output ~= format_ctfe("\"\n \""); | |
348 } | |
349 int spanLen = qMin(cast(uint)70, s.length - idx); | |
350 // don't cut escape sequences at the end of a line | |
351 int backSlashPos = s.lastIndexOf("\\", idx + spanLen - 1); | |
352 if (backSlashPos >= idx) { | |
353 int escapeLen = lengthOfEscapeSequence(s, backSlashPos); | |
354 spanLen = qBound(spanLen, backSlashPos + escapeLen - idx, cast(int)(s.length - idx)); | |
355 } | |
356 gen.output ~= s[idx..idx+spanLen]; | |
357 idx += spanLen; | |
358 col += spanLen; | |
359 } | |
360 | |
361 gen.output ~= "\\0"; | |
362 col += len + 2; | |
363 } | |
364 gen.output ~= "\";\n\n"; | |
365 | |
366 return gen.output; | |
367 } | |
368 | |
369 string metaCallArgs(Args...)() | |
370 { | |
371 string res; | |
372 foreach(i, _; Args) { | |
373 if (i > 0) | |
374 res ~= ","; | |
375 res ~= metaCallArgument!(Args[i])("_a[" ~ __toString(i+1) ~ "]"); | |
376 } | |
377 return res; | |
378 } | |
379 | |
380 string qtDeclArgs(Args...)() | |
381 { | |
382 string ret; | |
383 foreach(i, _; Args) | |
384 { | |
385 if(i > 0) | |
386 ret ~= ","; | |
387 ret ~= qtDeclArg!(Args[i]); | |
388 } | |
389 return ret; | |
390 } | |
391 | |
392 string generate_qt_metacall(alias Signals, alias Slots)() | |
393 { | |
394 string res = " | |
395 protected int qt_metacall(QMetaObject.Call _c, int _id, void **_a) | |
396 { | |
397 _id = super.qt_metacall(_c, _id, _a); | |
398 if (_id < 0) | |
399 return _id;\n"; | |
400 | |
401 alias TypeTuple!(Signals.at, Slots.at) Methods; | |
402 enum methodCount = Methods.length; | |
403 if(methodCount) | |
404 { | |
405 res ~= " | |
406 if (_c == QMetaObject.Call.InvokeMetaMethod) { | |
407 switch (_id) {"; | |
319
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
408 foreach(i, _; Repeat!(void, methodCount)) { |
288 | 409 res ~= " |
410 case " ~ __toString(i) ~ ": " ~ MetaEntryName!(Methods[i].at) ~ "(" ~ metaCallArgs!(MetaEntryArgs!(Methods[i].at))() ~ "); break;"; | |
411 } | |
412 res ~= "\n default: ;\n }\n"; | |
413 res ~= " _id -= " ~ __toString(methodCount) ~ ";"; | |
414 res ~= "\n }"; | |
415 } | |
416 | |
417 res ~= "\n return _id; | |
418 }"; | |
419 return res; | |
420 } | |
421 | |
422 string dDeclArgs(Args...)() | |
423 { | |
424 string ret; | |
425 foreach(i, _; Args) | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
320
diff
changeset
|
426 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
320
diff
changeset
|
427 if (i > 0) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
320
diff
changeset
|
428 ret ~= ", "; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
320
diff
changeset
|
429 ret ~= Args[i].stringof; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
320
diff
changeset
|
430 } |
288 | 431 return ret; |
432 } | |
433 string genMetaMethodsConstr(alias Funcs)(string className) | |
434 { | |
435 string res; | |
436 enum funcsCount = Funcs.at.length; | |
437 foreach(i, bogus; Repeat!(void, funcsCount)) | |
438 { | |
439 res ~= " index++;\n" ~ | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
320
diff
changeset
|
440 " _staticMetaObject.addMethod(new " ~ className ~ "(signature!(" ~ dDeclArgs!(MetaEntryArgs!(Funcs.at[i].at))()~ ")(\"" ~ MetaEntryName!(Funcs.at[i].at) ~ "\"), index));\n\n"; |
288 | 441 } |
442 return res; | |
443 } | |
444 string generateMetaObjectConstruction(alias Signals, alias Slots)() | |
445 { | |
446 string res; | |
447 res ~= "\n | |
448 private static void _populateMetaInfo() { | |
449 alias BaseClassesTuple!(typeof(this))[0] BaseClass; | |
450 int index = BaseClass.staticMetaObject().methodCount() - 1;\n\n"; | |
451 | |
452 res ~= genMetaMethodsConstr!(Signals)("QMetaSignal"); | |
453 res ~= genMetaMethodsConstr!(Slots)("QMetaSlot"); | |
454 | |
455 res ~= " | |
456 }\n"; | |
457 return res; | |
458 } | |
459 | |
460 string generateQMetaObject(string className) | |
461 { | |
462 string res; | |
463 res ~= " | |
464 QMetaObject metaObject() { return staticMetaObject; } | |
465 private static QMetaObject _staticMetaObject; | |
466 private static QMetaObjectNative _nativeStaticMetaObject; | |
467 public static QMetaObject staticMetaObject() { return _staticMetaObject; } | |
468 protected static void createStaticMetaObject() { | |
469 assert(!_staticMetaObject); | |
470 alias BaseClassesTuple!(typeof(this))[0] BaseClass; | |
471 if (!BaseClass._staticMetaObject) | |
472 BaseClass.createStaticMetaObject; | |
473 auto base = BaseClass._staticMetaObject; | |
474 _nativeStaticMetaObject = QMetaObjectNative(base.nativeId, qt_meta_stringdata_" ~ className ~ ".ptr, | |
475 qt_meta_data_" ~ className ~ ".ptr, null ); | |
476 | |
477 _staticMetaObject = new QMetaObject(&_nativeStaticMetaObject, base); | |
478 // _staticMetaObject.construct!(typeof(this)); | |
479 _populateMetaInfo(); | |
480 } | |
481 static this() | |
482 { | |
483 createStaticMetaObject(); | |
484 }\n\n"; | |
485 return res; | |
486 } | |
487 | |
488 size_t commaCount(int argCount) | |
489 { | |
490 size_t ret = 0; | |
491 if(argCount > 1) | |
492 ret = argCount - 1; | |
493 return ret; | |
494 } | |
495 | |
496 FunctionDef[] genFuncDefs(alias Funcs, alias newFunc)() | |
497 { | |
498 typeof(return) res; | |
499 enum funcsCount = Funcs.at.length; | |
500 foreach(i, bogus; Repeat!(void, funcsCount)) | |
501 { | |
502 string args = replicate(commaCount((MetaEntryArgs!(Funcs.at[i].at)).length), ','); | |
503 string funcSig = MetaEntryName!(Funcs.at[i].at) ~ "(" ~ qtDeclArgs!(MetaEntryArgs!(Funcs.at[i].at))() ~ ")"; | |
504 res ~= newFunc(funcSig, args); | |
505 } | |
506 return res; | |
507 } | |
508 | |
509 template Q_OBJECT_BIND() | |
510 { | |
511 } | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
320
diff
changeset
|
512 |
319
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
513 // ------------------------------------------------------------------------------------------ |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
514 |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
515 string generateSignalEmitters(alias Funcs)() |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
516 { |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
517 string res; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
518 enum funcsCount = Funcs.at.length; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
519 foreach(i, bogus; Repeat!(void, funcsCount)) |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
520 { |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
521 res ~= SignalEmitter!(MetaEntryArgs!(Funcs.at[i].at))(SignalType.NewSignal, MetaEntryName!(Funcs.at[i].at), [], i); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
522 } |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
523 return res; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
524 } |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
525 |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
526 string generateSlotAliases(alias Funcs)() |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
527 { |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
528 string res; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
529 enum funcsCount = Funcs.at.length; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
530 foreach(i, bogus; Repeat!(void, funcsCount)) |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
531 { |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
532 string name = MetaEntryName!(Funcs.at[i].at); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
533 res ~= format_ctfe(" alias slot_${} ${};\n", name, name); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
534 } |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
535 return res; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
536 } |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
537 |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
538 |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
539 string generateMetaInfo(T, alias Signals, alias Slots)() |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
540 { |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
541 string res = ""; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
542 auto signalList = genFuncDefs!(Signals, newSignal)(); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
543 auto slotList = genFuncDefs!(Slots, newSlot)(); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
544 res ~= generateSignalEmitters!(Signals)(); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
545 res ~= generateSlotAliases!(Slots)(); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
546 res ~= generateCode(T.stringof, signalList, slotList); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
547 res ~= generate_qt_metacall!(Signals, Slots); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
548 res ~= generateMetaObjectConstruction!(Signals, Slots); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
549 res ~= generateQMetaObject(T.stringof); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
550 return res; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
551 } |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
552 |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
553 template Q_OBJECT() |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
554 { |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
555 alias findSignals!(typeof(this)) SignalFuncs; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
556 alias toMetaEntries!(SignalFuncs) SignalMetaEntries; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
557 alias findSlots!(typeof(this)) SlotFuncs; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
558 alias toMetaEntries!(SlotFuncs) SlotMetaEntries; |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
559 |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
560 mixin(generateMetaInfo!(typeof(this), SignalMetaEntries, SlotMetaEntries)()); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
561 pragma(msg, generateMetaInfo!(typeof(this), SignalMetaEntries, SlotMetaEntries)()); |
894d40eb89b6
new signals and slots syntax. have to use prefixes now: signal_fooed and slot_onFooed
eldar_ins@eldar-laptop
parents:
302
diff
changeset
|
562 } |