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