annotate qt/core/QTypeInfo.d @ 296:5173835bb372 signals

iteration over QList with opApply
author eldar
date Sun, 22 Nov 2009 20:43:10 +0000
parents 463563fc9e17
children bc783e20da2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
1 module qt.core.QTypeInfo;
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
2
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
3 //import qt.QGlobal;
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
4 //import qt.qtd.Atomic;
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
5
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
6 /*
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
7 The catch-all template.
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
8 */
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
9 import std.traits;
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
10
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
11 import qt.qtd.MetaMarshall;
296
5173835bb372 iteration over QList with opApply
eldar
parents: 295
diff changeset
12 import qt.core.QString;
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
13
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
14 bool qIsDetached(T)(ref T) { return true; }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
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
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
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
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
19 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
20
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
21 template QTypeInfo(T)
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
22 {
296
5173835bb372 iteration over QList with opApply
eldar
parents: 295
diff changeset
23 static if(is(T == string))
5173835bb372 iteration over QList with opApply
eldar
parents: 295
diff changeset
24 {
5173835bb372 iteration over QList with opApply
eldar
parents: 295
diff changeset
25 alias QString.QTypeInfo QTypeInfo;
5173835bb372 iteration over QList with opApply
eldar
parents: 295
diff changeset
26 }
5173835bb372 iteration over QList with opApply
eldar
parents: 295
diff changeset
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 }
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 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
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
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
63 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
64 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
65
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
66
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
67 /*
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
68 Specialize a specific type with:
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
69
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
70 Q_DECLARE_TYPEINFO(type, flags);
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
71
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
72 where 'type' is the name of the type to specialize and 'flags' is
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
73 logically-OR'ed combination of the flags below.
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
74 */
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
75
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
76 /* presents in QGlobal
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
77 enum { /* TYPEINFO flags
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
78 Q_COMPLEX_TYPE = 0,
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
79 Q_PRIMITIVE_TYPE = 0x1,
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
80 Q_STATIC_TYPE = 0,
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
81 Q_MOVABLE_TYPE = 0x2,
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
82 Q_DUMMY_TYPE = 0x4
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
83 }
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
84 */
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
85
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
86 /*
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
87 template QTypeInfo(alias FLAGS)
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
88 {
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
89 template QTypeInfo(TYPE)
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
90 {
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
91 public:
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
92 enum {
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
93 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0),
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
94 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0),
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
95 isLarge = (TYPE.sizeof > (void*).sizeof),
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
96 isPointer = false,
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
97 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0)
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
98 }
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
99 }
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
100 }
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
101 */
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
102 /*
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
103 Specialize a shared type with:
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
104
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
105 Q_DECLARE_SHARED(type);
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
106
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
107 where 'type' is the name of the type to specialize. NOTE: shared
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
108 types must declare a 'bool isDetached(void) const;' member for this
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
109 to work.
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
110 */
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
111 /*
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
112 #if defined Q_CC_MSVC && _MSC_VER < 1300
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
113 template <typename T>
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
114 inline void qSwap_helper(T &value1, T &value2, T*)
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
115 {
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
116 T t = value1;
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
117 value1 = value2;
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
118 value2 = t;
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
119 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
120 #define Q_DECLARE_SHARED(TYPE) \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
121 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
122 template <> inline void qSwap_helper<TYPE>(TYPE &value1, TYPE &value2, TYPE*) \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
123 { \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
124 const TYPE::DataPtr t = value1.data_ptr(); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
125 value1.data_ptr() = value2.data_ptr(); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
126 value2.data_ptr() = t; \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
127 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
128 #else
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
129 #define Q_DECLARE_SHARED(TYPE) \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
130 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
131 template <typename T> inline void qSwap(T &, T &); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
132 template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
133 { \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
134 const TYPE::DataPtr t = value1.data_ptr(); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
135 value1.data_ptr() = value2.data_ptr(); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
136 value2.data_ptr() = t; \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
137 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
138 #endif
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
139 */