Ignore:
Timestamp:
Mar 30, 2007, 4:22:30 AM (17 years ago)
Author:
dai
Message:

オブジェクトの循環参照を許容した(構造体はダメ)。
抽象クラスをメンバの型に指定できるようにした。
メンバがオブジェクトだったとき、自動的にNewするのをやめ、初期値としてNothingを指定するようにした。

【ArrayListの改良】
・ArrayList_Elementを廃止し、実装をArrayListのprivateに置いた。
・一通りのパラメータを*ObjectからObjectへ変更した。

【その他】
・TypeInfo改良中...
・Objectクラスに実行時型情報用のtypeInfoメンバを追加した。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/Classes/System/TypeInfo.ab

    r186 r195  
    11' 実装中...
    22'(※ まだ組み込んでいません)
     3
     4
     5'Namespace System
     6
    37
    48Class TypeInfo
     
    3539
    3640' 中間的な実装(継承専用)
    37 Class TypeImpl
     41Class TypeBaseImpl
    3842    Inherits TypeInfo
    3943
     
    4650Protected
    4751
    48     Sub TypeImpl()
     52    Sub TypeBaseImpl()
    4953        name = ""
    5054        strNamespace = ""
     
    5256    End Sub
    5357
    54     Sub TypeImpl( name As String, strNamespace As String )
     58    Sub TypeBaseImpl( name As String, strNamespace As String )
    5559        This.name = name
    5660        This.strNamespace = strNamespace
    57         baseType = Nothing
    58     End Sub
    59 
    60     Sub TypeImpl( name As String, strNamespace As String, baseType As Type )
    61         TypeImpl( name, strNamespace )
     61        This.baseType = Nothing
     62    End Sub
     63
     64    Sub TypeBaseImpl( name As String, strNamespace As String, baseType As TypeInfo )
     65        This.name = name
     66        This.strNamespace = strNamespace
    6267        This.baseType = baseType
    6368    End Sub
    6469
    6570    /*
    66     Sub TypeImpl( name As String, strNamespace As String, baseType As Type, interfaces As ... )
    67         TypeImpl( name, strNamespace, baseType )
     71    Sub TypeBaseImpl( name As String, strNamespace As String, baseType As Type, interfaces As ... )
     72        TypeBaseImpl( name, strNamespace, baseType )
    6873    End Sub
    6974    */
     
    131136' 値型を管理するためのクラス
    132137Class _System_TypeForValueType
    133     Inherits TypeImpl
    134 Public
    135     Sub _System_TypeForValueType( name )
     138    Inherits TypeBaseImpl
     139Public
     140    Sub _System_TypeForValueType( name As String )
    136141        TypeInfo( name, "" )
    137142    End Sub
     
    144149' クラスを管理するためのクラス
    145150Class _System_TypeForClass
    146     Inherits TypeImpl
    147 Public
     151    Inherits TypeBaseImpl
     152Public
     153    Sub _System_TypeForClass( name As String, strNamespace As String, baseType As TypeInfo )
     154        TypeBaseImpl( name, strNamespace, baseType )
     155    End Sub
     156    Sub ~_System_TypeForClass()
     157    End Sub
     158    Override Function IsClass() As Boolean
     159        Return True
     160    End Function
    148161End Class
    149162
    150163' インターフェイスを管理するためのクラス
    151164Class _System_TypeForInterface
    152     Inherits TypeImpl
     165    Inherits TypeBaseImpl
    153166Public
    154167End Class
     
    156169' 列挙体を管理するためのクラス
    157170Class _System_TypeForEnum
    158     Inherits TypeImpl
     171    Inherits TypeBaseImpl
    159172Public
    160173End Class
     
    162175' デリゲートを管理するためのクラス
    163176Class _System_TypeForDelegate
    164     Inherits TypeImpl
     177    Inherits TypeBaseImpl
    165178Public
    166179End Class
     
    171184'--------------------------------------------------------------------
    172185Class _System_TypeBase
    173     ppTypes As *Type
     186    pTypes As *TypeInfo
    174187    count As Long
    175188
    176189    Sub _System_TypeBase()
    177         ppTypes = GC_malloc( 1 )
     190        pTypes = GC_malloc( 1 )
    178191        count = 0
    179192    End Sub
    180193    Sub ~_System_TypeBase()
    181         Dim i As Long
    182         For i=0 To ELM( count )
    183             Delete ppTypes[i]
    184         Next
     194    End Sub
     195
     196    Sub _add( typeInfo As TypeInfo )
     197        pTypes = realloc( pTypes, ( count + 1 ) * SizeOf(*TypeInfo) )
     198        pTypes[count] = typeInfo
     199        count++
    185200    End Sub
    186201
     
    190205Public
    191206
    192     Sub Add( pType As *Type )
    193         ppTypes = realloc( ppTypes, ( count + 1 ) * SizeOf(*Type) )
    194         ppTypes[count] = pType
    195         count++
     207    Static Sub Add( typeInfo As TypeInfo )
     208        obj._add( typeInfo )
    196209    End Sub
    197210
     
    214227        obj.Add( New _System_TypeForValueType( "Double" ) )
    215228    End Sub
    216 End Class
     229
     230    Static Sub InitializeUserTypes()
     231        ' このメソッドの実装はコンパイラが自動生成する
     232    End Sub
     233
     234    Static Sub Initialize()
     235        ' 値型を初期化
     236        InitializeValueType()
     237
     238        ' Class / Interface / Enum / Delegate を初期化
     239        InitializeUserTypes()
     240    End Sub
     241End Class
     242
     243' End Namespace ' System
Note: See TracChangeset for help on using the changeset viewer.