[275] | 1 | Namespace ActiveBasic
|
---|
| 2 | Namespace Core
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | ' 中間的な実装(継承専用)
|
---|
| 6 | Class TypeBaseImpl
|
---|
| 7 | Inherits System.TypeInfo
|
---|
| 8 |
|
---|
| 9 | strNamespace As String
|
---|
| 10 | name As String
|
---|
| 11 |
|
---|
| 12 | Protected
|
---|
| 13 |
|
---|
| 14 | baseType As System.TypeInfo
|
---|
| 15 | 'interfaces As f(^^;;;
|
---|
| 16 |
|
---|
| 17 | Sub TypeBaseImpl()
|
---|
| 18 | strNamespace = ""
|
---|
| 19 | name = ""
|
---|
| 20 | baseType = Nothing
|
---|
| 21 | End Sub
|
---|
| 22 |
|
---|
| 23 | Sub TypeBaseImpl( strNamespace As String, name As String )
|
---|
| 24 | This.strNamespace = strNamespace
|
---|
| 25 | This.name = name
|
---|
| 26 | This.baseType = Nothing
|
---|
| 27 | End Sub
|
---|
| 28 |
|
---|
| 29 | Sub TypeBaseImpl( strNamespace As String, name As String, baseType As System.TypeInfo )
|
---|
| 30 | This.strNamespace = strNamespace
|
---|
| 31 | This.name = name
|
---|
| 32 | This.baseType = baseType
|
---|
| 33 | End Sub
|
---|
| 34 |
|
---|
| 35 | /*
|
---|
| 36 | Sub TypeBaseImpl( strNamespace As String, name As String, baseType As Type, interfaces As ... )
|
---|
| 37 | This.strNamespace = strNamespace
|
---|
| 38 | This.name = name
|
---|
| 39 | This.baseType = baseType
|
---|
| 40 | This.interfaces = interfaces
|
---|
| 41 | End Sub
|
---|
| 42 | */
|
---|
| 43 |
|
---|
| 44 | Sub ~TypeBaseImpl()
|
---|
| 45 | End Sub
|
---|
| 46 |
|
---|
| 47 | Public
|
---|
| 48 |
|
---|
| 49 |
|
---|
| 50 | '----------------------------------------------------------------
|
---|
| 51 | ' Public properties
|
---|
| 52 | '----------------------------------------------------------------
|
---|
| 53 |
|
---|
| 54 | Override Function BaseType() As System.TypeInfo
|
---|
| 55 | Return baseType
|
---|
| 56 | End Function
|
---|
| 57 |
|
---|
| 58 | Sub SetBaseType( baseType As System.TypeInfo )
|
---|
| 59 | This.baseType = baseType
|
---|
| 60 | End Sub
|
---|
| 61 |
|
---|
| 62 | Override Function FullName() As String
|
---|
| 63 | If strNamespace.Length > 0 Then
|
---|
| 64 | Return strNamespace + "." + name
|
---|
| 65 | End If
|
---|
| 66 | Return name
|
---|
| 67 | End Function
|
---|
| 68 |
|
---|
| 69 | Override Function IsArray() As Boolean
|
---|
| 70 | Return False
|
---|
| 71 | End Function
|
---|
| 72 |
|
---|
| 73 | Override Function IsByRef() As Boolean
|
---|
| 74 | Return False
|
---|
| 75 | End Function
|
---|
| 76 |
|
---|
| 77 | Override Function IsClass() As Boolean
|
---|
| 78 | Return False
|
---|
| 79 | End Function
|
---|
| 80 |
|
---|
| 81 | Override Function IsEnum() As Boolean
|
---|
| 82 | Return False
|
---|
| 83 | End Function
|
---|
| 84 |
|
---|
| 85 | Override Function IsInterface() As Boolean
|
---|
| 86 | Return False
|
---|
| 87 | End Function
|
---|
| 88 |
|
---|
| 89 | Override Function IsPointer() As Boolean
|
---|
| 90 | Return False
|
---|
| 91 | End Function
|
---|
| 92 |
|
---|
| 93 | Override Function IsValueType() As Boolean
|
---|
| 94 | Return False
|
---|
| 95 | End Function
|
---|
| 96 |
|
---|
| 97 | Override Function Name() As String
|
---|
| 98 | Return name
|
---|
| 99 | End Function
|
---|
| 100 |
|
---|
| 101 | Override Function Namespace() As String
|
---|
| 102 | Return strNamespace
|
---|
| 103 | End Function
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | '----------------------------------------------------------------
|
---|
| 108 | ' Public methods
|
---|
| 109 | '----------------------------------------------------------------
|
---|
| 110 |
|
---|
| 111 | End Class
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | ' 値型を管理するためのクラス
|
---|
| 115 | Class _System_TypeForValueType
|
---|
| 116 | Inherits TypeBaseImpl
|
---|
| 117 | Public
|
---|
| 118 | Sub _System_TypeForValueType( name As String )
|
---|
| 119 | TypeBaseImpl( "", name )
|
---|
| 120 | End Sub
|
---|
| 121 |
|
---|
| 122 | Override Function IsValueType() As Boolean
|
---|
| 123 | Return True
|
---|
| 124 | End Function
|
---|
| 125 | End Class
|
---|
| 126 |
|
---|
| 127 | ' クラスを管理するためのクラス
|
---|
| 128 | Class _System_TypeForClass
|
---|
| 129 | Inherits TypeBaseImpl
|
---|
| 130 |
|
---|
| 131 | Public
|
---|
| 132 | referenceOffsets As *Long
|
---|
| 133 | numOfReference As Long
|
---|
| 134 |
|
---|
| 135 | Sub _System_TypeForClass( strNamespace As String, name As String, referenceOffsets As *Long, numOfReference As Long )
|
---|
| 136 | TypeBaseImpl( strNamespace, name )
|
---|
| 137 |
|
---|
| 138 | This.referenceOffsets = referenceOffsets
|
---|
| 139 | This.numOfReference = numOfReference
|
---|
| 140 | End Sub
|
---|
| 141 | Sub _System_TypeForClass( strNamespace As String, name As String )
|
---|
| 142 | TypeBaseImpl( strNamespace, name )
|
---|
| 143 | End Sub
|
---|
| 144 | Sub ~_System_TypeForClass()
|
---|
| 145 | End Sub
|
---|
| 146 |
|
---|
| 147 | Override Function IsClass() As Boolean
|
---|
| 148 | Return True
|
---|
| 149 | End Function
|
---|
| 150 | End Class
|
---|
| 151 |
|
---|
| 152 | ' インターフェイスを管理するためのクラス
|
---|
| 153 | Class _System_TypeForInterface
|
---|
| 154 | Inherits TypeBaseImpl
|
---|
| 155 | Public
|
---|
| 156 | End Class
|
---|
| 157 |
|
---|
| 158 | ' 列挙体を管理するためのクラス
|
---|
| 159 | Class _System_TypeForEnum
|
---|
| 160 | Inherits TypeBaseImpl
|
---|
| 161 | Public
|
---|
| 162 | End Class
|
---|
| 163 |
|
---|
| 164 | ' デリゲートを管理するためのクラス
|
---|
| 165 | Class _System_TypeForDelegate
|
---|
| 166 | Inherits TypeBaseImpl
|
---|
| 167 | Public
|
---|
| 168 | End Class
|
---|
| 169 |
|
---|
| 170 |
|
---|
| 171 | '--------------------------------------------------------------------
|
---|
| 172 | ' プロセスに存在するすべての型を管理する
|
---|
| 173 | '--------------------------------------------------------------------
|
---|
| 174 | Class _System_TypeBase
|
---|
| 175 | Static pTypes As *TypeBaseImpl
|
---|
[299] | 176 |
|
---|
[275] | 177 | Static isReady = False
|
---|
| 178 |
|
---|
| 179 | Static Sub Add( typeInfo As TypeBaseImpl )
|
---|
| 180 | pTypes = realloc( pTypes, ( count + 1 ) * SizeOf(*System.TypeInfo) )
|
---|
| 181 | pTypes[count] = typeInfo
|
---|
| 182 | count++
|
---|
| 183 | End Sub
|
---|
| 184 |
|
---|
| 185 | Static Sub InitializeValueType()
|
---|
| 186 | ' 値型の追加
|
---|
| 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" ) )
|
---|
| 198 | End Sub
|
---|
| 199 |
|
---|
| 200 | Static Sub InitializeUserTypes()
|
---|
| 201 | ' このメソッドの実装はコンパイラが自動生成する
|
---|
| 202 |
|
---|
| 203 | '例:
|
---|
| 204 | 'Add( New _System_TypeForClass( "System", "String", [__offsets...], __numOfOffsets ) )
|
---|
| 205 | 'Search( "System","String" ).SetBaseType( Search( "System","Object" ) )
|
---|
| 206 | End Sub
|
---|
| 207 |
|
---|
| 208 | Public
|
---|
[299] | 209 | Static count As Long
|
---|
[275] | 210 | Static Sub Initialize()
|
---|
| 211 | pTypes = GC_malloc( 1 )
|
---|
| 212 | count = 0
|
---|
| 213 |
|
---|
| 214 | ' 値型を初期化
|
---|
| 215 | InitializeValueType()
|
---|
| 216 |
|
---|
| 217 | isReady = True
|
---|
| 218 | ' Class / Interface / Enum / Delegate を初期化
|
---|
| 219 | InitializeUserTypes()
|
---|
| 220 |
|
---|
| 221 | selfTypeInfo = _System_TypeBase.Search( "System", "TypeInfo" ) As System.TypeInfo
|
---|
| 222 |
|
---|
| 223 | _System_DebugOnly_OutputDebugString( Ex"ready dynamic meta datas!\r\n" )
|
---|
| 224 | End Sub
|
---|
| 225 |
|
---|
| 226 | Static Sub _NextPointerForGC()
|
---|
| 227 | ' TODO: 実装
|
---|
| 228 | End Sub
|
---|
| 229 |
|
---|
| 230 | Static Function Search( strNamespace As LPSTR, typeName As LPSTR ) As TypeBaseImpl
|
---|
| 231 | ' TODO: 名前空間に対応する
|
---|
[299] | 232 |
|
---|
[275] | 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
|
---|
| 241 | End Function
|
---|
| 242 |
|
---|
| 243 | Static Function IsReady() As Boolean
|
---|
| 244 | Return isReady
|
---|
| 245 | End Function
|
---|
| 246 |
|
---|
| 247 | Static selfTypeInfo = Nothing As System.TypeInfo
|
---|
| 248 |
|
---|
| 249 | End Class
|
---|
| 250 |
|
---|
| 251 |
|
---|
| 252 | End Namespace
|
---|
| 253 | End Namespace
|
---|
[299] | 254 |
|
---|
| 255 | Function _System_TypeBase_Search( strNamespace As LPSTR, typeName As LPSTR ) As ActiveBasic.Core.TypeBaseImpl
|
---|
| 256 | Return ActiveBasic.Core._System_TypeBase.Search( strNamespace, typeName )
|
---|
| 257 | End Function
|
---|