Changeset 207 for Include/Classes


Ignore:
Timestamp:
Apr 7, 2007, 3:03:38 PM (17 years ago)
Author:
dai
Message:

動的型情報(Object.GetType)に対応。
戻り値やクラスメンバがオブジェクトだったとき、その初期値をNothingにした(※戻り値として関数名を使っている部分、要注意!!)。

Location:
Include/Classes/System
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Include/Classes/System/Collections/ArrayList.ab

    r203 r207  
    304304    End Sub
    305305
    306     /*Override*/ Virtual Function ToString() As String
     306    /*Override*/ Override Function ToString() As String
    307307        Return "System.Collections.ArrayList"
    308308    End Function
  • Include/Classes/System/DateTime.ab

    r166 r207  
    272272        End If
    273273
    274         AddTicks.Ticks = ticks + value
    275         AddTicks.Kind = Kind
     274        Return New DateTime( ticks + value, Kind )
    276275    End Function
    277276
     
    315314        End If
    316315       
    317         AddYears.Ticks = ticks
    318         AddYears.Kind = Kind
     316        Return New DateTime( ticks, Kind )
    319317    End Function
    320318
     
    363361            .wDayOfWeek = DayOfWeek() As Word
    364362        End With
     363
     364        GetDateTimeFormats = New String()
    365365
    366366        Dim size As Long
     
    481481        ElseIf dateData = &H03 Then
    482482            Return DateTimeKind.Utc
     483        Else
     484            ' どれにも該当しなかったときはどうなるんでしょうか??
     485            Return DateTimeKind.Local
    483486        End If
    484487    End Function
  • Include/Classes/System/Diagnostics/base.ab

    r147 r207  
    1212    ' コンストラクタ
    1313    Sub _System_TraceBase()
    14         Dim defaultTraceListener As DefaultTraceListener
    15         listeners.Add( defaultTraceListener )
     14        listeners = New TraceListenerCollection
     15        listeners.Add( New DefaultTraceListener() )
    1616
    1717        indentLevel = 0
  • Include/Classes/System/Object.ab

    r195 r207  
    11Class Object
    2 
    3     ' 実行時型情報
    4     typeInfo As TypeInfo
    52
    63Public
     
    3734    End Function
    3835*/
     36
     37
     38    '----------------------------------------------------------------
     39    ' 実行時型情報
     40    '----------------------------------------------------------------
     41
     42Private
     43    typeInfo As TypeInfo
     44
     45Public
     46    Sub _System_SetType( typeInfo As TypeInfo )
     47        If _System_TypeBase.IsReady() = False Then
     48            Return
     49        End If
     50
     51        This.typeInfo = typeInfo
     52    End Sub
     53
     54    Function GetType() As TypeInfo
     55        Return typeInfo
     56    End Function
     57
    3958End Class
     59Dim aaa As Long
  • Include/Classes/System/String.ab

    r203 r207  
    345345Private
    346346    Static Function ConcatStrChar(text1 As *StrChar, text1Length As Long, text2 As *StrChar, text2Length As Long) As String
     347        ConcatStrChar = New String()
    347348        With ConcatStrChar
    348349            .AllocStringBuffer(text1Length + text2Length)
  • Include/Classes/System/TypeInfo.ab

    r198 r207  
    1010
    1111    Sub TypeInfo()
     12    End Sub
     13    Sub ~TypeInfo()
    1214    End Sub
    1315
     
    4547    name As String
    4648
     49Protected
     50
    4751    baseType As TypeInfo
    4852    'interfaces As f(^^;;;
    49 
    50 Protected
    5153
    5254    Sub TypeBaseImpl()
     
    7779    */
    7880
     81    Sub ~TypeBaseImpl()
     82    End Sub
     83
    7984Public
    8085
     
    8893    End Function
    8994
     95    Sub SetBaseType( baseType As TypeInfo )
     96        This.baseType = baseType
     97    End Sub
     98
    9099    Override Function FullName() As String
    91100        Return strNamespace + "." + name
     
    142151Public
    143152    Sub _System_TypeForValueType( name As String )
    144         TypeInfo( "", name )
     153        TypeBaseImpl( "", name )
    145154    End Sub
    146155
     
    154163    Inherits TypeBaseImpl
    155164Public
    156     Sub _System_TypeForClass( strNamespace As String, name As String, baseType As TypeInfo )
    157         TypeBaseImpl( strNamespace, name, baseType )
     165    Sub _System_TypeForClass( strNamespace As String, name As String )
     166        TypeBaseImpl( strNamespace, name )
    158167    End Sub
    159168    Sub ~_System_TypeForClass()
     
    162171        Return True
    163172    End Function
    164 
    165     Sub SetBaseType( baseType As TypeInfo )
    166         This.baseType = baseType
    167     End Sub
    168173End Class
    169174
     
    188193
    189194'--------------------------------------------------------------------
    190 ' プロセスに存在するすべての型を管理する(シングルトン クラス)
     195' プロセスに存在するすべての型を管理する
    191196'--------------------------------------------------------------------
    192197Class _System_TypeBase
    193     pTypes As *TypeInfo
    194     count As Long
    195 
    196     Sub _System_TypeBase()
    197         pTypes = GC_malloc( 1 )
    198         count = 0
    199     End Sub
    200     Sub ~_System_TypeBase()
    201     End Sub
    202 
    203     Sub Add( typeInfo As TypeInfo )
     198    Static pTypes As *TypeBaseImpl
     199    Static count As Long
     200    Static isReady = False
     201
     202    Static Sub Add( typeInfo As TypeBaseImpl )
    204203        pTypes = realloc( pTypes, ( count + 1 ) * SizeOf(*TypeInfo) )
    205204        pTypes[count] = typeInfo
     
    207206    End Sub
    208207
    209     Function Search( strNamespace As String, typeName As String ) As TypeInfo
     208    Static Sub InitializeValueType()
     209        ' 値型の追加
     210        Add( New _System_TypeForValueType( "Byte" ) )
     211        Add( New _System_TypeForValueType( "SByte" ) )
     212        Add( New _System_TypeForValueType( "Word" ) )
     213        Add( New _System_TypeForValueType( "Integer" ) )
     214        Add( New _System_TypeForValueType( "DWord" ) )
     215        Add( New _System_TypeForValueType( "Long" ) )
     216        Add( New _System_TypeForValueType( "QWord" ) )
     217        Add( New _System_TypeForValueType( "Int64" ) )
     218        Add( New _System_TypeForValueType( "Boolean" ) )
     219        Add( New _System_TypeForValueType( "Single" ) )
     220        Add( New _System_TypeForValueType( "Double" ) )
     221    End Sub
     222
     223    Static Sub InitializeUserTypes()
     224        ' このメソッドの実装はコンパイラが自動生成する
     225
     226        '例:
     227        'Add( New _System_TypeForClass( "System", "String" ) )
     228        'Search( "String" ).SetBaseType( Search( "Object" ) )
     229    End Sub
     230
     231Public
     232
     233    Static Sub Initialize()
     234        pTypes = GC_malloc( 1 )
     235        count = 0
     236
     237        ' 値型を初期化
     238        InitializeValueType()
     239
     240        isReady = True
     241        ' Class / Interface / Enum / Delegate を初期化
     242        InitializeUserTypes()
     243
     244
     245        OutputDebugString( Ex"ready dynamic meta datas!\r\n" )
     246    End Sub
     247
     248    Static Sub _NextPointerForGC()
     249        ' TODO: 実装
     250    End Sub
     251
     252    Static Function Search( strNamespace As LPSTR, typeName As LPSTR ) As TypeBaseImpl
     253
    210254        ' TODO: 名前空間に対応する
    211255        Dim i As Long
     
    215259            End If
    216260        Next
     261
    217262        Return Nothing
    218263    End Function
    219264
    220     ' シングルトン オブジェクト
    221     Static obj As _System_TypeBase
    222 
    223     Static Sub InitializeValueType()
    224         ' 値型の追加
    225         obj.Add( New _System_TypeForValueType( "Byte" ) )
    226         obj.Add( New _System_TypeForValueType( "SByte" ) )
    227         obj.Add( New _System_TypeForValueType( "Word" ) )
    228         obj.Add( New _System_TypeForValueType( "Integer" ) )
    229         obj.Add( New _System_TypeForValueType( "DWord" ) )
    230         obj.Add( New _System_TypeForValueType( "Long" ) )
    231         obj.Add( New _System_TypeForValueType( "QWord" ) )
    232         obj.Add( New _System_TypeForValueType( "Int64" ) )
    233         obj.Add( New _System_TypeForValueType( "Boolean" ) )
    234         obj.Add( New _System_TypeForValueType( "Single" ) )
    235         obj.Add( New _System_TypeForValueType( "Double" ) )
    236     End Sub
    237 
    238     Static Sub InitializeUserTypes()
    239         ' このメソッドの実装はコンパイラが自動生成する
    240 
    241 #generate InitializeUserTypes
    242 
    243         '例:
    244         'obj.Add( New _System_TypeForClass( "System", "String" ) )
    245         'obj.Search( "String" ).SetBaseType( Search( "Object" ) )
    246     End Sub
    247 
    248 Public
    249 
    250     Static Sub _NextPointerForGC()
    251         ' TODO: 実装
    252     End Sub
    253 
    254     Static Sub Initialize()
    255         ' 値型を初期化
    256         InitializeValueType()
    257 
    258         ' Class / Interface / Enum / Delegate を初期化
    259         InitializeUserTypes()
    260     End Sub
    261 End Class
     265    Static Function IsReady() As Boolean
     266        Return isReady
     267    End Function
     268
     269End Class
     270
    262271
    263272' End Namespace ' System
Note: See TracChangeset for help on using the changeset viewer.