ActorStream.st
author Claus Gittinger <cg@exept.de>
Mon, 26 Aug 2019 10:24:45 +0200
changeset 5153 9bf4a6f51b33
parent 5151 bfed222dcaad
child 5157 ad4d06ecfb6c
permissions -rw-r--r--
#DOCUMENTATION by exept class: ActorStream comment/format in: #nextPutByte:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3531
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
     1
"{ Encoding: utf8 }"
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
     2
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 1989 by Claus Gittinger
1624
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
     5
              All Rights Reserved
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
936
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
    14
"{ Package: 'stx:libbasic2' }"
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
    15
3469
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
    16
"{ NameSpace: Smalltalk }"
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
    17
1621
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
    18
PeekableStream subclass:#ActorStream
3089
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    19
	instanceVariableNames:'nextPutBlock nextPutAllBlock nextPutLineBlock nextBlock
4968
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
    20
		atEndBlock peekBlock contentsSpecies bufferedLine'
3089
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    21
	classVariableNames:''
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    22
	poolDictionaries:''
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    23
	category:'Streams'
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
!ActorStream class methodsFor:'documentation'!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
copyright
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 COPYRIGHT (c) 1989 by Claus Gittinger
1624
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    31
              All Rights Reserved
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 This software is furnished under a license and may be used
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 only in accordance with the terms of that license and with the
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 inclusion of the above copyright notice.   This software may not
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 be provided or otherwise made available to, or used by, any
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 other person.  No title to or ownership of the software is
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 hereby transferred.
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
documentation
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    This class provides a hook for general objects to behave like Stream objects.
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    To the outside, actorStreams behave like streams and respond to the
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    usual stream messages (i.e. nextPut:, nextPutAll: etc).
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    In the inside, for every nextPut-message, the nextPutBlock is evaluated
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    passing the argument of nextPut: as block argument.
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    These blocks are to be provided by the user of the ActorStream.
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    Example use is in the Transcript, which is made Stream-like this way.
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
252
d52b05d6637a commentary
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    53
    [Instance variables:]
d52b05d6637a commentary
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    54
        nextPutBlock    <Block>   the block to evaluate for nextPut:-messages
d52b05d6637a commentary
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    55
        nextPutAllBlock <Block>   same for nextPutAll:-messages
d52b05d6637a commentary
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    56
        nextBlock       <Block>   the Block to evaluate for the next element
d52b05d6637a commentary
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    57
259
6d36f3ac42a2 documentation
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    58
    [author:]
6d36f3ac42a2 documentation
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    59
        Claus Gittinger
6d36f3ac42a2 documentation
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
    60
252
d52b05d6637a commentary
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    61
    [See also:]
d52b05d6637a commentary
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    62
        TextCollector
d52b05d6637a commentary
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
    63
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
! !
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!ActorStream class methodsFor:'instance creation'!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
new
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    "have to re-allow new - it was disabled in Stream"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    ^ self basicNew
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
! !
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
1624
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    74
!ActorStream methodsFor:'accessing'!
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    75
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    76
contentsSpecies
3089
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    77
    "return a class of which instances will be returned, when
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    78
     parts of the collection are asked for. 
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    79
     (see upTo-kind of methods in Stream)"
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    80
1624
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    81
    ^ contentsSpecies ? String
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    82
!
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    83
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    84
contentsSpecies:something
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    85
    contentsSpecies := something.
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    86
! !
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    87
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
!ActorStream methodsFor:'accessing-read/write'!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
next
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    "return the next element from the stream by evaluating the nextBlock"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    nextBlock notNil ifTrue:[
1624
1af2724496b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
    94
        ^ nextBlock value
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    ].
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    self error:'action for next is undefined'
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
4968
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
    99
nextPut:aCharacter
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "put something onto the stream by evaluating the nextPutBlock with
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
     something as argument"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   103
    nextPutBlock notNil ifTrue:[  
5151
bfed222dcaad #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 4968
diff changeset
   104
        nextPutBlock value:aCharacter.
bfed222dcaad #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 4968
diff changeset
   105
        ^ self.
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    ].
1008
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   107
    nextPutAllBlock notNil ifTrue:[    
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   108
        "/ fallBack to nextPutAll.
4968
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   109
        self nextPutAll:(aCharacter asString).
1008
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   110
        ^ self
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   111
    ].
4968
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   112
    "/ if there is a nextPutLineBlock, then collect the line in a buffer and wait for the cr
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   113
    nextPutLineBlock notNil ifTrue:[
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   114
        aCharacter == Character cr ifFalse:[
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   115
            bufferedLine := (bufferedLine ? '') , aCharacter.
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   116
        ] ifTrue:[
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   117
            self nextPutLine:(bufferedLine ? '').
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   118
            bufferedLine := ''.
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   119
        ].
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   120
        ^ self
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   121
    ].
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   122
    
