[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
|
---|
[367] | 11 | fullName As String
|
---|
[275] | 12 |
|
---|
[401] | 13 | ' メンバ情報
|
---|
| 14 | memberNames As **Char ' 名前リスト
|
---|
| 15 | memberTypeFullNames As **Char ' 型名リスト
|
---|
| 16 | memberCounts As Long ' 個数
|
---|
| 17 |
|
---|
[275] | 18 | Protected
|
---|
| 19 |
|
---|
| 20 | baseType As System.TypeInfo
|
---|
| 21 | 'interfaces As f(^^;;;
|
---|
| 22 |
|
---|
[367] | 23 | Sub TypeBaseImpl( strNamespace As String, name As String, fullName As String )
|
---|
[275] | 24 | This.strNamespace = strNamespace
|
---|
| 25 | This.name = name
|
---|
[367] | 26 | This.fullName = fullName
|
---|
[275] | 27 | This.baseType = Nothing
|
---|
| 28 | End Sub
|
---|
| 29 |
|
---|
| 30 | Sub ~TypeBaseImpl()
|
---|
| 31 | End Sub
|
---|
| 32 |
|
---|
| 33 | Public
|
---|
| 34 |
|
---|
[401] | 35 | Sub SetMemberTypes( memberNames As **Char, memberTypeFullNames As **Char, num As Long )
|
---|
| 36 | This.memberNames = memberNames
|
---|
| 37 | This.memberTypeFullNames = memberTypeFullNames
|
---|
| 38 | This.memberCounts = num
|
---|
| 39 | End Sub
|
---|
[275] | 40 |
|
---|
[401] | 41 |
|
---|
[275] | 42 | '----------------------------------------------------------------
|
---|
| 43 | ' Public properties
|
---|
| 44 | '----------------------------------------------------------------
|
---|
| 45 |
|
---|
| 46 | Override Function BaseType() As System.TypeInfo
|
---|
| 47 | Return baseType
|
---|
| 48 | End Function
|
---|
| 49 |
|
---|
| 50 | Sub SetBaseType( baseType As System.TypeInfo )
|
---|
| 51 | This.baseType = baseType
|
---|
| 52 | End Sub
|
---|
| 53 |
|
---|
| 54 | Override Function FullName() As String
|
---|
[367] | 55 | Return fullName
|
---|
[275] | 56 | End Function
|
---|
| 57 |
|
---|
| 58 | Override Function IsArray() As Boolean
|
---|
| 59 | Return False
|
---|
| 60 | End Function
|
---|
| 61 |
|
---|
| 62 | Override Function IsByRef() As Boolean
|
---|
| 63 | Return False
|
---|
| 64 | End Function
|
---|
| 65 |
|
---|
| 66 | Override Function IsClass() As Boolean
|
---|
| 67 | Return False
|
---|
| 68 | End Function
|
---|
| 69 |
|
---|
| 70 | Override Function IsEnum() As Boolean
|
---|
| 71 | Return False
|
---|
| 72 | End Function
|
---|
| 73 |
|
---|
| 74 | Override Function IsInterface() As Boolean
|
---|
| 75 | Return False
|
---|
| 76 | End Function
|
---|
| 77 |
|
---|
| 78 | Override Function IsPointer() As Boolean
|
---|
| 79 | Return False
|
---|
| 80 | End Function
|
---|
| 81 |
|
---|
| 82 | Override Function IsValueType() As Boolean
|
---|
| 83 | Return False
|
---|
| 84 | End Function
|
---|
| 85 |
|
---|
| 86 | Override Function Name() As String
|
---|
| 87 | Return name
|
---|
| 88 | End Function
|
---|
| 89 |
|
---|
| 90 | Override Function Namespace() As String
|
---|
| 91 | Return strNamespace
|
---|
| 92 | End Function
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | '----------------------------------------------------------------
|
---|
| 97 | ' Public methods
|
---|
| 98 | '----------------------------------------------------------------
|
---|
| 99 |
|
---|
| 100 | End Class
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 | ' 値型を管理するためのクラス
|
---|
| 104 | Class _System_TypeForValueType
|
---|
| 105 | Inherits TypeBaseImpl
|
---|
| 106 | Public
|
---|
| 107 | Sub _System_TypeForValueType( name As String )
|
---|
[367] | 108 | TypeBaseImpl( "", name, name )
|
---|
[275] | 109 | End Sub
|
---|
| 110 |
|
---|
| 111 | Override Function IsValueType() As Boolean
|
---|
| 112 | Return True
|
---|
| 113 | End Function
|
---|
| 114 | End Class
|
---|
| 115 |
|
---|
| 116 | ' クラスを管理するためのクラス
|
---|
| 117 | Class _System_TypeForClass
|
---|
| 118 | Inherits TypeBaseImpl
|
---|
| 119 |
|
---|
| 120 | Public
|
---|
| 121 | referenceOffsets As *Long
|
---|
| 122 | numOfReference As Long
|
---|
| 123 |
|
---|
[367] | 124 | Sub _System_TypeForClass( strNamespace As String, name As String, fullName As String, referenceOffsets As *Long, numOfReference As Long )
|
---|
| 125 | TypeBaseImpl( strNamespace, name, fullName )
|
---|
[275] | 126 |
|
---|
| 127 | This.referenceOffsets = referenceOffsets
|
---|
| 128 | This.numOfReference = numOfReference
|
---|
| 129 | End Sub
|
---|
[367] | 130 | Sub _System_TypeForClass( strNamespace As String, name As String, fullName As String )
|
---|
| 131 | TypeBaseImpl( strNamespace, name, fullName )
|
---|
[275] | 132 | End Sub
|
---|
| 133 | Sub ~_System_TypeForClass()
|
---|
| 134 | End Sub
|
---|
| 135 |
|
---|
| 136 | Override Function IsClass() As Boolean
|
---|
| 137 | Return True
|
---|
| 138 | End Function
|
---|
| 139 | End Class
|
---|
| 140 |
|
---|
| 141 | ' インターフェイスを管理するためのクラス
|
---|
| 142 | Class _System_TypeForInterface
|
---|
| 143 | Inherits TypeBaseImpl
|
---|
| 144 | Public
|
---|
| 145 | End Class
|
---|
| 146 |
|
---|
| 147 | ' 列挙体を管理するためのクラス
|
---|
| 148 | Class _System_TypeForEnum
|
---|
| 149 | Inherits TypeBaseImpl
|
---|
| 150 | Public
|
---|
| 151 | End Class
|
---|
| 152 |
|
---|
| 153 | ' デリゲートを管理するためのクラス
|
---|
| 154 | Class _System_TypeForDelegate
|
---|
| 155 | Inherits TypeBaseImpl
|
---|
| 156 | Public
|
---|
| 157 | End Class
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 | '--------------------------------------------------------------------
|
---|
| 161 | ' プロセスに存在するすべての型を管理する
|
---|
| 162 | '--------------------------------------------------------------------
|
---|
| 163 | Class _System_TypeBase
|
---|
[367] | 164 | Static types As System.Collections.Generic.Dictionary<String, TypeBaseImpl>
|
---|
[299] | 165 |
|
---|
[275] | 166 | Static isReady = False
|
---|
| 167 |
|
---|
| 168 | Static Sub Add( typeInfo As TypeBaseImpl )
|
---|
[367] | 169 | types.Add( typeInfo.FullName, typeInfo )
|
---|
[275] | 170 | End Sub
|
---|
| 171 |
|
---|
| 172 | Static Sub InitializeValueType()
|
---|
[400] | 173 | types = New System.Collections.Generic.Dictionary<String, TypeBaseImpl>(8191)
|
---|
[367] | 174 |
|
---|
[275] | 175 | ' 値型の追加
|
---|
[367] | 176 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Byte", fullName = "Byte" ] )
|
---|
| 177 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "SByte", fullName = "SByte" ] )
|
---|
| 178 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Word", fullName = "Word" ] )
|
---|
| 179 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Integer", fullName = "Integer" ] )
|
---|
| 180 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "DWord", fullName = "DWord" ] )
|
---|
| 181 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Long", fullName = "Long" ] )
|
---|
| 182 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "QWord", fullName = "QWord" ] )
|
---|
| 183 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Int64", fullName = "Int64" ] )
|
---|
| 184 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Boolean", fullName = "Boolean" ] )
|
---|
| 185 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Single", fullName = "Single" ] )
|
---|
| 186 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Double", fullName = "Double" ] )
|
---|
[275] | 187 | End Sub
|
---|
| 188 |
|
---|
| 189 | Static Sub InitializeUserTypes()
|
---|
| 190 | ' このメソッドの実装はコンパイラが自動生成する
|
---|
| 191 |
|
---|
| 192 | '例:
|
---|
[367] | 193 | 'Add( New _System_TypeForClass( "System", "String", "System.String", [__offsets...], __numOfOffsets ) )
|
---|
| 194 | '...
|
---|
[275] | 195 | End Sub
|
---|
[367] | 196 | Static Sub InitializeUserTypesForBaseType()
|
---|
| 197 | ' このメソッドの実装はコンパイラが自動生成する
|
---|
[275] | 198 |
|
---|
[367] | 199 | '例:
|
---|
| 200 | 'Search( "System.String" ).SetBaseType( Search( "System.Object" ) )
|
---|
| 201 | '...
|
---|
| 202 | End Sub
|
---|
| 203 |
|
---|
[275] | 204 | Public
|
---|
| 205 | Static Sub Initialize()
|
---|
| 206 | ' 値型を初期化
|
---|
| 207 | InitializeValueType()
|
---|
| 208 |
|
---|
| 209 | ' Class / Interface / Enum / Delegate を初期化
|
---|
| 210 | InitializeUserTypes()
|
---|
| 211 |
|
---|
[367] | 212 | isReady = True
|
---|
[275] | 213 |
|
---|
[367] | 214 | ' 基底クラスを登録
|
---|
| 215 | InitializeUserTypesForBaseType()
|
---|
| 216 |
|
---|
| 217 | selfTypeInfo = _System_TypeBase.Search( "System.TypeInfo" ) As System.TypeInfo
|
---|
| 218 |
|
---|
[275] | 219 | _System_DebugOnly_OutputDebugString( Ex"ready dynamic meta datas!\r\n" )
|
---|
| 220 | End Sub
|
---|
| 221 |
|
---|
| 222 | Static Sub _NextPointerForGC()
|
---|
| 223 | ' TODO: 実装
|
---|
| 224 | End Sub
|
---|
| 225 |
|
---|
[367] | 226 | Static Function Search( fullName As String ) As TypeBaseImpl
|
---|
| 227 | If Object.ReferenceEquals(types, Nothing) Then
|
---|
| 228 | Return Nothing
|
---|
| 229 | End If
|
---|
[299] | 230 |
|
---|
[367] | 231 | If isReady = False Then
|
---|
| 232 | Return Nothing
|
---|
| 233 | End If
|
---|
[275] | 234 |
|
---|
[400] | 235 | Search = types.Item(fullName)
|
---|
| 236 |
|
---|
| 237 | If Object.ReferenceEquals( Search, Nothing ) Then
|
---|
| 238 | OutputDebugString("TypeSearch Failed: ")
|
---|
| 239 | If Not ActiveBasic.IsNothing(fullName) Then
|
---|
| 240 | OutputDebugStringW(StrPtr(fullName) As PWSTR)
|
---|
| 241 | OutputDebugString(Ex"\r\n")
|
---|
| 242 | OutputDebugStringA(StrPtr(fullName) As PSTR)
|
---|
| 243 | End If
|
---|
| 244 | OutputDebugString(Ex"\r\n")
|
---|
[367] | 245 | End If
|
---|
[275] | 246 | End Function
|
---|
| 247 |
|
---|
| 248 | Static Function IsReady() As Boolean
|
---|
| 249 | Return isReady
|
---|
| 250 | End Function
|
---|
| 251 |
|
---|
[367] | 252 | Static selfTypeInfo As System.TypeInfo
|
---|
[275] | 253 |
|
---|
| 254 | End Class
|
---|
| 255 |
|
---|
| 256 |
|
---|
| 257 | End Namespace
|
---|
| 258 | End Namespace
|
---|
[299] | 259 |
|
---|
[367] | 260 | Function _System_TypeBase_Search( fullName As String ) As ActiveBasic.Core.TypeBaseImpl
|
---|
| 261 | Return ActiveBasic.Core._System_TypeBase.Search( fullName )
|
---|
[299] | 262 | End Function
|
---|