PeekableStream.st
author Stefan Vogel <sv@exept.de>
Sun, 22 Aug 2004 19:58:15 +0200
changeset 8485 d94728eaf4f0
parent 8443 7bc4348c059e
child 8714 b93862ab1caa
permissions -rw-r--r--
Use access methods for oldPackage and newPackage in notifications. Fix strings when doing infoPrint
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     1
"
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
379
5b5a130ccd09 revision added
claus
parents: 369
diff changeset
     3
	      All Rights Reserved
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     4
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    11
"
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    12
5394
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    13
"{ Package: 'stx:libbasic' }"
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    14
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    15
Stream subclass:#PeekableStream
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    16
	instanceVariableNames:''
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    17
	classVariableNames:'ErrorDuringFileInSignal CurrentFileInDirectoryQuerySignal'
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    18
	poolDictionaries:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    19
	category:'Streams'
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    20
!
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    22
!PeekableStream class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    23
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    25
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    26
 COPYRIGHT (c) 1994 by Claus Gittinger
379
5b5a130ccd09 revision added
claus
parents: 369
diff changeset
    27
	      All Rights Reserved
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    28
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    36
!
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    37
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    38
documentation
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    39
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    40
    abstract superclass for all Stream which support read-ahead
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    41
    (i.e. peeking) of one element.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    42
    Concrete subclasses must implement a peek method.
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    43
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    44
    [author:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    45
        Claus Gittinger
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    46
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    47
! !
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    48
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    49
!PeekableStream class methodsFor:'initialization'!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    50
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    51
initialize
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    52
    "setup the signal used to handle errors during fileIn"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    53
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    54
    ErrorDuringFileInSignal isNil ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    55
        ErrorDuringFileInSignal := Error newSignalMayProceed:true.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    56
        ErrorDuringFileInSignal nameClass:self message:#errorDuringFileInSignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    57
        ErrorDuringFileInSignal notifierString:'error during fileIn'.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    58
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    59
        CurrentFileInDirectoryQuerySignal := QuerySignal new.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    60
        CurrentFileInDirectoryQuerySignal nameClass:self message:#currentFileInDirectoryQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    61
        CurrentFileInDirectoryQuerySignal notifierString:'query for current directory when filing in'.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    62
        CurrentFileInDirectoryQuerySignal handlerBlock:[:ex | ex proceedWith:Filename currentDirectory].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    63
    ]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    64
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    65
    "
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    66
     self initialize
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    67
    "
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    68
! !
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    69
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    70
!PeekableStream class methodsFor:'Signal constants'!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    71
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    72
currentFileInDirectoryQuerySignal
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    73
    "return the querySignal, which can be used to ask for the current directory
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    74
     during a fileIn (that is the directory where the filed-in file resides),
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    75
     and in a fileBrowsers doIt.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    76
     Using this, allows for the loaded code or doIts to ask for the fileBrowsers
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    77
     current directory, by asking this querySignal (which is nice sometimes)."
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    78
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    79
    ^ CurrentFileInDirectoryQuerySignal
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    80
! !
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    81
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    82
!PeekableStream class methodsFor:'queries'!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    83
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    84
currentFileInDirectory
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    85
    "during a fileIn (if a script), the script can ask for the current directory"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    86
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    87
    ^ CurrentFileInDirectoryQuerySignal query
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    88
! !
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
    89
5394
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    90
!PeekableStream methodsFor:'chunk input/output'!
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    91
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    92
nextChunk
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    93
    "return the next chunk, i.e. all characters up to the next
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    94
     exclamation mark. Within the chunk, exclamation marks have to be doubled,
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    95
     they are undoubled here.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    96
     Except for primitive code, in which doubling is not needed (allowed).
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    97
     This exception was added to make it easier to edit primitive code with 
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    98
     external editors. However, this means, that other Smalltalks cannot always 
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    99
     read chunks containing primitive code 
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   100
     - but that doesnt really matter, since C-primitives are an ST/X feature anyway."
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   101
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   102
    |theString sep newString done thisChar nextChar inPrimitive
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   103
     index    "{ Class:SmallInteger }"
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   104
     currSize "{ Class:SmallInteger }" |
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   105
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   106
    sep := ChunkSeparator.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   107
    theString := String new:500.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   108
    currSize := 500.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   109
    thisChar := self skipSeparators.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   110
    thisChar := self next.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   111
    index := 0.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   112
    done := false.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   113
    inPrimitive := false.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   114
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   115
    [done] whileFalse:[
8192
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   116
        ((index + 2) <= currSize) ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   117
            newString := String new:(currSize * 2).
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   118
            newString replaceFrom:1 to:currSize with:theString.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   119
            currSize := currSize * 2.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   120
            theString := newString
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   121
        ].
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   122
        thisChar isNil ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   123
            done := true
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   124
        ] ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   125
            (thisChar == $% ) ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   126
                nextChar := self peek.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   127
                (nextChar == ${ ) ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   128
                    inPrimitive := true.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   129
                    index := index + 1.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   130
                    theString at:index put:thisChar.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   131
                    thisChar := self next
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   132
                ] ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   133
                    (nextChar == $} ) ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   134
                        inPrimitive := false.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   135
                        index := index + 1.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   136
                        theString at:index put:thisChar.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   137
                        thisChar := self next
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   138
                    ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   139
                ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   140
            ] ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   141
                inPrimitive ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   142
                    (thisChar == sep) ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   143
                        (self peek == sep) ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   144
                            done := true
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   145
                        ] ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   146
                            self next
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   147
                        ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   148
                    ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   149
                ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   150
            ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   151
        ].
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   152
        done ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   153
            index := index + 1.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   154
