annotate d2/qt/QGlobal.d @ 311:8674fd5f34f4 lifetime

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