PositionableStream.st
author Claus Gittinger <cg@exept.de>
Mon, 25 Feb 2002 21:06:54 +0100
changeset 6413 dc8d492a39ff
parent 6361 93376085b2df
child 6421 58dca33cf0fc
permissions -rw-r--r--
dolphin compatibility
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
5393
7e2230bd4bad moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents: 5308
diff changeset
    13
"{ Package: 'stx:libbasic' }"
7e2230bd4bad moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents: 5308
diff changeset
    14
57
db9677479d35 *** empty log message ***
claus
parents: 44
diff changeset
    15
PeekableStream subclass:#PositionableStream
973
5bb2473bf1ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 875
diff changeset
    16
	instanceVariableNames:'collection position readLimit writeLimit'
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    17
	classVariableNames:'ZeroPosition InvalidPositionErrorSignal ErrorDuringFileInSignal
5393
7e2230bd4bad moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents: 5308
diff changeset
    18
		CurrentFileInDirectoryQuerySignal ChunkSeparator'
973
5bb2473bf1ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 875
diff changeset
    19
	poolDictionaries:''
5bb2473bf1ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 875
diff changeset
    20
	category:'Streams'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    21
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    22
1897
22d1ce9b62a4 fixes for packageQuery
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
    23
!PositionableStream class methodsFor:'documentation'!
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    25
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    26
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    27
 COPYRIGHT (c) 1989 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    28
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    29
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    36
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    37
!
10
claus
parents: 5
diff changeset
    38
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    39
documentation
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    40
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    41
    Instances of PositionableStream allow positioning the read pointer.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    42
    The PositionableStream class also adds methods for source-chunk reading
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    43
    and writing, and for filing-in/out of source code.
