00001
00002
00003
00004
00005 #ifndef DOTYPEBASE_HPP
00006 #define DOTYPEBASE_HPP
00007
00008 #include "DoBase.hpp"
00009
00011
00013
00014
00015 #define DOT_PRIMITIVE 0x01 // 1: A primitive type 0: A user type
00016 #define DOT_REF 0x02 // It's a C++ reference
00017 #define DOT_CONST 0x04 // Innermost type is const
00018 #define DOT_ARRAY 0x08 // A sized array (requires trailing size descriptor)
00019 #define DOT_PTR 0x10 // First pointer bit
00020 #define DOT_PTR_MASK 0x70
00021 #define TO_PTR_MASK(n) ((n&7)<<4)
00022 #define TO_PTR_LEVEL(n) ((n>>4)&7)
00023 #define DOT_CONST_PTR 0x80 // Some pointer level have const (requires trailing const descriptor)
00024
00025
00026 #define DOT_HAS_NO_VTABLE 0x100 // 1: Has no VTable, 0: Has VTable
00027 #define DOT_IS_BASE_STRUCT 0x200 // 1 It is a base struct/class item
00028
00029
00030 #define DOT_IS_PRIMITIVE(t) (((t)&DOT_PRIMITIVE)!=0)
00031 #define DOT_IS_USERTYPE(t) (((t)&DOT_PRIMITIVE)==0)
00032 #define DOT_HAS_VTABLE(t) ( !((t)&DOT_HAS_NO_VTABLE) && (DOT_IS_USERTYPE(t) || ((t)&DOT_TYPE_MASK)==DOT_STRUCT) )
00033 #define DOT_IS_BASE(t) ( ((t)&DOT_IS_BASE_STRUCT) && (DOT_IS_USERTYPE(t) || ((t)&DOT_TYPE_MASK)==DOT_STRUCT) )
00034
00035
00036 #define DOT_COMMON_MASK 0xFFF // Bits shared by both common and user-types
00037 #define DOT_USERTYPE_MASK 0xFFFFF000 // All user-type bits
00038 #define DOT_BASETYPE_MASK (DOT_USERTYPE_MASK|DOT_PRIMITIVE)
00039
00040
00041 #define DOT_TYPE_MASK 0xF000
00042 #define DOT_VOID 0x0000
00043 #define DOT_BOOL 0x1000
00044 #define DOT_CHAR 0x2000
00045 #define DOT_SINT 0x3000 // Signed integer
00046 #define DOT_UINT 0x4000 // Unsigned integer
00047 #define DOT_UNSIGNED 0x1000 // Difference between signed & unsigned
00048 #define DOT_FLOAT 0x5000
00049 #define DOT_PADDING 0x6000 // Padding inside structures
00050 #define DOT_OPAQUE 0x7000 // Opaque type
00051 #define DOT_FUNC 0x8000 // Function
00052 #define DOT_STRUCT 0x9000 // struct
00053 #define DOT_ENUM 0xA000 // enums
00054 #define DOT_ACCESS_SPEC 0xB000 // protected/public/private/...
00055 #define DOT_TEMPLATE_ARG 0xF000 // Template arg, not yet determined
00056
00057
00058 #define DOT_SIZE_MASK 0x0700 // Size qualifier for base type (if appliciable)
00059 #define DOT_SIZE_POS 8 // (char/int/uint/float types)
00060 #define DOT_SIZE_1 0x0000
00061 #define DOT_SIZE_2 0x0100
00062 #define DOT_SIZE_4 0x0200
00063 #define DOT_SIZE_8 0x0300
00064 #define DOT_SIZE_16 0x0400
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 #define DOT_PTR_REF_LEVEL(t) (((t&DOT_PTR_MASK)+((t&DOT_REF)?DOT_PTR:0))>>3)
00093
00094 template<int N>
00095 struct DoLog2{ enum { v=1+DoLog2<N/2>::v }; };
00096
00097 template<>
00098 struct DoLog2<0>{ enum { v=-1 }; };
00099
00100
00101 template<class T>
00102 struct DoType2Int {
00103
00104 enum { v = IsVObj<T>::v ? 0 : DOT_HAS_NO_VTABLE };
00105 };
00106
00107 template<class T>
00108 struct DoType2Int<const T> {
00109 enum { v=DOT_CONST|DoType2Int<T>::v };
00110 };
00111
00112 template<class T>
00113 struct DoType2Int<T&> {
00114 enum { v=DOT_REF|DoType2Int<T>::v };
00115 };
00116
00117 template<class T>
00118 struct DoType2Int<T*> {
00119 enum { v=DOT_PTR+DoType2Int<T>::v };
00120 };
00121
00122 template<> struct DoType2Int<void> { enum { v=DOT_VOID|DOT_PRIMITIVE }; };
00123 template<> struct DoType2Int<bool> { enum { v=DOT_BOOL|DOT_PRIMITIVE }; };
00124
00125 template<> struct DoType2Int<char> { enum { v=DOT_CHAR|DOT_PRIMITIVE }; };
00126 template<> struct DoType2Int<wchar_t> { enum { v=DOT_CHAR|(DoLog2<sizeof(wchar_t)>::v<<DOT_SIZE_POS)|DOT_PRIMITIVE }; };
00127
00128 template<> struct DoType2Int<short> { enum { v=DOT_SINT|DOT_SIZE_2|DOT_PRIMITIVE }; };
00129 template<> struct DoType2Int<int> { enum { v=DOT_SINT|(DoLog2<sizeof(int)>::v<<DOT_SIZE_POS)|DOT_PRIMITIVE }; };
00130 template<> struct DoType2Int<long> { enum { v=DOT_SINT|(DoLog2<sizeof(long)>::v<<DOT_SIZE_POS)|DOT_PRIMITIVE }; };
00131 template<> struct DoType2Int<long long> { enum { v=DOT_SINT|(DoLog2<sizeof(long long)>::v<<DOT_SIZE_POS)|DOT_PRIMITIVE }; };
00132
00133 template<> struct DoType2Int<unsigned short> { enum { v=DOT_UINT|DOT_SIZE_2|DOT_PRIMITIVE }; };
00134 template<> struct DoType2Int<unsigned int> { enum { v=DOT_UINT|(DoLog2<sizeof(int)>::v<<DOT_SIZE_POS)|DOT_PRIMITIVE }; };
00135 template<> struct DoType2Int<unsigned long> { enum { v=DOT_UINT|(DoLog2<sizeof(long)>::v<<DOT_SIZE_POS)|DOT_PRIMITIVE }; };
00136 template<> struct DoType2Int<unsigned long long> { enum { v=DOT_UINT|(DoLog2<sizeof(long long)>::v<<DOT_SIZE_POS)|DOT_PRIMITIVE }; };
00137
00138 template<> struct DoType2Int<float> { enum { v=DOT_FLOAT|DOT_SIZE_4 }; };
00139 template<> struct DoType2Int<double> { enum { v=DOT_FLOAT|DOT_SIZE_8 }; };
00140
00142
00143
00150 template<class T>
00151 struct DoFullType2Int {
00153 static int Id(){
00154
00155 return DoType2Int<T>::v | doTypeInfo<T>::Id();
00156 }
00157 };
00158
00159 #endif // DO_TYPEBASE_HPP
00160