Mercurial > projects > qtd
view qt/core/QTypeInfo.d @ 292:19498f420252 signals
more QList goodness
author | eldar |
---|---|
date | Tue, 10 Nov 2009 19:29:42 +0000 |
parents | 0d2094800bdb |
children | bb37b0ed94c9 |
line wrap: on
line source
module qt.core.QTypeInfo; //import qt.QGlobal; //import qt.qtd.Atomic; /* The catch-all template. */ import std.traits; import qt.qtd.MetaMarshall; bool qIsDetached(T)(ref T) { return true; } template QTypeInfo(T) if ( !(isQObjectType!T || isObjectType!T) ) { public: enum { isPointer = isPointer!T, isComplex = !isPointer, isStatic = !isPointer, isLarge = (T.sizeof > (void*).sizeof), isDummy = false } } template QTypeInfo(T) if ( isQObjectType!T || isObjectType!T ) { public: enum { isPointer = true, isComplex = false, isStatic = false, isLarge = false, isDummy = false } } /* Specialize a specific type with: Q_DECLARE_TYPEINFO(type, flags); where 'type' is the name of the type to specialize and 'flags' is logically-OR'ed combination of the flags below. */ /* presents in QGlobal enum { /* TYPEINFO flags Q_COMPLEX_TYPE = 0, Q_PRIMITIVE_TYPE = 0x1, Q_STATIC_TYPE = 0, Q_MOVABLE_TYPE = 0x2, Q_DUMMY_TYPE = 0x4 } */ /* template QTypeInfo(alias FLAGS) { template QTypeInfo(TYPE) { public: enum { isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isLarge = (TYPE.sizeof > (void*).sizeof), isPointer = false, isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0) } } } */ /* Specialize a shared type with: Q_DECLARE_SHARED(type); where 'type' is the name of the type to specialize. NOTE: shared types must declare a 'bool isDetached(void) const;' member for this to work. */ /* #if defined Q_CC_MSVC && _MSC_VER < 1300 template <typename T> inline void qSwap_helper(T &value1, T &value2, T*) { T t = value1; value1 = value2; value2 = t; } #define Q_DECLARE_SHARED(TYPE) \ template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ template <> inline void qSwap_helper<TYPE>(TYPE &value1, TYPE &value2, TYPE*) \ { \ const TYPE::DataPtr t = value1.data_ptr(); \ value1.data_ptr() = value2.data_ptr(); \ value2.data_ptr() = t; \ } #else #define Q_DECLARE_SHARED(TYPE) \ template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ template <typename T> inline void qSwap(T &, T &); \ template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ { \ const TYPE::DataPtr t = value1.data_ptr(); \ value1.data_ptr() = value2.data_ptr(); \ value2.data_ptr() = t; \ } #endif */