3249
8401c3e42165 checkin to force re-checkout.
Claus Gittinger <cg@exept.de>
parents: 3184
diff changeset
    44
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    45
    This is an abstract class.
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
    46
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    47
    Compatibility Notice:
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    48
       For historical reasons, ST/X starts with a 1-position (i.e. as in collections),
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    49
       while ST-80 uses 0-based postions for streams and 1-based positions for collections.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    50
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    51
    THIS CERTAINLY IS BAD.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    52
    To allow for portable code, this method can be asked to return the initial position.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    53
    (for code, which ought to execute under other systems, use:
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    54
       posZero := (PositionableStream class respondsTo:#zeroPosition) 
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    55
                       ifTrue:[PositionableStream zeroPosition]
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    56
                       ifFalse:[0] 
5228
637a1a93b740 comments
Claus Gittinger <cg@exept.de>
parents: 5223
diff changeset
    57
    Please use this query for ST/X programs - we will eventually switch to a 0-based
637a1a93b740 comments
Claus Gittinger <cg@exept.de>
parents: 5223
diff changeset
    58
    indexing scheme, and your programs should be prepared for that.
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    59
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
    60
    [author:]
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    61
        Claus Gittinger
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    62
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    63
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    64
1897
22d1ce9b62a4 fixes for packageQuery
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
    65
!PositionableStream class methodsFor:'initialization'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    66
10
claus
parents: 5
diff changeset
    67
initialize
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
    68
    "setup the signal used to handle errors during fileIn"
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
    69
10
claus
parents: 5
diff changeset
    70
    ErrorDuringFileInSignal isNil ifTrue:[
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    71
        ErrorDuringFileInSignal := ErrorSignal newSignalMayProceed:true.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    72
        ErrorDuringFileInSignal nameClass:self message:#errorDuringFileInSignal.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    73
        ErrorDuringFileInSignal notifierString:'error during fileIn'.
276
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
    74
6314
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
    75
"/        InvalidPositionErrorSignal := PositionErrorSignal newSignalMayProceed:true.
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
    76
"/        InvalidPositionErrorSignal nameClass:self message:#invalidPositionErrorSignal.
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
    77
        InvalidPositionErrorSignal := PositionOutOfBoundsError.
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
    78
        InvalidPositionErrorSignal notifierString:'position out of bounds: '.
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
    79
5223
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
    80
        CurrentFileInDirectoryQuerySignal := QuerySignal new.
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
    81
        CurrentFileInDirectoryQuerySignal nameClass:self message:#currentFileInDirectoryQuerySignal.
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
    82
        CurrentFileInDirectoryQuerySignal notifierString:'query for current directory when filing in'.
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
    83
        CurrentFileInDirectoryQuerySignal handlerBlock:[:ex | ex proceedWith:Filename currentDirectory].
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
    84
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
    85
        ZeroPosition := 1.
10
claus
parents: 5
diff changeset
    86
    ]
claus
parents: 5
diff changeset
    87
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    88
1897
22d1ce9b62a4 fixes for packageQuery
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
    89
!PositionableStream class methodsFor:'instance creation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    90
a27a279701f8 Initial revision
claus
parents:
diff changeset
    91
on:aCollection
a27a279701f8 Initial revision
claus
parents:
diff changeset
    92
    "return a new PositionableStream streaming on aCollection"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    93
a27a279701f8 Initial revision
claus
parents:
diff changeset
    94
    ^ (self basicNew) on:aCollection
a27a279701f8 Initial revision
claus
parents:
diff changeset
    95
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    96
a27a279701f8 Initial revision
claus
parents:
diff changeset
    97
on:aCollection from:first to:last
a27a279701f8 Initial revision
claus
parents:
diff changeset
    98
    "return a new PositionableStream streaming on aCollection
a27a279701f8 Initial revision
claus
parents:
diff changeset
    99
     from first to last"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   100
369
claus
parents: 362
diff changeset
   101
    ^ (self basicNew) on:aCollection from:first to:last
57
db9677479d35 *** empty log message ***
claus
parents: 44
diff changeset
   102
!
db9677479d35 *** empty log message ***
claus
parents: 44
diff changeset
   103
db9677479d35 *** empty log message ***
claus
parents: 44
diff changeset
   104
with:aCollection
db9677479d35 *** empty log message ***
claus
parents: 44
diff changeset
   105
    "return a new PositionableStream streaming on aCollection,
db9677479d35 *** empty log message ***
claus
parents: 44
diff changeset
   106
     the stream is positioned to the end of the collection."
db9677479d35 *** empty log message ***
claus
parents: 44
diff changeset
   107
362
claus
parents: 360
diff changeset
   108
    ^ (self basicNew) with:aCollection
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   109
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   110
3032
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   111
!PositionableStream class methodsFor:'Signal constants'!
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   112
5223
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   113
currentFileInDirectoryQuerySignal
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   114
    "return the querySignal, which can be used to ask for the current directory
5228
637a1a93b740 comments
Claus Gittinger <cg@exept.de>
parents: 5223
diff changeset
   115
     during a fileIn (that is the directory where the filed-in file resides),
637a1a93b740 comments
Claus Gittinger <cg@exept.de>
parents: 5223
diff changeset
   116
     and in a fileBrowsers doIt.
637a1a93b740 comments
Claus Gittinger <cg@exept.de>
parents: 5223
diff changeset
   117
     Using this, allows for the loaded code or doIts to ask for the fileBrowsers
637a1a93b740 comments
Claus Gittinger <cg@exept.de>
parents: 5223
diff changeset
   118
     current directory, by asking this querySignal (which is nice sometimes)."
5223
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   119
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   120
    ^ CurrentFileInDirectoryQuerySignal
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   121
!
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   122
3032
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   123
invalidPositionErrorSignal
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   124
    "return the signal raised if positioning is attempted to an
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   125
     invalid position (i.e. before the begin of the stream or after
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   126
     the end)"
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   127
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   128
    ^ InvalidPositionErrorSignal
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   129
! !
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   130
1897
22d1ce9b62a4 fixes for packageQuery
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   131
!PositionableStream class methodsFor:'constants'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   132
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   133
zeroPosition
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   134
    "return the number, which marks the initial position.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   135
     Compatibility Notice:
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   136
        For historical reasons, ST/X starts with a 1-position (i.e. as in collections),
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   137
        while ST-80 uses 0-based postions for streams and 1-based positions for collections.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   138
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   139
     THIS CERTAINLY IS BAD.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   140
     To allow for portable code, this method can be asked to return the initial position.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   141
     (for code, which ought to execute under other systems, use:
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   142
        posZero := (PositionableStream class respondsTo:#zeroPosition) 
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   143
                        ifTrue:[PositionableStream zeroPosition]
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   144
                        ifFalse:[0] 
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   145
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   146
     Be prepared for this to be changed to return 0 as other ST's do.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   147
        "
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   148
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   149
    ^ ZeroPosition
360
claus
parents: 329
diff changeset
   150
! !
claus
parents: 329
diff changeset
   151
6413
dc8d492a39ff dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6361
diff changeset
   152
!PositionableStream methodsFor:'Compatibility - Dolphin'!
dc8d492a39ff dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6361
diff changeset
   153
dc8d492a39ff dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6361
diff changeset
   154
endChunk
dc8d492a39ff dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6361
diff changeset
   155
    self nextPutChunkSeparator
dc8d492a39ff dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6361
diff changeset
   156
! !
dc8d492a39ff dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6361
diff changeset
   157
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   158
!PositionableStream methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   159
a27a279701f8 Initial revision
claus
parents:
diff changeset
   160
contents
a27a279701f8 Initial revision
claus
parents:
diff changeset
   161
    "return the entire contents of the stream"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   162
a27a279701f8 Initial revision
claus
parents:
diff changeset
   163
    ^ collection
a27a279701f8 Initial revision
claus
parents:
diff changeset
   164
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   165
a27a279701f8 Initial revision
claus
parents:
diff changeset
   166
peek
a27a279701f8 Initial revision
claus
parents:
diff changeset
   167
    "look ahead for and return the next element"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   168
a27a279701f8 Initial revision
claus
parents:
diff changeset
   169
    |peekObject|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   170
a27a279701f8 Initial revision
claus
parents:
diff changeset
   171
    peekObject := self next.
10
claus
parents: 5
diff changeset
   172
    self backStep.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   173
    ^ peekObject
a27a279701f8 Initial revision
claus
parents:
diff changeset
   174
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   175
2432
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   176
peekForAll:aCollection
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   177
    "return true and advance if the next elements are the same
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   178
     as aCollection. 
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   179
     otherwise stay and let the position unchanged"
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   180
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   181
    |oldPos|
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   182
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   183
    oldPos := self position.
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   184
    (self next:(aCollection size)) = aCollection ifTrue:[
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   185
        ^ true
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   186
    ].
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   187
    self position:oldPos.
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   188
    ^ false
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   189
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   190
    "Created: 1.3.1997 / 15:11:25 / cg"
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   191
!
5338f9b60a66 added #peekForAll:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   192
3905
682fc38fd339 added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents: 3604
diff changeset
   193
readLimit
682fc38fd339 added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents: 3604
diff changeset
   194
    "return the read-limit; thats the position at which EOF is returned"
682fc38fd339 added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents: 3604
diff changeset
   195
682fc38fd339 added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents: 3604
diff changeset
   196
    ^ readLimit
682fc38fd339 added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents: 3604
diff changeset
   197
682fc38fd339 added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents: 3604
diff changeset
   198
    "Created: / 30.10.1998 / 16:47:04 / cg"
682fc38fd339 added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents: 3604
diff changeset
   199
!
682fc38fd339 added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents: 3604
diff changeset
   200
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   201
readLimit:aNumber
369
claus
parents: 362
diff changeset
   202
    "set the read-limit; thats the position at which EOF is returned"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   203
a27a279701f8 Initial revision
claus
parents:
diff changeset
   204
    readLimit := aNumber
369
claus
parents: 362
diff changeset
   205
!
claus
parents: 362
diff changeset
   206
claus
parents: 362
diff changeset
   207
writeLimit:aNumber
claus
parents: 362
diff changeset
   208
    "set the writeLimit; thats the position after which writing is prohibited"
claus
parents: 362
diff changeset
   209
claus
parents: 362
diff changeset
   210
    writeLimit := aNumber
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   211
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   212
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   213
!PositionableStream methodsFor:'chunk input/output'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   214
a27a279701f8 Initial revision
claus
parents:
diff changeset
   215
nextChunkPut:aString
a27a279701f8 Initial revision
claus
parents:
diff changeset
   216
    "put aString as a chunk onto the receiver;
217
a0400fdbc933 *** empty log message ***
claus
parents: 180
diff changeset
   217
     double all exclamation marks except within primitives and append a 
276
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   218
     single delimiting exclamation mark at the end.
718
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   219
     This modification of the chunk format (not doubling exclas in primitive code)
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   220
     was done to have primitive code more readable and easier be edited in the fileBrowser
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   221
     or other editors.
276
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   222
     Its no incompatibility, since inline primitives are an ST/X special
718
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   223
     and code containing ST/X primitives cannot be loaded into other smalltalks anyway."
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   224
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   225
    self nextPutAllAsChunk:aString.
5393
7e2230bd4bad moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents: 5308
diff changeset
   226
    self nextPut:(self class chunkSeparator)
718
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   227
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   228
    "Modified: 9.12.1995 / 15:56:54 / cg"
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   229
!
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   230
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   231
nextPutAllAsChunk:aString
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   232
    "put aString as a chunk onto the receiver;
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   233
     double all exclamation marks except within primitives.
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   234
     This modification of the chunk format (not doubling exclas in primitive code)
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   235
     was done to have primitive code more readable and easier be edited in the fileBrowser
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   236
     or other editors.
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   237
     Its no incompatibility, since inline primitives are an ST/X special
6f8222ff2ff0 extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   238
     and code containing ST/X primitives cannot be loaded into other smalltalks anyway."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   239
517
c8fae50c2cc5 fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents: 432
diff changeset
   240
    |sep stopChars inPrimitive character
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   241
     index    "{ Class:SmallInteger }"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   242
     endIndex "{ Class:SmallInteger }"
217
a0400fdbc933 *** empty log message ***
claus
parents: 180
diff changeset
   243
     stop     "{ Class:SmallInteger }"
253
30daee717a53 *** empty log message ***
claus
parents: 217
diff changeset
   244
     next     "{ Class:SmallInteger }"|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   245
3386
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   246
    endIndex := aString size.
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   247
    endIndex == 0 ifTrue:[^ self].
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   248
5393
7e2230bd4bad moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents: 5308
diff changeset
   249
    sep := self class chunkSeparator.
517
c8fae50c2cc5 fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents: 432
diff changeset
   250
    stopChars := '{}' copyWith:sep.
c8fae50c2cc5 fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents: 432
diff changeset
   251
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   252
    inPrimitive := false.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   253
    index := 1.
217
a0400fdbc933 *** empty log message ***
claus
parents: 180
diff changeset
   254
    stop := endIndex + 1.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   255
a27a279701f8 Initial revision
claus
parents:
diff changeset
   256
    [index <= endIndex] whileTrue:[
3386
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   257
        "
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   258
         find position of next interesting character; 
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   259
         output stuff up to that one in one piece
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   260
        "
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   261
        next := aString indexOfAny:stopChars startingAt:index ifAbsent:stop.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   262
3386
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   263
        ((index == 1) and:[next == stop]) ifTrue:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   264
            self nextPutAll:aString
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   265
        ] ifFalse:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   266
            self nextPutAll:aString startingAt:index to:(next - 1)
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   267
        ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   268
3386
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   269
        index := next.
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   270
        (index <= endIndex) ifTrue:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   271
            character := aString at:index.
276
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   272
3386
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   273
            (character == ${ ) ifTrue:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   274
                "/ starts a primitive
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   275
                ((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   276
                    inPrimitive := true
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   277
                ]
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   278
            ] ifFalse:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   279
                "/ ends a primitive
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   280
                (character == $} ) ifTrue:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   281
                    ((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   282
                        inPrimitive := false
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   283
                    ]
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   284
                ] ifFalse:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   285
                    "/
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   286
                    "/ exclas have to be doubled - except if within a primitive
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   287
                    "/
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   288
                    inPrimitive ifFalse:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   289
                        (character == sep) ifTrue:[
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   290
                            self nextPut:sep
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   291
                        ]
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   292
                    ]
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   293
                ]
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   294
            ].
276
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   295
3386
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   296
            self nextPut:character.
5694
20ccdf123aab add a cr, if the source does not end in a carriage return.
Claus Gittinger <cg@exept.de>
parents: 5441
diff changeset
   297
            index := index + 1.
20ccdf123aab add a cr, if the source does not end in a carriage return.
Claus Gittinger <cg@exept.de>
parents: 5441
diff changeset
   298
        ].
