ActorStream.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Jun 2019 11:06:22 +0200
changeset 5046 9b2d073d0573
parent 4968 99de1b56d09f
child 5151 bfed222dcaad
permissions -rw-r--r--
#DOCUMENTATION by cg class: LazyValue comment/format in: #displayOn: #displayString
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:[  
4968
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   104
        ^ nextPutBlock value:aCharacter
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    ].
1008
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   106
    nextPutAllBlock notNil ifTrue:[    
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   107
        "/ fallBack to nextPutAll.
4968
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   108
        self nextPutAll:(aCharacter asString).
1008
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   109
        ^ self
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   110
    ].
4968
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   111
    "/ 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
   112
    nextPutLineBlock notNil ifTrue:[
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   113
        aCharacter == Character cr ifFalse:[
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   114
            bufferedLine := (bufferedLine ? '') , aCharacter.
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   115
        ] ifTrue:[
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   116
            self nextPutLine:(bufferedLine ? '').
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   117
            bufferedLine := ''.
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   118
        ].
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   119
        ^ self
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   120
    ].
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   121
    
1008
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   122
    self error:'action for nextPut:/nextPutAll: are undefined'
67f75385259a allow for single nextPutAll block
Michael Beyl <mb@exept.de>
parents: 987
diff changeset
   123
4968
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   124
    "Modified: / 28-01-2002 / 20:59:32 / micha"
99de1b56d09f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   125
    "Modified: / 29-05-2019 / 23:28:34 / Claus Gittinger"
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
!
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
nextPutAll:something
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    "put all elements of something onto the stream by evaluating
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   130
     the nextPutAllBlock with something as argument.
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   131
     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
   132
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   133
    nextPutAllBlock notNil ifTrue:[    
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   134
        ^ nextPutAllBlock value:something
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    ].
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    super nextPutAll:something
554
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   137
!
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   138
3531
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   139
nextPutAll:count from:buffer startingAt:start
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   140
    "put some elements of something onto the stream by evaluating
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   141
     the nextPutAllBlock with something as argument.
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   142
     If there is no nextPutAllBlock, nextPuts will be used (as inherited)"
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   143
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   144
    nextPutAllBlock notNil ifTrue:[    
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   145
        nextPutAllBlock value:(buffer copyFrom:start to:start+count-1).
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   146
        ^ count
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   147
    ].
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   148
    ^ super nextPutAll:count from:buffer startingAt:start
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   149
!
88c3aa9a14fc class: ActorStream
Stefan Vogel <sv@exept.de>
parents: 3469
diff changeset
   150
3469
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   151
nextPutAll:something startingAt:start to:stop
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   152
    "put some elements of something onto the stream by evaluating
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   153
     the nextPutAllBlock with something as argument.
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   154
     If there is no nextPutAllBlock, nextPuts will be used (as inherited)"
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   155
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   156
    nextPutAllBlock notNil ifTrue:[    
4790
bacf758a10cc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4768
diff changeset
   157
        nextPutAllBlock value:(something copyFrom:start to:stop).
bacf758a10cc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4768
diff changeset
   158
        ^ self.
3469
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   159
    ].
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   160
    super nextPutAll:something startingAt:start to:stop
4768
a03651751649 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3531
diff changeset
   161
a03651751649 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3531
diff changeset
   162
    "Modified: / 22-11-2018 / 12:52:51 / Stefan Vogel"
4790
bacf758a10cc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4768
diff changeset
   163
    "Modified: / 14-01-2019 / 18:23:40 / Claus Gittinger"
3469
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   164
!
f8a8860f7253 class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 3089
diff changeset
   165
554
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   166
nextPutByte:something
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   167
    "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
   168
     something as argument"
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   169
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   170
    self nextPut:(something asCharacter)
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   171
84eb4d58dd04 allow binary data to be sent via #nextPutByte:.
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   172
    "Created: 6.8.1997 / 00:44:32 / cg"
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   173
!
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   174
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   175
nextPutLine:something
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   176
    "put the line onto the stream by evaluating
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   177
     the nextPutLineBlock with something as argument.
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   178
     If there is no nextPutLineBlock, nextPutAll/nextPut will be used (as inherited)"
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   179
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   180
    nextPutLineBlock notNil ifTrue:[    
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   181
        ^ nextPutLineBlock value:something
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   182
    ].
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   183
    super nextPutLine:something
1621
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   184
!
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   185
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   186
peek
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   187
    "peek ahead for return the next element from the stream by evaluating the peekBlock"
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   188
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   189
    peekBlock notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   190
        ^ peekBlock value
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   191
    ].
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   192
    self error:'action for peek is undefined'
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   193
! !
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   194
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   195
!ActorStream methodsFor:'converting'!
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   196
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   197
readStream
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   198
    "return a readStream from the receiver. 
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   199
     Since this is (hopefully) already a readStream, return self."
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   200
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   201
    ^ self
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
! !
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
!ActorStream methodsFor:'defining actions'!
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
936
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   206
atEndBlock:aBlock
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   207
    "define the block to be evaluated for every atEnd-message"
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   208
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
!
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   211
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
nextBlock:aBlock
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    "define the block to be evaluated for every next-message"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
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
!
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
nextPutAllBlock:aBlock
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   219
    "define the block to be evaluated for every nextPutAll-message.
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   220
     If undefined, nextPuts will be used (as inherited)"
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    nextPutAllBlock := aBlock
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
!
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
nextPutBlock:aBlock
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    "define the block to be evaluated for every nextPut-message"
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
987
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   229
!
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   230
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   231
nextPutLineBlock:aBlock
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   232
    "define the block to be evaluated for every nextPutLineBlock-message.
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   233
     If undefined, nextPutAll/nextPut will be used (as inherited)"
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   234
686f04a472ff added nextPutLineBlock support.
md
parents: 936
diff changeset
   235
    nextPutLineBlock := aBlock
1621
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   236
!
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   237
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   238
peekBlock:aBlock
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   239
    "define the block to be evaluated for every peek-message"
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   240
Claus Gittinger <cg@exept.de>
parents: 1008
diff changeset
   241
    peekBlock := aBlock
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
! !
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
!ActorStream methodsFor:'queries'!
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
atEnd
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    "return true, if at the end - actorStreams are never"
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
936
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   249
    atEndBlock isNil ifTrue:[
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   250
        ^ false
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   251
    ].
78dd80467275 added atEnd block (optional)
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   252
    ^ atEndBlock value
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
! !
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
!ActorStream class methodsFor:'documentation'!
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
version
4768
a03651751649 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3531
diff changeset
   258
    ^ '$Header$'
166
76948f2bd7e5 ActorStream moved from libbasic
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
! !
3089
c0936306138e class: ActorStream
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
   260