Changeset 203


Ignore:
Timestamp:
Apr 4, 2007, 6:53:48 PM (18 years ago)
Author:
イグトランス (egtra)
Message:

GCHandleの追加、String.Compareなどの追加、gc.sbpの修正

Location:
Include
Files:
3 added
4 edited

Legend:

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

    r195 r203  
    3737            Debug
    3838        End If
     39        capacity = size
    3940    End Sub
    4041
     
    4243        If This.capacity < capacity Then
    4344            This.capacity = capacity
    44             Realloc( capacity )
     45            Realloc(capacity)
    4546        End If
    4647    End Sub
     
    9697    /*Override*/ Virtual Sub Operator []=(index As Long, object As Object)
    9798        If 0 <= index And index < size Then
    98             pObject[i] = object
     99            pObject[index] = object
    99100        Else
    100101            'Throw OutOfRangeException?
     
    114115    End Sub
    115116/*
    116     Sub ArrayList(ByRef c As ICollection)
     117    Sub ArrayList(c As ICollection)
    117118        ' 未実装
    118119        Debug
     
    127128    End Sub
    128129
    129 '   Sub Operator =(ByRef a As ArrayList)
     130'   Sub Operator =(a As ArrayList)
    130131
    131132    /*Override*/ Virtual Function Add( object As Object ) As Long
     
    136137    End Function
    137138
    138     Virtual Sub AddRange(ByRef c As ICollection)
    139         ' TODO: 実装
    140     End Sub
    141 
    142     Const Virtual Function BinarySearch(x As *Object)
    143         ' TODO: 実装
    144     End Function
    145 
    146     Const Virtual Function BinarySearch(x As *Object, ByRef c As IComparer) As Long
    147         ' TODO: 実装
    148     End Function
    149 
    150     Const Virtual Function BinarySearch(index As Long, count As Long, x As *Object, ByRef c As IComparer) As Long
    151         ' TODO: 実装
     139    Virtual Sub AddRange(c As ICollection)
     140        ' TODO: 実装
     141    End Sub
     142
     143    Const Virtual Function BinarySearch(x As Object)
     144        ' TODO: 実装
     145    End Function
     146
     147    Const Virtual Function BinarySearch(x As Object, c As IComparer) As Long
     148        Return BinarySearch(0, size, x, c)
     149    End Function
     150
     151    Const Virtual Function BinarySearch(index As Long, count As Long, x As Object, c As IComparer) As Long
     152        Dim l = index
     153        Dim r = index + ELM(count)
     154        While l <= r
     155            Dim mid = (l + r) >> 2
     156            Dim ret = c.Compare(pObject[mid], x)
     157            If ret = 0 Then
     158                Return mid
     159            Else If ret < 0 Then 'pObject[mid] < x
     160                If l = r Then
     161                    If mid + 1 <= index + ELM(count) Then
     162                        Return Not (mid + 1)
     163                    Else
     164                        Return count
     165                    End If
     166                End If
     167                l = mid + 1
     168            Else 'pObject[mid] > x
     169                If l = r And mid + 1 <= index + ELM(count) Then
     170                    Return Not mid
     171                End If
     172                r = mid - 1
     173            End If
     174        Wend
     175        If l = index Then
     176            Return Not index
     177        Else 'r = index + ELM(count)
     178            Return Not count
     179        End If
    152180    End Function
    153181
     
    172200
    173201    ' CopyTo
    174     /*Const*/ /*Override*/ Virtual Function GetEnumerator() As *IEnumerator
    175         'Return GetEnumerator(index, count)
    176     End Function
    177 
    178     Const Virtual Function GetEnumerator(index As Long, count As Long) As *IEnumerator
    179         ' TODO: 実装
    180     End Function
    181 
    182     Virtual Function GetRange(index As Long, count As Long) As *ArrayList
     202
     203'   
     204'   /*Const*/ /*Override*/ Virtual Function GetEnumerator() As IEnumerator
     205'       'Return GetEnumerator(index, count)
     206'   End Function
     207
     208'   Const Virtual Function GetEnumerator(index As Long, count As Long) As IEnumerator
     209'       ' TODO: 実装
     210'   End Function
     211
     212    Virtual Function GetRange(index As Long, count As Long) As ArrayList
    183213        ' TODO: 実装
    184214    End Function
     
    210240    End Sub
    211241
    212     Virtual Sub InsertRange(index As Long, ByRef c As ICollection)
     242    Virtual Sub InsertRange(index As Long, c As ICollection)
    213243        ' TODO: 実装
    214244    End Sub
     
    253283    End Sub
    254284
    255     Virtual Sub SetRange(index As Long, ByRef c As ICollection)
     285    Virtual Sub SetRange(index As Long, c As ICollection)
    256286        ' TODO: 実装
    257287    End Sub
     
    261291    End Sub
    262292
    263     Virtual Sub Sort(ByRef c As IComparer)
     293    Virtual Sub Sort(c As IComparer)
    264294        Sort(0, size, c)
    265295    End Sub
    266296
    267     Virtual Sub Sort(index As Long, count As Long, ByRef c As IComparer)
     297    Virtual Sub Sort(index As Long, count As Long, c As IComparer)
    268298        ' TODO: 実装
    269299    End Sub
     
    280310    ' --------------------------------
    281311    ' static methods
    282     Static Function Adapter(ByRef l As IList) As *ArrayList
    283         ' TODO: 実装
    284     End Function
    285 
    286     Static Function FixedSize(ByRef l As ArrayList) As *ArrayList
    287         ' TODO: 実装
    288     End Function
    289 
    290     Static Function FixedSize(ByRef l As IList) As *IList
     312    Static Function Adapter(l As IList) As ArrayList
     313        ' TODO: 実装
     314    End Function
     315
     316    Static Function FixedSize(l As ArrayList) As ArrayList
     317        ' TODO: 実装
     318    End Function
     319
     320    Static Function FixedSize(l As IList) As IList
    291321        Return FixedSize(Adapter(VarPtr(i)))
    292322    End Function
    293323
    294     Static Function ReadOnly(ByRef l As ArrayList) As *ArrayList
    295         ' TODO: 実装
    296     End Function
    297 
    298     Static Function ReadOnly(ByRef l As IList) As *IList
     324    Static Function ReadOnly(l As ArrayList) As ArrayList
     325        ' TODO: 実装
     326    End Function
     327
     328    Static Function ReadOnly(l As IList) As IList
    299329        Return ReadOnly(Adapter(VarPtr(i)))
    300330    End Function
    301331
    302     Static Function Repeat(ByRef x As Object, c As Long) As *ArrayList
     332    Static Function Repeat(x As Object, c As Long) As ArrayList
    303333        Repeat = New ArrayList(c)
    304334        Dim i As Long
     
    308338    End Function
    309339
    310     Static Function Synchronized(ByRef l As ArrayList) As *ArrayList
    311         ' TODO: 実装
    312     End Function
    313 
    314     Static Function Synchronized(ByRef l As IList) As *IList
     340    Static Function Synchronized(l As ArrayList) As ArrayList
     341        ' TODO: 実装
     342    End Function
     343
     344    Static Function Synchronized(l As IList) As IList
    315345        Return Synchronized(Adapter(VarPtr(i)))
    316346    End Function
  • Include/Classes/System/String.ab

    r193 r203  
    1616
    1717Class String
     18'   Inherits IComparable, ICloneable, IConvertible, IEnumerable
     19
    1820    m_Length As Long
    1921Public
     
    2123
    2224    Sub String()
    23         Chars = _System_malloc(SizeOf (StrChar)) '0
     25        Chars = _System_malloc(SizeOf (StrChar))
    2426        Chars[0] = 0
    2527        m_Length = 0
     
    129131    End Function
    130132
    131     Const Function Operator + (ByRef objString As String) As String
     133    Const Function Operator + (objString As String) As String
    132134        Return Concat(objString.Chars, objString.m_Length)
    133135    End Function
     
    143145    End Function
    144146
    145     Const Function Operator & (ByRef objString As String) As String
     147    Const Function Operator & (objString As String) As String
    146148        Dim tempString = This + objString
    147149        Return tempString
    148150    End Function
    149151
    150     Const Function Operator == (ByRef objString As String) As Boolean
    151         Return _System_StrCmp(This.Chars, objString.Chars) = 0
     152    Const Function Operator == (objString As String) As Boolean
     153        Return String.Compare(This, objString) = 0
    152154    End Function
    153155
     
    156158    End Function
    157159
    158     Const Function Operator <> (ByRef objString As String) As Boolean
    159         Return _System_StrCmp(This.Chars, objString.Chars) <> 0
     160    Const Function Operator <> (objString As String) As Boolean
     161        Return String.Compare(This, objString) <> 0
    160162    End Function
    161163
     
    164166    End Function
    165167
    166     Const Function Operator < (ByRef objString As String) As Boolean
    167         Return _System_StrCmp(This.Chars, objString.Chars) < 0
     168    Const Function Operator < (objString As String) As Boolean
     169        Return String.Compare(This, objString) < 0
    168170    End Function
    169171
     
    172174    End Function
    173175
    174     Const Function Operator > (ByRef objString As String) As Boolean
    175         Return _System_StrCmp(This.Chars, objString.Chars) > 0
     176    Const Function Operator > (objString As String) As Boolean
     177        Return String.Compare(This, objString) > 0
    176178    End Function
    177179
     
    180182    End Function
    181183
    182     Const Function Operator <= (ByRef objString As String) As Boolean
    183         Return _System_StrCmp(This.Chars, objString.Chars) <= 0
     184    Const Function Operator <= (objString As String) As Boolean
     185        Return String.Compare(This, objString) <= 0
    184186    End Function
    185187
     
    188190    End Function
    189191
    190     Const Function Operator >= (ByRef objString As String) As Boolean
    191         Return _System_StrCmp(This.Chars, objString.Chars) >= 0
     192    Const Function Operator >= (objString As String) As Boolean
     193        Return String.Compare(This, objString) >= 0
    192194    End Function
    193195
    194196    Const Function Operator >= (text As *StrChar) As Boolean
    195197        Return _System_StrCmp(This.Chars, text) >= 0
     198    End Function
     199
     200    Static Function Compare(x As String, y As String) As Long
     201        Return CompareOrdinal(x, y)
     202    End Function
     203
     204    Static Function Compare(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long
     205        Return CompareOrdinal(x, indexX, y, indexY, length)
     206    End Function
     207
     208    Static Function CompareOrdinal(x As String, y As String) As Long
     209        Return _System_StrCmp(x.Chars, y.Chars)
     210    End Function
     211
     212    Static Function CompareOrdinal(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long
     213        If x = Nothing Then
     214            If y = Nothing Then
     215                Return 0
     216            Else
     217                Return -1
     218            End If
     219        ElseIf y = Nothing Then
     220            Return 1
     221        End If
     222        Return _System_StrCmpN(VarPtr(x.Chars[indexX]), VarPtr(y.Chars[indexY]), length)
     223    End Function
     224
     225    Function CompareTo(y As String) As Long
     226        Return String.Compare(This, y)
     227    End Function
     228
     229    Function CompareTo(y As Object) As Long
     230        Dim s = y As String
     231'       If y is not String Then
     232'           Throw New ArgumentException
     233'       End If
     234        Return CompareTo(y)
    196235    End Function
    197236
     
    341380#endif
    342381    End Function
    343     Const Function Contains(ByRef objString As String) As Boolean
     382
     383    Static Function Concat(x As String, y As String) As String
     384        If x = Nothing Then
     385            Return y
     386        Else
     387            Return x.Concat(objString.Chars, objString.m_Length)
     388        End If
     389    End Function
     390
     391    Static Function Concat(x As Object, y As Object) As String
     392        Return String.Concat(x.ToString, y.ToString)
     393    End Function
     394
     395    Const Function Contains(objString As String) As Boolean
    344396        Return IndexOf(objString, 0, m_Length) >= 0
    345397    End Function
  • Include/basic/function.sbp

    r192 r203  
    11691169End Function
    11701170
    1171 
    11721171Function _System_StrCmp(s1 As PCSTR, s2 As PCSTR) As Long
    11731172    Dim i = 0 As SIZE_T
     
    11921191End Function
    11931192
     1193Function _System_StrCmpN(s1 As PCSTR, s2 As PCSTR, size As SIZE_T) As Long
     1194    Dim i = 0 As SIZE_T
     1195    For i = 0 To ELM(size)
     1196        _System_StrCmp = s1[i] - s2[i]
     1197        If _System_StrCmp <> 0 Then
     1198            Exit Function
     1199        End If
     1200    Next
     1201End Function
     1202
     1203Function _System_StrCmpN(s1 As PCWSTR, s2 As PCWSTR, size As SIZE_T) As Long
     1204    Dim i = 0 As SIZE_T
     1205    For i = 0 To ELM(size)
     1206        _System_StrCmp = s1[i] - s2[i]
     1207        If _System_StrCmp <> 0 Then
     1208            Exit Function
     1209        End If
     1210    Next
     1211End Function
     1212
     1213Function _System_MemChr(s As PCSTR, c As CHAR, size As SIZE_T) As PCSTR
     1214    Dim i As SIZE_T
     1215    For i = 0 To ELM(size)
     1216        If s[i] = c Then
     1217            Return VarPtr(s[i])
     1218        End If
     1219    Next
     1220    Return 0
     1221End Function
     1222
     1223Function _System_MemChr(s As PCWSTR, c As WCHAR, size As SIZE_T) As PCWSTR
     1224    Dim i As SIZE_T
     1225    For i = 0 To ELM(size)
     1226        If s[i] = c Then
     1227            Return VarPtr(s[i])
     1228        End If
     1229    Next
     1230    Return 0
     1231End Function
     1232
     1233Function _System_MemPBrk(str As PCSTR, cStr As SIZE_T, Chars As PCSTR, cChars As SIZE_T) As PCSTR
     1234    Dim i As SIZE_T
     1235    For i = 0 To ELM(cStr)
     1236        If _System_MemChr(Chars, str[i], cChars) Then
     1237            Return VarPtr(str[i])
     1238        End If
     1239    Next
     1240    Return 0
     1241End Function
     1242
     1243Function _System_MemPBrk(str As PCWSTR, cStr As SIZE_T, Chars As PCWSTR, cChars As SIZE_T) As PCWSTR
     1244    Dim i As SIZE_T
     1245    For i = 0 To ELM(cStr)
     1246        If _System_MemChr(Chars, str[i], cChars) Then
     1247            Return VarPtr(str[i])
     1248        End If
     1249    Next
     1250    Return 0
     1251End Function
     1252
    11941253Function _System_GetHashFromWordArray(p As *Word, n As SIZE_T) As Long
    11951254    Dim hash = 0 As DWord
  • Include/system/gc.sbp

    r202 r203  
    139139
    140140    Function __malloc(size As SIZE_T,flags As Byte) As VoidPtr
    141         EnterCriticalSection(CriticalSection)
     141'       EnterCriticalSection(CriticalSection)
    142142            Dim dwFlags As DWord
    143143            If flags and _System_GC_FLAG_INITZERO Then
     
    149149            Dim ptr = HeapAlloc(_System_hProcessHeap,dwFlags,size)
    150150            add( ptr, size, flags )
    151         LeaveCriticalSection(CriticalSection)
     151'       LeaveCriticalSection(CriticalSection)
    152152
    153153        Return ptr
     
    202202            Exit Sub
    203203        End If
    204         isSweeping = True
    205204        OutputDebugString( Ex"garbage colletion sweep start!\r\n" )
    206205
     
    351350            ExitThread(0)
    352351        End If
     352        isSweeping = True
    353353
    354354        ' すべてのスレッドを一時停止
Note: See TracChangeset for help on using the changeset viewer.