0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
155
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
54
|
13 |
Stream subclass:#ActorStream
|
0
|
14 |
instanceVariableNames:'nextPutBlock nextPutAllBlock nextBlock'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Streams'
|
|
18 |
!
|
|
19 |
|
|
20 |
ActorStream comment:'
|
5
|
21 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
155
|
22 |
All Rights Reserved
|
92
|
23 |
|
379
|
24 |
$Header: /cvs/stx/stx/libbasic/Attic/ActorStr.st,v 1.11 1995-08-10 12:25:37 claus Exp $
|
28
|
25 |
'!
|
|
26 |
|
|
27 |
!ActorStream class methodsFor:'documentation'!
|
|
28 |
|
82
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
155
|
32 |
All Rights Reserved
|
82
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
379
|
45 |
$Header: /cvs/stx/stx/libbasic/Attic/ActorStr.st,v 1.11 1995-08-10 12:25:37 claus Exp $
|
|
46 |
$Revision: 1.11 $
|
82
|
47 |
"
|
|
48 |
!
|
|
49 |
|
28
|
50 |
documentation
|
|
51 |
"
|
155
|
52 |
This class provides a hook for general objects to behave like Stream objects.
|
|
53 |
To the outside, actorStreams behave like streams and respond to the
|
|
54 |
usual stream messages (i.e. nextPut:, nextPutAll: etc).
|
77
|
55 |
In the inside, for every nextPut-message, the nextPutBlock is evaluated
|
|
56 |
passing the argument of nextPut: as block argument.
|
54
|
57 |
|
77
|
58 |
These blocks are to be provided by the user of the ActorStream.
|
|
59 |
Example use is in the Transcript, which is made Stream-like this way.
|
0
|
60 |
|
77
|
61 |
Instance variables:
|
0
|
62 |
|
77
|
63 |
nextPutBlock <Block> the block to evaluate for nextPut:-messages
|
|
64 |
nextPutAllBlock <Block> same for nextPutAll:-messages
|
|
65 |
nextBlock <Block> the Block to evaluate for the next element
|
28
|
66 |
"
|
|
67 |
! !
|
0
|
68 |
|
|
69 |
!ActorStream class methodsFor:'instance creation'!
|
|
70 |
|
|
71 |
new
|
|
72 |
"have to re-allow new - it was disabled in Stream"
|
|
73 |
^ self basicNew
|
|
74 |
! !
|
|
75 |
|
|
76 |
!ActorStream methodsFor:'defining actions'!
|
|
77 |
|
|
78 |
nextBlock:aBlock
|
|
79 |
"define the block to be evaluated for every next-message"
|
|
80 |
|
|
81 |
nextBlock := aBlock
|
|
82 |
!
|
|
83 |
|
|
84 |
nextPutBlock:aBlock
|
|
85 |
"define the block to be evaluated for every nextPut-message"
|
|
86 |
|
|
87 |
nextPutBlock := aBlock
|
|
88 |
!
|
|
89 |
|
|
90 |
nextPutAllBlock:aBlock
|
|
91 |
"define the block to be evaluated for every nextPutAll-message"
|
|
92 |
|
|
93 |
nextPutAllBlock := aBlock
|
|
94 |
! !
|
|
95 |
|
54
|
96 |
!ActorStream methodsFor:'queries'!
|
|
97 |
|
|
98 |
atEnd
|
|
99 |
"return true, if at the end - actorStreams are never"
|
|
100 |
|
|
101 |
^ false
|
|
102 |
! !
|
|
103 |
|
155
|
104 |
!ActorStream methodsFor:'ignored style messages'!
|
|
105 |
|
|
106 |
bold
|
|
107 |
"ignored here.
|
|
108 |
this allows actorStreams to be used interchangeable with printStreams"
|
|
109 |
|
|
110 |
^ self
|
|
111 |
!
|
|
112 |
|
|
113 |
normal
|
|
114 |
"ignored here.
|
|
115 |
this allows actorStreams to be used interchangeable with printStreams"
|
|
116 |
|
|
117 |
^ self
|
|
118 |
!
|
|
119 |
|
|
120 |
italic
|
|
121 |
"ignored here.
|
|
122 |
this allows actorStreams to be used interchangeable with printStreams"
|
|
123 |
|
|
124 |
^ self
|
|
125 |
! !
|
|
126 |
|
0
|
127 |
!ActorStream methodsFor:'accessing-read/write'!
|
|
128 |
|
|
129 |
next
|
|
130 |
"return the next element from the stream by evaluating the nextBlock"
|
|
131 |
|
|
132 |
nextBlock notNil ifTrue:[
|
155
|
133 |
^ nextBlock value
|
0
|
134 |
].
|
|
135 |
self error:'action for next is undefined'
|
|
136 |
!
|
|
137 |
|
|
138 |
nextPut:something
|
|
139 |
"put something onto the stream by evaluating the nextPutBlock with
|
|
140 |
something as argument"
|
|
141 |
|
|
142 |
nextPutBlock notNil ifTrue:[
|
155
|
143 |
^ nextPutBlock value:something
|
0
|
144 |
].
|
54
|
145 |
self error:'action for nextPut: is undefined'
|
0
|
146 |
!
|
|
147 |
|
|
148 |
nextPutAll:something
|
|
149 |
"put all elements of something onto the stream by evaluating
|
|
150 |
the nextPutAllBlock with something as argument"
|
|
151 |
|
|
152 |
nextPutAllBlock notNil ifTrue:[
|
155
|
153 |
^ nextPutAllBlock value:something
|
0
|
154 |
].
|
|
155 |
super nextPutAll:something
|
|
156 |
! !
|