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