20ccdf123aab add a cr, if the source does not end in a carriage return.
Claus Gittinger <cg@exept.de>
parents: 5441
diff changeset
   299
    ].
5695
Claus Gittinger <cg@exept.de>
parents: 5694
diff changeset
   300
    (aString endsWith:Character cr) ifFalse:[
5694
20ccdf123aab add a cr, if the source does not end in a carriage return.
Claus Gittinger <cg@exept.de>
parents: 5441
diff changeset
   301
        self cr.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   302
    ].
517
c8fae50c2cc5 fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents: 432
diff changeset
   303
3386
735c8e814726 quicker empty chunk-putting
Claus Gittinger <cg@exept.de>
parents: 3249
diff changeset
   304
    "Modified: / 21.4.1998 / 17:22:47 / cg"
5694
20ccdf123aab add a cr, if the source does not end in a carriage return.
Claus Gittinger <cg@exept.de>
parents: 5441
diff changeset
   305
    "/ foo
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   306
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   307
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   308
nextPutChunkSeparator
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   309
    "append a chunk separator character"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   310
5393
7e2230bd4bad moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents: 5308
diff changeset
   311
    self nextPut:(self class chunkSeparator)
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   312
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   313
    "Created: 13.9.1995 / 17:39:26 / claus"
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   314
! !
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   315
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   316
!PositionableStream methodsFor:'fileIn'!
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   317
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   318
askForDebug:message
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   319
    "launch a box asking if a debugger is wanted - used when an error
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   320
     occurs while filing in"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   321
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   322
    ^ self askForDebug:message canContinueForAll:false
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   323
!
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   324
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   325
askForDebug:message canContinueForAll:canContinueForAll
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   326
    "launch a box asking if a debugger is wanted - used when an error
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   327
     occurs while filing in"
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   328
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   329
    |labels values|
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   330
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   331
    Smalltalk isInitialized ifFalse:[
2130
b9e7e1cf98bd newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   332
        'PositionableStream [warning]: fileIn error during startup: ' errorPrint. message errorPrintCR.
b9e7e1cf98bd newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   333
        ^ #debug
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   334
    ].
875
2bb6fea4cb55 dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   335
    "/
2bb6fea4cb55 dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   336
    "/ are we in the startup sequence of an image restart ?
2bb6fea4cb55 dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   337
    "/
2bb6fea4cb55 dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   338
    Processor activeProcessIsSystemProcess ifTrue:[
2130
b9e7e1cf98bd newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   339
        'PositionableStream [warning]: fileIn error during startup: ' errorPrint. message errorPrintCR.
b9e7e1cf98bd newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   340
        ^ #continue
875
2bb6fea4cb55 dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   341
    ].
2bb6fea4cb55 dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   342
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   343
    canContinueForAll ifTrue:[
6361
93376085b2df button labels in dialog
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
   344
          labels := #('Cancel' 'Skip' 'Debug' 'Dont ask again' 'Continue').
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   345
          values := #(#abort #skip #debug #continueForAll #continue).
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   346
    ] ifFalse:[
6361
93376085b2df button labels in dialog
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
   347
          labels := #('Cancel' 'Skip' 'Debug' 'Continue').
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   348
          values := #(#abort #skip #debug #continue).
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   349
    ].
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   350
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   351
    ^ OptionBox 
2130
b9e7e1cf98bd newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   352
          request:message 
b9e7e1cf98bd newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   353
          label:'Error in fileIn'
b9e7e1cf98bd newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   354
          form:(WarningBox iconBitmap)
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   355
          buttonLabels:labels
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   356
          values:values
5899
afe75e3fb2fd optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents: 5774
diff changeset
   357
          default:#continue
afe75e3fb2fd optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents: 5774
diff changeset
   358
          onCancel:#abort.
975
716245c81bc0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   359
2130
b9e7e1cf98bd newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   360
    "Modified: 10.1.1997 / 18:00:56 / cg"
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   361
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   362
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   363
fileIn
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   364
    "file in from the receiver, i.e. read chunks and evaluate them -
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   365
     return the value of the last chunk."
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   366
4912
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   367
    |oldPath val|
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   368
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   369
    self isFileStream ifFalse:[
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   370
        ^ self fileInNotifying:(SourceFileLoader on:self) passChunk:true.
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   371
    ].
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   372
5223
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   373
    [   |thisDirectory|
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   374
4912
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   375
        oldPath := Smalltalk systemPath.
5223
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   376
        thisDirectory := self pathName asFilename directory.
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   377
        Smalltalk systemPath:(oldPath copy addFirst:thisDirectory pathName; yourself).
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   378
        CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   379
            val := self fileInNotifying:(SourceFileLoader on:self) passChunk:true.
06cf79da1d4a added currentFileInDirectory query
tm
parents: 5098
diff changeset
   380
        ]
