Changeset 522


Ignore:
Timestamp:
Jun 21, 2008, 3:59:30 PM (14 years ago)
Author:
OverTaker
Message:

Console.Writeを実装。TextWriter?.Synchronizedは実装してません。

Location:
trunk/ab5.0/ablib/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/Console.ab

    r473 r522  
    1111Public
    1212    /*
     13    @brief 標準出力を設定する
     14    @date 2008/06/21
     15    @auther overtaker
     16    */
     17    Static Sub SetOut(newOut As IO.TextWriter)
     18        If ActiveBasic.IsNothing(newOut) Then
     19            Throw New ArgumentNullException("newOut")
     20        End If
     21        out = newOut
     22    End Sub
     23
     24    /*
     25    @brief 標準出力を取得する
     26    @date 2008/06/21
     27    @auther overtaker
     28    */
     29    Static Function Out() As IO.TextWriter
     30        Out = out
     31    End Function
     32
     33    /*
     34    @brief 標準出力に1行書き込む
     35    @date 2008/06/21
     36    @auther overtaker
     37    */
     38    Static Sub WriteLine(value As String)
     39        out.WriteLine(value)
     40        out.Flush()
     41    End Sub
     42
     43    Static Sub WriteLine()
     44        out.WriteLine()
     45        out.Flush()
     46    End Sub
     47
     48    Static Sub WriteLine(x As Boolean)
     49        WriteLine(Str$(x))
     50    End Sub
     51   
     52    Static Sub WriteLine(x As Char)
     53        WriteLine(Chr$(x))
     54    End Sub
     55
     56    Static Sub WriteLine(x As Byte)
     57        WriteLine(Str$(x))
     58    End Sub
     59#ifdef UNICODE
     60    Static Sub WriteLine(x As SByte)
     61        WriteLine(Str$(x))
     62    End Sub
     63#else
     64    Static Sub WriteLine(x As Word)
     65        WriteLine(Str$(x))
     66    End Sub
     67#endif
     68    Static Sub WriteLine(x As Integer)
     69        WriteLine(Str$(x))
     70    End Sub
     71
     72    Static Sub WriteLine(x As DWord)
     73        WriteLine(Str$(x))
     74    End Sub
     75
     76    Static Sub WriteLine(x As Long)
     77        WriteLine(Str$(x))
     78    End Sub
     79
     80    Static Sub WriteLine(x As QWord)
     81        WriteLine(Str$(x))
     82    End Sub
     83
     84    Static Sub WriteLine(x As Int64)
     85        WriteLine(Str$(x))
     86    End Sub
     87
     88    Static Sub WriteLine(x As Single)
     89        WriteLine(Str$(x))
     90    End Sub
     91
     92    Static Sub WriteLine(x As Double)
     93        WriteLine(Str$(x))
     94    End Sub
     95
     96    Static Sub WriteLine(x As Object)
     97        WriteLine(x.ToString)
     98    End Sub
     99
     100    /*
     101    @brief 標準出力に書き込む
     102    @date 2008/06/21
     103    @auther overtaker
     104    */
     105    Static Sub Write(s As String)
     106        out.Write(s)
     107        out.Flush()
     108    End Sub
     109
     110    Static Sub Write(x As Boolean)
     111        Write(Str$(x))
     112    End Sub
     113
     114    Static Sub Write(x As Char)
     115        Write(Chr$(x))
     116    End Sub
     117
     118    Static Sub Write(x As Byte)
     119        Write(Str$(x))
     120    End Sub
     121#ifdef UNICODE
     122    Static Sub Write(x As SByte)
     123        Write(Str$(x))
     124    End Sub
     125#else
     126    Static Sub Write(x As Word)
     127        Write(Str$(x))
     128    End Sub
     129#endif
     130    Static Sub Write(x As Integer)
     131        Write(Str$(x))
     132    End Sub
     133
     134    Static Sub Write(x As DWord)
     135        Write(Str$(x))
     136    End Sub
     137
     138    Static Sub Write(x As Long)
     139        Write(Str$(x))
     140    End Sub
     141
     142    Static Sub Write(x As QWord)
     143        Write(Str$(x))
     144    End Sub
     145
     146    Static Sub Write(x As Int64)
     147        Write(Str$(x))
     148    End Sub
     149
     150    /*
    13151    @brief 標準入力を設定する
    14152    @date 2008/02/26
     
    21159        in = newIn
    22160    End Sub
     161
    23162    /*
    24163    @brief 標準入力を取得する
     
    47186        Read = in.Read()
    48187    End Function
     188
    49189Private
    50190    Function enter() As ActiveBasic.Windows.CriticalSectionLock
     
    64204
    65205    Static in = Nothing As IO.TextReader
     206    Static out = Nothing As IO.TextWriter
    66207    Static cs = Nothing As ActiveBasic.Windows.CriticalSection
    67208End Class
  • trunk/ab5.0/ablib/src/Classes/System/IO/TextWriter.ab

    r473 r522  
    176176    End Function
    177177
     178    Static Function Synchronized(reader As TextWriter) As TextWriter
     179        ' TODO: 実装。とりあえずそのまま返却
     180        Return reader
     181    End Function
    178182Protected
    179183    Virtual Sub Dispose(disposing As Boolean)
     
    184188End Class
    185189
     190
    186191End Namespace
    187192End Namespace
  • trunk/ab5.0/ablib/src/basic/dos_console.sbp

    r497 r522  
    99Dim _System_hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
    1010Dim _System_hConsoleIn = GetStdHandle(STD_INPUT_HANDLE)
     11System.Console.SetOut(
     12     System.IO.TextWriter.Synchronized(New System.IO.StreamWriter(
     13        New System.IO.FileStream(_System_hConsoleOut, System.IO.FileAccess.Write, False))))
    1114System.Console.SetIn(
    1215    System.IO.TextReader.Synchronized(New System.IO.StreamReader(
     
    5760
    5861    Dim dwAccessBytes As DWord
    59     WriteConsole(_System_hConsoleOut, buf.StrPtr, buf.Length, dwAccessBytes, 0)
     62    System.Console.Write(buf)
     63'   WriteConsole(_System_hConsoleOut, buf.StrPtr, buf.Length, dwAccessBytes, 0)
    6064End Sub
    6165/* TODO: _System_GetUsingFormatを用意して実装する
Note: See TracChangeset for help on using the changeset viewer.