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