4912
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   381
    ] valueNowOrOnUnwindDo:[
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   382
        Smalltalk systemPath:oldPath.
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   383
    ].
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   384
    ^ val
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   385
43182d65eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4772
diff changeset
   386
    "Modified: / 16.10.1999 / 12:25:27 / cg"
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   387
!
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   388
6179
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   389
fileInBinary
6180
f1f0dfee9372 comment
Claus Gittinger <cg@exept.de>
parents: 6179
diff changeset
   390
    "file in from the receiver, i.e. read binary stored classes and/or objects.
6179
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   391
     Return the last object."
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   392
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   393
    |bos obj|
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   394
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   395
    bos := BinaryObjectStorage onOld:self.
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   396
    Class nameSpaceQuerySignal 
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   397
        answer:Smalltalk
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   398
        do:[
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   399
            [self atEnd] whileFalse:[
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   400
                obj := bos next.
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   401
            ]
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   402
        ].
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   403
    bos close.
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   404
    ^ obj
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   405
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   406
    "Created: / 13.11.2001 / 10:12:30 / cg"
6180
f1f0dfee9372 comment
Claus Gittinger <cg@exept.de>
parents: 6179
diff changeset
   407
    "Modified: / 13.11.2001 / 10:14:04 / cg"
6179
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   408
!
20ce3f4b3f5f + fileInBinary
Claus Gittinger <cg@exept.de>
parents: 6093
diff changeset
   409
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   410
fileInNextChunkNotifying:someone
a27a279701f8 Initial revision
claus
parents:
diff changeset
   411
    "read next chunk, evaluate it and return the result;
276
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   412
     someone (which is usually some codeView) is notified of errors.
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   413
     Filein is done as follows:
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   414
	read a chunk
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   415
	if it started with an excla, evaluate it, and let the resulting object
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   416
	fileIn more chunks.
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   417
	This is a nice trick, since the methodsFor: expression evaluates to
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   418
	a ClassCategoryReader which reads and compiles chunks for its class.
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   419
	However, other than methodsFor expressions are possible - you can
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   420
	(in theory) create readers for any syntax.
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   421
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   422
282
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   423
    ^ self fileInNextChunkNotifying:someone passChunk:false
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   424
!
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   425
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   426
fileInNextChunkNotifying:someone passChunk:passChunk
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   427
    "read next chunk, evaluate it and return the result;
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   428
     someone (which is usually some codeView) is notified of errors.
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   429
     Filein is done as follows:
3032
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   430
        read a chunk
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   431
        if it started with an excla, evaluate it, and let the resulting object
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   432
        fileIn more chunks.
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   433
        This is a nice trick, since the methodsFor: expression evaluates to
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   434
        a ClassCategoryReader which reads and compiles chunks for its class.
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   435
        However, other than methodsFor expressions are possible - you can
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   436
        (in theory) create readers for any syntax.
282
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   437
    "
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   438
5748
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   439
    ^ self fileInNextChunkNotifying:someone passChunk:passChunk silent:nil
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   440
!
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   441
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   442
fileInNextChunkNotifying:someone passChunk:passChunk silent:beSilent
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   443
    "read next chunk, evaluate it and return the result;
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   444
     someone (which is usually some codeView) is notified of errors.
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   445
     Filein is done as follows:
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   446
        read a chunk
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   447
        if it started with an excla, evaluate it, and let the resulting object
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   448
        fileIn more chunks.
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   449
        This is a nice trick, since the methodsFor: expression evaluates to
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   450
        a ClassCategoryReader which reads and compiles chunks for its class.
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   451
        However, other than methodsFor expressions are possible - you can
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   452
        (in theory) create readers for any syntax.
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   453
    "
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   454
276
3b6d97620494 *** empty log message ***
claus
parents: 253
diff changeset
   455
    |aString sawExcla rslt done|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   456
a27a279701f8 Initial revision
claus
parents:
diff changeset
   457
    self skipSeparators.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   458
    self atEnd ifFalse:[
5393
7e2230bd4bad moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents: 5308
diff changeset
   459
        sawExcla := self peekFor:(self class chunkSeparator).
3032
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   460
        aString := self nextChunk.
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   461
        "/
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   462
        "/ handle empty chunks;
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   463
        "/ this allows for Squeak code to be filedIn
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   464
        "/
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   465
        [aString size == 0
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   466
        and:[self atEnd not]] whileTrue:[
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   467
            aString := self nextChunk.
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   468
        ].
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   469
        aString size ~~ 0 ifTrue:[
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   470
            passChunk ifTrue:[
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   471
                someone source:aString
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   472
            ].
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   473
            sawExcla ifFalse:[
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   474
                rslt := Smalltalk::Compiler evaluate:aString notifying:someone.
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   475
            ] ifTrue:[
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   476
                Smalltalk::Compiler emptySourceNotificationSignal handle:[:ex |
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   477
                    ^ nil
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   478
                ] do:[
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   479
                    rslt := Smalltalk::Compiler evaluate:aString notifying:someone compile:false.
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   480
                ].
282
94f5c3a6230d *** empty log message ***
claus
parents: 276
diff changeset
   481
3032
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   482
                "
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   483
                 usually, the above chunk consists of some methodsFor:-expression
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   484
                 in this case, the returned value is a ClassCategoryReader,
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   485
                 which is used to load & compile the methods ...
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   486
                "
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   487
                rslt isNil ifTrue:[
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   488
                    "
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   489
                     however, if that was nil (i.e. some error), we skip chunks
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   490
                     up to the next empty chunk.
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   491
                    "
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   492
                    Transcript showCR:'skipping chunks ...'.
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   493
                    done := false.
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   494
                    [done] whileFalse:[
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   495
                        aString := self nextChunk.
3990
be7844e1e603 size == 0 implies isEmpty == true
Claus Gittinger <cg@exept.de>
parents: 3966
diff changeset
   496
                        done := (aString size == 0).
3032
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   497
                    ]
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   498
                ] ifFalse:[
5748
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   499
                    rslt := rslt 
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   500
                                fileInFrom:self 
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   501
                                notifying:someone 
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   502
                                passChunk:passChunk
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   503
                                single:false
a3d02f8df18e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5734
diff changeset
   504
                                silent:beSilent
3032
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   505
                ]
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   506
            ]
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   507
        ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   508
    ].
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
   509
    ^ rslt
1420
be5f8e9574cc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   510
3032
d267a0b1b48d handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   511
    "Modified: 14.10.1997 / 17:10:35 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   512
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   513
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   514
fileInNotifying:someone passChunk:passChunk
5302
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   515
    "central method to file in from the receiver, i.e. read chunks and evaluate them -
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   516
     return the value of the last chunk.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   517
     Someone (which is usually some codeView) is notified of errors."
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   518
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   519
    |lastValue pkg spc spaces
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   520
     packageQuerySignal nameSpaceQuerySignal usedNameSpaceQuerySignal
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   521
     changeDefaultApplicationNotificationSignal
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   522
     defaultApplicationQuerySignal defaultApplication
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   523
     confirmationQuerySignal handledSignals passedSignals
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   524
     dontAskSignals askSomeoneForPackage redef outerContext|
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   525
5302
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   526
    self skipSeparators.
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   527
    self peek == $< ifTrue:[
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   528
        "/ assume, its an xml file
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   529
        ^ self fileInXMLNotifying:someone passChunk:passChunk.
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   530
    ].
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   531
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   532
    "/ support for V'Age applications
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   533
    defaultApplicationQuerySignal := Class defaultApplicationQuerySignal.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   534
    changeDefaultApplicationNotificationSignal := Class changeDefaultApplicationNotificationSignal.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   535
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   536
    "/ support for ST/X's namespaces & packages
2343
93152bcf4101 only fetch signals once
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   537
    packageQuerySignal := Class packageQuerySignal.
93152bcf4101 only fetch signals once
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   538
    nameSpaceQuerySignal := Class nameSpaceQuerySignal.
93152bcf4101 only fetch signals once
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   539
    usedNameSpaceQuerySignal := Class usedNameSpaceQuerySignal.
93152bcf4101 only fetch signals once
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   540
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   541
    (someone respondsTo:#packageToInstall) ifFalse:[
4059
75f3acfd7ac9 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 3990
diff changeset
   542
        pkg := packageQuerySignal query.
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   543
        askSomeoneForPackage := false.
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   544
    ] ifTrue:[
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   545
        pkg := someone packageToInstall.
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   546
        askSomeoneForPackage := true.
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   547
    ].
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   548
    (someone respondsTo:#currentNameSpace) ifFalse:[
4059
75f3acfd7ac9 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 3990
diff changeset
   549
        spc := nameSpaceQuerySignal query.
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   550
    ] ifTrue:[
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   551
        spc := someone currentNameSpace
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   552
    ].
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   553
    (someone respondsTo:#usedNameSpaces) ifFalse:[
4059
75f3acfd7ac9 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 3990
diff changeset
   554
        spaces := usedNameSpaceQuerySignal query.
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   555
    ] ifTrue:[
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   556
        spaces := someone usedNameSpaces
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   557
    ].
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   558
    (someone respondsTo:#defaultApplication) ifFalse:[
4059
75f3acfd7ac9 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 3990
diff changeset
   559
        defaultApplication := defaultApplicationQuerySignal query.
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   560
    ] ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   561
        defaultApplication := someone defaultApplication
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   562
    ].
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   563
3966
1013f1476687 suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents: 3905
diff changeset
   564
    confirmationQuerySignal := Metaclass confirmationQuerySignal.
