--- a/PositionableStream.st Fri Aug 22 15:19:16 2003 +0200
+++ b/PositionableStream.st Sat Aug 23 14:09:21 2003 +0200
@@ -370,162 +370,7 @@
"Modified: 10.1.1997 / 18:00:56 / cg"
!
-fileIn
- "file in from the receiver, i.e. read chunks and evaluate them -
- return the value of the last chunk."
-
- |oldPath val notifiedLoader|
-
- SourceFileLoader notNil ifTrue:[
- notifiedLoader := SourceFileLoader on:self.
- ].
-
- self isFileStream ifFalse:[
- ^ self fileInNotifying:notifiedLoader passChunk:true.
- ].
-
- [ |thisDirectory|
-
- oldPath := Smalltalk systemPath.
- thisDirectory := self pathName asFilename directory.
- Smalltalk systemPath:(oldPath copy addFirst:thisDirectory pathName; yourself).
- CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[
- val := self fileInNotifying:notifiedLoader passChunk:true.
- ]
- ] ensure:[
- Smalltalk systemPath:oldPath.
- ].
- ^ val
-
- "Modified: / 16.10.1999 / 12:25:27 / cg"
-!
-
-fileInBinary
- "file in from the receiver, i.e. read binary stored classes and/or objects.
- Return the last object."
-
- |bos obj|
-
- bos := BinaryObjectStorage onOld:self.
- Class nameSpaceQuerySignal
- answer:Smalltalk
- do:[
- [self atEnd] whileFalse:[
- obj := bos next.
- ]
- ].
- bos close.
- ^ obj
-
- "Created: / 13.11.2001 / 10:12:30 / cg"
- "Modified: / 13.11.2001 / 10:14:04 / cg"
-!
-
-fileInNextChunkNotifying:someone
- "read next chunk, evaluate it and return the result;
- someone (which is usually some codeView) is notified of errors.
- Filein is done as follows:
- read a chunk
- if it started with an excla, evaluate it, and let the resulting object
- fileIn more chunks.
- This is a nice trick, since the methodsFor: expression evaluates to
- a ClassCategoryReader which reads and compiles chunks for its class.
- However, other than methodsFor expressions are possible - you can
- (in theory) create readers for any syntax.
- "
-
- ^ self fileInNextChunkNotifying:someone passChunk:false
-!
-
-fileInNextChunkNotifying:someone passChunk:passChunk
- "read next chunk, evaluate it and return the result;
- someone (which is usually some codeView) is notified of errors.
- Filein is done as follows:
- read a chunk
- if it started with an excla, evaluate it, and let the resulting object
- fileIn more chunks.
- This is a nice trick, since the methodsFor: expression evaluates to
- a ClassCategoryReader which reads and compiles chunks for its class.
- However, other than methodsFor expressions are possible - you can
- (in theory) create readers for any syntax.
- "
-
- ^ self fileInNextChunkNotifying:someone passChunk:passChunk silent:nil
-!
-
-fileInNextChunkNotifying:someone passChunk:passChunk silent:beSilent
- "read next chunk, evaluate it and return the result;
- someone (which is usually some codeView) is notified of errors.
- Filein is done as follows:
- read a chunk
- if it started with an excla, evaluate it, and let the resulting object
- fileIn more chunks.
- This is a nice trick, since the methodsFor: expression evaluates to
- a ClassCategoryReader which reads and compiles chunks for its class.
- However, other than methodsFor expressions are possible - you can
- (in theory) create readers for any syntax.
- "
-
- |aString sawExcla rslt done|
-
- self skipSeparators.
- self atEnd ifFalse:[
- sawExcla := self peekFor:(self class chunkSeparator).
- aString := self nextChunk.
- "/
- "/ handle empty chunks;
- "/ this allows for Squeak code to be filedIn
- "/
- [aString size == 0
- and:[self atEnd not]] whileTrue:[
- aString := self nextChunk.
- ].
- aString size ~~ 0 ifTrue:[
- passChunk ifTrue:[
- someone notNil ifTrue:[someone source:aString]
- ].
- sawExcla ifFalse:[
- rslt := Smalltalk::Compiler evaluate:aString notifying:someone.
- ] ifTrue:[
- Smalltalk::Compiler emptySourceNotificationSignal handle:[:ex |
- ^ nil
- ] do:[
- rslt := Smalltalk::Compiler evaluate:aString notifying:someone compile:false.
- ].
-
- "
- usually, the above chunk consists of some methodsFor:-expression
- in this case, the returned value is a ClassCategoryReader,
- which is used to load & compile the methods ...
- "
- rslt isNil ifTrue:[
- "
- however, if that was nil (i.e. some error), we skip chunks
- up to the next empty chunk.
- "
- Transcript showCR:'skipping chunks ...'.
- done := false.
- [done] whileFalse:[
- aString := self nextChunk.
- done := (aString size == 0).
- ]
- ] ifFalse:[
- rslt := rslt
- fileInFrom:self
- notifying:someone
- passChunk:passChunk
- single:false
- silent:beSilent
- ]
- ]
- ]
- ].
- ^ rslt
-
- "Modified: 14.10.1997 / 17:10:35 / cg"
-!
-
-fileInNotifying:someone passChunk:passChunk
+basicFileInNotifying:someone passChunk:passChunk
"central method to file in from the receiver, i.e. read chunks and evaluate them -
return the value of the last chunk.
Someone (which is usually some codeView) is notified of errors."
@@ -731,6 +576,7 @@
"/ otherwise ask what should be done now and either
"/ continue or abort the fileIn
+Transcript showCR:Screen current.
redef ifTrue:[
action := OptionBox
request:(msg withCRs)
@@ -802,6 +648,179 @@
"Modified: / 16.11.2001 / 16:21:28 / cg"
!
+fileIn
+ "file in from the receiver, i.e. read chunks and evaluate them -
+ return the value of the last chunk."
+
+ |notifiedLoader|
+
+ SourceFileLoader notNil ifTrue:[
+ notifiedLoader := SourceFileLoader on:self.
+ ].
+
+ ^ self fileInNotifying:notifiedLoader passChunk:true.
+!
+
+fileInBinary
+ "file in from the receiver, i.e. read binary stored classes and/or objects.
+ Return the last object."
+
+ |bos obj|
+
+ bos := BinaryObjectStorage onOld:self.
+ Class nameSpaceQuerySignal
+ answer:Smalltalk
+ do:[
+ [self atEnd] whileFalse:[
+ obj := bos next.
+ ]
+ ].
+ bos close.
+ ^ obj
+
+ "Created: / 13.11.2001 / 10:12:30 / cg"
+ "Modified: / 13.11.2001 / 10:14:04 / cg"
+!
+
+fileInNextChunkNotifying:someone
+ "read next chunk, evaluate it and return the result;
+ someone (which is usually some codeView) is notified of errors.
+ Filein is done as follows:
+ read a chunk
+ if it started with an excla, evaluate it, and let the resulting object
+ fileIn more chunks.
+ This is a nice trick, since the methodsFor: expression evaluates to
+ a ClassCategoryReader which reads and compiles chunks for its class.
+ However, other than methodsFor expressions are possible - you can
+ (in theory) create readers for any syntax.
+ "
+
+ ^ self fileInNextChunkNotifying:someone passChunk:false
+!
+
+fileInNextChunkNotifying:someone passChunk:passChunk
+ "read next chunk, evaluate it and return the result;
+ someone (which is usually some codeView) is notified of errors.
+ Filein is done as follows:
+ read a chunk
+ if it started with an excla, evaluate it, and let the resulting object
+ fileIn more chunks.
+ This is a nice trick, since the methodsFor: expression evaluates to
+ a ClassCategoryReader which reads and compiles chunks for its class.
+ However, other than methodsFor expressions are possible - you can
+ (in theory) create readers for any syntax.
+ "
+
+ ^ self fileInNextChunkNotifying:someone passChunk:passChunk silent:nil
+!
+
+fileInNextChunkNotifying:someone passChunk:passChunk silent:beSilent
+ "read next chunk, evaluate it and return the result;
+ someone (which is usually some codeView) is notified of errors.
+ Filein is done as follows:
+ read a chunk
+ if it started with an excla, evaluate it, and let the resulting object
+ fileIn more chunks.
+ This is a nice trick, since the methodsFor: expression evaluates to
+ a ClassCategoryReader which reads and compiles chunks for its class.
+ However, other than methodsFor expressions are possible - you can
+ (in theory) create readers for any syntax.
+ "
+
+ |aString sawExcla rslt done|
+
+ self skipSeparators.
+ self atEnd ifFalse:[
+ sawExcla := self peekFor:(self class chunkSeparator).
+ aString := self nextChunk.
+ "/
+ "/ handle empty chunks;
+ "/ this allows for Squeak code to be filedIn
+ "/
+ [aString size == 0
+ and:[self atEnd not]] whileTrue:[
+ aString := self nextChunk.
+ ].
+ aString size ~~ 0 ifTrue:[
+ passChunk ifTrue:[
+ someone notNil ifTrue:[someone source:aString]
+ ].
+ sawExcla ifFalse:[
+ rslt := Smalltalk::Compiler evaluate:aString notifying:someone.
+ ] ifTrue:[
+ Smalltalk::Compiler emptySourceNotificationSignal handle:[:ex |
+ ^ nil
+ ] do:[
+ rslt := Smalltalk::Compiler evaluate:aString notifying:someone compile:false.
+ ].
+
+ "
+ usually, the above chunk consists of some methodsFor:-expression
+ in this case, the returned value is a ClassCategoryReader,
+ which is used to load & compile the methods ...
+ "
+ rslt isNil ifTrue:[
+ "
+ however, if that was nil (i.e. some error), we skip chunks
+ up to the next empty chunk.
+ "
+ Transcript showCR:'skipping chunks ...'.
+ done := false.
+ [done] whileFalse:[
+ aString := self nextChunk.
+ done := (aString size == 0).
+ ]
+ ] ifFalse:[
+ rslt := rslt
+ fileInFrom:self
+ notifying:someone
+ passChunk:passChunk
+ single:false
+ silent:beSilent
+ ]
+ ]
+ ]
+ ].
+ ^ rslt
+
+ "Modified: 14.10.1997 / 17:10:35 / cg"
+!
+
+fileInNotifying:notifiedLoader passChunk:passChunk
+ "central method to file in from the receiver, i.e. read chunks and evaluate them -
+ return the value of the last chunk.
+ Someone (which is usually some codeView) is notified of errors."
+
+ self isFileStream ifFalse:[
+ ^ self basicFileInNotifying:notifiedLoader passChunk:passChunk.
+ ].
+
+ ^ self fileInNotifying:notifiedLoader passChunk:passChunk inDirectory:(self pathName asFilename directory).
+!
+
+fileInNotifying:notifiedLoader passChunk:passChunk inDirectory:aDirectory
+ "central method to file in from the receiver, i.e. read chunks and evaluate them -
+ return the value of the last chunk.
+ Someone (which is usually some codeView) is notified of errors."
+
+ |oldPath val|
+
+ [
+ |thisDirectory|
+
+ thisDirectory := aDirectory asFilename.
+
+ oldPath := Smalltalk systemPath.
+ Smalltalk systemPath:(oldPath copy addFirst:thisDirectory pathName; yourself).
+ CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[
+ val := self basicFileInNotifying:notifiedLoader passChunk:passChunk.
+ ]
+ ] ensure:[
+ Smalltalk systemPath:oldPath.
+ ].
+ ^ val
+!
+
fileInXMLNotifying:someone passChunk:passChunk
"filein an XML source file (format as in campSmalltalk DTD)"
@@ -1192,7 +1211,7 @@
!PositionableStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.131 2003-07-14 10:50:45 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.132 2003-08-23 12:09:21 cg Exp $'
! !
PositionableStream initialize!