Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.299.mcz
==================== Summary ====================
Name: Graphics-nice.299
Author: nice
Time: 28 July 2014, 12:17:36.812 pm
UUID: 571c7dc6-b3c2-45cd-8a70-372784b82f72
Ancestors: Graphics-nice.298
Continue cleaning of RWBinaryOrTextStream reset uggliness:
- don't reset the stream in ImageReadWriter initialization (>>on:)
- reset the stream after sending #understandsImageFormat:
- make sure the stream is still binary after the reset in JPEGReadWriter class>>understandsImageFormat: - NOTE: from what I understand, RWBinaryOrTextStream and it's Multi alternative are those loosing the binary property, not FileStream... These swiss knife streams are really a next of undue complexity. This workaround should go away when we finally get rid of them.
=============== Diff against Graphics-nice.298 ===============
Item was changed:
----- Method: ImageReadWriter class>>formFromStream: (in category 'image reading/writing') -----
formFromStream: aBinaryStream
"Answer a ColorForm stored on the given stream. closes the stream"
| reader readerClass form |
readerClass := self withAllSubclasses
detect: [:subclass | subclass understandsImageFormat: aBinaryStream]
ifNone: [
aBinaryStream close.
^self error: 'image format not recognized'].
+ aBinaryStream reset.
reader := readerClass new on: aBinaryStream.
Cursor read showWhile: [
form := reader nextImage.
reader close].
^ form
!
Item was changed:
----- Method: ImageReadWriter>>on: (in category 'private') -----
on: aStream
+ stream := aStream.
+ stream binary.!
- (stream := aStream) reset.
- stream binary.
- "Note that 'reset' makes a file be text. Must do this after."!
Item was changed:
----- Method: JPEGReadWriter class>>understandsImageFormat: (in category 'image reading/writing') -----
understandsImageFormat: aStream
(JPEGReadWriter2 understandsImageFormat: aStream) ifTrue:[^false].
+ aStream reset; binary.
- aStream reset.
aStream next = 16rFF ifFalse: [^ false].
aStream next = 16rD8 ifFalse: [^ false].
^true!
Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.298.mcz
==================== Summary ====================
Name: Graphics-nice.298
Author: nice
Time: 27 July 2014, 4:20:11.638 pm
UUID: 170cf894-37d9-4c00-adc3-8531594246dc
Ancestors: Graphics-nice.297
Rather than commenting uggliness, remove it.
Compatibility notes:
>From now on, DON'T expect (ImageReadWriter formFromStream: yourStream) to reset yourStream. It's not its business, besides it does not work for every kind of Stream.
Resetting a Stream was only ever required for constructs like (ReadWriteStream with: 'someData') reset.
But you DON'T have to use a ReadWriteStream if it's just for reading. Rather use a ReadStream, this way, no reset is required.
If really ReadWriteStream is what fits (why?) then you'll now have to perform the reset by yourself.
=============== Diff against Graphics-nice.297 ===============
Item was changed:
----- Method: Form>>readNativeResourceFrom: (in category 'resources') -----
readNativeResourceFrom: byteStream
| img aStream |
+ aStream := byteStream.
- (byteStream isKindOf: FileStream) ifTrue:[
- "Ugly, but ImageReadWriter will send #reset which is implemented as #reopen and we may not be able to do so."
- aStream := RWBinaryOrTextStream with: byteStream contents.
- ] ifFalse:[
- aStream := byteStream.
- ].
img := [ImageReadWriter formFromStream: aStream] on: Error do:[:ex| nil].
img ifNil:[^nil].
(img isColorForm and:[self isColorForm]) ifTrue:[
| cc |
cc := img colors.
img colors: nil.
img displayOn: self.
img colors: cc.
] ifFalse:[
img displayOn: self.
].
img := nil.!
Item was changed:
----- Method: ImageReadWriter class>>formFromStream: (in category 'image reading/writing') -----
formFromStream: aBinaryStream
"Answer a ColorForm stored on the given stream. closes the stream"
| reader readerClass form |
readerClass := self withAllSubclasses
detect: [:subclass | subclass understandsImageFormat: aBinaryStream]
ifNone: [
aBinaryStream close.
^self error: 'image format not recognized'].
+ reader := readerClass new on: aBinaryStream.
- reader := readerClass new on: aBinaryStream reset.
Cursor read showWhile: [
form := reader nextImage.
reader close].
^ form
!
Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.298.mcz
==================== Summary ====================
Name: Graphics-nice.298
Author: nice
Time: 27 July 2014, 4:20:11.638 pm
UUID: 170cf894-37d9-4c00-adc3-8531594246dc
Ancestors: Graphics-nice.297
Rather than commenting uggliness, remove it.
Compatibility notes:
>From now on, DON'T expect (ImageReadWriter formFromStream: yourStream) to reset yourStream. It's not its business, besides it does not work for every kind of Stream.
Resetting a Stream was only ever required for constructs like (ReadWriteStream with: 'someData') reset.
But you DON'T have to use a ReadWriteStream if it's just for reading. Rather use a ReadStream, this way, no reset is required.
If really ReadWriteStream is what fits (why?) then you'll now have to perform the reset by yourself.
=============== Diff against Graphics-nice.297 ===============
Item was changed:
----- Method: Form>>readNativeResourceFrom: (in category 'resources') -----
readNativeResourceFrom: byteStream
| img aStream |
+ aStream := byteStream.
- (byteStream isKindOf: FileStream) ifTrue:[
- "Ugly, but ImageReadWriter will send #reset which is implemented as #reopen and we may not be able to do so."
- aStream := RWBinaryOrTextStream with: byteStream contents.
- ] ifFalse:[
- aStream := byteStream.
- ].
img := [ImageReadWriter formFromStream: aStream] on: Error do:[:ex| nil].
img ifNil:[^nil].
(img isColorForm and:[self isColorForm]) ifTrue:[
| cc |
cc := img colors.
img colors: nil.
img displayOn: self.
img colors: cc.
] ifFalse:[
img displayOn: self.
].
img := nil.!
Item was changed:
----- Method: ImageReadWriter class>>formFromStream: (in category 'image reading/writing') -----
formFromStream: aBinaryStream
"Answer a ColorForm stored on the given stream. closes the stream"
| reader readerClass form |
readerClass := self withAllSubclasses
detect: [:subclass | subclass understandsImageFormat: aBinaryStream]
ifNone: [
aBinaryStream close.
^self error: 'image format not recognized'].
+ reader := readerClass new on: aBinaryStream.
- reader := readerClass new on: aBinaryStream reset.
Cursor read showWhile: [
form := reader nextImage.
reader close].
^ form
!
Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.298.mcz
==================== Summary ====================
Name: Graphics-nice.298
Author: nice
Time: 27 July 2014, 4:20:11.638 pm
UUID: 170cf894-37d9-4c00-adc3-8531594246dc
Ancestors: Graphics-nice.297
Rather than commenting uggliness, remove it.
Compatibility notes:
>From now on, DON'T expect (ImageReadWriter formFromStream: yourStream) to reset yourStream. It's not its business, besides it does not work for every kind of Stream.
Resetting a Stream was only ever required for constructs like (ReadWriteStream with: 'someData') reset.
But you DON'T have to use a ReadWriteStream if it's just for reading. Rather use a ReadStream, this way, no reset is required.
If really ReadWriteStream is what fits (why?) then you'll now have to perform the reset by yourself.
=============== Diff against Graphics-nice.297 ===============
Item was changed:
----- Method: Form>>readNativeResourceFrom: (in category 'resources') -----
readNativeResourceFrom: byteStream
| img aStream |
+ aStream := byteStream.
- (byteStream isKindOf: FileStream) ifTrue:[
- "Ugly, but ImageReadWriter will send #reset which is implemented as #reopen and we may not be able to do so."
- aStream := RWBinaryOrTextStream with: byteStream contents.
- ] ifFalse:[
- aStream := byteStream.
- ].
img := [ImageReadWriter formFromStream: aStream] on: Error do:[:ex| nil].
img ifNil:[^nil].
(img isColorForm and:[self isColorForm]) ifTrue:[
| cc |
cc := img colors.
img colors: nil.
img displayOn: self.
img colors: cc.
] ifFalse:[
img displayOn: self.
].
img := nil.!
Item was changed:
----- Method: ImageReadWriter class>>formFromStream: (in category 'image reading/writing') -----
formFromStream: aBinaryStream
"Answer a ColorForm stored on the given stream. closes the stream"
| reader readerClass form |
readerClass := self withAllSubclasses
detect: [:subclass | subclass understandsImageFormat: aBinaryStream]
ifNone: [
aBinaryStream close.
^self error: 'image format not recognized'].
+ reader := readerClass new on: aBinaryStream.
- reader := readerClass new on: aBinaryStream reset.
Cursor read showWhile: [
form := reader nextImage.
reader close].
^ form
!
Nicolas Cellier uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-nice.69.mcz
==================== Summary ====================
Name: ToolsTests-nice.69
Author: nice
Time: 27 July 2014, 3:55:03.028 pm
UUID: 53091322-737b-4b76-9e47-2e35cefb723b
Ancestors: ToolsTests-cmm.68
Don't use a ReadWriteStream when our intention is just to sequentially write then read.
ReadWriteStream and its complexity should be reserved to random read/write access.
Instead, write on a WriteStream, then read from a ReadStream using new conveniency WriteStream>>readStream..
=============== Diff against ToolsTests-cmm.68 ===============
Item was changed:
----- Method: FileContentsBrowserTest>>setUp (in category 'as yet unclassified') -----
setUp
| fileout testCat package packageDict organizer |
testCat := self class category.
+ fileout := WriteStream on: (String new: 10000).
- fileout := ReadWriteStream on: (String new: 10000).
SystemOrganization fileOutCategory: testCat on: fileout.
packageDict := Dictionary new.
browser := FileContentsBrowser new.
organizer := SystemOrganizer defaultList: Array new.
+ package := (FilePackage new fullName: testCat; fileInFrom: fileout readStream).
- package := (FilePackage new fullName: testCat; fileInFrom: fileout).
packageDict
at: package packageName
put: package.
organizer
classifyAll: package classes keys
under: package packageName.
(browser := FileContentsBrowser systemOrganizer: organizer)
packages: packageDict.!
Nicolas Cellier uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-nice.69.mcz
==================== Summary ====================
Name: ToolsTests-nice.69
Author: nice
Time: 27 July 2014, 3:55:03.028 pm
UUID: 53091322-737b-4b76-9e47-2e35cefb723b
Ancestors: ToolsTests-cmm.68
Don't use a ReadWriteStream when our intention is just to sequentially write then read.
ReadWriteStream and its complexity should be reserved to random read/write access.
Instead, write on a WriteStream, then read from a ReadStream using new conveniency WriteStream>>readStream..
=============== Diff against ToolsTests-cmm.68 ===============
Item was changed:
----- Method: FileContentsBrowserTest>>setUp (in category 'as yet unclassified') -----
setUp
| fileout testCat package packageDict organizer |
testCat := self class category.
+ fileout := WriteStream on: (String new: 10000).
- fileout := ReadWriteStream on: (String new: 10000).
SystemOrganization fileOutCategory: testCat on: fileout.
packageDict := Dictionary new.
browser := FileContentsBrowser new.
organizer := SystemOrganizer defaultList: Array new.
+ package := (FilePackage new fullName: testCat; fileInFrom: fileout readStream).
- package := (FilePackage new fullName: testCat; fileInFrom: fileout).
packageDict
at: package packageName
put: package.
organizer
classifyAll: package classes keys
under: package packageName.
(browser := FileContentsBrowser systemOrganizer: organizer)
packages: packageDict.!
Nicolas Cellier uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-nice.69.mcz
==================== Summary ====================
Name: ToolsTests-nice.69
Author: nice
Time: 27 July 2014, 3:55:03.028 pm
UUID: 53091322-737b-4b76-9e47-2e35cefb723b
Ancestors: ToolsTests-cmm.68
Don't use a ReadWriteStream when our intention is just to sequentially write then read.
ReadWriteStream and its complexity should be reserved to random read/write access.
Instead, write on a WriteStream, then read from a ReadStream using new conveniency WriteStream>>readStream..
=============== Diff against ToolsTests-cmm.68 ===============
Item was changed:
----- Method: FileContentsBrowserTest>>setUp (in category 'as yet unclassified') -----
setUp
| fileout testCat package packageDict organizer |
testCat := self class category.
+ fileout := WriteStream on: (String new: 10000).
- fileout := ReadWriteStream on: (String new: 10000).
SystemOrganization fileOutCategory: testCat on: fileout.
packageDict := Dictionary new.
browser := FileContentsBrowser new.
organizer := SystemOrganizer defaultList: Array new.
+ package := (FilePackage new fullName: testCat; fileInFrom: fileout readStream).
- package := (FilePackage new fullName: testCat; fileInFrom: fileout).
packageDict
at: package packageName
put: package.
organizer
classifyAll: package classes keys
under: package packageName.
(browser := FileContentsBrowser systemOrganizer: organizer)
packages: packageDict.!