1013f1476687 suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents: 3905
diff changeset
   565
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   566
    passedSignals := IdentitySet new.
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   567
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   568
    handledSignals := SignalSet new.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   569
    handledSignals add:changeDefaultApplicationNotificationSignal.
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   570
    passedSignals add:changeDefaultApplicationNotificationSignal.
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   571
    handledSignals add:defaultApplicationQuerySignal.
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   572
    passedSignals add:defaultApplicationQuerySignal.
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   573
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   574
    handledSignals add:packageQuerySignal.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   575
    handledSignals add:usedNameSpaceQuerySignal.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   576
    handledSignals add:nameSpaceQuerySignal.
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   577
3592
ac5e8c09ff42 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3584
diff changeset
   578
    handledSignals add:(Object errorSignal).
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   579
    passedSignals add:(Object errorSignal).
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   580
3592
ac5e8c09ff42 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3584
diff changeset
   581
    handledSignals add:(Class methodRedefinitionSignal).
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   582
    passedSignals add:(Class methodRedefinitionSignal).
3597
98bd336b3c3f also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents: 3592
diff changeset
   583
    handledSignals add:(Class classRedefinitionSignal).
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   584
    passedSignals add:(Class classRedefinitionSignal).
3966
1013f1476687 suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents: 3905
diff changeset
   585
    handledSignals add:confirmationQuerySignal.
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   586
    passedSignals add:confirmationQuerySignal.
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   587
4772
8e701a1c9d6e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4770
diff changeset
   588
    outerContext := thisContext.
8e701a1c9d6e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4770
diff changeset
   589
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   590
    handledSignals handle:[:ex |
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   591
        |sig action what sender msg param oldPackage newPackage proceedValue
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   592
         canContinueForAll|
1902
52376295aca8 namespace fixes
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
   593
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   594
        sig := ex signal.
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   595
"/sig == packageQuerySignal ifTrue:[
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   596
"/self halt.
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   597
"/].
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   598
        (passedSignals includes:sig) ifTrue:[
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   599
            (sig isHandledIn:outerContext) ifTrue:[
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   600
                ex reject
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   601
            ]
4772
8e701a1c9d6e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4770
diff changeset
   602
        ].
8e701a1c9d6e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4770
diff changeset
   603
        
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   604
        sig == changeDefaultApplicationNotificationSignal ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   605
            "/ invoked via #becomeDefault to set the defaultApp and the package.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   606
            "/ (only when filing in V'Age code)
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   607
            defaultApplication := ex parameter.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   608
            pkg := defaultApplication name asSymbol.
4487
6d4340c18e4f replaced #proceed with #proceedWith:nil
Claus Gittinger <cg@exept.de>
parents: 4452
diff changeset
   609
            ex proceedWith:nil
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   610
        ].
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   611
        sig == defaultApplicationQuerySignal ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   612
            "/ query for the application to add classes & methods into
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   613
            "/ (only when filing in V'Age code)
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   614
            ex proceedWith:defaultApplication
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   615
        ].
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   616
        sig == packageQuerySignal ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   617
            "/ query for the package to use for classes & methods
5250
991f068f9a80 not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents: 5228
diff changeset
   618
            askSomeoneForPackage ifTrue:[
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   619
                ex proceedWith:someone packageToInstall
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   620
            ] ifFalse:[
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   621
                ex proceedWith:pkg
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   622
            ]
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   623
        ].
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   624
        sig == usedNameSpaceQuerySignal ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   625
            "/ query for the namespaces searched when encountering globals
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   626
            ex proceedWith:spaces
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   627
        ].
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   628
        sig == nameSpaceQuerySignal ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   629
            "/ query for the namespace to install new classes in
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   630
            ex proceedWith:spc
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   631
        ].
3966
1013f1476687 suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents: 3905
diff changeset
   632
        sig == confirmationQuerySignal ifTrue:[
1013f1476687 suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents: 3905
diff changeset
   633
            ex proceedWith:false "/ no dialogs popping up
1013f1476687 suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents: 3905
diff changeset
   634
        ].
1013f1476687 suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents: 3905
diff changeset
   635
3592
ac5e8c09ff42 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3584
diff changeset
   636
        sig == Stream endOfStreamSignal ifTrue:[
ac5e8c09ff42 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3584
diff changeset
   637
            ex reject
ac5e8c09ff42 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3584
diff changeset
   638
        ].
3580
47534257f9e5 avoid two queries for rejected signals.
Claus Gittinger <cg@exept.de>
parents: 3386
diff changeset
   639
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   640
        sig == Signal noHandlerSignal ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   641
            ex parameter rejected ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   642
                ex reject
3592
ac5e8c09ff42 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3584
diff changeset
   643
            ].
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   644
        ].
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   645
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   646
        (dontAskSignals notNil and:[dontAskSignals includesKey:sig]) ifTrue:[
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   647
            ex proceedWith:(dontAskSignals at:sig)
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   648
        ].
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   649
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   650
        canContinueForAll := false.
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   651
        redef := false.
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   652
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   653
        "/ for your convenience ...
