equal
deleted
inserted
replaced
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 UnboundedExternalStream subclass:#NonPositionableExternalStream |
13 UnboundedExternalStream subclass:#NonPositionableExternalStream |
14 instanceVariableNames:'' |
14 instanceVariableNames:'' |
15 classVariableNames:'StdInStream StdOutStream StdErrorStream' |
15 classVariableNames:'StdInStream StdOutStream StdErrorStream' |
16 poolDictionaries:'' |
16 poolDictionaries:'' |
17 category:'Streams-External' |
17 category:'Streams-External' |
18 ! |
18 ! |
|
19 |
|
20 !NonPositionableExternalStream primitiveDefinitions! |
|
21 %{ |
|
22 #include <stdio.h> |
|
23 #define _STDIO_H_INCLUDED_ |
|
24 %} |
|
25 |
|
26 ! ! |
19 |
27 |
20 !NonPositionableExternalStream class methodsFor:'documentation'! |
28 !NonPositionableExternalStream class methodsFor:'documentation'! |
21 |
29 |
22 copyright |
30 copyright |
23 " |
31 " |
31 other person. No title to or ownership of the software is |
39 other person. No title to or ownership of the software is |
32 hereby transferred. |
40 hereby transferred. |
33 " |
41 " |
34 ! |
42 ! |
35 |
43 |
36 version |
|
37 ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.23 1995-11-22 15:08:51 cg Exp $' |
|
38 ! |
|
39 |
|
40 documentation |
44 documentation |
41 " |
45 " |
42 This class provides common protocol for all non-positionable, |
46 This class provides common protocol for all non-positionable, |
43 external streams. Concrete subclasses are terminal streams, pipe streams, |
47 external streams. Concrete subclasses are terminal streams, pipe streams, |
44 PrinterStreams, Sockets etc. |
48 PrinterStreams, Sockets etc. |
50 (see Smalltalk>>initializeStandardStreams). |
54 (see Smalltalk>>initializeStandardStreams). |
51 |
55 |
52 The name of this class is a historical leftover - it should be called |
56 The name of this class is a historical leftover - it should be called |
53 'TTYStream' or similar. |
57 'TTYStream' or similar. |
54 " |
58 " |
55 ! ! |
59 ! |
56 |
60 |
57 !NonPositionableExternalStream primitiveDefinitions! |
61 version |
58 |
62 ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.24 1995-11-23 01:51:07 cg Exp $' |
59 %{ |
|
60 #include <stdio.h> |
|
61 #define _STDIO_H_INCLUDED_ |
|
62 %} |
|
63 |
|
64 ! ! |
63 ! ! |
65 |
64 |
66 !NonPositionableExternalStream class methodsFor:'instance creation'! |
65 !NonPositionableExternalStream class methodsFor:'instance creation'! |
|
66 |
|
67 forStderr |
|
68 "return a NonPositionableExternalStream object for writing to |
|
69 Unixes standard error output file descriptor" |
|
70 |
|
71 StdErrorStream isNil ifTrue:[ |
|
72 StdErrorStream := self basicNew initializeForStderr |
|
73 ]. |
|
74 ^ StdErrorStream |
|
75 ! |
67 |
76 |
68 forStdin |
77 forStdin |
69 "return a NonPositionableExternalStream object for reading from |
78 "return a NonPositionableExternalStream object for reading from |
70 Unixes standard input file descriptor" |
79 Unixes standard input file descriptor" |
71 |
80 |
81 |
90 |
82 StdOutStream isNil ifTrue:[ |
91 StdOutStream isNil ifTrue:[ |
83 StdOutStream := self basicNew initializeForStdout |
92 StdOutStream := self basicNew initializeForStdout |
84 ]. |
93 ]. |
85 ^ StdOutStream |
94 ^ StdOutStream |
86 ! |
95 ! ! |
87 |
96 |
88 forStderr |
97 !NonPositionableExternalStream methodsFor:'error handling'! |
89 "return a NonPositionableExternalStream object for writing to |
98 |
90 Unixes standard error output file descriptor" |
99 positionError |
91 |
100 "notify that this stream has no concept of a position" |
92 StdErrorStream isNil ifTrue:[ |
101 |
93 StdErrorStream := self basicNew initializeForStderr |
102 ^ PositionErrorSignal raiseRequestWith:self in:thisContext sender |
94 ]. |
103 ! ! |
95 ^ StdErrorStream |
104 |
|
105 !NonPositionableExternalStream methodsFor:'positioning'! |
|
106 |
|
107 position |
|
108 "catch position - there is none here" |
|
109 |
|
110 ^ self positionError |
|
111 ! |
|
112 |
|
113 position:aPosition |
|
114 "catch position - there is none here" |
|
115 |
|
116 ^ self positionError |
|
117 ! |
|
118 |
|
119 skip:numberToSkip |
|
120 "skip count objects, return the receiver" |
|
121 |
|
122 "dont know how to unread ..." |
|
123 numberToSkip < 0 ifTrue:[ |
|
124 ^ self error:'stream is not positionable' |
|
125 ]. |
|
126 numberToSkip timesRepeat:self next |
96 ! ! |
127 ! ! |
97 |
128 |
98 !NonPositionableExternalStream methodsFor:'printing & storing'! |
129 !NonPositionableExternalStream methodsFor:'printing & storing'! |
99 |
130 |
100 printOn:aStream |
131 printOn:aStream |
125 ^ self printOn:aStream |
156 ^ self printOn:aStream |
126 ]. |
157 ]. |
127 super storeOn:aStream |
158 super storeOn:aStream |
128 ! ! |
159 ! ! |
129 |
160 |
130 !NonPositionableExternalStream methodsFor:'error handling'! |
|
131 |
|
132 positionError |
|
133 "notify that this stream has no concept of a position" |
|
134 |
|
135 ^ PositionErrorSignal raiseRequestWith:self in:thisContext sender |
|
136 ! ! |
|
137 |
|
138 !NonPositionableExternalStream methodsFor:'queries'! |
|
139 |
|
140 isPositionable |
|
141 "return true, if the stream supports positioning (this one is not)" |
|
142 |
|
143 ^ false |
|
144 ! ! |
|
145 |
|
146 !NonPositionableExternalStream methodsFor:'positioning'! |
|
147 |
|
148 position |
|
149 "catch position - there is none here" |
|
150 |
|
151 ^ self positionError |
|
152 ! |
|
153 |
|
154 position:aPosition |
|
155 "catch position - there is none here" |
|
156 |
|
157 ^ self positionError |
|
158 ! |
|
159 |
|
160 skip:numberToSkip |
|
161 "skip count objects, return the receiver" |
|
162 |
|
163 "dont know how to unread ..." |
|
164 numberToSkip < 0 ifTrue:[ |
|
165 ^ self error:'stream is not positionable' |
|
166 ]. |
|
167 numberToSkip timesRepeat:self next |
|
168 ! ! |
|
169 |
|
170 !NonPositionableExternalStream methodsFor:'private'! |
161 !NonPositionableExternalStream methodsFor:'private'! |
|
162 |
|
163 initializeForStderr |
|
164 "setup for writing to stderr" |
|
165 |
|
166 mode := #readwrite. |
|
167 buffered := false. |
|
168 %{ |
|
169 OBJ fp; |
|
170 |
|
171 _INST(filePointer) = fp = __MKOBJ(stderr); __STORE(self, fp); |
|
172 _INST(buffered) = true; |
|
173 %} |
|
174 ! |
171 |
175 |
172 initializeForStdin |
176 initializeForStdin |
173 "setup for reading stdin" |
177 "setup for reading stdin" |
174 |
178 |
175 mode := #readonly. |
179 mode := #readonly. |
189 buffered := false. |
193 buffered := false. |
190 %{ |
194 %{ |
191 OBJ fp; |
195 OBJ fp; |
192 |
196 |
193 _INST(filePointer) = fp = __MKOBJ(stdout); __STORE(self, fp); |
197 _INST(filePointer) = fp = __MKOBJ(stdout); __STORE(self, fp); |
194 _INST(buffered) = true; |
|
195 %} |
|
196 ! |
|
197 |
|
198 initializeForStderr |
|
199 "setup for writing to stderr" |
|
200 |
|
201 mode := #readwrite. |
|
202 buffered := false. |
|
203 %{ |
|
204 OBJ fp; |
|
205 |
|
206 _INST(filePointer) = fp = __MKOBJ(stderr); __STORE(self, fp); |
|
207 _INST(buffered) = true; |
198 _INST(buffered) = true; |
208 %} |
199 %} |
209 ! |
200 ! |
210 |
201 |
211 reOpen |
202 reOpen |
221 (self == StdErrorStream) ifTrue:[ |
212 (self == StdErrorStream) ifTrue:[ |
222 ^ self initializeForStderr |
213 ^ self initializeForStderr |
223 ]. |
214 ]. |
224 ^ super reOpen |
215 ^ super reOpen |
225 ! ! |
216 ! ! |
|
217 |
|
218 !NonPositionableExternalStream methodsFor:'queries'! |
|
219 |
|
220 isPositionable |
|
221 "return true, if the stream supports positioning (this one is not)" |
|
222 |
|
223 ^ false |
|
224 ! ! |
|
225 |