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
|
292
|
15 template QTypeInfo(T)
|
291
|
16 {
|
|
17 public:
|
|
18 enum {
|
292
|
19 isPointer = isPointer!T,
|
|
20 isComplex = !isPointer,
|
|
21 isStatic = !isPointer,
|
|
22 isLarge = (T.sizeof > (void*).sizeof),
|
291
|
23 isDummy = false
|
|
24 }
|
|
25 }
|
|
26
|
292
|
27 template QTypeInfo(T)
|
|
28 if ( isQObjectType!T || isObjectType!T )
|
291
|
29 {
|
|
30 public:
|
|
31 enum {
|
|
32 isPointer = true,
|
|
33 isComplex = false,
|
|
34 isStatic = false,
|
|
35 isLarge = false,
|
|
36 isDummy = false
|
|
37 }
|
|
38 }
|
|
39
|
|
40
|
|
41 /*
|
|
42 Specialize a specific type with:
|
|
43
|
|
44 Q_DECLARE_TYPEINFO(type, flags);
|
|
45
|
|
46 where 'type' is the name of the type to specialize and 'flags' is
|
|
47 logically-OR'ed combination of the flags below.
|
|
48 */
|
292
|
49
|
|
50 /* presents in QGlobal
|
|
51 enum { /* TYPEINFO flags
|
291
|
52 Q_COMPLEX_TYPE = 0,
|
|
53 Q_PRIMITIVE_TYPE = 0x1,
|
|
54 Q_STATIC_TYPE = 0,
|
|
55 Q_MOVABLE_TYPE = 0x2,
|
|
56 Q_DUMMY_TYPE = 0x4
|
292
|
57 }
|
|
58 */
|
291
|
59
|
292
|
60 /*
|
|
61 template QTypeInfo(alias FLAGS)
|
|
62 {
|
|
63 template QTypeInfo(TYPE)
|
|
64 {
|
|
65 public:
|
|
66 enum {
|
|
67 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0),
|
|
68 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0),
|
|
69 isLarge = (TYPE.sizeof > (void*).sizeof),
|
|
70 isPointer = false,
|
|
71 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0)
|
|
72 }
|
|
73 }
|
291
|
74 }
|
292
|
75 */
|
291
|
76 /*
|
|
77 Specialize a shared type with:
|
|
78
|
|
79 Q_DECLARE_SHARED(type);
|
|
80
|
|
81 where 'type' is the name of the type to specialize. NOTE: shared
|
|
82 types must declare a 'bool isDetached(void) const;' member for this
|
|
83 to work.
|
|
84 */
|
292
|
85 /*
|
291
|
86 #if defined Q_CC_MSVC && _MSC_VER < 1300
|
|
87 template <typename T>
|
|
88 inline void qSwap_helper(T &value1, T &value2, T*)
|
|
89 {
|
|
90 T t = value1;
|
|
91 value1 = value2;
|
|
92 value2 = t;
|
|
93 }
|
|
94 #define Q_DECLARE_SHARED(TYPE) \
|
|
95 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
|
|
96 template <> inline void qSwap_helper<TYPE>(TYPE &value1, TYPE &value2, TYPE*) \
|
|
97 { \
|
|
98 const TYPE::DataPtr t = value1.data_ptr(); \
|
|
99 value1.data_ptr() = value2.data_ptr(); \
|
|
100 value2.data_ptr() = t; \
|
|
101 }
|
|
102 #else
|
|
103 #define Q_DECLARE_SHARED(TYPE) \
|
|
104 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
|
|
105 template <typename T> inline void qSwap(T &, T &); \
|
|
106 template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
|
|
107 { \
|
|
108 const TYPE::DataPtr t = value1.data_ptr(); \
|
|
109 value1.data_ptr() = value2.data_ptr(); \
|
|
110 value2.data_ptr() = t; \
|
|
111 }
|
|
112 #endif
|
292
|
113 */ |