1008
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   123
    self error:'action for nextPut:/nextPutAll: are undefined'
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   124
4968
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   125
    "Modified: / 28-01-2002 / 20:59:32 / micha"
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   126
    "Modified: / 29-05-2019 / 23:28:34 / Claus Gittinger"
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
nextPutAll:something
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    "put all elements of something onto the stream by evaluating
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   131
     the nextPutAllBlock with something as argument.
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   132
     If there is no nextPutAllBlock, nextPuts will be used (as inherited)"
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   134
    nextPutAllBlock notNil ifTrue:[    
5151
bfed222dcaad #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 4968
diff changeset
   135
        nextPutAllBlock value:something.
bfed222dcaad #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 4968
diff changeset
   136
    ] ifFalse:[
bfed222dcaad #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 4968
diff changeset
   137
        super nextPutAll:something
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    ].
554
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   139
!
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   140
3531
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   141
nextPutAll:count from:buffer startingAt:start
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   142
    "put some elements of something onto the stream by evaluating
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   143
     the nextPutAllBlock with something as argument.
5151
bfed222dcaad #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 4968
diff changeset
   144
     If there is no nextPutAllBlock, individual nextPuts will be used (as inherited).
bfed222dcaad #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 4968
diff changeset
   145
     Answer the number of elements that were appended."
3531
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   146
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   147
    nextPutAllBlock notNil ifTrue:[    
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   148
        nextPutAllBlock value:(buffer copyFrom:start to:start+count-1).
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   149
        ^ count
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   150
    ].
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   151
    ^ super nextPutAll:count from:buffer startingAt:start
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   152
!
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   153
3469
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   154
nextPutAll:something startingAt:start to:stop
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   155
    "put some elements of something onto the stream by evaluating
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   156
     the nextPutAllBlock with something as argument.
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   157
     If there is no nextPutAllBlock, nextPuts will be used (as inherited)"
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   158
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   159
    nextPutAllBlock notNil ifTrue:[    
4790
bacf758a10cc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4768
diff changeset
   160
        nextPutAllBlock value:(something copyFrom:start to:stop).
bacf758a10cc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4768
diff changeset
   161
        ^ self.
3469
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   162
    ].
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   163
    super nextPutAll:something startingAt:start to:stop
4768
a03651751649 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3531
diff changeset
   164
a03651751649 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3531
diff changeset
   165
    "Modified: / 22-11-2018 / 12:52:51 / Stefan Vogel"
4790
bacf758a10cc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4768
diff changeset
   166
    "Modified: / 14-01-2019 / 18:23:40 / Claus Gittinger"
3469
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   167
!
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   168
554
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   169
nextPutByte:something
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   170
    "put something onto the stream by evaluating the nextPutBlock with
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   171
     something as argument"
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   172
5153
9bf4a6f51b33 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5151
diff changeset
   173
    self nextPut:(something asCharacter).
554
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   174
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   175
    "Created: 6.8.1997 / 00:44:32 / cg"
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   176
!
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   177
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   178
nextPutLine:something
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   179
    "put the line onto the stream by evaluating
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   180
     the nextPutLineBlock with something as argument.
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   181
     If there is no nextPutLineBlock, nextPutAll/nextPut will be used (as inherited)"
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   182
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   183
    nextPutLineBlock notNil ifTrue:[    
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   184
        ^ nextPutLineBlock value:something
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   185
    ].
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   186
    super nextPutLine:something
1621
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   187
!
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   188
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   189
peek
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   190
    "peek ahead for return the next element from the stream by evaluating the peekBlock"
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   191
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   192
    peekBlock notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   193
        ^ peekBlock value
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   194
    ].
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   195
    self error:'action for peek is undefined'
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   196
! !
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   197
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   198
!ActorStream methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   199
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   200
readStream
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   201
    "return a readStream from the receiver. 
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   202
     Since this is (hopefully) already a readStream, return self."
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   203
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   204
    ^ self
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
! !
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
!ActorStream methodsFor:'defining actions'!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
936
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   209
atEndBlock:aBlock
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   210
    "define the block to be evaluated for every atEnd-message"
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   211
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   212
    atEndBlock := aBlock
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   213
!
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   214
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
nextBlock:aBlock
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    "define the block to be evaluated for every next-message"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    nextBlock := aBlock
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
nextPutAllBlock:aBlock
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   222
    "define the block to be evaluated for every nextPutAll-message.
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   223
     If undefined, nextPuts will be used (as inherited)"
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    nextPutAllBlock := aBlock
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
nextPutBlock:aBlock
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    "define the block to be evaluated for every nextPut-message"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    nextPutBlock := aBlock
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   232
!
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   233
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   234
nextPutLineBlock:aBlock
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   235
    "define the block to be evaluated for every nextPutLineBlock-message.
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   236
     If undefined, nextPutAll/nextPut will be used (as inherited)"
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   237
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   238
    nextPutLineBlock := aBlock
1621
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   239
!
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   240
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   241
peekBlock:aBlock
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   242
    "define the block to be evaluated for every peek-message"
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   243
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   244
    peekBlock := aBlock
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
! !
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
!ActorStream methodsFor:'queries'!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
atEnd
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    "return true, if at the end - actorStreams are never"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
936
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   252
    atEndBlock isNil ifTrue:[
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   253
        ^ false
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   254
    ].
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   255
    ^ atEndBlock value
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
! !
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
!ActorStream class methodsFor:'documentation'!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
version
4768
a03651751649 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3531
diff changeset
   261
    ^ '$Header$'
5153
9bf4a6f51b33 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5151
diff changeset
   262
!
9bf4a6f51b33 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5151
diff changeset
   263
9bf4a6f51b33 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5151
diff changeset
   264
version_CVS
9bf4a6f51b33 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 5151
diff changeset
   265
    ^ '$Header$'
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
! !
3089
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
   267