File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change
1
+ //===----------------------------------------------------------------------===//
2
+ // InputStream
3
+ //===----------------------------------------------------------------------===//
4
+
5
+ // XXX FIXME -- replace and flush this out with parsing logic
6
+
7
+ class Keyboard {
8
+ func read( buf : UInt8 [ ] ) -> Int {
9
+ var r = posix_read ( 0 , buf. base. value, buf. length)
10
+ assert ( r >= 0 )
11
+ return r
12
+ }
13
+
14
+ func read( ) -> Int {
15
+ var c = new UInt8 [ 1 ]
16
+ if read ( c) != 1 {
17
+ return - 1
18
+ }
19
+ return Int ( c [ 0 ] )
20
+ }
21
+ }
22
+
23
+ extension Keyboard {
24
+ func getline( ) -> String {
25
+ return getline ( '\n')
26
+ }
27
+
28
+ func getline( delim : Char ) -> String {
29
+ var r : String
30
+ var i = read ( )
31
+ while i != - 1 {
32
+ var c = Char ( i)
33
+ if c == delim {
34
+ break
35
+ }
36
+ r = r + c
37
+ i = read ( )
38
+ }
39
+ return r
40
+ }
41
+ }
42
+
43
+ var kbd : Keyboard = new Keyboard
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ LINK_LIBS_IN_SHARED := 1
18
18
SHARED_LIBRARY := 1
19
19
SWIFT_SOURCES := Bool.swift FixedPoint.swift FloatingPoint.swift Misc.swift \
20
20
String.swift Dictionary.swift Vector.swift Algorithm.swift \
21
- Demangle.swift OutputStream.swift \
21
+ Demangle.swift InputStream.swift OutputStream.swift \
22
22
POSIX/Descriptor.swift POSIX/File.swift POSIX/Misc.swift
23
23
SOURCES := swift.swift
24
24
NO_BUILD_ARCHIVE := 1
You can’t perform that action at this time.
0 commit comments