Mercurial > projects > qtd
annotate qt/core/QTypeInfo.d @ 295:463563fc9e17 signals
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.
author | eldar |
---|---|
date | Sun, 22 Nov 2009 11:01:19 +0000 |
parents | bb37b0ed94c9 |
children | 5173835bb372 |
rev | line source |
---|---|
291 | 1 module qt.core.QTypeInfo; |
2 | |
3 //import qt.QGlobal; | |
4 //import qt.qtd.Atomic; | |
5 | |
6 /* | |
7 The catch-all template. | |
8 */ | |
292 | 9 import std.traits; |
10 | |
11 import qt.qtd.MetaMarshall; | |
291 | 12 |
13 bool qIsDetached(T)(ref T) { return true; } | |
14 | |
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
|
15 template isBasicType(T) |
291 | 16 { |
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
|
17 enum isBasicType = isNumeric!T || is(T == bool); |
291 | 18 } |
19 | |
292 | 20 template QTypeInfo(T) |
291 | 21 { |
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
|
22 static if(isBasicType!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
|
23 { |
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
|
24 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
|
25 { |
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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 } |
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 } |
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 else static if(__traits(compiles, mixin("T.TypeInfo"))) |
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 { |
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 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
|
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 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
|
38 { |
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 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
|
40 { |
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 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 } |
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 } |
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 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
|
49 { |
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 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
|
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 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 } |
291 | 58 } |
59 } | |
60 | |
61 | |
62 /* | |
63 Specialize a specific type with: | |
64 | |
65 Q_DECLARE_TYPEINFO(type, flags); | |
66 | |
67 where 'type' is the name of the type to specialize and 'flags' is | |
68 logically-OR'ed combination of the flags below. | |
69 */ | |
292 | 70 |
71 /* presents in QGlobal | |
72 enum { /* TYPEINFO flags | |
291 | 73 Q_COMPLEX_TYPE = 0, |
74 Q_PRIMITIVE_TYPE = 0x1, | |
75 Q_STATIC_TYPE = 0, | |
76 Q_MOVABLE_TYPE = 0x2, | |
77 Q_DUMMY_TYPE = 0x4 | |
292 | 78 } |
79 */ | |
291 | 80 |
292 | 81 /* |
82 template QTypeInfo(alias FLAGS) | |
83 { | |
84 template QTypeInfo(TYPE) | |
85 { | |
86 public: | |
87 enum { | |
88 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), | |
89 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), | |
90 isLarge = (TYPE.sizeof > (void*).sizeof), | |
91 isPointer = false, | |
92 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0) | |
93 } | |
94 } | |
291 | 95 } |
292 | 96 */ |
291 | 97 /* |
98 Specialize a shared type with: | |
99 | |
100 Q_DECLARE_SHARED(type); | |
101 | |
102 where 'type' is the name of the type to specialize. NOTE: shared | |
103 types must declare a 'bool isDetached(void) const;' member for this | |
104 to work. | |
105 */ | |
292 | 106 /* |
291 | 107 #if defined Q_CC_MSVC && _MSC_VER < 1300 |
108 template <typename T> | |
109 inline void qSwap_helper(T &value1, T &value2, T*) | |
110 { | |
111 T t = value1; | |
112 value1 = value2; | |
113 value2 = t; | |
114 } | |
115 #define Q_DECLARE_SHARED(TYPE) \ | |
116 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ | |
117 template <> inline void qSwap_helper<TYPE>(TYPE &value1, TYPE &value2, TYPE*) \ | |
118 { \ | |
119 const TYPE::DataPtr t = value1.data_ptr(); \ | |
120 value1.data_ptr() = value2.data_ptr(); \ | |
121 value2.data_ptr() = t; \ | |
122 } | |
123 #else | |
124 #define Q_DECLARE_SHARED(TYPE) \ | |
125 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ | |
126 template <typename T> inline void qSwap(T &, T &); \ | |
127 template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ | |
128 { \ | |
129 const TYPE::DataPtr t = value1.data_ptr(); \ | |
130 value1.data_ptr() = value2.data_ptr(); \ | |
131 value2.data_ptr() = t; \ | |
132 } | |
133 #endif | |
292 | 134 */ |