Ignore:
Timestamp:
Jun 29, 2009, 4:03:45 AM (15 years ago)
Author:
イグトランス (egtra)
Message:

最新のコンパイラに通るように修正。参照クラスのセマンティクスに合うように修正(Setter系プロパティの削除など)。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/com/bstring.ab

    r478 r709  
    55
    66Class BString
    7     Implements System.IDisposable ', System.ICloneable
     7    Implements System.IDisposable, System.ICloneable
    88Public
    99    Sub BString()
     
    1515    End Sub
    1616
    17     Sub BString(s As BString)
    18         If Not IsNothing(s) Then
    19             bs = copy(s.bs)
    20         End If
    21     End Sub
    22 
    2317    Sub BString(s As LPCOLESTR, len As DWord)
    24         If s <> 0 Then
    25             bs = SysAllocStringLen(s, len)
    26         End If
     18        init(s, len)
    2719    End Sub
    2820
    2921    Sub BString(s As String)
    3022        If Not IsNothing(s) Then
    31             Init(s.StrPtr, s.Length As DWord)
     23            init(s.StrPtr, s.Length As DWord)
    3224        End If
    3325    End Sub
     
    7365    End Function
    7466
    75     /*Override*/ Function Clone() As BString
    76         Return New BString(This)
    77     End Function
    78 
    79     /*Override*/ Sub Dispose()
     67    Function Clone() As BString
     68        Return New BString(bs, Length)
     69    End Function
     70
     71    Sub Dispose()
    8072        Clear()
    8173    End Sub
     
    10395
    10496    Const Function Length() As DWord
    105         Length = GetDWord(bs As VoidPtr - SizeOf (DWord)) 'SysStringLen(bs)
     97        Length = SysStringLen(bs)
    10698    End Function
    10799
    108100    Const Function Operator [](i As SIZE_T) As OLECHAR
    109101        If i > Length Then
    110             Throw New ArgumentOutOfRangeException("i")
     102            Throw New System.ArgumentOutOfRangeException("i - BString.Operator [] (get)")
    111103        End If
    112104        Return bs[i]
     
    115107    Sub Operator []=(i As SIZE_T, c As OLECHAR)
    116108        If i > Length Then
    117             Throw New ArgumentOutOfRangeException("i")
     109            Throw New System.ArgumentOutOfRangeException("i - BString.Operator [] (set)")
    118110        End If
    119111        bs[i] = c
     
    148140            End If
    149141        Else
    150             If IsNullOrEmpty(bsr) Then
     142            If IsNullOrEmpty(r) Then
    151143                Compare = 1
    152144            Else
     
    156148    End Function
    157149
    158     Static Function IsNullOrEmpty(s As BString)
     150    Static Function IsNullOrEmpty(s As BString) As Boolean
    159151        If IsNothing(s) Then
    160152            IsNullOrEmpty = True
     
    196188
    197189    Sub init(s As PCSTR, len As DWord)
    198         If <> 0 Then
    199             Dim lenBS = MultiByteToWideChar(CP_THREAD_ACP, 0, s, len As Long, 0, 0)
     190        If s <> 0 Then
     191            Dim lenBS = MultiByteToWideChar(CP_ACP, 0, s, len As Long, 0, 0)
    200192            bs = SysAllocStringLen(0, lenBS)
    201193            If bs <> 0 Then
    202                 MultiByteToWideChar(CP_THREAD_ACP, 0, s, len As Long, bs, lenBS)
    203             End If
     194                MultiByteToWideChar(CP_ACP, 0, s, len As Long, bs, lenBS)
     195            End If
     196        End If
     197    End Sub
     198
     199    Sub init(s As PCWSTR, len As DWord)
     200        If s <> 0 Then
     201            bs = SysAllocStringLen(s, len)
    204202        End If
    205203    End Sub
    206204
    207205    Sub reset(newBS As BSTR)
    208         Dim old = InterlockedExchangePointer(bs, newBS)
     206        Dim old = InterlockedExchangePointer(ByVal VarPtr(bs) As *VoidPtr, newBS)
    209207        SysFreeString(old)
    210208    End Sub
     
    215213
    216214    Static Function move(ByRef src As BSTR) As BSTR
    217         move = InterlockedExchangePointer(src, 0)
     215        move = InterlockedExchangePointer(ByVal VarPtr(src) As *VoidPtr, 0)
    218216    End Function
    219217End Class
Note: See TracChangeset for help on using the changeset viewer.