Mercurial > projects > qtd
annotate d2/qt/QGlobal.d @ 350:31520b2c0b3c
Removed dependency on parent trait and stringof
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Thu, 20 May 2010 15:49:08 +0300 |
parents | 96a75b1e5b26 |
children | 0a671b1382d7 |
rev | line source |
---|---|
1 | 1 module qt.QGlobal; |
2 | |
344 | 3 public import qtd.Str; |
194
ba7abb5c9e03
move the generated data from qt.QGlobal to qt.QDefines.
SokoL_SD
parents:
191
diff
changeset
|
4 public import qt.QDefines; |
1 | 5 |
6 version (Tango) | |
7 { | |
8 import tango.io.Stdout; | |
9 void writeln(string s) | |
10 { | |
11 Stdout(s).newline; | |
12 } | |
188 | 13 package import tango.stdc.stdlib, |
14 tango.core.Memory; | |
1 | 15 } |
16 else | |
188 | 17 { |
1 | 18 import std.stdio; |
188 | 19 package import std.c.stdlib, |
20 core.memory; | |
21 } | |
1 | 22 |
254 | 23 T static_cast(T, U)(U obj) |
24 { | |
25 return cast(T)cast(void*)obj; | |
26 } | |
27 | |
1 | 28 template QT_BEGIN_NAMESPACE() { |
29 } | |
30 | |
31 template QT_END_NAMESPACE() { | |
32 } | |
33 | |
34 template QT_BEGIN_HEADER() { | |
35 } | |
36 | |
37 template QT_END_HEADER() { | |
38 } | |
39 | |
40 mixin QT_BEGIN_HEADER; | |
41 mixin QT_BEGIN_NAMESPACE; | |
42 | |
254 | 43 //TODO: this sucks |
44 extern(C) void qtd_dummy() {} | |
45 // Defined in QObject.d | |
46 extern(C) void qtd_delete_d_qobject(void* dPtr); | |
125 | 47 |
48 version(cpp_shared) | |
1 | 49 { |
254 | 50 extern (C) void qtd_core_initCallBacks(void* toUtf8, void* dummy); |
1 | 51 static this() { |
254 | 52 qtd_core_initCallBacks(&qtd_toUtf8, &qtd_dummy); |
53 } | |
54 | |
55 extern (C) void qtd_QObjectEntity_initCallBacks(void* del_d_obj); | |
56 static this() { | |
57 qtd_QObjectEntity_initCallBacks(&qtd_delete_d_qobject); | |
1 | 58 } |
59 } | |
60 | |
350
31520b2c0b3c
Removed dependency on parent trait and stringof
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
61 string _tr(string arg) { |
1 | 62 return arg; |
63 } | |
64 | |
350
31520b2c0b3c
Removed dependency on parent trait and stringof
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
65 alias _tr tr; |
31520b2c0b3c
Removed dependency on parent trait and stringof
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
66 |
1 | 67 /* |
68 can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) | |
69 */ | |
70 bool QT_VERSION_CHECK( ushort major, ushort minor, ushort patch ) | |
71 { | |
72 return cast(bool)((major<<16)|(minor<<8)|(patch)); | |
73 } | |
74 //TODO(katrina) get this from the C++ side | |
75 const char[] QT_PACKAGEDATE_STR = "2008-09-27"; | |
76 //TODO(katrina) get this from the C++ side | |
77 const char[] QT_PACKAGE_TAG = "gc9953de622c6a0f655322e0d9f5bd6dc2803b470"; | |
78 | |
79 /* | |
80 Size-dependent types (architechture-dependent byte order) | |
81 | |
82 Make sure to update QMetaType when changing these typedefs | |
83 */ | |
84 | |
85 alias char qint8; /* 8 bit signed */ | |
86 alias char quint8; /* 8 bit unsigned */ | |
87 alias short qint16; /* 16 bit signed */ | |
88 alias ushort quint16; /* 16 bit unsigned */ | |
89 alias int qint32; /* 32 bit signed */ | |
90 alias uint quint32; /* 32 bit unsigned */ | |
91 alias long qint64; /* 64 bit signed */ | |
92 alias ulong quint64; /* 64 bit unsigned */ | |
93 | |
39 | 94 version (X86) |
95 { | |
96 alias quint32 quintptr; | |
97 alias qint32 qptrdiff; | |
98 } | |
99 else version (X86_64) | |
100 { | |
101 alias quint64 quintptr; | |
102 alias qint64 qptrdiff; | |
103 } | |
104 | |
1 | 105 const byte QT_POINTER_SIZE = 8; |
106 | |
107 alias int QNoImplicitBoolCast; | |
108 | |
109 alias double qreal; | |
110 | |
111 | |
112 /* | |
113 Utility macros and inline functions | |
114 TODO(katrina) see if we need to do anything to make these | |
115 able to be evaluated at compile time | |
116 */ | |
117 | |
118 T qAbs(T)(T t) { return t >= 0 ? t : -t; } | |
119 | |
120 int qRound(qreal d) | |
121 { return d >= 0.0 ? cast(int)(d + 0.5) : cast(int)(d - cast(int)(d-1) + 0.5) + cast(int)(d-1); } | |
122 | |
123 qint64 qRound64(qreal d) | |
124 { return d >= 0.0 ? cast(qint64)(d + 0.5) : cast(qint64)(d - cast(qint64)(d-1) + 0.5) + cast(qint64)(d-1); } | |
125 | |
126 T qMin(T)(T a,T b) { if (a < b) return a; return b; } | |
127 T qMax(T)(T a, T b) { if (a < b) return b; return a; } | |
128 T qBound(T)(T min, T val,T max) { return qMax(min, qMin(max, val)); } | |
129 | |
130 /* | |
131 Data stream functions are provided by many classes (defined in qdatastream.h) | |
132 */ | |
133 | |
134 //class QDataStream; | |
135 | |
136 /* | |
137 System information | |
138 */ | |
139 | |
140 class QSysInfo { | |
141 public: | |
142 enum Sizes { | |
143 WordSize = ((void *).sizeof<<3) | |
144 }; | |
145 | |
146 enum Endian { | |
147 BigEndian, | |
148 LittleEndian, | |
149 ByteOrder = BigEndian | |
150 }; | |
151 /* needed to bootstrap qmake */ | |
152 static const int ByteOrder; | |
153 | |
154 enum WinVersion { | |
155 WV_32s = 0x0001, | |
156 WV_95 = 0x0002, | |
157 WV_98 = 0x0003, | |
158 WV_Me = 0x0004, | |
159 WV_DOS_based= 0x000f, | |
160 | |
161 WV_NT = 0x0010, | |
162 WV_2000 = 0x0020, | |
163 WV_XP = 0x0030, | |
164 WV_2003 = 0x0040, | |
165 WV_VISTA = 0x0080, | |
166 WV_NT_based = 0x00f0, | |
167 | |
168 WV_CE = 0x0100, | |
169 WV_CENET = 0x0200, | |
170 WV_CE_5 = 0x0300, | |
171 WV_CE_6 = 0x0400, | |
172 WV_CE_based = 0x0f00 | |
173 }; | |
174 static const WinVersion WindowsVersion; | |
175 static WinVersion windowsVersion(); | |
176 | |
177 enum MacVersion { | |
178 MV_Unknown = 0x0000, | |
179 | |
180 /* version */ | |
181 MV_9 = 0x0001, | |
182 MV_10_0 = 0x0002, | |
183 MV_10_1 = 0x0003, | |
184 MV_10_2 = 0x0004, | |
185 MV_10_3 = 0x0005, | |
186 MV_10_4 = 0x0006, | |
187 MV_10_5 = 0x0007, | |
188 | |
189 /* codenames */ | |
190 MV_CHEETAH = MV_10_0, | |
191 MV_PUMA = MV_10_1, | |
192 MV_JAGUAR = MV_10_2, | |
193 MV_PANTHER = MV_10_3, | |
194 MV_TIGER = MV_10_4, | |
195 MV_LEOPARD = MV_10_5 | |
196 }; | |
197 static const MacVersion MacintoshVersion; | |
198 }; | |
199 | |
247 | 200 |
201 extern(C) stringz qtd_qVersion(); | |
202 /// | |
203 string qVersion() | |
204 { | |
205 return fromStringz(qtd_qVersion); | |
206 } | |
1 | 207 |
247 | 208 extern(C) bool qtd_qSharedBuild(); |
209 /// | |
210 bool qSharedBuild() | |
211 { | |
212 return qtd_qSharedBuild; | |
213 } | |
214 | |
215 /// | |
1 | 216 int qMacVersion() { return QSysInfo.MacintoshVersion; } |
217 | |
247 | 218 /// |
1 | 219 void qUnused(T)(T x) { cast(void) x; } |
247 | 220 /// |
1 | 221 void Q_UNUSED(T)(T x) { qUnused(x); } |
222 | |
223 /* | |
224 Debugging and error handling | |
225 */ | |
226 | |
227 //class QString; | |
228 //char[] qPrintable(QString string) { string.toLocal8Bit().constData(); } | |
229 //TODO(katrina) These should probably actually call into the c++ functions | |
291 | 230 void qFatal(string str) |
231 { | |
232 throw new Exception(str); | |
233 } | |
234 | |
1 | 235 void qDebug( char[] str ) /* print debug message */ |
236 { writeln(str); } | |
237 | |
238 extern (C) void Qt_qWarning( char * ); | |
239 | |
240 void qWarning(char[] str) /* print warning message */ | |
241 { writeln(str); } | |
242 | |
243 //QString qt_error_string(int errorCode = -1); | |
244 void qCritical(char[] str) /* print critical message */ | |
245 { writeln(str); } | |
246 | |
247 /* | |
248 Forward declarations only. | |
249 | |
250 In order to use the qDebug() stream, you must #include<QDebug> | |
251 */ | |
252 //class QDebug; | |
253 //class QNoDebug; | |
254 //QDebug qDebug(); | |
255 //QDebug qWarning(); | |
256 //QDebug qCritical(); | |
257 | |
258 void qt_noop() {} | |
259 //TODO(katrina) Implement these | |
260 void qt_assert(char[] assertion, char[] file, int line); | |
261 | |
262 void qt_assert_x(char[] where, char[] what, char[] file, int line); | |
263 | |
264 void qt_check_pointer(char[], int); | |
265 | |
266 enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg }; | |
267 | |
268 void qt_message_output(QtMsgType, char[] buf); | |
269 //class QtMsgHandler; | |
270 //QtMsgHandler qInstallMsgHandler(QtMsgHandler); | |
271 | |
272 // forward declaration, since qatomic.h needs qglobal.h | |
273 class QBasicAtomicPointer(T); | |
274 | |
275 // POD for Q_GLOBAL_STATIC | |
276 class QGlobalStatic(T) | |
277 { | |
278 public: | |
279 QBasicAtomicPointer!(T) pointer; | |
280 bool destroyed; | |
281 }; | |
282 | |
283 // Created as a function-local static to delete a QGlobalStatic<T> | |
284 class QGlobalStaticDeleter(T) | |
285 { | |
286 public: | |
287 QGlobalStatic!(T) globalStatic; | |
288 this(QGlobalStatic!(T) _globalStatic) { | |
289 globalStatic(_globalStatic); | |
290 } | |
291 | |
292 ~this() | |
293 { | |
294 delete globalStatic.pointer; | |
295 globalStatic.pointer = 0; | |
296 globalStatic.destroyed = true; | |
297 } | |
298 }; | |
299 | |
300 class QBool | |
301 { | |
302 bool b; | |
303 | |
304 public: | |
305 this(bool B) { b = B; } | |
306 // void *() const | |
307 // { return b ? static_cast<const void *>(this) : static_cast<const void *>(0); } | |
308 } | |
309 | |
310 bool qFuzzyCompare(double p1, double p2) | |
311 { | |
312 return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2))); | |
313 } | |
314 | |
315 bool qFuzzyCompare(float p1, float p2) | |
316 { | |
317 return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2))); | |
318 } | |
319 | |
320 /* | |
321 This function tests a double for a null value. It doesn't | |
322 check whether the actual value is 0 or close to 0, but whether | |
323 it is binary 0. | |
324 */ | |
325 bool qIsNull(double d) | |
326 { | |
327 union U { | |
328 double d; | |
329 quint64 u; | |
330 }; | |
331 U val; | |
332 val.d = d; | |
333 return val.u == cast(quint64)(0); | |
334 } | |
335 | |
336 /* | |
337 This function tests a float for a null value. It doesn't | |
338 check whether the actual value is 0 or close to 0, but whether | |
339 it is binary 0. | |
340 */ | |
341 bool qIsNull(float f) | |
342 { | |
343 union U { | |
344 float f; | |
345 quint32 u; | |
346 }; | |
347 U val; | |
348 val.f = f; | |
349 return val.u == 0u; | |
350 } | |
351 | |
352 /* | |
353 Compilers which follow outdated template instantiation rules | |
354 require a class to have a comparison operator to exist when | |
355 a QList of this type is instantiated. It's not actually | |
356 used in the list, though. Hence the dummy implementation. | |
357 Just in case other code relies on it we better trigger a warning | |
358 mandating a real implementation. | |
359 */ | |
360 | |
361 | |
362 /* | |
363 QTypeInfo - type trait functionality | |
364 qIsDetached - data sharing functionality | |
365 */ | |
366 | |
367 /* | |
368 The catch-all template. | |
369 */ | |
292 | 370 /* |
1 | 371 bool qIsDetached(T)(T) { return true; } |
372 | |
373 class QTypeInfossss(T) | |
374 { | |
375 public: | |
376 enum { | |
377 isPointer = false, | |
378 isComplex = true, | |
379 isStatic = true, | |
380 isLarge = ((T).sizeof>(void*).sizeof), | |
381 isDummy = false | |
382 }; | |
383 }; | |
384 | |
385 class QTypeInfo(T) | |
386 { | |
387 public: | |
388 enum { | |
389 isPointer = true, | |
390 isComplex = false, | |
391 isStatic = false, | |
392 isLarge = false, | |
393 isDummy = false | |
394 }; | |
395 }; | |
292 | 396 */ |
1 | 397 |
398 /* | |
399 Specialize a specific type with: | |
400 | |
401 Q_DECLARE_TYPEINFO(type, flags); | |
402 | |
403 where 'type' is the name of the type to specialize and 'flags' is | |
404 logically-OR'ed combination of the flags below. | |
405 */ | |
406 enum { /* TYPEINFO flags */ | |
407 Q_COMPLEX_TYPE = 0, | |
408 Q_PRIMITIVE_TYPE = 0x1, | |
409 Q_STATIC_TYPE = 0, | |
410 Q_MOVABLE_TYPE = 0x2, | |
411 Q_DUMMY_TYPE = 0x4 | |
412 }; | |
413 | |
414 /* | |
415 Specialize a shared type with: | |
416 | |
417 Q_DECLARE_SHARED(type); | |
418 | |
419 where 'type' is the name of the type to specialize. NOTE: shared | |
420 types must declare a 'bool isDetached(void) const;' member for this | |
421 to work. | |
422 */ | |
423 void qSwap_helper(T)(ref T value1, ref T value2, T*) | |
424 { | |
425 T t = value1; | |
426 value1 = value2; | |
427 value2 = t; | |
428 } | |
429 bool qIsDetached(T)(ref T t) { return t.isDetached(); } | |
430 void qSwap_helper(T)(ref T value1, ref T value2, T*) | |
431 { | |
432 const T.DataPtr t = value1.data_ptr(); | |
433 value1.data_ptr() = value2.data_ptr(); | |
434 value2.data_ptr() = t; | |
435 } | |
155 | 436 |
1 | 437 void qSwap(T)(ref T value1, ref T value2) |
438 { | |
155 | 439 T t = value1; |
440 value1 = value2; | |
441 value2 = t; | |
1 | 442 } |
443 | |
444 /* | |
445 QTypeInfo primitive specializations | |
446 TODO(katrina) Find out what we need to do here | |
447 */ | |
448 /* | |
449 Q_DECLARE_TYPEINFO(bool, Q_PRIMITIVE_TYPE); | |
450 Q_DECLARE_TYPEINFO(char, Q_PRIMITIVE_TYPE); | |
451 Q_DECLARE_TYPEINFO(signed char, Q_PRIMITIVE_TYPE); | |
452 Q_DECLARE_TYPEINFO(uchar, Q_PRIMITIVE_TYPE); | |
453 Q_DECLARE_TYPEINFO(short, Q_PRIMITIVE_TYPE); | |
454 Q_DECLARE_TYPEINFO(ushort, Q_PRIMITIVE_TYPE); | |
455 Q_DECLARE_TYPEINFO(int, Q_PRIMITIVE_TYPE); | |
456 Q_DECLARE_TYPEINFO(uint, Q_PRIMITIVE_TYPE); | |
457 Q_DECLARE_TYPEINFO(long, Q_PRIMITIVE_TYPE); | |
458 Q_DECLARE_TYPEINFO(ulong, Q_PRIMITIVE_TYPE); | |
459 Q_DECLARE_TYPEINFO(qint64, Q_PRIMITIVE_TYPE); | |
460 Q_DECLARE_TYPEINFO(quint64, Q_PRIMITIVE_TYPE); | |
461 Q_DECLARE_TYPEINFO(float, Q_PRIMITIVE_TYPE); | |
462 Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE); | |
463 #ifndef Q_OS_DARWIN | |
464 Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE); | |
465 #endif | |
466 */ | |
467 /* | |
468 These functions make it possible to use standard C++ functions with | |
469 a similar name from Qt header files (especially template classes). | |
470 TODO(katrina) Implement these | |
471 */ | |
472 void * qMalloc(size_t size); | |
473 void qFree(void * ptr); | |
474 void * qRealloc(void * ptr, size_t size); | |
475 void * qMemCopy(void * dest, void * src, size_t n); | |
476 void * qMemSet(void * dest, int c, size_t n); | |
477 | |
478 struct QFlags(Enum) | |
479 { | |
480 private: | |
481 alias void **Zero; | |
482 int i; | |
483 | |
484 public: | |
485 alias Enum enum_type; | |
486 | |
487 public static QFlags!(Enum) opCall(Enum)(QFlags f) { | |
488 QFlags!(Enum) res; | |
489 res.i = f.i; | |
490 return res; | |
491 } | |
492 | |
493 public static QFlags opCall(Enum)(Enum f) { | |
494 QFlags!(Enum) res; | |
495 res.i = f; | |
496 return res; | |
497 } | |
498 | |
499 public static QFlags opCall(Enum)(int f) { | |
500 QFlags!(Enum) res; | |
501 res.i = cast(Enum) f; | |
502 return res; | |
503 } | |
504 | |
505 // this(Zero = 0) : i(0) {} | |
506 // this(QFlag f) : i(f) {} | |
507 | |
508 // QFlags!(Enum) opAssign(QFlags f) { i = f.i; return *this; } | |
509 QFlags!(Enum) opAssign(int f) { i = f; return *this; } | |
510 QFlags!(Enum) opAndAssign(int mask) { i &= mask; return *this; } | |
511 QFlags!(Enum) opAndAssign(uint mask) { i &= mask; return *this; } | |
512 QFlags!(Enum) opOrAssign(QFlags f) { i |= f.i; return *this; } | |
513 QFlags!(Enum) opOrAssign(Enum f) { i |= f; return *this; } | |
514 QFlags!(Enum) opXorAssign(QFlags f) { i ^= f.i; return *this; } | |
515 QFlags!(Enum) opXorAssign(Enum f) { i ^= f; return *this; } | |
516 | |
517 int toInt() { return i; } | |
518 | |
519 QFlags!(Enum) opOr(QFlags f) { QFlags g; g.i = i | f.i; return g; } | |
520 QFlags!(Enum) opOr(Enum f) { QFlags g; g.i = i | f; return g; } | |
521 QFlags!(Enum) opXor(QFlags f) { QFlags g; g.i = i ^ f.i; return g; } | |
522 QFlags!(Enum) opXor(Enum f) { QFlags g; g.i = i ^ f; return g; } | |
523 QFlags!(Enum) opAnd(int mask) { QFlags g; g.i = i & mask; return g; } | |
524 QFlags!(Enum) opAnd(uint mask) { QFlags g; g.i = i & mask; return g; } | |
525 QFlags!(Enum) opAnd(Enum f) { QFlags g; g.i = i & f; return g; } | |
526 QFlags!(Enum) opCom() { QFlags g; g.i = ~i; return g; } | |
527 | |
528 // bool operator!() { return !i; } | |
529 | |
530 // bool testFlag(Enum f) { return i & f; } | |
531 } | |
532 | |
533 /* TODO typesafety | |
534 #define Q_DECLARE_FLAGS(Flags, Enum)\ | |
535 typedef QFlags<Enum> Flags; | |
536 #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \ | |
537 QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \ | |
538 { return QFlags<Flags::enum_type>(f1) | f2; } \ | |
539 QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \ | |
540 { return f2 | f1; } | |
541 */ | |
542 | |
543 char[] QT_TR_NOOP(char[] x) { return x; } | |
544 char[] QT_TRANSLATE_NOOP(char[] s, char[] x) { return x; } | |
545 char[] QT_TRANSLATE_NOOP3(char[] s, char[] x, char[] comment) { return x; } | |
546 | |
547 //class QByteArray; | |
548 //QByteArray qgetenv(char[] varName); | |
549 //bool qputenv(char[] varName, QByteArray value); | |
550 | |
551 int qIntCast(double f) { return cast(int)(f); } | |
552 int qIntCast(float f) { return cast(int)(f); } | |
553 | |
554 /* | |
555 Reentrant versions of basic rand() functions for random number generation | |
556 */ | |
557 void qsrand(uint seed); | |
558 int qrand(); | |
559 | |
560 | |
561 /* | |
562 This gives us the possibility to check which modules the user can | |
563 use. These are purely compile time checks and will generate no code. | |
564 */ | |
565 | |
566 /* Qt modules */ | |
567 | |
568 const ushort QT_MODULE_CORE = 0x0001; | |
569 const ushort QT_MODULE_GUI = 0x0002; | |
570 const ushort QT_MODULE_NETWORK = 0x0004; | |
571 const ushort QT_MODULE_OPENGL = 0x0008; | |
572 const ushort QT_MODULE_SQL = 0x0010; | |
573 const ushort QT_MODULE_XML = 0x0020; | |
574 const ushort QT_MODULE_QT3SUPPORTLIGHT = 0x0040; | |
575 const ushort QT_MODULE_QT3SUPPORT = 0x0080; | |
576 const ushort QT_MODULE_SVG = 0x0100; | |
577 const ushort QT_MODULE_ACTIVEQT = 0x0200; | |
578 const ushort QT_MODULE_GRAPHICSVIEW = 0x0400; | |
579 const ushort QT_MODULE_SCRIPT = 0x0800; | |
580 const ushort QT_MODULE_XMLPATTERNS = 0x1000; | |
581 const ushort QT_MODULE_HELP = 0x2000; | |
582 const ushort QT_MODULE_TEST = 0x4000; | |
583 const ushort QT_MODULE_DBUS = 0x8000; | |
584 | |
585 /* Qt editions */ | |
586 | |
587 const ushort QT_EDITION_CONSOLE = (QT_MODULE_CORE | |
588 | QT_MODULE_NETWORK | |
589 | QT_MODULE_SQL | |
590 | QT_MODULE_SCRIPT | |
591 | QT_MODULE_XML | |
592 | QT_MODULE_XMLPATTERNS | |
593 | QT_MODULE_TEST | |
594 | QT_MODULE_DBUS); | |
595 const ushort QT_EDITION_DESKTOPLIGHT = (QT_MODULE_CORE | |
596 | QT_MODULE_GUI | |
597 | QT_MODULE_QT3SUPPORTLIGHT | |
598 | QT_MODULE_TEST | |
599 | QT_MODULE_DBUS); | |
600 const ushort QT_EDITION_OPENSOURCE = (QT_MODULE_CORE | |
601 | QT_MODULE_GUI | |
602 | QT_MODULE_NETWORK | |
603 | QT_MODULE_OPENGL | |
604 | QT_MODULE_SQL | |
605 | QT_MODULE_XML | |
606 | QT_MODULE_XMLPATTERNS | |
607 | QT_MODULE_SCRIPT | |
608 | QT_MODULE_QT3SUPPORTLIGHT | |
609 | QT_MODULE_QT3SUPPORT | |
610 | QT_MODULE_SVG | |
611 | QT_MODULE_GRAPHICSVIEW | |
612 | QT_MODULE_HELP | |
613 | QT_MODULE_TEST | |
614 | QT_MODULE_DBUS); | |
615 const ushort QT_EDITION_DESKTOP = (QT_EDITION_OPENSOURCE | |
616 | QT_MODULE_ACTIVEQT); | |
617 const ushort QT_EDITION_UNIVERSAL = QT_EDITION_DESKTOP; | |
618 const ushort QT_EDITION_ACADEMIC = QT_EDITION_DESKTOP; | |
619 const ushort QT_EDITION_EDUCATIONAL = QT_EDITION_DESKTOP; | |
620 const ushort QT_EDITION_EVALUATION = QT_EDITION_DESKTOP; | |
621 | |
622 mixin QT_END_NAMESPACE; | |
183 | 623 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
624 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
625 struct Align |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
626 { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
627 ubyte a; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
628 void* b; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
629 } |
247 | 630 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
631 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
632 const PTR_ALIGN = Align.tupleof[1].alignof; |
247 | 633 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
634 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
635 template AlignPad(size_t base, size_t aligned) |
183 | 636 { |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
637 static if( aligned == 0 ) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
638 const AlignPad = base; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
639 else |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
640 const AlignPad = ((base+PTR_ALIGN-1)/PTR_ALIGN)*PTR_ALIGN |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
641 + aligned; |
183 | 642 } |
247 | 643 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
644 template InstanceSize(T) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
645 { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
646 static if( is( T == Object ) ) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
647 const InstanceSize = 2*(void*).sizeof; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
648 else |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
649 const InstanceSize = Max!( |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
650 AlignPad!( |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
651 InstanceSize!(Super!(T)), |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
652 InterfaceCount!(T)*(void*).sizeof), |
247 | 653 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
654 AlignPad!( |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
655 InstanceSizeImpl!(T, 0), |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
656 + InterfaceCount!(T)*(void*).sizeof)); |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
657 } |
247 | 658 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
659 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
660 template Super(T) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
661 { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
662 static if( is( T S == super ) ) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
663 alias First!(S) Super; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
664 else |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
665 static assert(false, "Can't get super of "~T.mangleof); |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
666 } |
247 | 667 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
668 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
669 template First(T) |
183 | 670 { |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
671 alias T First; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
672 } |
247 | 673 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
674 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
675 template First(T, Ts...) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
676 { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
677 alias T First; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
678 } |
247 | 679 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
680 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
681 template InstanceSizeImpl(T, size_t i) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
682 { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
683 static if( i < T.tupleof.length ) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
684 const InstanceSizeImpl = Max!( |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
685 T.tupleof[i].offsetof + T.tupleof[i].sizeof, |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
686 InstanceSizeImpl!(T, i+1)); |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
687 else |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
688 // This is necessary to account for classes without member |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
689 // variables. |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
690 const InstanceSizeImpl = 2*(void*).sizeof; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
691 } |
247 | 692 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
693 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
694 template Max(size_t a, size_t b) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
695 { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
696 static if( a > b ) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
697 const Max = a; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
698 else |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
699 const Max = b; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
700 } |
247 | 701 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
702 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
703 template InterfaceCount(T) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
704 { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
705 static if( is( T == Object ) ) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
706 const InterfaceCount = 0u; |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
707 else static if( is( T S == super ) ) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
708 const InterfaceCount = InterfaceCountImpl!(S); |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
709 } |
247 | 710 |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
711 private |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
712 template InterfaceCountImpl(TBase, TInterfaces...) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
713 { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
714 const InterfaceCountImpl = TInterfaces.length; |
183 | 715 } |
716 | |
254 | 717 /+ |
183 | 718 scope class StackObject(C) |
719 { | |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
720 byte[InstanceSize!(C)] data; |
183 | 721 bool constructed; |
722 | |
723 C opCall(A...)(A args) | |
724 { | |
725 assert(!constructed); | |
726 | |
727 auto r = new(&data)C(args); | |
728 r.__stackAllocated = true; | |
729 constructed = true; | |
730 | |
731 return r; | |
732 } | |
733 | |
734 ~this() | |
735 { | |
736 if (constructed) | |
737 { | |
738 auto obj = cast(C)&data; | |
739 delete obj; | |
740 } | |
741 } | |
742 } | |
254 | 743 +/ |
183 | 744 |
298
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
292
diff
changeset
|
745 alias void DArray; |
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
292
diff
changeset
|
746 |
1 | 747 mixin QT_END_HEADER; |
183 | 748 |