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