3597
98bd336b3c3f also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents: 3592
diff changeset
   654
        (sig == Class methodRedefinitionSignal) ifTrue:[
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   655
            param := ex parameter. "/ an association: oldMethod -> newMethod
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   656
            oldPackage := param key package.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   657
            newPackage := param value package.
4770
9a6dcf673683 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4717
diff changeset
   658
            msg := 'trying to overwrite method:\\    ' , param key whoString , '\\in package ''' 
4325
a342aa8ff8c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4118
diff changeset
   659
                   , oldPackage , ''' with method from package ''' , newPackage , ''''.
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   660
            canContinueForAll := true.
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   661
        ] ifFalse:[
3597
98bd336b3c3f also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents: 3592
diff changeset
   662
            (sig == Class classRedefinitionSignal) ifTrue:[
98bd336b3c3f also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents: 3592
diff changeset
   663
                param := ex parameter. "/ an association: oldClass -> newClass
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   664
                
3597
98bd336b3c3f also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents: 3592
diff changeset
   665
                oldPackage := param key package.
98bd336b3c3f also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents: 3592
diff changeset
   666
                newPackage := param value package.
5734
c734386ad598 asText allBold -> allBold
Claus Gittinger <cg@exept.de>
parents: 5695
diff changeset
   667
                msg := 'trying to redefine class: ' , param key name allBold , '\\in package ''' 
4325
a342aa8ff8c7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4118
diff changeset
   668
                       , oldPackage , ''' with new definition from package ''' , newPackage , ''''.
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   669
                canContinueForAll := true.
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   670
                redef := true.
3597
98bd336b3c3f also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents: 3592
diff changeset
   671
            ] ifFalse:[
98bd336b3c3f also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents: 3592
diff changeset
   672
                msg := 'error in fileIn: %1'
98bd336b3c3f also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents: 3592
diff changeset
   673
            ]
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   674
        ].
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   675
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   676
        what := ex errorString.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   677
        what isNil ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   678
            what := ex signal notifierString.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   679
        ].
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   680
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   681
        "/ handle the case where no GUI has been built in,
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   682
        "/ just abort the fileIn with a notification
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   683
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   684
        Display isNil ifTrue:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   685
            sender := ex suspendedContext sender.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   686
            self notify:(what , 
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   687
                         ' in ' , sender receiver class name ,
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   688
                         '>>>' , sender selector).
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   689
            ex return
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   690
        ].
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   691
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   692
        msg := msg bindWith:what.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   693
6201
389dc86fdb80 class based exceptions - no longer need to send #haltSígnal
Claus Gittinger <cg@exept.de>
parents: 6180
diff changeset
   694
        sig == HaltInterrupt ifTrue:[
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   695
            sender := ex suspendedContext.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   696
            msg := msg , ('\\in ' , sender receiver class name , '>>>' , sender selector) withCRs
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   697
        ].
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2559
diff changeset
   698
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   699
        "/ otherwise ask what should be done now and either
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   700
        "/ continue or abort the fileIn
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   701
        redef ifTrue:[
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   702
            action := OptionBox 
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   703
                          request:(msg withCRs) 
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   704
                          label:'Class redefinition in fileIn'
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   705
                          form:(WarningBox iconBitmap)
5098
4cb82101e94a always preserve the packageID, when redefining a class
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
   706
"/ cg: now always keep the old packageID
4cb82101e94a always preserve the packageID, when redefining a class
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
   707
"/                          buttonLabels:#('cancel' 'skip' 'debug' 'keep' 'keep all' 'continue' 'continue all')
4cb82101e94a always preserve the packageID, when redefining a class
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
   708
"/                          values:#(#abort #skip #debug #keep #keepAll #continue #continueForAll)
4cb82101e94a always preserve the packageID, when redefining a class
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
   709
                          buttonLabels:#('cancel' 'skip' 'debug' 'continue' 'continue all')
4cb82101e94a always preserve the packageID, when redefining a class
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
   710
                          values:#(#abort #skip #debug #keep #keepAll)
5899
afe75e3fb2fd optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents: 5774
diff changeset
   711
                          default:#continue
afe75e3fb2fd optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents: 5774
diff changeset
   712
                          onCancel:#abort.
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   713
        ] ifFalse:[
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   714
            action := self askForDebug:msg withCRs canContinueForAll:canContinueForAll.
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   715
        ].
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   716
        action == #continueForAll ifTrue:[
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   717
            dontAskSignals isNil ifTrue:[
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   718
                dontAskSignals := IdentityDictionary new.
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   719
            ].
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   720
            dontAskSignals at:sig put:#continue.
4717
db56d09f509a Fix assignment.
Stefan Vogel <sv@exept.de>
parents: 4716
diff changeset
   721
            action := proceedValue := #continue.
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   722
        ] ifFalse:[
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   723
            action == #keepForAll ifTrue:[
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   724
                dontAskSignals isNil ifTrue:[
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   725
                    dontAskSignals := IdentityDictionary new.
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   726
                ].
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   727
                dontAskSignals at:sig put:#keep.
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   728
                action := #continue.
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   729
                proceedValue := #keep.
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   730
            ] ifFalse:[
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   731
                action == #keep ifTrue:[
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   732
                    action := #continue.
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   733
                    proceedValue := #keep.
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   734
                ].
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   735
            ].
4416
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   736
        ].
c6f292792b81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4405
diff changeset
   737
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   738
        action == #continue ifTrue:[
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   739
            ex proceedWith:(proceedValue ? #continue)
2005
d77ecd466b5b handle usedNameSpaces request
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
   740
        ].
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   741
        action == #abort ifTrue:[
4118
c43e3a30b8b4 cancel button now raises abortSignal.
Claus Gittinger <cg@exept.de>
parents: 4059
diff changeset
   742
            AbortSignal raise.
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   743
            ex return
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   744
        ].
3604
a86858b05849 offer skip on error
Claus Gittinger <cg@exept.de>
parents: 3597
diff changeset
   745
        action == #skip ifTrue:[
a86858b05849 offer skip on error
Claus Gittinger <cg@exept.de>
parents: 3597
diff changeset
   746
            ex proceedWith:nil
a86858b05849 offer skip on error
Claus Gittinger <cg@exept.de>
parents: 3597
diff changeset
   747
        ].
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   748
        action == #debug ifTrue:[
4716
e44df17fcbc7 Fix #enter:.. selector for Debugger
Stefan Vogel <sv@exept.de>
parents: 4639
diff changeset
   749
            Debugger enter:ex suspendedContext 
e44df17fcbc7 Fix #enter:.. selector for Debugger
Stefan Vogel <sv@exept.de>
parents: 4639
diff changeset
   750
                     withMessage:ex errorString 
e44df17fcbc7 Fix #enter:.. selector for Debugger
Stefan Vogel <sv@exept.de>
parents: 4639
diff changeset
   751
                     mayProceed:true.
4639
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   752
            ex proceedWith:proceedValue
a139399c5f4f package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents: 4559
diff changeset
   753
        ].
3584
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   754
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   755
        "/ (ex signal) enterDebuggerWith:ex message:what.
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   756
        ex reject
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   757
    ] do:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   758
        [self atEnd] whileFalse:[
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   759
            lastValue := self fileInNextChunkNotifying:someone passChunk:passChunk
099a64bc9b63 support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
   760
        ]
180
c488255bd0be *** empty log message ***
claus
parents: 159
diff changeset
   761
    ].
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   762
    ^ lastValue
973
5bb2473bf1ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 875
diff changeset
   763
4717
db56d09f509a Fix assignment.
Stefan Vogel <sv@exept.de>
parents: 4716
diff changeset
   764
    "Modified: / 10.9.1999 / 16:54:01 / stefan"
6201
389dc86fdb80 class based exceptions - no longer need to send #haltSígnal
Claus Gittinger <cg@exept.de>
parents: 6180
diff changeset
   765
    "Modified: / 16.11.2001 / 16:21:28 / cg"
5302
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   766
!
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   767
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   768
fileInXMLNotifying:someone passChunk:passChunk
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   769
    "filein an XML source file (format as in campSmalltalk DTD)"
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   770
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   771
    | builder parser|
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   772
6093
871a6f06ea1e XML-fileIn fixed
Claus Gittinger <cg@exept.de>
parents: 6003
diff changeset
   773
    (XML isNil or:[XML::SourceNodeBuilder isNil or:[XML::XMLParser isNil]]) ifTrue:[
871a6f06ea1e XML-fileIn fixed
Claus Gittinger <cg@exept.de>
parents: 6003
diff changeset
   774
        Smalltalk loadPackage:'stx:goodies/xml-vw'.
871a6f06ea1e XML-fileIn fixed
Claus Gittinger <cg@exept.de>
parents: 6003
diff changeset
   775
        (XML isNil or:[XML::SourceNodeBuilder isNil or:[XML::XMLParser isNil]]) ifTrue:[
871a6f06ea1e XML-fileIn fixed
Claus Gittinger <cg@exept.de>
parents: 6003
diff changeset
   776
            self error:'Could not load XML package(s) from ''stx:goodies/xml-vw'''.
871a6f06ea1e XML-fileIn fixed
Claus Gittinger <cg@exept.de>
parents: 6003
diff changeset
   777
        ]
