Changeset 367 for trunk/Include/Classes
- Timestamp:
- Nov 2, 2007, 2:55:38 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/ActiveBasic/Core/TypeInfo.ab
r299 r367 9 9 strNamespace As String 10 10 name As String 11 fullName As String 11 12 12 13 Protected … … 15 16 'interfaces As f(^^;;; 16 17 17 Sub TypeBaseImpl() 18 strNamespace = "" 19 name = "" 20 baseType = Nothing 21 End Sub 22 23 Sub TypeBaseImpl( strNamespace As String, name As String ) 18 Sub TypeBaseImpl( strNamespace As String, name As String, fullName As String ) 24 19 This.strNamespace = strNamespace 25 20 This.name = name 21 This.fullName = fullName 26 22 This.baseType = Nothing 27 23 End Sub 28 29 Sub TypeBaseImpl( strNamespace As String, name As String, baseType As System.TypeInfo )30 This.strNamespace = strNamespace31 This.name = name32 This.baseType = baseType33 End Sub34 35 /*36 Sub TypeBaseImpl( strNamespace As String, name As String, baseType As Type, interfaces As ... )37 This.strNamespace = strNamespace38 This.name = name39 This.baseType = baseType40 This.interfaces = interfaces41 End Sub42 */43 24 44 25 Sub ~TypeBaseImpl() … … 61 42 62 43 Override Function FullName() As String 63 If strNamespace.Length > 0 Then 64 Return strNamespace + "." + name 65 End If 66 Return name 44 Return fullName 67 45 End Function 68 46 … … 117 95 Public 118 96 Sub _System_TypeForValueType( name As String ) 119 TypeBaseImpl( "", name )97 TypeBaseImpl( "", name, name ) 120 98 End Sub 121 99 … … 133 111 numOfReference As Long 134 112 135 Sub _System_TypeForClass( strNamespace As String, name As String, referenceOffsets As *Long, numOfReference As Long )136 TypeBaseImpl( strNamespace, name )113 Sub _System_TypeForClass( strNamespace As String, name As String, fullName As String, referenceOffsets As *Long, numOfReference As Long ) 114 TypeBaseImpl( strNamespace, name, fullName ) 137 115 138 116 This.referenceOffsets = referenceOffsets 139 117 This.numOfReference = numOfReference 140 118 End Sub 141 Sub _System_TypeForClass( strNamespace As String, name As String )142 TypeBaseImpl( strNamespace, name )119 Sub _System_TypeForClass( strNamespace As String, name As String, fullName As String ) 120 TypeBaseImpl( strNamespace, name, fullName ) 143 121 End Sub 144 122 Sub ~_System_TypeForClass() … … 173 151 '-------------------------------------------------------------------- 174 152 Class _System_TypeBase 175 Static pTypes As *TypeBaseImpl153 Static types As System.Collections.Generic.Dictionary<String, TypeBaseImpl> 176 154 177 155 Static isReady = False 178 156 179 157 Static Sub Add( typeInfo As TypeBaseImpl ) 180 pTypes = realloc( pTypes, ( count + 1 ) * SizeOf(*System.TypeInfo) ) 181 pTypes[count] = typeInfo 182 count++ 158 types.Add( typeInfo.FullName, typeInfo ) 183 159 End Sub 184 160 185 161 Static Sub InitializeValueType() 162 types = New System.Collections.Generic.Dictionary<String, TypeBaseImpl>(8192) 163 186 164 ' 値型の追加 187 Add( New _System_TypeForValueType( "Byte" ))188 Add( New _System_TypeForValueType( "SByte" ))189 Add( New _System_TypeForValueType( "Word" ))190 Add( New _System_TypeForValueType( "Integer" ))191 Add( New _System_TypeForValueType( "DWord" ))192 Add( New _System_TypeForValueType( "Long" ))193 Add( New _System_TypeForValueType( "QWord" ))194 Add( New _System_TypeForValueType( "Int64" ))195 Add( New _System_TypeForValueType( "Boolean" ))196 Add( New _System_TypeForValueType( "Single" ))197 Add( New _System_TypeForValueType( "Double" ))165 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Byte", fullName = "Byte" ] ) 166 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "SByte", fullName = "SByte" ] ) 167 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Word", fullName = "Word" ] ) 168 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Integer", fullName = "Integer" ] ) 169 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "DWord", fullName = "DWord" ] ) 170 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Long", fullName = "Long" ] ) 171 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "QWord", fullName = "QWord" ] ) 172 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Int64", fullName = "Int64" ] ) 173 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Boolean", fullName = "Boolean" ] ) 174 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Single", fullName = "Single" ] ) 175 Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Double", fullName = "Double" ] ) 198 176 End Sub 199 177 … … 202 180 203 181 '例: 204 'Add( New _System_TypeForClass( "System", "String", [__offsets...], __numOfOffsets ) ) 205 'Search( "System","String" ).SetBaseType( Search( "System","Object" ) ) 206 End Sub 207 208 Public 209 Static count As Long 182 'Add( New _System_TypeForClass( "System", "String", "System.String", [__offsets...], __numOfOffsets ) ) 183 '... 184 End Sub 185 Static Sub InitializeUserTypesForBaseType() 186 ' このメソッドの実装はコンパイラが自動生成する 187 188 '例: 189 'Search( "System.String" ).SetBaseType( Search( "System.Object" ) ) 190 '... 191 End Sub 192 193 Public 210 194 Static Sub Initialize() 211 pTypes = GC_malloc( 1 )212 count = 0213 214 195 ' 値型を初期化 215 196 InitializeValueType() 216 197 217 isReady = True218 198 ' Class / Interface / Enum / Delegate を初期化 219 199 InitializeUserTypes() 220 200 221 selfTypeInfo = _System_TypeBase.Search( "System", "TypeInfo" ) As System.TypeInfo 201 isReady = True 202 203 ' 基底クラスを登録 204 InitializeUserTypesForBaseType() 205 206 selfTypeInfo = _System_TypeBase.Search( "System.TypeInfo" ) As System.TypeInfo 222 207 223 208 _System_DebugOnly_OutputDebugString( Ex"ready dynamic meta datas!\r\n" ) … … 228 213 End Sub 229 214 230 Static Function Search( strNamespace As LPSTR, typeName As LPSTR ) As TypeBaseImpl 231 ' TODO: 名前空間に対応する 232 233 Dim i As Long 234 For i = 0 To ELM( count ) 235 If pTypes[i].Name = typeName Then 236 Return pTypes[i] 237 End If 238 Next 239 240 Return Nothing 215 Static Function Search( fullName As String ) As TypeBaseImpl 216 If Object.ReferenceEquals(types, Nothing) Then 217 Return Nothing 218 End If 219 220 If isReady = False Then 221 Return Nothing 222 End If 223 224 If Object.ReferenceEquals( types.Item(fullName), Nothing ) Then 225 OutputDebugString( "TypeSearch Failed: " ) 226 OutputDebugString( fullName ) 227 OutputDebugString( Ex"\r\n" ) 228 End If 229 230 Return types.Item(fullName) 241 231 End Function 242 232 … … 245 235 End Function 246 236 247 Static selfTypeInfo = NothingAs System.TypeInfo237 Static selfTypeInfo As System.TypeInfo 248 238 249 239 End Class … … 253 243 End Namespace 254 244 255 Function _System_TypeBase_Search( strNamespace As LPSTR, typeName As LPSTR) As ActiveBasic.Core.TypeBaseImpl256 Return ActiveBasic.Core._System_TypeBase.Search( strNamespace, typeName )245 Function _System_TypeBase_Search( fullName As String ) As ActiveBasic.Core.TypeBaseImpl 246 Return ActiveBasic.Core._System_TypeBase.Search( fullName ) 257 247 End Function
Note:
See TracChangeset
for help on using the changeset viewer.