"/            thisChar == Character return ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   155
"/                self peekOrNil == Character lf ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   156
"/                    thisChar := Character lf.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   157
"/                    self next.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   158
"/                ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   159
"/            ].
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   160
            theString at:index put:thisChar.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   161
            thisChar := self next.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   162
        ]
5394
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   163
    ].
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   164
    (index == 0) ifTrue:[^ ''].
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   165
    ^ theString copyTo:index
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   166
! !
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   167
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   168
!PeekableStream methodsFor:'fileIn'!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   169
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   170
askForDebug:message
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   171
    "launch a box asking if a debugger is wanted - used when an error
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   172
     occurs while filing in"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   173
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   174
    ^ self askForDebug:message canContinueForAll:false
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   175
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   176
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   177
askForDebug:message canContinueForAll:canContinueForAll
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   178
    "launch a box asking if a debugger is wanted - used when an error
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   179
     occurs while filing in"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   180
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   181
    |labels values|
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   182
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   183
    Smalltalk isInitialized ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   184
        'PositionableStream [warning]: fileIn error during startup: ' errorPrint. message errorPrintCR.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   185
        ^ #debug
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   186
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   187
    "/
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   188
    "/ are we in the startup sequence of an image restart ?
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   189
    "/
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   190
    Processor activeProcessIsSystemProcess ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   191
        'PositionableStream [warning]: fileIn error during startup: ' errorPrint. message errorPrintCR.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   192
        ^ #continue
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   193
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   194
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   195
    canContinueForAll ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   196
          labels := #('Cancel' 'Skip' 'Debug' 'Dont ask again' 'Continue').
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   197
          values := #(#abort   #skip  #debug  #continueForAll #continue).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   198
    ] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   199
          labels := #('Cancel' 'Skip' 'Debug' 'Continue').
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   200
          values := #(#abort  #skip   #debug #continue).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   201
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   202
    AbortAllSignal isHandled ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   203
      labels := #('Cancel All') , labels.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   204
      values := #(#cancelAll) , values.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   205
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   206
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   207
    ^ OptionBox 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   208
          request:message 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   209
          label:'Error in fileIn'
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   210
          image:(WarningBox iconBitmap)
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   211
          buttonLabels:labels
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   212
          values:values
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   213
          default:#continue
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   214
          onCancel:#abort.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   215
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   216
    "Modified: 10.1.1997 / 18:00:56 / cg"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   217
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   218
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   219
basicFileInNotifying:someone passChunk:passChunk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   220
    "central method to file in from the receiver, i.e. read chunks and evaluate them -
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   221
     return the value of the last chunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   222
     Someone (which is usually some codeView) is notified of errors."
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   223
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   224
    |lastValue pkg nameSpace usedNameSpaces
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   225
     packageQuerySignal nameSpaceQuerySignal usedNameSpaceQuerySignal
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   226
     changeDefaultApplicationNotificationSignal
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   227
     defaultApplicationQuerySignal defaultApplication
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   228
     confirmationQuerySignal handledSignals passedSignals
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   229
     dontAskSignals askSomeoneForPackage redef outerContext|
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   230
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   231
    self skipSeparators.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   232
    lastValue := self peek.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   233
    lastValue == $< ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   234
        "/ assume, its an xml file
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   235
        ^ self fileInXMLNotifying:someone passChunk:passChunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   236
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   237
    lastValue == $# ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   238
        "assume unix interpreter name:
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   239
         '#!!stx -e' or something like this"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   240
        self nextPeek == $!! ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   241
            "skip the unix command line"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   242
            self nextLine
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   243
        ] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   244
             self error:'Invalid chunk start'
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   245
        ]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   246
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   247
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   248
    Smalltalk::Compiler isNil ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   249
        self isFileStream ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   250
            Transcript show:('[' , self pathName , '] ').
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   251
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   252
        Transcript showCR:'cannot fileIn (no compiler).'.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   253
        ^ nil.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   254
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   255
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   256
    "/ support for V'Age applications
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   257
    defaultApplicationQuerySignal := Class defaultApplicationQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   258
    changeDefaultApplicationNotificationSignal := Class changeDefaultApplicationNotificationSignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   259
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   260
    "/ support for ST/X's nameSpaces & packages
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   261
    packageQuerySignal := Class packageQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   262
    nameSpaceQuerySignal := Class nameSpaceQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   263
    usedNameSpaceQuerySignal := Class usedNameSpaceQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   264
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   265
    (someone respondsTo:#packageToInstall) ifTrue:[
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   266
        pkg := someone packageToInstall.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   267
        askSomeoneForPackage := true.
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   268
    ] ifFalse:[
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   269
        pkg := packageQuerySignal query.
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   270
        askSomeoneForPackage := false.
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   271
    ].
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   272
    (someone respondsTo:#currentNameSpace) ifTrue:[
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   273
        nameSpace := someone currentNameSpace
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   274
    ] ifFalse:[
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   275
        nameSpace := nameSpaceQuerySignal query.
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   276
    ].
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   277
    (someone respondsTo:#usedNameSpaces) ifTrue:[
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   278
        usedNameSpaces := someone usedNameSpaces
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   279
    ] ifFalse:[
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   280
        usedNameSpaces := usedNameSpaceQuerySignal query.
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   281
    ].
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   282
    (someone respondsTo:#defaultApplication) ifTrue:[
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   283
        defaultApplication := someone defaultApplication
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   284
    ] ifFalse:[
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   285
        defaultApplication := defaultApplicationQuerySignal query.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   286
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   287
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   288
    confirmationQuerySignal := Metaclass confirmationQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   289
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   290
    passedSignals := IdentitySet new.
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   291
    handledSignals := SignalSet new.
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   292
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   293
    handledSignals add:changeDefaultApplicationNotificationSignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   294
    passedSignals add:changeDefaultApplicationNotificationSignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   295
    handledSignals add:defaultApplicationQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   296
    passedSignals add:defaultApplicationQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   297
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   298
    handledSignals add:packageQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   299
    handledSignals add:usedNameSpaceQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   300
    handledSignals add:nameSpaceQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   301
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   302
    handledSignals add:Error.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   303
    passedSignals add:Error.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   304
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   305
    handledSignals add:(Class methodRedefinitionSignal).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   306
    passedSignals add:(Class methodRedefinitionSignal).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   307
    handledSignals add:(Class classRedefinitionSignal).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   308
    passedSignals add:(Class classRedefinitionSignal).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   309
    handledSignals add:confirmationQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   310
    passedSignals add:confirmationQuerySignal.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   311
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   312
    outerContext := thisContext.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   313
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   314
    handledSignals handle:[:ex |
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   315
        |sig action what sender msg proceedValue canContinueForAll|
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   316
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   317
        sig := ex signal.
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   318
        ((passedSignals includes:sig) and:[sig isHandledIn:outerContext]) ifTrue:[
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   319
            ex reject
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   320
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   321
        
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   322
        sig == changeDefaultApplicationNotificationSignal ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   323
            "/ invoked via #becomeDefault to set the defaultApp and the package.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   324
            "/ (only when filing in V'Age code)
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   325
            defaultApplication := ex parameter.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   326
            pkg := defaultApplication name asSymbol.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   327
            ex proceedWith:nil
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   328
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   329
        sig == defaultApplicationQuerySignal ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   330
            "/ query for the application to add classes & methods into
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   331
            "/ (only when filing in V'Age code)
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   332
            ex proceedWith:defaultApplication
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   333
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   334
        sig == packageQuerySignal ifTrue:[
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   335
            "answer the package to use for classes & methods"
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   336
            askSomeoneForPackage ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   337
                ex proceedWith:someone packageToInstall
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   338
            ] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   339
                ex proceedWith:pkg
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   340
            ]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   341
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   342
        sig == usedNameSpaceQuerySignal ifTrue:[
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   343
            "answer the nameSpaces to be searched when encountering globals"
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   344
            ex proceedWith:usedNameSpaces
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   345
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   346
        sig == nameSpaceQuerySignal ifTrue:[
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   347
            "answer the nameSpace to install new classes in"
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   348
            ex proceedWith:nameSpace
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   349
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   350
        sig == confirmationQuerySignal ifTrue:[
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   351
            "don't pop up dialogs"
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   352
            ex proceedWith:false
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   353
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   354
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   355
        sig == Stream endOfStreamSignal ifTrue:[
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   356
            "pass premature end of stream signal"
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   357
            ex reject
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   358
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   359
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   360
        sig == NoHandlerError ifTrue:[
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   361
            ex parameter rejected ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   362
                ex reject
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   363
            ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   364
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   365
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   366
        (dontAskSignals notNil and:[dontAskSignals includesKey:sig]) ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   367
            ex proceedWith:(dontAskSignals at:sig)
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   368
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   369
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   370
        canContinueForAll := false.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   371
        redef := false.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   372
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   373
        "/ for your convenience ...
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   374
        (sig == Class methodRedefinitionSignal) ifTrue:[
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   375
            msg := 'trying to overwrite method:\\    ' , ex oldMethod whoString , '\\in package ''' 
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   376
                   , ex oldPackage , ''' with method from package ''' , ex newPackage , ''''.
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   377
            canContinueForAll := true.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   378
        ] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   379
            (sig == Class classRedefinitionSignal) ifTrue:[
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   380
                msg := 'trying to redefine class: ' , ex oldClass name allBold , '\\in package ''' 
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   381
                       , ex oldPackage , ''' with new definition from package ''' , ex newPackage , ''''.
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   382
                canContinueForAll := true.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   383
                redef := true.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   384
            ] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   385
                msg := 'error in fileIn: %1'
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   386
            ]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   387
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   388
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   389
        what := ex description.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   390
        what isNil ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   391
            what := ex signal notifierString.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   392
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   393
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   394
        msg := msg bindWith:what.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   395
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   396
        "/ handle the case where no GUI has been built in,
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   397
        "/ just abort the fileIn with a notification
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   398
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   399
        Screen current isNil ifTrue:[
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   400
            sender := ex suspendedContext sender.
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   401
            msg := (msg , '\\in ' , sender receiver class name , '>>' , sender selector) withCRs.
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   402
            self notify:msg.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   403
            ex return
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   404
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   405
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   406
        sig == HaltInterrupt ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   407
            sender := ex suspendedContext.
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   408
            msg := (msg , '\\in ' , sender receiver class name , '>>' , sender selector) withCRs
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   409
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   410
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   411
        "/ otherwise ask what should be done now and either
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   412
        "/ continue or abort the fileIn
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   413
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   414
        redef ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   415
            action := OptionBox 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   416
                          request:(msg withCRs) 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   417
                          label:'Class redefinition in fileIn'
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   418
                          image:(WarningBox iconBitmap)
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   419
"/ cg: now always keep the old packageID
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   420
"/                          buttonLabels:#('cancel' 'skip' 'debug' 'keep' 'keep all' 'continue' 'continue all')
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   421
"/                          values:#(#abort #skip #debug #keep #keepAll #continue #continueForAll)
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   422
                          buttonLabels:#('Cancel' 'Skip' 'Debug' 'Continue' 'Continue All')
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   423
                          values:#(#abort #skip #debug #keep #keepAll)
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   424
                          default:#keep
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   425
                          onCancel:#abort.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   426
        ] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   427
            action := self askForDebug:msg withCRs canContinueForAll:canContinueForAll.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   428
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   429
        action == #continueForAll ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   430
            dontAskSignals isNil ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   431
                dontAskSignals := IdentityDictionary new.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   432
            ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   433
            dontAskSignals at:sig put:#continue.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   434
            action := proceedValue := #continue.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   435
        ] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   436
            action == #keepForAll ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   437
                dontAskSignals isNil ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   438
                    dontAskSignals := IdentityDictionary new.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   439
                ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   440
                dontAskSignals at:sig put:#keep.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   441
                action := #continue.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   442
                proceedValue := #keep.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   443
            ] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   444
                action == #keep ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   445
                    action := #continue.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   446
                    proceedValue := #keep.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   447
                ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   448
            ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   449
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   450
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   451
        action == #continue ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   452
            ex proceedWith:proceedValue
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   453
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   454
        action == #abort ifTrue:[
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   455
            AbortOperationRequest raise.
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   456
            ex return
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   457
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   458
        action == #cancelAll ifTrue:[
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   459
            AbortAllOperationRequest raise.
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   460
            ex return
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   461
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   462
        action == #skip ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   463
            ex proceedWith:nil
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   464
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   465
        action == #debug ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   466
            Debugger enter:ex suspendedContext 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   467
                     withMessage:ex description 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   468
                     mayProceed:true.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   469
            ex proceedWith:proceedValue
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   470
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   471
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   472
        "/ (ex signal) enterDebuggerWith:ex message:what.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   473
        ex reject
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   474
    ] do:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   475
        [self atEnd] whileFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   476
            lastValue := self fileInNextChunkNotifying:someone passChunk:passChunk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   477
        ]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   478
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   479
    ^ lastValue
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   480
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   481
    "Modified: / 10.9.1999 / 16:54:01 / stefan"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   482
    "Modified: / 16.11.2001 / 16:21:28 / cg"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   483
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   484
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   485
fileIn
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   486
    "file in from the receiver, i.e. read chunks and evaluate them -
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   487
     return the value of the last chunk."
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   488
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   489
    |notifiedLoader|
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   490
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   491
    SourceFileLoader notNil ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   492
        notifiedLoader := SourceFileLoader on:self.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   493
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   494
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   495
    ^ self fileInNotifying:notifiedLoader passChunk:true.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   496
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   497
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   498
fileInBinary
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   499
    "file in from the receiver, i.e. read binary stored classes and/or objects.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   500
     Return the last object."
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   501
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   502
    |bos obj|
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   503
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   504
    bos := BinaryObjectStorage onOld:self.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   505
    Class nameSpaceQuerySignal 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   506
	answer:Smalltalk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   507
	do:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   508
	    [self atEnd] whileFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   509
		obj := bos next.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   510
	    ]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   511
	].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   512
    bos close.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   513
    ^ obj
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   514
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   515
    "Created: / 13.11.2001 / 10:12:30 / cg"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   516
    "Modified: / 13.11.2001 / 10:14:04 / cg"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   517
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   518
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   519
fileInNextChunkNotifying:someone
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   520
    "read next chunk, evaluate it and return the result;
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   521
     someone (which is usually some codeView) is notified of errors.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   522
     Filein is done as follows:
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   523
	read a chunk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   524
	if it started with an excla, evaluate it, and let the resulting object
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   525
	fileIn more chunks.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   526
	This is a nice trick, since the methodsFor: expression evaluates to
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   527
	a ClassCategoryReader which reads and compiles chunks for its class.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   528
	However, other than methodsFor expressions are possible - you can
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   529
	(in theory) create readers for any syntax.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   530
    "
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   531
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   532
    ^ self fileInNextChunkNotifying:someone passChunk:false
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   533
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   534
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   535
fileInNextChunkNotifying:someone passChunk:passChunk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   536
    "read next chunk, evaluate it and return the result;
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   537
     someone (which is usually some codeView) is notified of errors.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   538
     Filein is done as follows:
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   539
	read a chunk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   540
	if it started with an excla, evaluate it, and let the resulting object
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   541
	fileIn more chunks.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   542
	This is a nice trick, since the methodsFor: expression evaluates to
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   543
	a ClassCategoryReader which reads and compiles chunks for its class.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   544
	However, other than methodsFor expressions are possible - you can
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   545
	(in theory) create readers for any syntax.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   546
    "
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   547
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   548
    ^ self fileInNextChunkNotifying:someone passChunk:passChunk silent:nil
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   549
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   550
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   551
fileInNextChunkNotifying:someone passChunk:passChunk silent:beSilent
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   552
    "read next chunk, evaluate it and return the result;
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   553
     someone (which is usually some codeView) is notified of errors.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   554
     Filein is done as follows:
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   555
	read a chunk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   556
	if it started with an excla, evaluate it, and let the resulting object
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   557
	fileIn more chunks.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   558
	This is a nice trick, since the methodsFor: expression evaluates to
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   559
	a ClassCategoryReader which reads and compiles chunks for its class.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   560
	However, other than methodsFor expressions are possible - you can
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   561
	(in theory) create readers for any syntax.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   562
    "
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   563
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   564
    |aString sawExcla rslt done|
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   565
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   566
    self skipSeparators.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   567
    self atEnd ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   568
	sawExcla := self peekFor:(self class chunkSeparator).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   569
	aString := self nextChunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   570
	"/
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   571
	"/ handle empty chunks;
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   572
	"/ this allows for Squeak code to be filedIn
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   573
	"/
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   574
	[aString size == 0
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   575
	and:[self atEnd not]] whileTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   576
	    aString := self nextChunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   577
	].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   578
	aString size ~~ 0 ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   579
	    passChunk ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   580
		someone notNil ifTrue:[someone source:aString]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   581
	    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   582
	    sawExcla ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   583
		rslt := Smalltalk::Compiler evaluate:aString notifying:someone.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   584
	    ] ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   585
		Smalltalk::Compiler emptySourceNotificationSignal handle:[:ex |
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   586
		    ^ nil
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   587
		] do:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   588
		    rslt := Smalltalk::Compiler evaluate:aString notifying:someone compile:false.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   589
		].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   590
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   591
		"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   592
		 usually, the above chunk consists of some methodsFor:-expression
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   593
		 in this case, the returned value is a ClassCategoryReader,
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   594
		 which is used to load & compile the methods ...
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   595
		"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   596
		rslt isNil ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   597
		    "
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   598
		     however, if that was nil (i.e. some error), we skip chunks
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   599
		     up to the next empty chunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   600
		    "
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   601
		    Transcript showCR:'skipping chunks ...'.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   602
		    done := false.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   603
		    [done] whileFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   604
			aString := self nextChunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   605
			done := (aString size == 0).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   606
		    ]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   607
		] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   608
		    rslt := rslt 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   609
				fileInFrom:self 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   610
				notifying:someone 
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   611
				passChunk:passChunk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   612
				single:false
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   613
				silent:beSilent
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   614
		]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   615
	    ]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   616
	]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   617
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   618
    ^ rslt
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   619
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   620
    "Modified: 14.10.1997 / 17:10:35 / cg"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   621
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   622
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   623
fileInNotifying:notifiedLoader passChunk:passChunk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   624
    "central method to file in from the receiver, i.e. read chunks and evaluate them -
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   625
     return the value of the last chunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   626
     Someone (which is usually some codeView) is notified of errors."
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   627
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   628
    self isFileStream ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   629
        ^ self basicFileInNotifying:notifiedLoader passChunk:passChunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   630
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   631
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   632
    ^ self fileInNotifying:notifiedLoader passChunk:passChunk inDirectory:(self pathName asFilename directory).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   633
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   634
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   635
fileInNotifying:notifiedLoader passChunk:passChunk inDirectory:aDirectory
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   636
    "central method to file in from the receiver, i.e. read chunks and evaluate them -
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   637
     return the value of the last chunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   638
     Someone (which is usually some codeView) is notified of errors."
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   639
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   640
    |oldPath val thisDirectory thisDirectoryPathName|
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   641
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   642
    thisDirectory := aDirectory asFilename.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   643
    thisDirectoryPathName := thisDirectory pathName.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   644
    oldPath := Smalltalk systemPath.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   645
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   646
    [   
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   647
        Smalltalk systemPath:(oldPath copy addFirst:thisDirectoryPathName; yourself).
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   648
        CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   649
            val := self basicFileInNotifying:notifiedLoader passChunk:passChunk.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   650
        ]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   651
    ] ensure:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   652
        "take care, someone could have changed SystemPath during fileIn!!"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   653
        (Smalltalk systemPath copyFrom:2) = oldPath ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   654
            Smalltalk systemPath:oldPath.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   655
        ] ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   656
            (oldPath includes:thisDirectoryPathName) ifFalse:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   657
                Smalltalk systemPath remove:thisDirectoryPathName ifAbsent:[].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   658
                Smalltalk flushPathCaches.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   659
            ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   660
        ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   661
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   662
    ^ val
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   663
!
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   664
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   665
fileInXMLNotifying:someone passChunk:passChunk
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   666
    "filein an XML source file (format as in campSmalltalk DTD)"
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   667
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   668
    | builder parser|
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   669
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   670
    (XML isNil or:[XML::SourceNodeBuilder isNil or:[XML::XMLParser isNil]]) ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   671
	Smalltalk loadPackage:'stx:goodies/xml/vw'.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   672
	(XML isNil or:[XML::SourceNodeBuilder isNil or:[XML::XMLParser isNil]]) ifTrue:[
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   673
	    self error:'Could not load XML package(s) from ''stx:goodies/xml/vw'''.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   674
	]
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   675
    ].
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   676
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   677
    builder := XML::SourceNodeBuilder new.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   678
    parser := XML::XMLParser on:self.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   679
    parser builder:builder.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   680
    parser validate:false.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   681
    parser scanDocument.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   682
    "/ self halt.
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   683
! !
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   684
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   685
!PeekableStream methodsFor:'positioning'!
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
   686
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   687
skipAny:skipCollection
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   688
    "skip all characters included in the argument-set.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   689
     returns the next peeked element or nil, if the end-of-stream was reached."
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   690
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   691
    |nextOne|
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   692
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   693
    nextOne := self peekOrNil.
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   694
    [nextOne notNil and:[skipCollection includes:nextOne]] whileTrue:[
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   695
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   696
        nextOne := self peekOrNil
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   697
    ].
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   698
    ^ nextOne
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   699
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   700
    "
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   701
     |s skipChars|
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   702
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   703
     s := ReadStream on:'some numbers1234with\in other99 stuff' withCRs.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   704
     skipChars := 'abcdefghijklmnopqrstuvwxyz\ ' withCRs.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   705
     s skipAny:skipChars.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   706
     Transcript showCR:(Integer readFrom:s).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   707
     s skipAny:skipChars.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   708
     Transcript showCR:(Integer readFrom:s).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   709
    "
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   710
!
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   711
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   712
skipSeparators
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   713
    "skip all whitespace; returns the next peeked element or
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   714
     nil, if the end-of-stream was reached.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   715
     The streams elements should be characters.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   716
     Notice: compare this method to skipSpaces"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   717
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   718
    |nextOne|
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   719
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   720
    nextOne := self peekOrNil.
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   721
    [nextOne notNil and:[nextOne isSeparator]] whileTrue:[
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   722
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   723
        nextOne := self peekOrNil
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   724
    ].
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   725
    ^ nextOne
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   726
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   727
    "
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   728
     |s|
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   729
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   730
     s := ReadStream on:'one      two\three' withCRs.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   731
     s skipSeparators.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   732
     Transcript showCR:(s nextWord).
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   733
     s skipSeparators.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   734
     Transcript showCR:(s nextWord).
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   735
     s skipSeparators.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   736
     Transcript showCR:(s next displayString).
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   737
    "
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   738
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   739
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   740
skipSeparatorsExceptCR
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   741
    "skip all whitespace except carriage return; returns the 
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   742
     next peeked element or nil, if the end-of-stream was reached.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   743
     The streams elements should be characters.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   744
     Notice: compare this method to skipSpaces and skipSeparators"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   745
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   746
    |nextOne|
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   747
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   748
    nextOne := self peekOrNil.
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   749
    [nextOne notNil 
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   750
     and:[nextOne isSeparator
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   751
     and:[nextOne ~~ Character cr]]] whileTrue:[
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   752
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   753
        nextOne := self peekOrNil
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   754
    ].
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   755
    ^ nextOne
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   756
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   757
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   758
skipSpaces
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   759
    "skip all spaces; returns the next peeked element or
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   760
     nil, if the end-of-stream was reached.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   761
     The streams elements should be characters.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   762
     Notice: this one skips only spaces (i.e. no cr, tabs etc)
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   763
             usually, skipSeparators is what you want."
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   764
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   765
    |nextOne|
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   766
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   767
    nextOne := self peekOrNil.
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   768
    [nextOne notNil and:[nextOne == Character space]] whileTrue:[
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   769
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   770
        nextOne := self peekOrNil
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   771
    ].
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   772
    ^ nextOne
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   773
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   774
    "
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   775
     |s|
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   776
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   777
     s := ReadStream on:'one      two\three' withCRs.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   778
     s skipSpaces.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   779
     Transcript showCR:(s nextWord).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   780
     s skipSpaces.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   781
     Transcript showCR:(s nextWord).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   782
     s skipSpaces.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   783
     Transcript showCR:(s next displayString).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   784
    "
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   785
! !
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   786
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   787
!PeekableStream methodsFor:'reading'!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   788
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   789
nextDecimalInteger
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   790
    "read the next integer in radix 10. Does NOT skip initial whitespace.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   791
     The streams elements should be characters.
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   792
     Be careful - this method returns 0 if not posiioned on a digit intitially
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   793
     or if the end of the stream is encountered."
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   794
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   795
    |nextOne value|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   796
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   797
    nextOne := self peekOrNil.
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   798
    value := 0.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   799
    [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   800
        value := (value * 10) + nextOne digitValue.
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   801
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   802
        nextOne := self peekOrNil
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   803
    ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   804
    ^ value
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   805
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   806
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   807
     |s|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   808
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   809
     s := '1234 5678' readStream.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   810
     s nextDecimalInteger. 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   811
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   812
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   813
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   814
     |s|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   815
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   816
     s := '1234 5678' readStream.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   817
     s nextDecimalInteger.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   818
     s skipSpaces.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   819
     s nextDecimalInteger. 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   820
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   821
!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   822
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   823
nextDelimited:terminator
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   824
    "return the contents of the receiver, up to the next terminator character. 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   825
     Doubled terminators indicate an embedded terminator character.  
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   826
     For example: 'this '' was a quote'. 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   827
     Start postioned before the initial terminator."
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   828
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   829
    | out ch |
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   830
7685
535a69a7cd69 String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
   831
    out := WriteStream on: (String uninitializedNew: 1000).
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   832
    self atEnd ifTrue: [^ ''].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   833
    self next == terminator ifFalse: [self skip: -1].       "absorb initial terminator"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   834
    [(ch := self next) == nil] whileFalse: [
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   835
        (ch == terminator) ifTrue: [
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   836
            self peek == terminator ifFalse: [
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   837
                ^ out contents  "terminator is not doubled; we're done!!"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   838
            ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   839
            self next.  "skip doubled terminator"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   840
        ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   841
        out nextPut: ch.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   842
    ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   843
    ^ out contents
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   844
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   845
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   846
     ('*foo bar baz* more foo' readStream nextDelimited:$*) 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   847
     ('*foo bar **baz***' readStream nextDelimited:$*)   
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   848
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   849
!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   850
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   851
nextPeek
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   852
    "advance to next element and return the peeked element"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   853
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   854
    self next.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   855
    ^ self peek
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   856
!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   857
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   858
peek 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   859
    "return the next element of the stream without advancing (i.e.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   860
     the following send of next will return this element again.)
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   861
     - we do not know here how to do it, it must be redefined in subclass"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   862
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   863
    ^ self subclassResponsibility
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   864
!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   865
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   866
peekFor:anObject 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   867
    "if the next-to-be-read object is equal to the argument, anObject, read it
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   868
     and return true. Otherwise, leave the receiver unaffected and return false."
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   869
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   870
    self peek = anObject ifTrue:[
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   871
	self next.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   872
	^ true
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   873
    ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   874
    ^ false
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   875
!
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   876
2419
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   877
upToMatching:aBlock
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   878
    "Return the next elements up to but not including the next element
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   879
     for which aBlock returns true.
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   880
     The next read will return that matching element."
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   881
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   882
    |answerStream element|
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   883
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   884
    answerStream := WriteStream on:(self contentsSpecies new).
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   885
    [self atEnd] whileFalse: [
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   886
        element := self peek.
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   887
        (aBlock value:element) ifTrue: [^ answerStream contents].
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   888
        answerStream nextPut:element.
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   889
        self next.
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   890
    ].
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   891
    ^ answerStream contents
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   892
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   893
    "
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   894
     'hello world' readStream upToMatching:[:c | c isSeparator].
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   895
    "
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   896
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   897
     |s|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   898
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   899
     s := 'hello world' readStream.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   900
     s upToMatching:[:c | c isSeparator].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   901
     s upToEnd
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   902
    "
2419
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   903
2421
0b8966d99a87 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   904
    "Modified: 26.2.1997 / 12:20:57 / cg"
2419
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   905
!
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   906
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   907
upToSeparator
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   908
    "Return the next elements up to but not including the next separator.
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   909
     The next read will return the separator.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   910
     If no separator is encountered, the contents up to the end is returned.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   911
     The elements are supposed to understand #isSeparator 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   912
     (i.e. the receiver is supposed to be a character-stream)."
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   913
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   914
    ^ self upToMatching:[:ch | ch isSeparator]
2060
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   915
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   916
    "
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   917
     'hello world' readStream upToSeparator  
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   918
     'helloworld' readStream upToSeparator   
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   919
     'helloworld' readStream upToSeparator   
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   920
     '' readStream upToSeparator   
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   921
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   922
     |s|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   923
     s := 'hello world' readStream.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   924
     s upToSeparator.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   925
     s upToEnd  
2060
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   926
    "
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   927
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   928
    "Modified: 4.1.1997 / 23:38:05 / cg"
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   929
! !
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
   930
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   931
!PeekableStream class methodsFor:'documentation'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   932
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   933
version
8485
d94728eaf4f0 Use access methods for oldPackage and newPackage in notifications.
Stefan Vogel <sv@exept.de>
parents: 8443
diff changeset
   934
    ^ '$Header: /cvs/stx/stx/libbasic/PeekableStream.st,v 1.25 2004-08-22 17:58:15 stefan Exp $'
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   935
! !
8443
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   936
7bc4348c059e fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents: 8192
diff changeset
   937
PeekableStream initialize!