Changeset 435 for trunk


Ignore:
Timestamp:
Feb 28, 2008, 1:39:16 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

Consoleをスレッド安全化(クリティカルセクション使用)。
Exception.HResultをPublicにした。
StringBuilder.Replaceが正しく機能しない問題を解消。

Location:
trunk/Include/Classes/System
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/System/Console.ab

    r432 r435  
    3636    */
    3737    Static Function ReadLine() As String
    38         ReadLine = in.ReadLine()
     38        Dim lock = enter()
     39        Try
     40            ReadLine = in.ReadLine()
     41        Finally
     42            lock.Leave()
     43        End Try
     44    End Function
     45
     46    /*
     47    @brief 標準入力から1行読み込む
     48    @date 2008/02/26
     49    @auther Egtra
     50    */
     51    Static Function Read() As Long
     52        Dim lock = enter()
     53        Try
     54            Read = in.Read()
     55        Finally
     56            lock.Leave()
     57        End Try
    3958    End Function
    4059Private
     60    Function enter() As ActiveBasic.Windows.CriticalSectionLock
     61        Imports ActiveBasic.Windows
     62        If ActiveBasic.IsNothing(cs) Then
     63            Dim lock = New CriticalSectionLock(_System_CriticalSection)
     64            Try
     65                If ActiveBasic.IsNothing(cs) Then
     66                    cs = New CriticalSection
     67                End If
     68            Finally
     69                lock.Dispose()
     70            End Try
     71        End If
     72        enter = cs.Enter
     73    End Function
     74
    4175    Static in = Nothing As IO.TextReader
     76    Static cs = Nothing As ActiveBasic.Windows.CriticalSection
    4277End Class
    4378
  • trunk/Include/Classes/System/Exception.ab

    r411 r435  
    152152        Return src
    153153    End Function
    154 Protected
     154
    155155    /*!
    156156    @brief  HRESULT値の設定
  • trunk/Include/Classes/System/IO/Exception.ab

    r391 r435  
    6464    */
    6565    Sub ThrowWinIOException(msg As String, error As DWord)
    66 '       Throw IOException(msg, HRESULT_FROM_WIN32(error))
     66        Throw New IOException(msg, HRESULT_FROM_WIN32(error))
    6767    End Sub
    6868
     
    7474    */
    7575    Sub ThrowWinLastErrorIOException(msg As String)
    76 '       Throw IOException(msg, HRESULT_FROM_WIN32(GetLastError()))
     76        Throw New IOException(msg, HRESULT_FROM_WIN32(GetLastError()))
    7777    End Sub
    7878End Namespace
  • trunk/Include/Classes/System/IO/File.ab

    r432 r435  
    2727
    2828Enum FileMode
    29     Append = OPEN_ALWAYS
    30     Create = CREATE_ALWAYS
    31     CreateNew = CREATE_NEW
    32     Open = OPEN_EXISTING
    33     OpenOrCreate = OPEN_ALWAYS
    34     Truncate = TRUNCATE_EXISTING
     29    Append = 4 'OPEN_ALWAYS
     30    Create = 2 'CREATE_ALWAYS
     31    CreateNew = 1 'CREATE_NEW
     32    Open = 3 'OPEN_EXISTING
     33    OpenOrCreate = 4 'OPEN_ALWAYS
     34    Truncate = 5 'TRUNCATE_EXISTING
    3535End Enum
    3636
  • trunk/Include/Classes/System/IO/FileStream.ab

    r432 r435  
    3434    /* コンストラクタ.NETと同じように実装は難しい、一先ず動くものを実装したが変更が必要だと思う */
    3535    Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
     36        If ActiveBasic.IsNothing(path) Then
     37            Throw New ArgumentNullException("path")
     38        ElseIf path.Length = 0 Then
     39            Throw New ArgumentException
     40        End If
     41
     42
    3643        Dim ac = access As DWord
    3744        Dim sh = share As DWord
     
    4956        'Throw System.IO.FileNotFoundException
    5057            This.handle=0
    51             Beep(220,500)
     58            Detail.ThrowWinLastErrorIOException("Failed to open/create file.")
    5259            Exit Sub
    5360        End If
  • trunk/Include/Classes/System/IO/StreamReader.ab

    r432 r435  
    5050    Override Function Read() As Long
    5151        Read = Peek()
    52         cur++
     52        If Read <> -1 Then
     53            cur++
     54        End If
    5355    End Function
    5456
  • trunk/Include/Classes/System/Text/StringBuilder.ab

    r388 r435  
    387387
    388388        Dim s = New StringBuilder(capacity, maxCapacity)
    389         Dim curPos = 0 As Long
     389        Dim curPos = start
     390        Dim last = start + count
    390391        Do
    391392            Dim nextPos = ActiveBasic.Strings.ChrFind(VarPtr(chars[curPos]) As *StrChar, size As SIZE_T, StrPtr(oldStr), oldStr.Length As SIZE_T) As Long
    392             If nextPos = -1 As SIZE_T Then
    393                 Exit Sub
     393            If nextPos = -1 As SIZE_T Or curPos > last Then
     394                s.appendCore(chars, curPos, size - curPos)
     395                Exit Do
    394396            End If
    395397           
Note: See TracChangeset for help on using the changeset viewer.