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
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;
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
12
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
13 bool qIsDetached(T)(ref T) { return true; }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
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
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
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
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
18 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
19
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
20 template QTypeInfo(T)
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
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
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
58 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
59 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
60
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
61
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
62 /*
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
63 Specialize a specific type with:
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
64
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
65 Q_DECLARE_TYPEINFO(type, flags);
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
66
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
67 where 'type' is the name of the type to specialize and 'flags' is
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
68 logically-OR'ed combination of the flags below.
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
69 */
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
70
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
71 /* presents in QGlobal
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
72 enum { /* TYPEINFO flags
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
73 Q_COMPLEX_TYPE = 0,
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
74 Q_PRIMITIVE_TYPE = 0x1,
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
75 Q_STATIC_TYPE = 0,
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
76 Q_MOVABLE_TYPE = 0x2,
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
77 Q_DUMMY_TYPE = 0x4
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
78 }
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
79 */
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
80
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
81 /*
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
82 template QTypeInfo(alias FLAGS)
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
83 {
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
84 template QTypeInfo(TYPE)
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
85 {
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
86 public:
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
87 enum {
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
88 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0),
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
89 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0),
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
90 isLarge = (TYPE.sizeof > (void*).sizeof),
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
91 isPointer = false,
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
92 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0)
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
93 }
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
94 }
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
95 }
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
96 */
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
97 /*
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
98 Specialize a shared type with:
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
99
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
100 Q_DECLARE_SHARED(type);
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
101
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
102 where 'type' is the name of the type to specialize. NOTE: shared
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
103 types must declare a 'bool isDetached(void) const;' member for this
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
104 to work.
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
105 */
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
106 /*
291
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
107 #if defined Q_CC_MSVC && _MSC_VER < 1300
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
108 template <typename T>
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
109 inline void qSwap_helper(T &value1, T &value2, T*)
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
110 {
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
111 T t = value1;
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
112 value1 = value2;
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
113 value2 = t;
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
114 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
115 #define Q_DECLARE_SHARED(TYPE) \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
116 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
117 template <> inline void qSwap_helper<TYPE>(TYPE &value1, TYPE &value2, TYPE*) \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
118 { \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
119 const TYPE::DataPtr t = value1.data_ptr(); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
120 value1.data_ptr() = value2.data_ptr(); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
121 value2.data_ptr() = t; \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
122 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
123 #else
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
124 #define Q_DECLARE_SHARED(TYPE) \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
125 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
126 template <typename T> inline void qSwap(T &, T &); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
127 template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
128 { \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
129 const TYPE::DataPtr t = value1.data_ptr(); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
130 value1.data_ptr() = value2.data_ptr(); \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
131 value2.data_ptr() = t; \
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
132 }
0d2094800bdb QList native implementation
eldar
parents:
diff changeset
133 #endif
292
19498f420252 more QList goodness
eldar
parents: 291
diff changeset
134 */