Mercurial > projects > qtd
annotate d2/qt/core/QTypeInfo.d @ 344:96a75b1e5b26
project structure changes
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Fri, 14 May 2010 12:14:37 +0300 |
parents | qt/core/QTypeInfo.d@adae77fdc1ea |
children | 970332a88b72 |
rev | line source |
---|---|
291 | 1 module qt.core.QTypeInfo; |
2 | |
3 //import qt.QGlobal; | |
344 | 4 //import qtd.Atomic; |
291 | 5 |
6 /* | |
7 The catch-all template. | |
8 */ | |
292 | 9 import std.traits; |
10 | |
344 | 11 import qtd.MetaMarshall; |
296 | 12 import qt.core.QString; |
291 | 13 |
14 bool qIsDetached(T)(ref T) { return true; } | |
15 | |
295
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
16 template isBasicType(T) |
291 | 17 { |
298
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
297
diff
changeset
|
18 enum isBasicType = isNumeric!T || is(T == bool) || is(T == enum); |
291 | 19 } |
20 | |
292 | 21 template QTypeInfo(T) |
291 | 22 { |
296 | 23 static if(is(T == string)) |
24 { | |
25 alias QString.QTypeInfo QTypeInfo; | |
26 } | |
27 else static if(isBasicType!T) | |
295
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
28 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
29 public enum |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
30 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
31 isPointer = false, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
32 isComplex = false, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
33 isStatic = false, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
34 isLarge = (T.sizeof > (void*).sizeof), |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
35 isDummy = false |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
36 } |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
37 } |
297 | 38 else static if(is(T.QTypeInfo)) |
295
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
39 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
40 alias T.QTypeInfo QTypeInfo; // alias member QTypeInfo |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
41 } |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
42 else static if ( isQObjectType!T || isObjectType!T ) |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
43 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
44 public enum // are pointers |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
45 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
46 isPointer = true, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
47 isComplex = false, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
48 isStatic = false, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
49 isLarge = false, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
50 isDummy = false |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
51 } |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
52 } |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
53 else // default parameters |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
54 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
55 public enum |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
56 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
57 isPointer = isPointer!T, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
58 isComplex = !isPointer, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
59 isStatic = !isPointer, |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
60 isLarge = (T.sizeof > (void*).sizeof), |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
61 isDummy = false |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
294
diff
changeset
|
62 } |
291 | 63 } |
64 } | |
65 | |
66 | |
67 /* | |
68 Specialize a specific type with: | |
69 | |
70 Q_DECLARE_TYPEINFO(type, flags); | |
71 | |
72 where 'type' is the name of the type to specialize and 'flags' is | |
73 logically-OR'ed combination of the flags below. | |
74 */ | |
292 | 75 |
76 /* presents in QGlobal | |
77 enum { /* TYPEINFO flags | |
291 | 78 Q_COMPLEX_TYPE = 0, |
79 Q_PRIMITIVE_TYPE = 0x1, | |
80 Q_STATIC_TYPE = 0, | |
81 Q_MOVABLE_TYPE = 0x2, | |
82 Q_DUMMY_TYPE = 0x4 | |
292 | 83 } |
84 */ | |
291 | 85 |
292 | 86 /* |
87 template QTypeInfo(alias FLAGS) | |
88 { | |
89 template QTypeInfo(TYPE) | |
90 { | |
91 public: | |
92 enum { | |
93 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), | |
94 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), | |
95 isLarge = (TYPE.sizeof > (void*).sizeof), | |
96 isPointer = false, | |
97 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0) | |
98 } | |
99 } | |
291 | 100 } |
292 | 101 */ |
291 | 102 /* |
103 Specialize a shared type with: | |
104 | |
105 Q_DECLARE_SHARED(type); | |
106 | |
107 where 'type' is the name of the type to specialize. NOTE: shared | |
108 types must declare a 'bool isDetached(void) const;' member for this | |
109 to work. | |
110 */ | |
292 | 111 /* |
291 | 112 #if defined Q_CC_MSVC && _MSC_VER < 1300 |
113 template <typename T> | |
114 inline void qSwap_helper(T &value1, T &value2, T*) | |
115 { | |
116 T t = value1; | |
117 value1 = value2; | |
118 value2 = t; | |
119 } | |
120 #define Q_DECLARE_SHARED(TYPE) \ | |
121 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ | |
122 template <> inline void qSwap_helper<TYPE>(TYPE &value1, TYPE &value2, TYPE*) \ | |
123 { \ | |
124 const TYPE::DataPtr t = value1.data_ptr(); \ | |
125 value1.data_ptr() = value2.data_ptr(); \ | |
126 value2.data_ptr() = t; \ | |
127 } | |
128 #else | |
129 #define Q_DECLARE_SHARED(TYPE) \ | |
130 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ | |
131 template <typename T> inline void qSwap(T &, T &); \ | |
132 template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ | |
133 { \ | |
134 const TYPE::DataPtr t = value1.data_ptr(); \ | |
135 value1.data_ptr() = value2.data_ptr(); \ | |
136 value2.data_ptr() = t; \ | |
137 } | |
138 #endif | |
344 | 139 */ |