Mercurial > projects > qtd
annotate qt/core/QTypeInfo.d @ 297:bc783e20da2b signals
share strange dmd
author | eldar |
---|---|
date | Sun, 22 Nov 2009 22:18:06 +0000 |
parents | 5173835bb372 |
children | adae77fdc1ea |
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; | |
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 { |
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
|
18 enum isBasicType = isNumeric!T || is(T == bool); |
291 | 19 } |
20 | |
292 | 21 template QTypeInfo(T) |
291 | 22 { |
297 | 23 static if(T.stringof == "QModelIndex") |
24 { | |
25 pragma(msg, T.stringof ~ " has QTypeInfo"); | |
26 pragma(msg, T.QTypeInfo.stringof); | |
27 } | |
28 | |
296 | 29 static if(is(T == string)) |
30 { | |
31 alias QString.QTypeInfo QTypeInfo; | |
32 } | |
33 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
|
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 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
|
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 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 } |
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 } |
297 | 44 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
|
45 { |
297 | 46 pragma(msg, T.stringof ~ " has struct"); |
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
|
47 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
|
48 } |
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 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
|
50 { |
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 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
|
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 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 } |
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 } |
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 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
|
61 { |
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 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
|
63 { |
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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 } |
291 | 70 } |
71 } | |
72 | |
73 | |
74 /* | |
75 Specialize a specific type with: | |
76 | |
77 Q_DECLARE_TYPEINFO(type, flags); | |
78 | |
79 where 'type' is the name of the type to specialize and 'flags' is | |
80 logically-OR'ed combination of the flags below. | |
81 */ | |
292 | 82 |
83 /* presents in QGlobal | |
84 enum { /* TYPEINFO flags | |
291 | 85 Q_COMPLEX_TYPE = 0, |
86 Q_PRIMITIVE_TYPE = 0x1, | |
87 Q_STATIC_TYPE = 0, | |
88 Q_MOVABLE_TYPE = 0x2, | |
89 Q_DUMMY_TYPE = 0x4 | |
292 | 90 } |
91 */ | |
291 | 92 |
292 | 93 /* |
94 template QTypeInfo(alias FLAGS) | |
95 { | |
96 template QTypeInfo(TYPE) | |
97 { | |
98 public: | |
99 enum { | |
100 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), | |
101 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), | |
102 isLarge = (TYPE.sizeof > (void*).sizeof), | |
103 isPointer = false, | |
104 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0) | |
105 } | |
106 } | |
291 | 107 } |
292 | 108 */ |
291 | 109 /* |
110 Specialize a shared type with: | |
111 | |
112 Q_DECLARE_SHARED(type); | |
113 | |
114 where 'type' is the name of the type to specialize. NOTE: shared | |
115 types must declare a 'bool isDetached(void) const;' member for this | |
116 to work. | |
117 */ | |
292 | 118 /* |
291 | 119 #if defined Q_CC_MSVC && _MSC_VER < 1300 |
120 template <typename T> | |
121 inline void qSwap_helper(T &value1, T &value2, T*) | |
122 { | |
123 T t = value1; | |
124 value1 = value2; | |
125 value2 = t; | |
126 } | |
127 #define Q_DECLARE_SHARED(TYPE) \ | |
128 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ | |
129 template <> inline void qSwap_helper<TYPE>(TYPE &value1, TYPE &value2, TYPE*) \ | |
130 { \ | |
131 const TYPE::DataPtr t = value1.data_ptr(); \ | |
132 value1.data_ptr() = value2.data_ptr(); \ | |
133 value2.data_ptr() = t; \ | |
134 } | |
135 #else | |
136 #define Q_DECLARE_SHARED(TYPE) \ | |
137 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ | |
138 template <typename T> inline void qSwap(T &, T &); \ | |
139 template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ | |
140 { \ | |
141 const TYPE::DataPtr t = value1.data_ptr(); \ | |
142 value1.data_ptr() = value2.data_ptr(); \ | |
143 value2.data_ptr() = t; \ | |
144 } | |
145 #endif | |
292 | 146 */ |