[75] | 1 | #pragma once
|
---|
[71] | 2 |
|
---|
[75] | 3 | class CClass;
|
---|
[71] | 4 |
|
---|
| 5 | class Type{
|
---|
| 6 | int basicType;
|
---|
| 7 | union{
|
---|
| 8 | LONG_PTR index;
|
---|
[114] | 9 | const CClass *pClass;
|
---|
[71] | 10 | };
|
---|
| 11 |
|
---|
| 12 | public:
|
---|
[75] | 13 | static int GetBasicSize( int basicType );
|
---|
[73] | 14 |
|
---|
| 15 | Type():
|
---|
| 16 | basicType( DEF_NON ),
|
---|
| 17 | index( -1 ){}
|
---|
[71] | 18 | Type( int basicType ):
|
---|
| 19 | basicType( basicType ),
|
---|
| 20 | index( -1 ){}
|
---|
| 21 |
|
---|
| 22 | Type( int basicType, LONG_PTR index ):
|
---|
| 23 | basicType( basicType ),
|
---|
| 24 | index( index ){}
|
---|
| 25 |
|
---|
[75] | 26 | Type( int basicType, const CClass &objClass ):
|
---|
[71] | 27 | basicType( basicType ),
|
---|
| 28 | index( (LONG_PTR)&objClass ){}
|
---|
| 29 |
|
---|
| 30 | Type( const Type &type ):
|
---|
| 31 | basicType( type.basicType ),
|
---|
| 32 | index( type.index ){}
|
---|
| 33 |
|
---|
[75] | 34 | __inline int GetBasicType() const
|
---|
[71] | 35 | {
|
---|
| 36 | return basicType;
|
---|
| 37 | }
|
---|
| 38 | LONG_PTR GetIndex() const
|
---|
| 39 | {
|
---|
| 40 | return index;
|
---|
| 41 | }
|
---|
| 42 | const CClass &GetClass() const
|
---|
| 43 | {
|
---|
| 44 | return *pClass;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
[73] | 47 | void SetBasicType( int basicType ){
|
---|
| 48 | this->basicType = basicType;
|
---|
[71] | 49 | }
|
---|
[73] | 50 | void SetIndex( LONG_PTR index ){
|
---|
| 51 | this->index = index;
|
---|
[71] | 52 | }
|
---|
[73] | 53 | void SetNull(){
|
---|
| 54 | SetBasicType( DEF_NON );
|
---|
[75] | 55 | SetIndex( -1 );
|
---|
[73] | 56 | }
|
---|
| 57 | void SetType( int basicType, LONG_PTR index ){
|
---|
| 58 | SetBasicType( basicType );
|
---|
| 59 | SetIndex( index );
|
---|
| 60 | }
|
---|
[114] | 61 | void SetType( int basicType, const CClass *pClass ){
|
---|
[73] | 62 | SetBasicType( basicType );
|
---|
| 63 | this->pClass = pClass;
|
---|
| 64 | }
|
---|
[71] | 65 |
|
---|
[75] | 66 | int PtrLevel() const
|
---|
| 67 | {
|
---|
| 68 | return PTR_LEVEL( basicType );
|
---|
| 69 | }
|
---|
[73] | 70 | void PtrLevelUp(){
|
---|
| 71 | PTR_LEVEL_UP( basicType );
|
---|
[71] | 72 | }
|
---|
[75] | 73 | void PtrLevelDown(){
|
---|
| 74 | PTR_LEVEL_DOWN( basicType );
|
---|
| 75 | }
|
---|
[71] | 76 |
|
---|
[73] | 77 | bool Equals( const Type &type ) const;
|
---|
[71] | 78 |
|
---|
[75] | 79 | int GetBasicSize() const;
|
---|
| 80 | int GetSize() const;
|
---|
| 81 |
|
---|
[73] | 82 | bool IsNull() const;
|
---|
[75] | 83 |
|
---|
| 84 | bool IsByte() const;
|
---|
| 85 | bool IsSByte() const;
|
---|
| 86 | bool IsWord() const;
|
---|
| 87 | bool IsInteger() const;
|
---|
| 88 | bool IsDWord() const;
|
---|
| 89 | bool IsLong() const;
|
---|
| 90 | bool IsQWord() const;
|
---|
| 91 | bool IsInt64() const;
|
---|
| 92 | bool IsSingle() const;
|
---|
| 93 | bool IsDouble() const;
|
---|
| 94 | bool IsBoolean() const;
|
---|
| 95 |
|
---|
[73] | 96 | bool IsPointer() const;
|
---|
| 97 | bool IsSigned() const;
|
---|
| 98 | bool IsNaturalWhole() const;
|
---|
| 99 | bool IsWhole() const;
|
---|
| 100 | bool IsReal() const;
|
---|
| 101 | bool Is64() const;
|
---|
| 102 | bool IsProcPtr() const;
|
---|
| 103 | bool IsStruct() const;
|
---|
[75] | 104 | bool IsStructPtr() const;
|
---|
| 105 | bool IsObject() const;
|
---|
| 106 | bool IsObjectPtr() const;
|
---|
[97] | 107 | bool IsObjectClass() const;
|
---|
| 108 | bool IsStringClass() const;
|
---|
[75] | 109 | bool IsVoidPtr() const;
|
---|
| 110 | bool IsAny() const;
|
---|
[71] | 111 |
|
---|
[97] | 112 | // オブジェクトや構造体など、メンバを持つ型かどうかを判別する
|
---|
| 113 | bool HasMember() const;
|
---|
| 114 |
|
---|
[75] | 115 | const string ToString() const;
|
---|
| 116 |
|
---|
| 117 | void operator= ( const Type &type ){
|
---|
| 118 | basicType = type.basicType;
|
---|
| 119 | index = type.index;
|
---|
| 120 | }
|
---|
[77] | 121 |
|
---|
| 122 | static Type String();
|
---|
[79] | 123 |
|
---|
| 124 |
|
---|
| 125 | private:
|
---|
| 126 | static const int basicTypeList[];
|
---|
| 127 | static const string basicTypeNameList[];
|
---|
| 128 | public:
|
---|
| 129 | static bool StringToBasicType( const string &typeName, int &basicType );
|
---|
| 130 | static bool StringToType( const string &typeName, Type &type );
|
---|
[71] | 131 | };
|
---|
[128] | 132 |
|
---|
| 133 | class BlittableType
|
---|
| 134 | {
|
---|
| 135 | Type basicType;
|
---|
| 136 | CClass *pClass;
|
---|
| 137 | public:
|
---|
| 138 | BlittableType( const Type &basicType, CClass *pClass )
|
---|
| 139 | : basicType( basicType )
|
---|
| 140 | , pClass( pClass )
|
---|
| 141 | {
|
---|
| 142 | }
|
---|
| 143 | BlittableType(){}
|
---|
| 144 | const Type &GetBasicType() const
|
---|
| 145 | {
|
---|
| 146 | return basicType;
|
---|
| 147 | }
|
---|
| 148 | const CClass *GetClassPtr() const
|
---|
| 149 | {
|
---|
| 150 | return pClass;
|
---|
| 151 | }
|
---|
| 152 | const string GetCreateStaticMethodFullName() const;
|
---|
| 153 | };
|
---|
| 154 | class BlittableTypes : public vector<BlittableType>
|
---|
| 155 | {
|
---|
| 156 | public:
|
---|
| 157 | bool IsExist( Type type ) const
|
---|
| 158 | {
|
---|
| 159 | const BlittableTypes &blittableTypes = *this;
|
---|
| 160 | BOOST_FOREACH( const BlittableType &blittableType, blittableTypes ){
|
---|
| 161 | if( blittableType.GetBasicType().Equals( type ) ){
|
---|
| 162 | return true;
|
---|
| 163 | }
|
---|
| 164 | }
|
---|
| 165 | return false;
|
---|
| 166 | }
|
---|
| 167 | const BlittableType &Find( const Type &type ) const
|
---|
| 168 | {
|
---|
| 169 | const BlittableTypes &blittableTypes = *this;
|
---|
| 170 | BOOST_FOREACH( const BlittableType &blittableType, blittableTypes ){
|
---|
| 171 | if( blittableType.GetBasicType().Equals( type ) ){
|
---|
| 172 | return blittableType;
|
---|
| 173 | }
|
---|
| 174 | }
|
---|
| 175 | throw "Blittable型ではない";
|
---|
| 176 | }
|
---|
| 177 | const CClass *GetClassPtr( const Type &type ) const
|
---|
| 178 | {
|
---|
| 179 | const BlittableTypes &blittableTypes = *this;
|
---|
| 180 | BOOST_FOREACH( const BlittableType &blittableType, blittableTypes ){
|
---|
| 181 | if( blittableType.GetBasicType().Equals( type ) ){
|
---|
| 182 | return blittableType.GetClassPtr();
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
| 185 | return NULL;
|
---|
| 186 | }
|
---|
| 187 | const CClass &GetClass( const Type &type ) const
|
---|
| 188 | {
|
---|
| 189 | return *GetClassPtr( type );
|
---|
| 190 | }
|
---|
| 191 | };
|
---|