6003
9bfa2051faeb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5899
diff changeset
   778
    ].
9bfa2051faeb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5899
diff changeset
   779
6093
871a6f06ea1e XML-fileIn fixed
Claus Gittinger <cg@exept.de>
parents: 6003
diff changeset
   780
    builder := XML::SourceNodeBuilder new.
871a6f06ea1e XML-fileIn fixed
Claus Gittinger <cg@exept.de>
parents: 6003
diff changeset
   781
    parser := XML::XMLParser on:self.
5302
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   782
    parser builder:builder.
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   783
    parser validate:false.
f654a1cbc5b0 support for xml-fileIn
Claus Gittinger <cg@exept.de>
parents: 5250
diff changeset
   784
    parser scanDocument.
6093
871a6f06ea1e XML-fileIn fixed
Claus Gittinger <cg@exept.de>
parents: 6003
diff changeset
   785
    "/ self halt.
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   786
! !
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   787
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   788
!PositionableStream methodsFor:'positioning'!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   789
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   790
backStep
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   791
    "move backward read position by one"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   792
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   793
    self position:(self position - 1)
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   794
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   795
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   796
position
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   797
    "return the read position"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   798
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   799
    ^ position
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   800
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   801
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   802
position:index
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   803
    "set the read (or write) position"
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   804
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   805
    "/ FIX: allow positioning right after last element of stream
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   806
    "/ ((index > readLimit) or:[index < 0]) ifTrue: [^ self positionError].
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   807
6314
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
   808
    ((index > (readLimit+1)) or:[index < ZeroPosition]) ifTrue: [^ self positionError:index].
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   809
    position := index
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   810
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   811
    "
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   812
     |s|
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   813
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   814
     s := '1234567890' readStream.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   815
     s next:5.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   816
     s position:1.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   817
     s next:7.       
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   818
    "
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   819
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   820
    "
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   821
     |s|
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   822
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   823
     s := '' writeStream.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   824
     s nextPutAll:'1234567890'.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   825
     s position:5.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   826
     s nextPutAll:'abcdefg'.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   827
     s contents 
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   828
    "
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   829
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   830
    "
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   831
     |s|
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   832
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   833
     s := '' writeStream.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   834
     s nextPutAll:'1234567890'.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   835
     s position:0.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   836
     s nextPutAll:'abcdefg'.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   837
     s contents 
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   838
    "
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   839
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   840
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   841
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   842
reset
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   843
    "set the read position to the beginning of the collection"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   844
5308
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   845
    self resetPosition
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   846
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   847
    "
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   848
     |s|
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   849
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   850
     s := 'hello world' readStream.
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   851
     Transcript showCR:(s next:5).
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   852
     s reset.
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   853
     Transcript showCR:(s next:10).
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   854
    "
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   855
!
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   856
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   857
resetPosition
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   858
    "set the read position to the beginning of the collection"
8e8b5d2b3b8e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5302
diff changeset
   859
4405
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   860
    position := self class zeroPosition
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   861
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   862
    "
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   863
     |s|
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   864
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   865
     s := 'hello world' readStream.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   866
     Transcript showCR:(s next:5).
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   867
     s reset.
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   868
     Transcript showCR:(s next:10).
247058206089 added ZeroPosition;
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
   869
    "
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   870
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   871
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   872
setToEnd
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   873
    "set the read position to the end of the collection"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   874
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   875
    position := readLimit
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   876
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   877
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   878
skip:numberToSkip
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   879
    "skip the next numberToSkip elements"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   880
5774
dafe65be735b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5748
diff changeset
   881
    numberToSkip ~~ 0 ifTrue:[
dafe65be735b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5748
diff changeset
   882
        self position:(self position + numberToSkip)
dafe65be735b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5748
diff changeset
   883
    ]
1489
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   884
!
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   885
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   886
skipThroughAll:aCollection
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   887
    "skip for and through the sequence given by the argument, aCollection;
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   888
     return nil if not found, self otherwise. 
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   889
     On a successful match, the next read will return elements after aCollection;
2153
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   890
     if no match was found, the receiver will be positioned at the end.
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   891
     This is redefined here, to make use of positioning."
1489
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   892
2154
89e96599e1e2 skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   893
    |buffer l first idx|
1489
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   894
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   895
    l := aCollection size.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   896
    first := aCollection at:1.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   897
    [self atEnd] whileFalse:[
2153
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   898
        buffer := self nextAvailable:l.
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   899
        buffer = aCollection ifTrue:[
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   900
            ^ self
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   901
        ].
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   902
        idx := buffer indexOf:first startingAt:2.
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   903
        idx == 0 ifFalse:[
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   904
            self position:(self position - l + idx - 1)
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   905
        ]
1489
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   906
    ].
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   907
    ^ nil
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   908
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   909
    "
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   910
     |s|
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   911
     s := ReadStream on:'12345678901234567890'.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   912
     s skipThroughAll:'901'.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   913
     s upToEnd  
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   914
    "
2153
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   915
    "
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   916
     |s|
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   917
     s := ReadStream on:'12345678901234567890'.
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   918
     s skipThroughAll:'1234'.
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   919
     s upToEnd  
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   920
    "
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   921
    "
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   922
     |s|
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   923
     s := ReadStream on:'12345678901234567890'.
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   924
     s skipThroughAll:'999'.
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   925
     s atEnd  
