Changeset 272 for Include


Ignore:
Timestamp:
Jun 12, 2007, 7:24:38 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

StringBuilderを追加。String不変へ。共通の文字列操作関数をActiveBasic.Strings内に配置(設計に検討の余地あり)。

Location:
Include
Files:
6 added
9 edited

Legend:

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

    r268 r272  
    178178    End Function
    179179
    180     Static Function ToDay() As DateTime
     180    Static Function Today() As DateTime
    181181        Dim time As SYSTEMTIME
    182182        GetLocalTime(time)
     
    292292        Dim dateFormatSize = GetDateFormat(LOCALE_USER_DEFAULT, 0, time, NULL, NULL, 0)
    293293        Dim timeFormatSize = GetTimeFormat(LOCALE_USER_DEFAULT, 0, time, NULL, NULL, 0)
    294         Dim dateTimeFormats = malloc(dateFormatSize + timeFormatSize) As PTSTR
     294        Dim strLength = dateFormatSize + timeFormatSize
     295        Dim dateTimeFormats = GC_malloc_atomic(SizeOf (TCHAR) * (strLength)) As PTSTR
    295296        GetDateFormat(LOCALE_USER_DEFAULT, 0, time, NULL, dateTimeFormats, dateFormatSize)
    296297        dateTimeFormats[dateFormatSize - 1] = Asc(" ")
    297298        GetTimeFormat(LOCALE_USER_DEFAULT, 0, time, NULL, dateTimeFormats + dateFormatSize, timeFormatSize)
    298 
    299         Return New String(dateTimeFormats)
     299'Debug
     300        Return New String(dateTimeFormats, strLength)
    300301    End Function
    301302
  • Include/Classes/System/String.ab

    r270 r272  
    22
    33#require <basic/function.sbp>
     4#require <Classes/System/Text/StringBuilder.ab>
     5#require <Classes/ActiveBasic/Strings/Strings.ab>
    46
    57#ifdef __STRING_IS_NOT_ALWAYS_UNICODE
     
    2123
    2224        m_Length As Long
     25        Chars As *StrChar
     26
     27        Sub validPointerCheck(p As VoidPtr, size = 1 As Long)
     28            If p As ULONG_PTR < &h10000 Then
     29                'Throw ArgumentException
     30                Debug
     31            ElseIf IsBadReadPtr(p, size As ULONG_PTR) Then
     32                'Throw ArgumentException
     33                Debug
     34            End If
     35        End Sub
    2336    Public
    24         Chars As *StrChar
     37        Static Const Empty = New String
    2538
    2639        Sub String()
    27             Chars = _System_malloc(SizeOf (StrChar))
    28             Chars[0] = 0
    29             m_Length = 0
     40'           Chars = 0
     41'           m_Length = 0
     42        End Sub
     43
     44        Sub String(initStr As PCWSTR)
     45            validPointerCheck(initStr)
     46            Assign(initStr, lstrlenW(initStr))
     47        End Sub
     48
     49        Sub String(initStr As PCWSTR, length As Long)
     50            validPointerCheck(initStr, length)
     51            Assign(initStr, length)
     52        End Sub
     53
     54        Sub String(initStr As PCWSTR, start As Long, length As Long)
     55            If start < 0 Or length Or start + length < 0 Then
     56                'Throw New ArgumentOutOfRangeException
     57            End If
     58            validPointerCheck(initStr + start, length)
     59            Assign(initStr + start, length)
    3060        End Sub
    3161
    3262        Sub String(initStr As PCSTR)
    33             Assign(initStr)
     63            validPointerCheck(initStr)
     64            Assign(initStr, lstrlenA(initStr))
    3465        End Sub
    3566
    3667        Sub String(initStr As PCSTR, length As Long)
     68            validPointerCheck(initStr, length)
    3769            Assign(initStr, length)
    3870        End Sub
    3971
    40         Sub String(initStr As PCWSTR)
    41             Assign(initStr)
    42         End Sub
    43 
    44         Sub String(initStr As PCWSTR, length As Long)
    45             Assign(initStr, length)
    46         End Sub
    47 
    48         Sub String(ByRef initStr As String)
    49             Assign(initStr)
    50         End Sub
    51 
    52         Sub String(length As Long)
    53             ReSize(length)
     72        Sub String(initStr As PCSTR, start As Long, length As Long)
     73            If start < 0 Or length Or start + length < 0 Then
     74                'Throw New ArgumentOutOfRangeException
     75            End If
     76            validPointerCheck(initStr + start, length)
     77            Assign(initStr + start, length)
     78        End Sub
     79       
     80        Sub String(initStr As String)
     81            If Not String.IsNullOrEmpty(initStr) Then
     82                Assign(initStr.Chars, initStr.m_Length)
     83            End If
    5484        End Sub
    5585
    5686        Sub String(initChar As StrChar, length As Long)
    57             ReSize(length, initChar)
    58         End Sub
    59 
    60         Sub ~String()
    61             _System_free(Chars)
    62             Chars = 0
    63 #ifdef _DEBUG
    64             m_Length = 0
    65 #endif
     87            AllocStringBuffer(length)
     88            ActiveBasic.Strings.ChrFill(Chars, length, initChar)
     89            Chars[length] = 0
     90        End Sub
     91
     92        Sub String(sb As System.Text.StringBuilder)
     93            Chars = StrPtr(sb)
     94            m_Length = sb.Length
     95            sb.__Stringized()
    6696        End Sub
    6797
     
    75105
    76106        Const Function Operator [] (n As Long) As StrChar
    77 #ifdef _DEBUG
    78             If n > Length Then
    79                 'Throw ArgumentOutOfRangeException
    80                 Debug
    81             End If
    82 #endif
     107            rangeCheck(n)
    83108            Return Chars[n]
    84109        End Function
    85110
    86         Sub Operator []= (n As Long, c As StrChar)
    87 #ifdef _DEBUG
    88             If n >= Length Then
    89                 'Throw ArgumentOutOfRangeException
    90                 Debug
    91             End If
    92 #endif
    93             Chars[n] = c
    94         End Sub
    95 
    96     /*  Const Function Operator + (text As *Byte) As String
    97             Return Concat(text As PCTSTR, lstrlen(text))
    98         End Function*/
    99 
    100         Const Function Operator + (text As PCSTR) As String
    101             Return Concat(text, lstrlenA(text))
    102         End Function
    103 
    104         Const Function Operator + (text As PCWSTR) As String
    105             Return Concat(text, lstrlenW(text))
    106         End Function
    107 
    108         Const Function Operator + (objString As String) As String
    109             Return Concat(objString.Chars, objString.m_Length)
    110         End Function
    111 
    112         Const Function Operator & (text As PCSTR) As String
    113             Dim tempString = This + text
     111        Const Function Operator + (y As PCSTR) As String
     112            Return Concat(y, lstrlenA(y))
     113        End Function
     114
     115        Const Function Operator + (y As PCWSTR) As String
     116            Return Concat(y, lstrlenW(y))
     117        End Function
     118
     119        Const Function Operator + (y As String) As String
     120            Return Concat(y.Chars, y.m_Length)
     121        End Function
     122
     123        Const Function Operator & (y As PCSTR) As String
     124            Return This + y
     125        End Function
     126
     127        Const Function Operator & (y As PCWSTR) As String
     128            Dim tempString = This + y
    114129            Return tempString
    115130        End Function
    116131
    117         Const Function Operator & (text As PCWSTR) As String
    118             Dim tempString = This + text
     132        Const Function Operator & (y As String) As String
     133            Dim tempString = This + y
    119134            Return tempString
    120135        End Function
    121136
    122         Const Function Operator & (objString As String) As String
    123             Dim tempString = This + objString
    124             Return tempString
    125         End Function
    126 
    127         Const Function Operator == (objString As String) As Boolean
    128             Return String.Compare(This, objString) = 0
    129         End Function
    130 
    131         Const Function Operator == (text As *StrChar) As Boolean
    132             Return _System_StrCmp(This.Chars, text) = 0
    133         End Function
    134 
    135         Const Function Operator <> (objString As String) As Boolean
    136             Return String.Compare(This, objString) <> 0
    137         End Function
    138 
    139         Const Function Operator <> (text As *StrChar) As Boolean
    140             Return _System_StrCmp(This.Chars, text) <> 0
    141         End Function
    142 
    143         Const Function Operator < (objString As String) As Boolean
    144             Return String.Compare(This, objString) < 0
    145         End Function
    146 
    147         Const Function Operator < (text As *StrChar) As Boolean
    148             Return _System_StrCmp(This.Chars, text) < 0
    149         End Function
    150 
    151         Const Function Operator > (objString As String) As Boolean
    152             Return String.Compare(This, objString) > 0
    153         End Function
    154 
    155         Const Function Operator > (text As *StrChar) As Boolean
    156             Return _System_StrCmp(This.Chars, text) > 0
    157         End Function
    158 
    159         Const Function Operator <= (objString As String) As Boolean
    160             Return String.Compare(This, objString) <= 0
    161         End Function
    162 
    163         Const Function Operator <= (text As *StrChar) As Boolean
    164             Return _System_StrCmp(This.Chars, text) <= 0
    165         End Function
    166 
    167         Const Function Operator >= (objString As String) As Boolean
    168             Return String.Compare(This, objString) >= 0
    169         End Function
    170 
    171         Const Function Operator >= (text As *StrChar) As Boolean
    172             Return _System_StrCmp(This.Chars, text) >= 0
     137        Const Function Operator == (y As String) As Boolean
     138            Return String.Compare(This, y) = 0
     139        End Function
     140
     141        Const Function Operator == (y As *StrChar) As Boolean
     142            Return String.Compare(This, y) = 0
     143        End Function
     144
     145        Const Function Operator <> (y As String) As Boolean
     146            Return String.Compare(This, y) <> 0
     147        End Function
     148
     149        Const Function Operator <> (y As *StrChar) As Boolean
     150            Return String.Compare(This, y) <> 0
     151        End Function
     152
     153        Const Function Operator < (y As String) As Boolean
     154            Return String.Compare(This, y) < 0
     155        End Function
     156
     157        Const Function Operator < (y As *StrChar) As Boolean
     158            Return String.Compare(This, y) < 0
     159        End Function
     160
     161        Const Function Operator > (y As String) As Boolean
     162            Return String.Compare(This, y) > 0
     163        End Function
     164
     165        Const Function Operator > (y As *StrChar) As Boolean
     166            Return String.Compare(This, y) > 0
     167        End Function
     168
     169        Const Function Operator <= (y As String) As Boolean
     170            Return String.Compare(This, y) <= 0
     171        End Function
     172
     173        Const Function Operator <= (y As *StrChar) As Boolean
     174            Return String.Compare(This, y) <= 0
     175        End Function
     176
     177        Const Function Operator >= (y As String) As Boolean
     178            Return String.Compare(This, y) >= 0
     179        End Function
     180
     181        Const Function Operator >= (y As *StrChar) As Boolean
     182            Return String.Compare(This, y) >= 0
    173183        End Function
    174184
     
    177187        End Function
    178188
     189    Public
    179190        Static Function Compare(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long
    180             Return CompareOrdinal(x, indexX, y, indexY, length)
     191            Return String.CompareOrdinal(x, indexX, y, indexY, length)
    181192        End Function
    182193
    183194        Static Function CompareOrdinal(x As String, y As String) As Long
    184             Return _System_StrCmp(x.Chars, y.Chars)
     195            Return String.CompareOrdinal(x.Chars, y.Chars)
    185196        End Function
    186197
    187198        Static Function CompareOrdinal(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long
    188             If Object.ReferenceEquals(x, Nothing) Then
    189                 If Object.ReferenceEquals(y, Nothing) Then
     199            Return String.CompareOrdinal(x.Chars, indexX, y.Chars, indexY, length)
     200        End Function
     201    Private
     202        Static Function Compare(x As String, y As *StrChar) As Long
     203            Return String.CompareOrdinal(x, y)
     204        End Function
     205
     206        Static Function CompareOrdinal(x As String, y As *StrChar) As Long
     207            Return String.CompareOrdinal(x.Chars, y)
     208        End Function
     209
     210        Static Function CompareOrdinal(x As *StrChar, y As *StrChar) As Long
     211            If x = 0 Then
     212                If y = 0 Then
    190213                    Return 0
    191214                Else
    192215                    Return -1
    193216                End If
    194             ElseIf Object.ReferenceEquals(y, Nothing) Then
     217            ElseIf y = 0 Then
    195218                Return 1
    196219            End If
    197             Return _System_StrCmpN(VarPtr(x.Chars[indexX]), VarPtr(y.Chars[indexY]), length As SIZE_T)
    198         End Function
    199 
     220            Return ActiveBasic.Strings.StrCmp(x, y)
     221        End Function
     222
     223        Static Function CompareOrdinal(x As *StrChar, indexX As Long, y As *StrChar, indexY As Long, length As Long) As Long
     224            If x = 0 Then
     225                If y = 0 Then
     226                    Return 0
     227                Else
     228                    Return -1
     229                End If
     230            ElseIf y = 0 Then
     231                Return 1
     232            End If
     233            Return ActiveBasic.Strings.ChrCmp(VarPtr(x[indexX]), VarPtr(y[indexY]), length As SIZE_T)
     234        End Function
     235    Public
    200236        Function CompareTo(y As String) As Long
    201237            Return String.Compare(This, y)
     
    207243    '           Throw New ArgumentException
    208244    '       End If
    209             Return CompareTo(y)
     245            Return CompareTo(y As String)
    210246        End Function
    211247
     
    213249            Return Chars
    214250        End Function
    215 
    216         Sub ReSize(allocLength As Long)
    217             If allocLength < 0 Then Exit Sub
    218             Dim oldLength  = m_Length
    219             If AllocStringBuffer(allocLength) <> 0 Then
    220                 If allocLength > oldLength Then
    221                     ZeroMemory(VarPtr(Chars[oldLength]), SizeOf (StrChar) * (m_Length - oldLength + 1))
    222                 Else
    223                     Chars[m_Length] = 0
    224                 End If
    225             End If
    226         End Sub
    227 
    228         Sub ReSize(allocLength As Long, c As StrChar)
    229             If allocLength < 0 Then Exit Sub
    230             Dim oldLength = m_Length
    231             If AllocStringBuffer(allocLength) <> 0 Then
    232                 If allocLength > oldLength Then
    233                     _System_FillChar(VarPtr(Chars[oldLength]), (m_Length - oldLength) As SIZE_T, c)
    234                 End If
    235                 Chars[m_Length] = 0
    236             End If
    237         End Sub
     251Private
    238252
    239253        Sub Assign(text As PCSTR, textLengthA As Long)
     
    261275        End Sub
    262276
    263         Sub Assign(ByRef objString As String)
    264             Assign(objString.Chars, objString.m_Length)
    265         End Sub
    266 
    267         Sub Assign(text As PCSTR)
    268             If text Then
    269                 Assign(text, lstrlenA(text))
    270             Else
    271                 If Chars <> 0 Then
    272                     Chars[0] = 0
    273                 End If
    274                 m_Length = 0
    275             End If
    276         End Sub
    277 
    278         Sub Assign(text As PCWSTR)
    279             If text Then
    280                 Assign(text, lstrlenW(text))
    281             Else
    282                 If Chars <> 0 Then
    283                     Chars[0] = 0
    284                 End If
    285                 m_Length = 0
    286             End If
    287         End Sub
    288 
    289         Sub Append(text As *StrChar, textLength As Long)
    290             Dim prevLen As Long
    291             prevLen = m_Length
    292             If AllocStringBuffer(m_Length + textLength) <> 0 Then
    293                 memcpy(VarPtr(Chars[prevLen]), text, SizeOf (StrChar) * textLength)
    294                 Chars[m_Length] = 0
    295             End If
    296         End Sub
    297 
    298         Sub Append(text As *StrChar)
    299             Append(text, lstrlen(text))
    300         End Sub
    301 
    302         Sub Append(ByRef str As String)
    303             Append(str.Chars, str.m_Length)
    304         End Sub
    305 
    306         Const Function Clone() As String
    307             Return This
    308         End Function
    309277    Private
    310278        Static Function ConcatStrChar(text1 As *StrChar, text1Length As Long, text2 As *StrChar, text2Length As Long) As String
     
    312280            With ConcatStrChar
    313281                .AllocStringBuffer(text1Length + text2Length)
    314                 memcpy(.Chars, text1, SizeOf (StrChar) * text1Length)
    315                 memcpy(VarPtr(.Chars[text1Length]), text2, SizeOf (StrChar) * text2Length)
     282                ActiveBasic.Strings.ChrCopy(.Chars, text1, text1Length As SIZE_T)
     283                ActiveBasic.Strings.ChrCopy(VarPtr(.Chars[text1Length]), text2, text2Length As SIZE_T)
    316284                .Chars[text1Length + text2Length] = 0
    317285            End With
     
    324292            With Concat
    325293                Dim lenW = MultiByteToWideChar(CP_THREAD_ACP, 0, text, len, 0, 0)
     294                Concat = New String
    326295                .AllocStringBuffer(m_Length + lenW)
    327                 memcpy(.Chars, This.Chars, m_Length)
     296                ActiveBasic.Strings.ChrCopy(.Chars, This.Chars, m_Length)
    328297                MultiByteToWideChar(CP_THREAD_ACP, 0, text, len, VarPtr(.Chars[m_Length]), lenW)
    329298                .Chars[m_Length + lenW] = 0
     
    335304#ifdef __STRING_IS_NOT_UNICODE
    336305            With Concat
     306                Concat = New String
    337307                Dim lenA = WideCharToMultiByte(CP_THREAD_ACP, 0, text, len, 0, 0, 0, 0)
    338308                .AllocStringBuffer(m_Length + lenA)
    339                 memcpy(.Chars, This.Chars, m_Length)
     309                ActiveBasic.Strings.ChrCopy(.Chars, This.Chars, m_Length As SIZE_T)
    340310                WideCharToMultiByte(CP_THREAD_ACP, 0, text, len, VarPtr(.Chars[m_Length]), lenA, 0, 0)
    341311                .Chars[m_Length + lenA] = 0
     
    358328        End Function
    359329
    360         Const Function Contains(objString As String) As Boolean
    361             Return IndexOf(objString, 0, m_Length) >= 0
    362         End Function
    363 
    364         Const Function Contains(lpszText As *StrChar) As Boolean
    365             Return IndexOf(lpszText, 0, m_Length) >= 0
    366         End Function
    367 
    368         Const Function IndexOf(lpszText As *StrChar) As Long
    369             Return IndexOf(lpszText, 0, m_Length)
    370         End Function
    371 
    372         Const Function IndexOf(lpszText As *StrChar, startIndex As Long) As Long
    373             Return IndexOf(lpszText, startIndex, m_Length - startIndex)
    374         End Function
    375 
    376         Const Function IndexOf(lpszText As *StrChar, startIndex As Long, count As Long) As Long
    377             Dim length = lstrlen(lpszText)
    378 
    379             If startIndex < 0 Then Return -1
    380             If count < 1 Or count + startIndex > m_Length Then Return -1
    381             If length > m_Length Then Return -1
    382 
     330        Const Function Contains(s As String) As Boolean
     331            If Object.ReferenceEquals(s, Nothing) Then
     332                'Throw New ArgumentNullException
     333            End If
     334            Return IndexOf(s, 0, m_Length) >= 0
     335        End Function
     336
     337        Const Function IndexOf(c As StrChar) As Long
     338            Return indexOfCore(c, 0, m_Length)
     339        End Function
     340
     341        Const Function IndexOf(c As StrChar, start As Long) As Long
     342            rangeCheck(start)
     343            Return indexOfCore(c, start, m_Length - start)
     344        End Function
     345
     346        Const Function IndexOf(c As StrChar, start As Long, count As Long) As Long
     347            rangeCheck(start, count)
     348            Return indexOfCore(c, start, count)
     349        End Function
     350    Private
     351        Const Function indexOfCore(c As StrChar, start As Long, count As Long) As Long
     352            indexOfCore = ActiveBasic.Strings.ChrFind(VarPtr(Chars[start]), count, c)
     353            If indexOfCore <> -1 Then
     354                indexOfCore += start
     355            End If
     356        End Function
     357    Public
     358        Const Function IndexOf(s As String) As Long
     359            Return IndexOf(s, 0, m_Length)
     360        End Function
     361
     362        Const Function IndexOf(s As String, startIndex As Long) As Long
     363            Return IndexOf(s, startIndex, m_Length - startIndex)
     364        End Function
     365
     366        Const Function IndexOf(s As String, startIndex As Long, count As Long) As Long
     367            rangeCheck(startIndex, count)
     368            If Object.ReferenceEquals(s, Nothing) Then
     369                'Throw New ArgumentNullException
     370                Debug
     371            End If
     372
     373            Dim length = s.Length
    383374            If length = 0 Then Return startIndex
    384375
     
    386377            For i = startIndex To startIndex + count - 1
    387378                For j = 0 To length - 1
    388                     If Chars[i + j] = lpszText[j] Then
     379                    If Chars[i + j] = s[j] Then
    389380                        If j = length - 1 Then Return i
    390381                    Else
     
    396387        End Function
    397388
    398         Const Function LastIndexOf(lpszText As *StrChar) As Long
    399             Return LastIndexOf(lpszText, m_Length - 1, m_Length)
    400         End Function
    401 
    402         Const Function LastIndexOf(lpszText As *StrChar, startIndex As Long) As Long
    403             Return LastIndexOf(lpszText As *StrChar, startIndex, startIndex + 1)
    404         End Function
    405 
    406         Const Function LastIndexOf(lpszText As *StrChar, startIndex As Long, count As Long) As Long
    407             Dim length = lstrlen(lpszText)
    408 
    409             If startIndex < 0 Or startIndex > m_Length - 1 Then Return -1
    410             If count < 1 Or count > startIndex + 2 Then Return -1
     389        Const Function LastIndexOf(s As String) As Long
     390            Return LastIndexOf(s, m_Length - 1, m_Length)
     391        End Function
     392
     393        Const Function LastIndexOf(s As String, startIndex As Long) As Long
     394            Return LastIndexOf(s, startIndex, startIndex + 1)
     395        End Function
     396
     397        Const Function LastIndexOf(s As String, startIndex As Long, count As Long) As Long
     398            If Object.ReferenceEquals(s, Nothing) Then
     399                'Throw New ArgumentNullException
     400                Debug
     401            End If
     402
     403            If startIndex < 0 Or startIndex > m_Length - 1 Or _
     404                count < 0 Or count > startIndex + 2 Then
     405                'Throw New ArgumentOutOfRangeException
     406                Debug
     407            End If
     408            Dim length = s.Length
    411409            If length > m_Length Then Return -1
    412 
    413410            If length = 0 Then Return startIndex
    414411
     
    416413            For i = startIndex To  startIndex - count + 1 Step -1
    417414                For j = length - 1 To 0 Step -1
    418                     If Chars[i + j] = lpszText[j] Then
     415                    If Chars[i + j] = s[j] Then
    419416                        If j = 0 Then Return i
    420417                    Else
     
    426423        End Function
    427424
    428         Const Function StartsWith(lpszText As *StrChar) As Boolean
    429             Return IndexOf(lpszText) = 0
    430         End Function
    431 
    432         Const Function EndsWith(lpszText As *StrChar) As Boolean
    433             Return LastIndexOf(lpszText) = m_Length - lstrlen(lpszText)
     425        Const Function StartsWith(s As String) As Boolean
     426            Return IndexOf(s) = 0
     427        End Function
     428
     429        Const Function EndsWith(s As String) As Boolean
     430            Return LastIndexOf(s) = m_Length - s.Length
    434431        End Function
    435432
    436433        Const Function Insert(startIndex As Long, text As String) As String
    437             Return Insert(startIndex, text.Chars, text.Length)
    438         End Function
    439 
    440         Const Function Insert(startIndex As Long, text As *StrChar) As String
    441             Return Insert(startIndex, text, lstrlen(text))
    442         End Function
    443 
    444         Const Function Insert(startIndex As Long, text As *StrChar, length As Long) As String
    445             If startIndex < 0 Or startIndex > m_Length Or length < 0 Then
    446                 Debug 'ArgumentOutOfRangeException
    447 
    448             End If
    449             Insert = New String(m_Length + length)
    450             memcpy(Insert.Chars, Chars, SizeOf (StrChar) * startIndex)
    451             memcpy(VarPtr(Insert.Chars[startIndex]), text, SizeOf (StrChar) * length)
    452             memcpy(VarPtr(Insert.Chars[startIndex + length]), VarPtr(Chars[startIndex]), SizeOf (StrChar) * (m_Length - startIndex + 1))
    453         End Function
    454 
    455         Const Function SubString(startIndex As Long) As String
    456             Return SubString(startIndex, m_Length - startIndex)
    457         End Function
    458 
    459         Const Function SubString(startIndex As Long, length As Long) As String
    460             If startIndex < 0 Or length <= 0 Then Return ""
    461             If startIndex + length > m_Length Then Return ""
    462 
    463             Dim temp As String
    464             temp.AllocStringBuffer(length)
    465             memcpy(temp.Chars, VarPtr(Chars[startIndex]), SizeOf (StrChar) * length)
    466             temp.Chars[length] = 0
    467             Return temp
     434            Dim sb = New System.Text.StringBuilder(This)
     435            sb.Insert(startIndex, text)
     436            Return sb.ToString
     437        End Function
     438
     439        Const Function Substring(startIndex As Long) As String
     440            rangeCheck(startIndex)
     441            Return Substring(startIndex, m_Length - startIndex)
     442        End Function
     443
     444        Const Function Substring(startIndex As Long, length As Long) As String
     445            rangeCheck(startIndex, length)
     446            Return New String(Chars, startIndex, length)
    468447        End Function
    469448
    470449        Const Function Remove(startIndex As Long) As String
    471             If startIndex < 0 Or startIndex > m_Length Then
    472                 Debug 'ArgumentOutOfRangeException
    473             End If
    474 
    475             Remove = New String(startIndex)
    476             memcpy(Remove.Chars, This.Chars, SizeOf (StrChar) * startIndex)
     450            rangeCheck(startIndex)
     451            Remove = Substring(0, startIndex)
    477452        End Function
    478453
    479454        Const Function Remove(startIndex As Long, count As Long) As String
    480             If startIndex < 0 Or count < 0 Or startIndex + count > m_Length Then
    481                 Debug 'ArgumentOutOfRangeException
    482             End If
    483 
    484             Remove = New String(m_Length - count)
    485             memcpy(Remove.Chars, This.Chars, SizeOf (StrChar) * startIndex)
    486             memcpy(VarPtr(Remove.Chars[startIndex]), VarPtr(This.Chars[startIndex + count]), SizeOf (StrChar) * (m_Length - startIndex - count))
     455            Dim sb = New System.Text.StringBuilder(This)
     456            sb.Remove(startIndex, count)
     457            Remove = sb.ToString
    487458        End Function
    488459
     
    497468
    498469        Const Function Replace(oldChar As StrChar, newChar As StrChar) As String
    499             Replace = Copy(This)
    500             With Replace
    501                 Dim i As Long
    502                 For i = 0 To ELM(.m_Length)
    503                     If .Chars[i] = oldChar Then
    504                         .Chars[i] = newChar
    505                     End If
    506                 Next
    507             End With
    508         End Function
    509 
    510         Const Function Replace(ByRef oldStr As String, ByRef newStr As String) As String
    511     '       If oldStr = Nothing Then Throw ArgumentNullException
    512     '
    513     '       If newStr = Nothing Then
    514     '           Return ReplaceCore(oldStr, oldStr.m_Length, "", 0)
    515     '       Else
    516                 Return ReplaceCore(oldStr, oldStr.m_Length, newStr, newStr.m_Length)
    517     '       End If
    518         End Function
    519 
    520         Const Function Replace(oldStr As *StrChar, newStr As *StrChar) As String
    521             If oldStr = 0 Then Debug 'Throw ArgumentNullException
    522             If newStr = 0 Then newStr = ""
    523             Return ReplaceCore(oldStr, lstrlen(oldStr), newStr, lstrlen(newStr))
    524         End Function
    525 
    526         Const Function Replace(oldStr As *StrChar, oldLen As Long, newStr As *StrChar, newLen As Long) As String
    527             If oldStr = 0 Then Debug 'Throw ArgumentNullException
    528             If newStr = 0 Then
    529                 newStr = ""
    530                 newLen = 0
    531             End If
    532             Return ReplaceCore(oldStr, oldLen, newStr, newLen)
     470            Dim sb = New System.Text.StringBuilder(This)
     471            sb.Replace(oldChar, newChar)
     472            Replace = sb.ToString
     473        End Function
     474
     475        Const Function Replace(oldStr As String, newStr As String) As String
     476            Dim sb = New System.Text.StringBuilder(This)
     477            sb.Replace(oldStr, newStr)
     478            Return sb.ToString
    533479        End Function
    534480
    535481        Const Function ToLower() As String
    536             ToLower.ReSize(m_Length)
     482            Dim sb = New System.Text.StringBuilder(m_Length)
     483            sb.Length = m_Length
    537484            Dim i As Long
    538485            For i = 0 To ELM(m_Length)
    539                 ToLower.Chars[i] = _System_ASCII_ToLower(Chars[i])
     486                sb[i] = _System_ASCII_ToLower(Chars[i])
    540487            Next
     488            Return sb.ToString
    541489        End Function
    542490
    543491        Const Function ToUpper() As String
    544             ToUpper.ReSize(m_Length)
     492            Dim sb = New System.Text.StringBuilder(m_Length)
     493            sb.Length = m_Length
    545494            Dim i As Long
    546495            For i = 0 To ELM(m_Length)
    547                 ToUpper.Chars[i] = _System_ASCII_ToUpper(Chars[i])
     496                sb[i] = _System_ASCII_ToUpper(Chars[i])
    548497            Next
    549         End Function
    550     /*
    551         Sub Swap(ByRef x As String)
    552             Dim tempLen As Long
    553             Dim tempChars As *StrChar
    554             tempLen = x.m_Length
    555             tempChars = x.Chars
    556             x.m_Length = This.m_Length
    557             x.Chars = This.Chars
    558             This.m_Length = tempLen
    559             This.Chars = tempChars
    560         End Sub
    561     */
     498            Return sb.ToString
     499        End Function
     500
    562501        Override Function ToString() As String
    563             Return This
    564         End Function
    565 
     502            ToString = This
     503        End Function
     504
     505        Const Function Clone() As String
     506            Clone = This
     507        End Function
    566508        Static Function Copy(s As String) As String
    567             Copy.ReSize(s.m_Length)
    568             memcpy(Copy.Chars, This.Chars, SizeOf (StrChar) * m_Length)
    569         End Function
     509            Copy = New String(s.Chars, s.m_Length)
     510        End Function
     511
     512        Sub CopyTo(sourceIndex As Long, destination As *StrChar, destinationIndex As Long, count As Long)
     513            ActiveBasic.Strings.ChrCopy(VarPtr(destination[destinationIndex]), VarPtr(Chars[sourceIndex]), count As SIZE_T)
     514        End Sub
    570515
    571516        Override Function GetHashCode() As Long
     
    577522            Return _System_GetHashFromWordArray(Chars As *Word, size)
    578523        End Function
     524
     525        Function PadLeft(total As Long) As String
     526            PadLeft(total, &h30 As StrChar)
     527        End Function
     528
     529        Function PadLeft(total As Long, c As StrChar) As String
     530            If total < 0 Then
     531                'Throw New ArgumentException
     532            End If
     533            If total >= m_Length Then
     534                Return This
     535            End If
     536            Dim sb = New System.Text.StringBuilder(total)
     537            sb.Append(c, total - m_Length)
     538            sb.Append(This)
     539            Return sb.ToString
     540        End Function
     541
     542        Function PadRight(total As Long) As String
     543            PadLeft(total, &h30 As StrChar)
     544        End Function
     545
     546        Function PadRight(total As Long, c As StrChar) As String
     547            If total < 0 Then
     548                'Throw New ArgumentException
     549            End If
     550            If total >= m_Length Then
     551                Return This
     552            End If
     553            Dim sb = New System.Text.StringBuilder(total)
     554            sb.Append(This)
     555            sb.Append(c, total - m_Length)
     556            Return sb.ToString
     557        End Function
    579558    Private
    580         ' メモリ確保に失敗すると元の文字列は失われない。(例外安全でいう強い保障)
    581559        Function AllocStringBuffer(textLength As Long) As *StrChar
    582560            If textLength < 0 Then
    583561                Return 0
    584             ElseIf textLength > m_Length or Chars = 0 Then
    585                 AllocStringBuffer = _System_realloc(Chars, SizeOf(StrChar) * (textLength + 1))
    586                 If AllocStringBuffer <> 0 Then
    587                     m_Length = textLength
    588                     Chars = AllocStringBuffer
    589                 End If
    590             Else
    591                 m_Length = textLength
    592                 AllocStringBuffer = Chars
    593             End If
    594         End Function
    595 
    596         Function ReplaceCore(oldStr As *StrChar, oldLen As Long, newStr As *StrChar, newLen As Long) As String
    597             If oldLen = 0 Then
    598                 Debug 'Throw ArgumentException
    599             End If
    600             Dim tmp As String
    601             With tmp
    602                 Dim current = 0 As Long
    603                 Do
    604                     Dim pos = IndexOf(oldStr, current)
    605                     If pos = -1 Then
    606                         Exit Do
    607                     End If
    608                     .Append(VarPtr(Chars[current]), pos - current)
    609                     .Append(newStr, newLen)
    610                     current = pos + oldLen
    611                 Loop
    612                 .Append(VarPtr(Chars[current]), m_Length - current)
    613             End With
    614             Return tmp
     562            End If
     563            AllocStringBuffer = GC_malloc_atomic(SizeOf(StrChar) * (textLength + 1))
     564            If AllocStringBuffer = 0 Then
     565                'Throw New OutOfMemoryException
     566            End If
     567            m_Length = textLength
     568            Chars = AllocStringBuffer
    615569        End Function
    616570
    617571        Sub AssignFromStrChar(text As *StrChar, textLength As Long)
    618             If text = Chars Then Exit Sub
    619             If AllocStringBuffer(textLength) <> 0 Then
    620                 memcpy(Chars, text, SizeOf (StrChar) * textLength)
    621                 Chars[m_Length] = 0
     572            AllocStringBuffer(textLength)
     573            ActiveBasic.Strings.ChrCopy(Chars, text, textLength As SIZE_T)
     574            Chars[m_Length] = 0
     575        End Sub
     576
     577        Const Sub rangeCheck(index As Long)
     578            If index < 0 Or index > m_Length Then
     579                Debug 'ArgumentOutOfRangeException
     580            End If
     581        End Sub
     582       
     583        Const Sub rangeCheck(start As Long, length As Long)
     584            If start < 0 Or start > This.m_Length Or length < 0 Then
     585                Debug 'ArgumentOutOfRangeException
    622586            End If
    623587        End Sub
  • Include/basic/command.sbp

    r269 r272  
    163163Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
    164164Sub INPUT_FromFile(FileNumber As Long)
    165     Dim i As Long ,i2 As Long, i3 As Long
    166     Dim buffer As String
     165    FileNumber--
     166   
     167    Dim i = 0 As Long
     168    Dim i2 As Long, i3 As Long
     169    Dim buffer = New System.Text.StringBuilder(GetFileSize(_System_hFile[FileNumber], 0) + 1)
    167170    Dim temp[1] As StrChar
    168171    Dim dwAccessBytes As DWord
    169172    Dim IsStr As Long
    170173
    171     FileNumber--
    172 
    173     buffer=ZeroString(GetFileSize(_System_hFile[FileNumber],0) + 1)
    174 
    175     i=0
    176174    While 1
    177175        '次のデータをサーチ
     
    226224
    227225        'データを変数に格納
    228         _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buffer, i3)
     226        _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buffer.ToString)
    229227
    230228
     
    234232End Sub
    235233
    236 Sub _System_Input_SetArgument(arg As VoidPtr, dataType As DWord, ByRef buf As String, bufLen As Long)
     234Sub _System_Input_SetArgument(arg As VoidPtr, dataType As DWord, buf As String)
    237235    Select Case dataType
    238236        Case _System_Type_Double
     
    253251            Dim pTempStr As *String
    254252            pTempStr = arg As *String
    255             pTempStr->ReSize(bufLen)
    256             memcpy(pTempStr->Chars, buf.Chars, SizeOf (StrChar) * pTempStr->Length)
    257             pTempStr->Chars[pTempStr->Length] = 0
     253            pTempStr[0] = buf
    258254    End Select
    259255End Sub
     
    269265Dim _System_UsingStrData[_System_MAX_PARMSNUM] As *Char     'TODO: 暫定対応(動作未確認)
    270266Dim _System_UsingDataType[_System_MAX_PARMSNUM] As DWord
     267/*
    271268Function _System_GetUsingFormat(UsingStr As String) As String
    272269    Dim i2 As Long, i3 As Long, i4 As Long, i5 As Long, ParmNum As Long
    273270    Dim temporary[255] As StrChar
    274     Dim buffer As String
    275 
    276     buffer = ZeroString(1024)
     271    Dim buffer = New System.Text.StringBuilder(1024)
    277272
    278273    ParmNum = 0
     
    334329            If length_buf>=length_num Then
    335330                '通常時
    336                 _System_FillChar(VarPtr(buffer.Chars[i3]), length_buf - length_num, &h20) 'Asc(" ")
     331                ActiveBasic.Strings.Detail.ChrFill(VarPtr(buffer.Chars[i3]), length_buf - length_num, &h20) 'Asc(" ")
    337332
    338333                i3 += length_buf - length_num
     
    354349            Else
    355350                '表示桁が足りないとき
    356                 _System_FillChar(VarPtr(buffer.Chars[i3]), length_buf, &h23) 'Asc("#")
     351                ActiveBasic.Strings.Detail.ChrFill(VarPtr(buffer.Chars[i3]), length_buf, &h23) 'Asc("#")
    357352                i3 += length_buf
    358353            End If
     
    395390                    i5=i4
    396391                Else
    397                     _System_FillChar(VarPtr(buffer.Chars[i3]), i4, &h20) 'Asc(" ")
     392                    ActiveBasic.Strings.Detail.ChrFill(VarPtr(buffer.Chars[i3]), i4, &h20) 'Asc(" ")
    398393                End If
    399394                memcpy(VarPtr(buffer.Chars[i3]), _System_UsingStrData[ParmNum], SizeOf (StrChar) * i5)
     
    411406    Wend
    412407
    413     _System_GetUsingFormat = Left$(buffer, lstrlen(buffer))
     408    _System_GetUsingFormat = buffer.ToString(0, lstrlen(StrBPtr(buffer)))
    414409End Function
     410*/
    415411Sub PRINTUSING_ToFile(FileNumber As Long, UsingStr As String)
    416412    Dim dwAccessByte As DWord
  • Include/basic/dos_console.sbp

    r268 r272  
    88
    99#include <api_console.sbp>
     10#include <Classes/ActiveBasic/Strings/Strings.ab>
    1011
    1112Dim _System_hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
     
    1718'---------------------------------------------
    1819Sub INPUT_FromPrompt(ShowStr As String)
    19     Dim i As Long, i2 As Long, i3 As Long
    20     Dim buf As String
    2120    Dim InputBuf[1023] As TCHAR
    2221    Dim dwAccessBytes As DWord
     
    3029    If InputBuf[dwAccessBytes-2] = &h0d And InputBuf[dwAccessBytes-1] = &h0a Then
    3130        InputBuf[dwAccessBytes-2] = 0
     31        dwAccessBytes -= 2
    3232    End If
    33     Dim InputStr As String(InputBuf)
     33
     34    If dwAccessBytes = 0 Then Goto *InputReStart
    3435
    3536    'データを変数に格納
    36     i=0
    37     i2=0
    38     buf.ReSize(lstrlen(InputStr) + 1, 0)
    39     Dim comma As Char
    40     comma = &h2c 'Asc(",")
    41     While 1
    42         i3=0
    43         While 1
    44             If InputStr[i2]=comma Then
    45                 buf[i3]=0
    46                 Exit While
    47             End If
    48 
    49             buf[i3]=InputStr[i2]
    50 
    51             If InputStr[i2]=0 Then Exit While
    52 
    53             i2++
    54             i3++
    55         Wend
    56 
    57         _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buf, i3)
    58 
    59         i++
    60         If _System_InputDataPtr[i]=0 And InputStr[i2]=comma Then
     37    Const comma = &h2c As StrChar 'Asc(",")
     38    Dim broken = ActiveBasic.Strings.Detail.Split(New String(InputBuf, dwAccessBytes As Long), comma)
     39    Dim i As Long
     40    For i = 0 To ELM(broken.Count)
     41        If _System_InputDataPtr[i] = 0 Then
    6142            PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
    6243            Goto *InputReStart
    63         ElseIf InputStr[i2]=0 Then
    64             If _System_InputDataPtr[i]<>0 Then
    65                 PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
    66                 Goto *InputReStart
    67             Else
    68                 Exit While
    69             End If
    7044        End If
     45        _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], broken[i].ToString)
     46    Next
    7147
    72         i2++
    73     Wend
     48    If _System_InputDataPtr[i]<>0 Then
     49        PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
     50        Goto *InputReStart
     51    End If
    7452End Sub
    7553
     
    9068    _System_free(pszOut)
    9169#else
    92     WriteConsole(_System_hConsoleOut, buf.Chars, buf.Length, dwAccessBytes, 0)
     70    WriteConsole(_System_hConsoleOut, buf.StrPtr, buf.Length, dwAccessBytes, 0)
    9371#endif
    9472End Sub
  • Include/basic/function.sbp

    r269 r272  
    1313
    1414#require <Classes/System/Math.ab>
     15#require <Classes/System/DateTime.ab>
     16#require <Classes/System/Text/StringBuilder.ab>
    1517#require <Classes/ActiveBasic/Math/Math.ab>
     18#require <Classes/ActiveBasic/Strings/Strings.ab>
    1619
    1720
     
    9295End Function
    9396
    94 Const RAND_MAX=&H7FFFFFFF
    95 Dim _System_RndNext=1 As DWord
     97Const RAND_MAX = &H7FFFFFFF
     98Dim _System_RndNext = 1 As DWord
    9699
    97100Function rand() As Long
    98101    _System_RndNext = _System_RndNext * 1103515245 + 12345
    99     rand = _System_RndNext >> 1
     102    rand = (_System_RndNext >> 1) As Long
    100103End Function
    101104
     
    233236
    234237Function Chr$(code As StrChar) As String
    235     Chr$ = ZeroString(1)
    236     Chr$[0] = code
     238    Chr$ = New String(code, 1)
    237239End Function
    238240
     
    252254Function ChrW(c As UCSCHAR) As String
    253255    If c <= &hFFFF Then
    254         ChrW.ReSize(1)
    255         ChrW[0] = c As WCHAR
     256        Return New String(c As StrChar, 1)
    256257    ElseIf c < &h10FFFF Then
    257         ChrW.ReSize(2)
    258         ChrW[0] = &hD800 Or (c >> 10)
    259         ChrW[1] = &hDC00 Or (c And &h3FF)
    260     Else
    261         ' OutOfRangeException
     258        Dim t[1] = [&hD800 Or (c >> 10), &hDC00 Or (c And &h3FF)] As StrChar
     259        Return New String(t, 2)
     260    Else
     261        'ArgumentOutOfRangeException
    262262    End If
    263263End Function
     
    265265
    266266Function Date$() As String
    267     Dim st As SYSTEMTIME
    268     GetLocalTime(st)
     267    Dim date = DateTime.Now
     268    Dim buf = New System.Text.StringBuilder(10)
    269269
    270270    'year
    271     Date$=Str$(st.wYear)
     271    buf.Append(date.Year)
    272272
    273273    'month
    274     If st.wMonth<10 Then
    275         Date$=Date$+"/0"
    276     Else
    277         Date$=Date$+"/"
    278     End If
    279     Date$=Date$+Str$(st.wMonth)
     274    If date.Month < 10 Then
     275        buf.Append("/0")
     276    Else
     277        buf.Append("/")
     278    End If
     279    buf.Append(date.Month)
    280280
    281281    'day
    282     If st.wDay<10 Then
    283         Date$=Date$+"/0"
    284     Else
    285         Date$=Date$+"/"
    286     End If
    287     Date$=Date$+Str$(st.wDay)
     282    If date.Day < 10 Then
     283        buf.Append("/0")
     284    Else
     285        buf.Append("/")
     286    End If
     287    buf.Append(date.Day)
     288
     289    Date$ = buf.ToString
    288290End Function
    289291
     
    358360End Function
    359361
    360 Function Left$(buf As String, length As Long) As String
    361     Left$ = ZeroString(length)
    362     memcpy(StrPtr(Left$), StrPtr(buf), SizeOf (StrChar) * length)
    363 End Function
    364 
    365 Function Mid$(buf As String, StartPos As Long)(ReadLength As Long) As String
    366     Dim length As Long
    367 
    368     StartPos--
    369     If StartPos<0 Then
    370         'error
    371         'Debug
    372         Exit Function
    373     End If
    374 
    375     length=Len(buf)
    376     If length<=StartPos Then Exit Function
    377 
    378     If ReadLength=0 Then
    379         ReadLength=length-StartPos
    380     End If
    381 
    382     If ReadLength>length-StartPos Then
    383         ReadLength=length-StartPos
    384     End If
    385 
    386     Mid$=ZeroString(ReadLength)
    387     memcpy(StrPtr(Mid$), VarPtr(buf.Chars[StartPos]), SizeOf (StrChar) * ReadLength)
    388 End Function
    389 
    390 Function Oct$(num As DWord) As String
    391     Dim i As DWord, i2 As DWord
    392 
    393     For i=10 To 1 Step -1
    394         If (num \ CDWord(8^i)) And &H07 Then
    395             Exit For
    396         End If
    397     Next
    398 
    399     Oct$=ZeroString(i+1)
    400     i2=0
     362Function Left$(s As String, length As Long) As String
     363    Left$ = s.Substring(0, System.Math.Min(s.Length, length))
     364End Function
     365
     366Function Mid$(s As String, startPos As Long) As String
     367    startPos--
     368    Mid$ = s.Substring(startPos)
     369End Function
     370
     371Function Mid$(s As String, startPos As Long, readLength = 0 As Long) As String
     372    startPos--
     373    Dim length = s.Length
     374    Mid$ = s.Substring(System.Math.Min(startPos, length), System.Math.Min(readLength, length - startPos))
     375End Function
     376
     377Const _System_MaxFigure_Oct_QW = 22 As DWord 'QWORD_MAX = &o1,777,777,777,777,777,777,777
     378Function Oct$(n As QWord) As String
     379    Dim s[ELM(_System_MaxFigure_Oct_QW)] As StrChar
     380    Dim i = ELM(_System_MaxFigure_Oct_QW) As Long
    401381    Do
    402         Oct$[i2] = &h30 + ((num \ CDWord(8 ^ i)) And &H07) As StrChar ' &h30 = Asc("0")
    403         If i=0 Then Exit Do
     382        s[i] = ((n And &o7) + &h30) As StrChar '&h30 = Asc("0")
     383        n >>= 3
     384        If n = 0 Then
     385            Return New String(s + i, _System_MaxFigure_Oct_QW - i)
     386        End If
    404387        i--
    405         i2++
    406388    Loop
    407389End Function
    408390
    409 Function Right$(buf As String, length As Long) As String
    410     Dim i As Long
    411 
    412     i=Len(buf)
    413     If i>length Then
    414         Right$=ZeroString(length)
    415         memcpy(StrPtr(Right$), VarPtr(buf.Chars[i-length]), SizeOf (StrChar) * length)
    416     Else
    417         Right$=buf
    418     End If
     391Const _System_MaxFigure_Oct_DW = 11 As DWord 'DWORD_MAX = &o37,777,777,777
     392Function Oct$(n As DWord) As String
     393    Dim s[ELM(_System_MaxFigure_Oct_DW)] As StrChar
     394    Dim i = ELM(_System_MaxFigure_Oct_DW) As Long
     395    Do
     396        s[i] = ((n And &o7) + &h30) As StrChar '&h30 = Asc("0")
     397        n >>= 3
     398        If n = 0 Then
     399            Return New String(s + i, _System_MaxFigure_Oct_DW - i)
     400        End If
     401        i--
     402    Loop
     403End Function
     404
     405Function Right$(s As String, length As Long) As String
     406    Right$ = s.Substring(System.Math.Max(0, s.Length - length), s.Length)
    419407End Function
    420408
     
    447435    '値が0の場合
    448436    If value = 0 Then
    449         _System_FillChar(_System_ecvt_buffer, count As SIZE_T, &H30 As StrChar)
     437        ActiveBasic.Strings.ChrFill(_System_ecvt_buffer, count As SIZE_T, &H30 As StrChar)
    450438        _System_ecvt_buffer[count] = 0
    451439        dec = 0
     
    523511        buffer[i] = Asc(".")
    524512        i++
    525         memcpy(VarPtr(buffer[i]), VarPtr(temp[1]), SizeOf (StrChar) * 14)
     513        ActiveBasic.Strings.ChrCopy(VarPtr(buffer[i]), VarPtr(temp[1]), 14)
    526514        i += 14
    527515        buffer[i] = Asc("e")
    528516        i++
    529         _stprintf(VarPtr(buffer[i]), "+%03d", dec - 1)
     517        _stprintf(VarPtr(buffer[i]), "+%03d", dec - 1) 'ToDo: __STRING_UNICODE_WINDOWS_ANSI状態への対応
    530518
    531519        Return MakeStr(buffer)
     
    538526        buffer[i] = Asc(".")
    539527        i++
    540         memcpy(VarPtr(buffer[i]), VarPtr(temp[1]), SizeOf (StrChar) * 14)
     528        ActiveBasic.Strings.ChrCopy(VarPtr(buffer[i]), VarPtr(temp[1]), 14)
    541529        i+=14
    542530        buffer[i] = Asc("e")
    543531        i++
    544         _stprintf(VarPtr(buffer[i]), "+%03d", dec - 1)
     532        _stprintf(VarPtr(buffer[i]), "+%03d", dec - 1) 'ToDo: __STRING_UNICODE_WINDOWS_ANSI状態への対応
    545533
    546534        Return MakeStr(buffer)
     
    603591
    604592    Dim buf[20] As StrChar
    605     buf[20] = 0
     593    'buf[20] = 0
    606594    Dim i = 19 As Long
    607595    Do
     
    640628    Dim i = 9 As Long
    641629    Do
    642         buf[i] = (x Mod 10 + &h30) As StrChar
     630        buf[i] = (x As Int64 Mod 10 + &h30) As StrChar 'Int64への型変換は#117対策
    643631        x \= 10
    644632        If x = 0 Then
    645             Exit Do
     633            Return New String(VarPtr(buf[i]), 10 - i)
    646634        End If
    647635        i--
    648     Loop
    649     Return New String(VarPtr(buf[i]), 10 - i)
     636    Loop   
    650637#endif
    651638End Function
     
    679666End Function
    680667
    681 Function String$(num As Long, buf As String) As String
    682     Dim dwStrPtr As DWord
    683     Dim length As Long
    684 
    685     length=Len(buf)
    686 
    687     'バッファ領域を確保
    688     String$=ZeroString(length*num)
    689 
    690     '文字列をコピー
     668Function String$(n As Long, s As StrChar) As String
     669    Return New String(s, n)
     670End Function
     671       
     672#ifdef _AB4_COMPATIBILITY_STRING$_
     673Function String$(n As Long, s As String) As String
     674    If n < 0 Then
     675        'Throw ArgumentOutOfRangeException
     676    End If
     677
     678    Dim buf = New System.Text.StringBuilder(s.Length * n)
    691679    Dim i As Long
    692     For i=0 To num-1
    693         memcpy(VarPtr(String$.Chars[i*length]), StrPtr(buf), SizeOf (StrChar) * length)
     680    For i = 0 To n
     681        buf.Append(s)
    694682    Next
    695683End Function
     684#else
     685Function String$(n As Long, s As String) As String
     686    If String.IsNullOrEmpty(s) Then
     687        Return New String(0 As StrChar, n)
     688            Else
     689        Return New String(s[0], n)
     690    End If
     691End Function
     692#endif
    696693
    697694Function Time$() As String
    698     Dim st As SYSTEMTIME
    699 
    700     GetLocalTime(st)
     695    Dim time = DateTime.Now
     696
     697    Dim buf = New System.Text.StringBuilder(8)
    701698
    702699    'hour
    703     If st.wHour<10 Then
    704         Time$="0"
    705     End If
    706     Time$=Time$+Str$(st.wHour)
     700    If time.Hour < 10 Then
     701        buf.Append("0")
     702    End If
     703    buf.Append(time.Hour)
    707704
    708705    'minute
    709     If st.wMinute<10 Then
    710         Time$=Time$+":0"
    711     Else
    712         Time$=Time$+":"
    713     End If
    714     Time$=Time$+Str$(st.wMinute)
     706    If time.Minute < 10 Then
     707        buf.Append(":0")
     708    Else
     709        buf.Append(":")
     710    End If
     711    buf.Append(time.Minute)
    715712
    716713    'second
    717     If st.wSecond<10 Then
    718         Time$=Time$+":0"
    719     Else
    720         Time$=Time$+":"
    721     End If
    722     Time$=Time$+Str$(st.wSecond)
     714    If time.Second < 10 Then
     715        buf.Append(":0")
     716    Else
     717        buf.Append(":")
     718    End If
     719    buf.Append(time.Second)
     720    Time$ = buf.ToString
    723721End Function
    724722
     
    738736    If buf[0]=Asc("&") Then
    739737        temporary = New String( buf )
    740         temporary.ToUpper()
     738        temporary = temporary.ToUpper()
    741739        TempPtr = StrPtr(temporary)
    742740        If TempPtr(1)=Asc("O") Then
     
    816814
    817815Function Loc(FileNum As Long) As Long
    818     Dim NowPos As Long, BeginPos As Long
    819 
    820816    FileNum--
    821817
    822     NowPos=SetFilePointer(_System_hFile(FileNum),0,NULL,FILE_CURRENT)
    823     BeginPos=SetFilePointer(_System_hFile(FileNum),0,NULL,FILE_BEGIN)
    824     SetFilePointer(_System_hFile(FileNum),NowPos-BeginPos,NULL,FILE_BEGIN)
    825 
    826     Loc=NowPos-BeginPos
     818    Dim NowPos = SetFilePointer(_System_hFile(FileNum), 0, 0, FILE_CURRENT)
     819    Dim BeginPos = SetFilePointer(_System_hFile(FileNum), 0, 0, FILE_BEGIN)
     820    SetFilePointer(_System_hFile(FileNum), NowPos - BeginPos, 0, FILE_BEGIN)
     821
     822    Loc = NowPos - BeginPos
    827823End Function
    828824
     
    851847    _System_pGC->__free(lpMem)
    852848End Sub
    853 
    854849
    855850Function _System_malloc(stSize As SIZE_T) As VoidPtr
     
    10441039End Function
    10451040
    1046 Sub _System_FillChar(p As PWSTR, n As SIZE_T, c As WCHAR)
    1047     Dim i As SIZE_T
    1048     For i = 0 To ELM(n)
    1049         p[i] = c
    1050     Next
    1051 End Sub
    1052 
    1053 Sub _System_FillChar(p As PSTR, n As SIZE_T, c As SByte)
    1054     Dim i As SIZE_T
    1055     For i = 0 To ELM(n)
    1056         p[i] = c
    1057     Next
    1058 End Sub
    1059 
    10601041Function _System_ASCII_IsUpper(c As WCHAR) As Boolean
    10611042    Return c As DWord - &h41 < 26 ' &h41 = Asc("A")
     
    10961077Function _System_ASCII_ToUpper(c As SByte) As SByte
    10971078    Return _System_ASCII_ToUpper(c As Byte As WCHAR) As Byte As SByte
    1098 End Function
    1099 
    1100 Function _System_ChrCpy(dst As PCWSTR, src As PCWSTR, size As SIZE_T) As PCWSTR
    1101     memcpy(dst, src, size * SizeOf (WCHAR))
    1102     Return dst
    1103 End Function
    1104 
    1105 Function _System_ChrCpy(dst As PCSTR, src As PCSTR, size As SIZE_T) As PCSTR
    1106     memcpy(dst, src, size)
    1107     Return dst
    1108 End Function
    1109 
    1110 Function _System_StrCmp(s1 As PCSTR, s2 As PCSTR) As Long
    1111     Dim i = 0 As SIZE_T
    1112     While s1[i] = s2[i]
    1113         If s1[i] = 0 Then
    1114             Exit While
    1115         End If
    1116         i++
    1117     Wend
    1118     _System_StrCmp = s1[i] - s2[i]
    1119 End Function
    1120 
    1121 Function _System_StrCmp(s1 As PCWSTR, s2 As PCWSTR) As Long
    1122     Dim i = 0 As SIZE_T
    1123     While s1[i] = s2[i]
    1124         If s1[i] = 0 Then
    1125             Exit While
    1126         End If
    1127         i++
    1128     Wend
    1129     _System_StrCmp = s1[i] - s2[i]
    1130 End Function
    1131 
    1132 Function _System_StrCmpN(s1 As PCSTR, s2 As PCSTR, size As SIZE_T) As Long
    1133     Dim i = 0 As SIZE_T
    1134     For i = 0 To ELM(size)
    1135         _System_StrCmpN = s1[i] - s2[i]
    1136         If _System_StrCmpN <> 0 Then
    1137             Exit Function
    1138         End If
    1139     Next
    1140 End Function
    1141 
    1142 Function _System_StrCmpN(s1 As PCWSTR, s2 As PCWSTR, size As SIZE_T) As Long
    1143     Dim i = 0 As SIZE_T
    1144     For i = 0 To ELM(size)
    1145         _System_StrCmpN = s1[i] - s2[i]
    1146         If _System_StrCmpN <> 0 Then
    1147             Exit Function
    1148         End If
    1149     Next
    1150 End Function
    1151 
    1152 Function _System_MemChr(s As PCSTR, c As CHAR, size As SIZE_T) As PCSTR
    1153     Dim i As SIZE_T
    1154     For i = 0 To ELM(size)
    1155         If s[i] = c Then
    1156             Return VarPtr(s[i])
    1157         End If
    1158     Next
    1159     Return 0
    1160 End Function
    1161 
    1162 Function _System_MemChr(s As PCWSTR, c As WCHAR, size As SIZE_T) As PCWSTR
    1163     Dim i As SIZE_T
    1164     For i = 0 To ELM(size)
    1165         If s[i] = c Then
    1166             Return VarPtr(s[i])
    1167         End If
    1168     Next
    1169     Return 0
    1170 End Function
    1171 
    1172 Function _System_MemPBrk(str As PCSTR, cStr As SIZE_T, Chars As PCSTR, cChars As SIZE_T) As PCSTR
    1173     Dim i As SIZE_T
    1174     For i = 0 To ELM(cStr)
    1175         If _System_MemChr(Chars, str[i], cChars) Then
    1176             Return VarPtr(str[i])
    1177         End If
    1178     Next
    1179     Return 0
    1180 End Function
    1181 
    1182 Function _System_MemPBrk(str As PCWSTR, cStr As SIZE_T, Chars As PCWSTR, cChars As SIZE_T) As PCWSTR
    1183     Dim i As SIZE_T
    1184     For i = 0 To ELM(cStr)
    1185         If _System_MemChr(Chars, str[i], cChars) Then
    1186             Return VarPtr(str[i])
    1187         End If
    1188     Next
    1189     Return 0
    11901079End Function
    11911080
  • Include/basic/prompt.sbp

    r269 r272  
    7575
    7676Sub _PromptSys_Initialize()
    77 _PromptSys_hInitFinish = CreateEvent(0, FALSE, FALSE, 0)
    78 Dim _PromptSys_hThread = CreateThread(0, 0, AddressOf(PromptMain), 0, 0, _PromptSys_dwThreadID)
    79 If _PromptSys_hThread = 0 Then
    80     Debug
    81     ExitProcess(1)
    82 End If
    83 WaitForSingleObject(_PromptSys_hInitFinish, INFINITE)
     77    _PromptSys_hInitFinish = CreateEvent(0, FALSE, FALSE, 0)
     78    Dim _PromptSys_hThread = CreateThread(0, 0, AddressOf(PromptMain), 0, 0, _PromptSys_dwThreadID)
     79    If _PromptSys_hThread = 0 Then
     80        Debug
     81        ExitProcess(1)
     82    End If
     83    WaitForSingleObject(_PromptSys_hInitFinish, INFINITE)
    8484End Sub
    8585
     
    191191                            charLen = 1
    192192                        EndIf
    193                         _PromptSys_GetTextExtentPoint32(hdc, VarPtr(buf.Chars[i2]) As *StrChar, charLen, sz)
     193                        Dim p = buf.StrPtr
     194                        _PromptSys_GetTextExtentPoint32(hdc, VarPtr(p[i2]) As *StrChar, charLen, sz)
    194195                        currentLineCharInfo[.x + 1].StartPos = currentLineCharInfo[.x].StartPos + sz.cx
    195196/*
     
    363364*/
    364365        Else
    365             _PromptSys_InputStr[_PromptSys_InputLen] = wParam As Byte
     366            Dim t = wParam As TCHAR
     367            TempStr = New String(VarPtr(t), 1)
     368            _PromptSys_InputStr[_PromptSys_InputLen] = TempStr[0]
    366369            _PromptSys_InputLen++
    367 
    368             TempStr.ReSize(1)
    369             TempStr[0] = wParam As Char
    370370        End If
    371371
     
    403403            Return 0
    404404        End If
    405         Dim tempStr As String
     405        Dim tempStr = Nothing As String
    406406        Dim str As *StrChar
    407407#ifdef __STRING_IS_NOT_UNICODE
    408408        Dim size = _PromptWnd_GetCompositionStringA(himc, str)
    409         tempStr.Assign(str, size)
     409        tempStr = New String(str, size As Long)
    410410#else
    411411        Dim osver = System.Environment.OSVersion
     
    415415                Dim strA As PCSTR
    416416                Dim sizeA = _PromptWnd_GetCompositionStringA(himc, strA)
    417                 tempStr.AssignFromMultiByte(strA, sizeA)
     417                tempStr = New String(strA, sizeA As Long)
    418418            Else
    419419                Dim size = _PromptWnd_GetCompositionStringW(himc, str)
    420                 tempStr.Assign(str, size \ SizeOf (WCHAR))
     420                tempStr = New String(str, (size \ SizeOf (WCHAR)) As Long)
    421421            End If
    422422        End With
     
    425425        _System_free(str)
    426426
    427         memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), tempStr.Chars, SizeOf (StrChar) * tempStr.Length)
     427        ActiveBasic.Strings.ChrCopy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), tempStr.StrPtr, tempStr.Length As SIZE_T)
    428428        _PromptSys_InputLen += tempStr.Length
    429429
     
    583583
    584584Sub INPUT_FromPrompt(showStr As String)
    585     Dim i As Long, i2 As Long, i3 As Long
    586     Dim buf As String
    587 
    588585*InputReStart
    589586
     
    599596
    600597    'Set value to variable
    601     i = 0
    602     i2 = 0
    603     buf = ZeroString(lstrlen(_PromptSys_InputStr))
    604     While 1
    605         i3 = 0
    606         While 1
    607             If _PromptSys_InputStr[i2] = &h2c Then
    608                 buf.Chars[i3] = 0
    609                 Exit While
    610             End If
    611 
    612             buf.Chars[i3] = _PromptSys_InputStr[i2]
    613 
    614             If _PromptSys_InputStr[i2] = 0 Then Exit While
    615 
    616             i2++
    617             i3++
    618         Wend
    619 
    620         _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buf, i3)
    621 
    622         i++
    623         If _System_InputDataPtr[i] = 0 and _PromptSys_InputStr[i2] = &h2c Then 'Asc(",")
     598    Const comma = &h2c As StrChar 'Asc(",")
     599    Dim broken = ActiveBasic.Strings.Detail.Split(New String(_PromptSys_InputStr), comma)
     600    Dim i As Long
     601    For i = 0 To ELM(broken.Count)
     602        If _System_InputDataPtr[i] = 0 Then
    624603            ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
    625604            Goto *InputReStart
    626         ElseIf _PromptSys_InputStr[i2] = 0 Then
    627             If _System_InputDataPtr[i]<>0 Then
    628                 ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
    629                 Goto *InputReStart
    630             Else
    631                 Exit While
    632             End If
    633         End If
    634 
    635         i2++
    636     Wend
     605        End If
     606        _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], broken[i].ToString)
     607    Next
     608
     609    If _System_InputDataPtr[i]<>0 Then
     610        ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
     611        Goto *InputReStart
     612    End If
    637613End Sub
    638614
  • Include/com/bstring.ab

    r267 r272  
    88
    99Class BString
    10     Sub Init(s As PCSTR, len As DWord)
    11         Dim lenBS = MultiByteToWideChar(CP_THREAD_ACP, 0, s, len As Long, 0, 0)
    12         bs = SysAllocStringLen(0, lenBS)
    13         MultiByteToWideChar(CP_THREAD_ACP, 0, s, len As Long, bs, lenBS)
    14     End Sub
     10    'Inherits System.IDisposable, System.ICloneable
    1511Public
    1612    Sub BString()
     
    2218    End Sub
    2319
    24     Sub BString(ByRef s As BString)
     20    Sub BString(s As BString)
    2521        Init(s.bs, s.Length)
    2622    End Sub
     
    4440    End Sub
    4541
    46     Sub BString(ByRef s As String)
     42    Sub BString(s As String)
    4743        Init(s.StrPtr, s.Length As DWord)
    4844    End Sub
     
    5248    End Sub
    5349
    54     Sub Assign(ByRef bstr As BString)
     50    Sub Assign(bstr As BString)
    5551        Clear()
    5652        Init(bstr, bstr.Length)
     
    7066        BString.Copy(Copy, bs)
    7167    End Function
     68
     69    /*Override*/ Function Clone() As BString
     70        Return New BString(This)
     71    End Function
     72
     73    /*Override*/ Sub Dispose()
     74        Clear()
     75    End Sub
    7276
    7377    Sub Clear()
     
    134138    bs As BSTR
    135139
     140    Sub Init(s As PCSTR, len As DWord)
     141        Dim lenBS = MultiByteToWideChar(CP_THREAD_ACP, 0, s, len As Long, 0, 0)
     142        bs = SysAllocStringLen(0, lenBS)
     143        MultiByteToWideChar(CP_THREAD_ACP, 0, s, len As Long, bs, lenBS)
     144    End Sub
     145
    136146    Static Sub Copy(ByRef dst As BSTR, ByVal src As BSTR)
    137147        dst = SysAllocStringLen(src, SysStringLen(src))
  • Include/system/string.sbp

    r258 r272  
    55#define _INC_BASIC_STRING
    66
    7 Function StrPtr(buf As *StrChar) As *StrChar
    8     StrPtr = buf
     7Function StrPtr(s As String) As *StrChar
     8    StrPtr = s.StrPtr
    99End Function
    1010
     
    9393
    9494Function GetStr(s As String, ByRef mbs As PSTR) As SIZE_T
    95     Return GetStr(s.Chars, s.Length As SIZE_T, mbs)
     95    Return GetStr(s.StrPtr, s.Length As SIZE_T, mbs)
    9696End Function
    9797
    9898Function GetStr(s As String, ByRef wcs As PWSTR) As SIZE_T
    99     Return GetStr(s.Chars, s.Length As SIZE_T, wcs)
     99    Return GetStr(s.StrPtr, s.Length As SIZE_T, wcs)
    100100End Function
    101101
     
    117117
    118118Function GetWCStr(s As String, ByRef wcs As PWSTR) As SIZE_T
    119     Return GetStr(s.Chars, s.Length As SIZE_T, wcs)
     119    Return GetStr(s.StrPtr, s.Length As SIZE_T, wcs)
    120120End Function
    121121
     
    137137
    138138Function GetMBStr(s As String, ByRef mbs As PSTR) As SIZE_T
    139     Return GetStr(s.Chars, s.Length As SIZE_T, mbs)
     139    Return GetStr(s.StrPtr, s.Length As SIZE_T, mbs)
    140140End Function
    141141
     
    157157
    158158Function GetTCStr(s As String, ByRef tcs As PCTSTR) As SIZE_T
    159     Return GetStr(s.Chars, s.Length As SIZE_T, tcs)
     159    Return GetStr(s.StrPtr, s.Length As SIZE_T, tcs)
    160160End Function
    161161
     
    177177
    178178Function GetSCStr(s As String, ByRef ss As *StrChar) As SIZE_T
    179     Return GetStr(s.Chars, s.Length As SIZE_T, ss)
     179    Return GetStr(s.StrPtr, s.Length As SIZE_T, ss)
    180180End Function
    181181
     
    197197
    198198Function ToWCStr(s As String) As PWSTR
    199     GetStr(s.Chars, s.Length As SIZE_T, ToWCStr)
     199    GetStr(s.StrPtr, s.Length As SIZE_T, ToWCStr)
    200200End Function
    201201
     
    217217
    218218Function ToMBStr(s As String) As PSTR
    219     GetStr(s.Chars, s.Length As SIZE_T, ToMBStr)
     219    GetStr(s.StrPtr, s.Length As SIZE_T, ToMBStr)
    220220End Function
    221221
     
    237237
    238238Function ToTCStr(s As String) As PCTSTR
    239     GetStr(s.Chars, s.Length As SIZE_T, ToTCStr)
     239    GetStr(s.StrPtr, s.Length As SIZE_T, ToTCStr)
    240240End Function
    241241
     
    257257
    258258Function ToSCStr(s As String) As *StrChar
    259     GetStr(s.Chars, s.Length As SIZE_T, ToSCStr)
     259    GetStr(s.StrPtr, s.Length As SIZE_T, ToSCStr)
    260260End Function
    261261
  • Include/windows/WindowHandle.sbp

    r237 r272  
    55
    66#ifdef _WIN64
     7Declare Function _System_GetClassLongPtr Lib "user32" Alias _FuncName_GetClassLongPtr (hWnd As HWND, nIndex As Long) As LONG_PTR
     8Declare Function _System_SetClassLongPtr Lib "user32" Alias _FuncName_SetClassLongPtr (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
    79Declare Function _System_GetWindowLongPtr Lib "user32" Alias _FuncName_GetWindowLongPtr (hWnd As HWND, nIndex As Long) As LONG_PTR
    810Declare Function _System_SetWindowLongPtr Lib "user32" Alias _FuncName_SetWindowLongPtr (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
    911#else
     12Declare Function _System_GetClassLongPtr Lib "user32" Alias _FuncName_GetClassLong (hWnd As HWND, nIndex As Long) As LONG_PTR
     13Declare Function _System_SetClassLongPtr Lib "user32" Alias _FuncName_SetClassLong (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
    1014Declare Function _System_GetWindowLongPtr Lib "user32" Alias _FuncName_GetWindowLong (hWnd As HWND, nIndex As Long) As LONG_PTR
    1115Declare Function _System_SetWindowLongPtr Lib "user32" Alias _FuncName_SetWindowLong (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
     
    3135Declare Function _System_Isiconic Lib "user32" Alias "Isiconic" (hWnd As HWND) As BOOL
    3236Declare Function _System_GetClientRect Lib "user32" Alias "GetClientRect" (hWnd As HWND, ByRef Rect As RECT) As BOOL
     37Declare Function _System_GetProp Lib "user32" Alias _FuncName_GetProp (hWnd As HWND, pString As PCTSTR) As HANDLE
     38Declare Function _System_SetProp Lib "user32" Alias _FuncName_SetProp (hWnd As HWND, pString As PCTSTR, hData As HANDLE) As BOOL
     39Declare Function _System_GetClassName Lib "user32" Alias _FuncName_GetClassName (hWnd As HWND, lpClassName As PTSTR, nMaxCount As Long) As Long
     40Declare Function _System_GetScrollInfo Lib "user32" Alias "GetScrollInfo" (hWnd As HWND, fnBar As Long, ByRef lpsi As SCROLLINFO) As BOOL
     41Declare Function _System_SetScrollInfo Lib "user32" Alias "SetScrollInfo" (hWnd As HWND, fnBar As Long, ByRef lpsi As SCROLLINFO, bRedraw As Long) As BOOL
     42Declare Function _System_GetSystemMenu Lib "user32" Alias "GetSystemMenu" (hWnd As HWND, bRevert As BOOL) As HMENU
    3343
    3444Class WindowHandle
     
    116126
    117127    Const Function GetClassLongPtr(index As Long) As LONG_PTR
    118         Return GetClassLongPtr(hwnd, index)
     128        Return _System_GetClassLongPtr(hwnd, index)
    119129    End Function
    120130
    121131    Const Function GetClassName(className As PTSTR, maxCount As Long) As Long
    122         Return GetClassName(className, maxCount)
     132        Return _System_GetClassName(className, maxCount)
    123133    End Function
    124134
     
    161171
    162172    Const Function GetProp(str As String) As HANDLE
    163         Return GetProp(hwnd, ToTCStr(str))
     173        Return _System_GetProp(hwnd, ToTCStr(str))
    164174    End Function
    165175
    166176    Const Function GetProp(psz As PCTSTR) As HANDLE
    167         Return GetProp(hwnd, psz)
     177        Return _System_GetProp(hwnd, psz)
    168178    End Function
    169179
    170180    Const Function GetProp(atom As ATOM) As HANDLE
    171         Return GetProp(hwnd, atom As ULONG_PTR As PCTSTR)
     181        Return _System_GetProp(hwnd, atom As ULONG_PTR As PCTSTR)
    172182    End Function
    173183
    174184    Const Function GetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
    175         Return GetScrollInfo(hwnd, fnBar, si) As Boolean
     185        Return _System_GetScrollInfo(hwnd, fnBar, si) As Boolean
    176186    End Function
    177187
     
    410420
    411421    Function SetClassLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR
    412         Return SetClassLongPtr(hwnd, index, newLong)
     422        Return _System_SetClassLongPtr(hwnd, index, newLong)
    413423    End Function
    414424
     
    430440
    431441    Function SetProp(str As String, hData As HANDLE) As Boolean
    432         Return SetProp(hwnd, ToTCStr(str), hData) As Boolean
     442        Return _System_SetProp(hwnd, ToTCStr(str), hData) As Boolean
    433443    End Function
    434444
    435445    Function SetProp(psz As PCTSTR, hData As HANDLE) As Boolean
    436         Return SetProp(hwnd, psz, hData) As Boolean
     446        Return _System_SetProp(hwnd, psz, hData) As Boolean
    437447    End Function
    438448
    439449    Function SetProp(atom As ATOM, hData As HANDLE) As Boolean
    440         Return SetProp(atom As ULONG_PTR As PCTSTR, hData) As Boolean
     450        Return SetProp((atom As ULONG_PTR) As PCTSTR, hData) As Boolean
    441451    End Function
    442452
    443453    Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO, redraw As Boolean) As Boolean
    444         Return SetScrollInfo(hwnd, fnBar, si, redraw) As Boolean
     454        Return _System_SetScrollInfo(hwnd, fnBar, si, redraw) As Boolean
    445455    End Function
    446456
    447457    Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
    448         Return SetScrollInfo(hwnd, fnBar, si, TRUE) As Boolean
     458        Return _System_SetScrollInfo(hwnd, fnBar, si, TRUE) As Boolean
    449459    End Function
    450460
     
    652662
    653663    Const Function Maximized() As Boolean
    654         Return IsIconic(hwnd) As Boolean
     664        Return IsIconic() As Boolean
    655665    End Function
    656666
     
    727737    Const Function Text() As String
    728738        Dim size = GetWindowTextLength(hwnd) + 1
    729         Dim p = _System_malloc(SizeOf (TCHAR) * size) As PTSTR
     739        Dim p = GC_malloc_atomic(SizeOf (TCHAR) * size) As PTSTR
    730740        Dim length = GetWindowText(hwnd, p, size)
    731         Return New String(p, length As SIZE_T)
     741        Text = New String(p, length As Long)
    732742    End Function
    733743
Note: See TracChangeset for help on using the changeset viewer.