244e36cbbd9b skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   926
    "
1489
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   927
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   928
    "Created: 26.6.1996 / 09:35:35 / cg"
2154
89e96599e1e2 skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   929
    "Modified: 11.1.1997 / 19:16:38 / cg"
1489
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   930
!
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   931
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   932
skipToAll:aCollection
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   933
    "skip for the sequence given by the argument, aCollection;
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   934
     return nil if not found, self otherwise. 
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   935
     On a successful match, the next read will return elements of aCollection."
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   936
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   937
    |oldPos buffer l first idx|
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   938
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   939
    oldPos := self position.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   940
    l := aCollection size.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   941
    first := aCollection at:1.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   942
    [self atEnd] whileFalse:[
1998
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   943
	buffer := self next:l.
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   944
	buffer = aCollection ifTrue:[
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   945
	    self position:(self position - l).
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   946
	    ^ self
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   947
	].
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   948
	idx := buffer indexOf:first startingAt:2.
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   949
	idx == 0 ifFalse:[
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   950
	    self position:(self position - l + idx - 1)
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   951
	]
1489
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   952
    ].
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   953
    self position:oldPos.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   954
    ^ nil
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   955
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   956
    "
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   957
     |s|
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   958
     s := ReadStream on:'12345678901234567890'.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   959
     s skipToAll:'901'.
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   960
     s upToEnd  
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   961
    "
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   962
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   963
    "Modified: 26.6.1996 / 09:28:27 / cg"
9e3b166483fb moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   964
    "Created: 26.6.1996 / 09:35:06 / cg"
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   965
! !
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   966
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   967
!PositionableStream methodsFor:'private'!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   968
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   969
contentsSpecies
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   970
    "return a class of which instances will be returned, when
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   971
     parts of the collection are asked for. 
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   972
     (see upTo-kind of methods in subclasses)"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   973
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   974
    ^ collection species
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   975
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   976
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   977
on:aCollection
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   978
    "setup for streaming on aCollection"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   979
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   980
    collection := aCollection.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   981
    readLimit := aCollection size.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   982
    position := "0" 1
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   983
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   984
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   985
on:aCollection from:first to:last
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   986
    "setup for streaming on aCollection from first to last"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   987
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   988
    collection := aCollection.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   989
    position := first.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   990
    readLimit := last
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   991
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   992
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   993
positionError
1998
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   994
    "{ Pragma: +optSpace }"
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   995
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   996
    "report an error when positioning past the end
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   997
     or before the beginning."
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   998
4559
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
   999
    ^ InvalidPositionErrorSignal raiseRequestWith:nil
4452
3d050f505a0a Raise proceedable signals proceedable.
Stefan Vogel <sv@exept.de>
parents: 4416
diff changeset
  1000
3d050f505a0a Raise proceedable signals proceedable.
Stefan Vogel <sv@exept.de>
parents: 4416
diff changeset
  1001
    "Modified: / 26.7.1999 / 10:59:13 / stefan"
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1002
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1003
6314
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
  1004
positionError:badPostition
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
  1005
    "{ Pragma: +optSpace }"
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
  1006
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
  1007
    "report an error when positioning past the end
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
  1008
     or before the beginning."
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
  1009
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
  1010
    ^ InvalidPositionErrorSignal raiseRequestWith:badPostition
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
  1011
!
e1aad938d629 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6230
diff changeset
  1012
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1013
with:aCollection
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1014
    "setup for streaming to the end of aCollection"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1015
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1016
    collection := aCollection.
6230
877a8da90c7c fixed initial position in
Claus Gittinger <cg@exept.de>
parents: 6201
diff changeset
  1017
    readLimit := aCollection size + 1.
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1018
    self setToEnd
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1019
! !
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1020
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1021
!PositionableStream methodsFor:'queries'!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1022
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1023
isPositionable
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1024
    "return true, if the stream supports positioning (this one is)"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1025
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1026
    ^ true
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1027
! !
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1028
3170
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1029
!PositionableStream methodsFor:'reading'!
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1030
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1031
upToAll:aCollection
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1032
    "read until a subcollection consisisting of the elements in aCollection
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1033
     is encountered.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1034
     Return everything read excluding the elements in aCollection.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1035
     The position is left before the collection; i.e. the next
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1036
     read operations will return those elements.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1037
     If no such subcollection is encountered, all elements up to the end 
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1038
     are read and returned.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1039
     Compare this with #throughAll: which also reads up to some objects
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1040
     but positions behind it and DOES include it in the returned
3184
d99302322139 Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents: 3170
diff changeset
  1041
     collection.
d99302322139 Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents: 3170
diff changeset
  1042
d99302322139 Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents: 3170
diff changeset
  1043
     Note: this behavior is inconsistent with the other upTo.. methods,
d99302322139 Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents: 3170
diff changeset
  1044
           which position after the found item. We implement the method
d99302322139 Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents: 3170
diff changeset
  1045
           this way for the sake of ST80-compatibility."
3170
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1046
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1047
    |answerStream element last rslt|
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1048
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1049
    last := aCollection last.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1050
    answerStream := WriteStream on:(self contentsSpecies new).
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1051
    [self atEnd] whileFalse:[
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1052
        element := self next.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1053
        answerStream nextPut:element.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1054
        element == last ifTrue:[
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1055
            ((rslt := answerStream contents) endsWith:aCollection) ifTrue:[
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1056
                self position:(self position - aCollection size).
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1057
                ^ rslt copyWithoutLast:aCollection size
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1058
            ]
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1059
        ].
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1060
    ].
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1061
    ^ answerStream contents
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1062
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1063
    "
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1064
     |s|
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1065
     s := ReadStream on:'hello world'.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1066
     Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'. 
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1067
     Transcript show:'<'; show:(s upToEnd); showCR:'>'. 
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1068
    "
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1069
    "
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1070
     |s|
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1071
     s := ReadStream on:'hello world'.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1072
     Transcript show:'<'; show:(s upToAll:'xx'); showCR:'>'. 
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1073
     Transcript showCR:s atEnd.
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1074
     Transcript show:'<'; show:(s upToEnd); showCR:'>'. 
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1075
    "
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1076
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1077
    "Modified: / 12.1.1998 / 22:06:42 / cg"
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1078
    "Created: / 12.1.1998 / 22:07:01 / cg"
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1079
! !
7b299d83c45a moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1080
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1081
!PositionableStream methodsFor:'testing'!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1082
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1083
atEnd
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1084
    "return true, if the read-position is at the end"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1085
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1086
    ^ position > readLimit
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1087
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1088
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1089
isEmpty
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1090
    "return true, if the contents of the stream is empty"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1091
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1092
    ^ readLimit == 0
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1093
! !
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1094
1897
22d1ce9b62a4 fixes for packageQuery
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
  1095
!PositionableStream class methodsFor:'documentation'!
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
  1096
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
  1097
version
6413
dc8d492a39ff dolphin compatibility
Claus Gittinger <cg@exept.de>
parents: 6361
diff changeset
  1098
    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.108 2002-02-25 20:06:54 cg Exp $'
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
  1099
! !
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1100
PositionableStream initialize!