The Trunk: Collections-eem.744.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-eem.744.mcz

commits-2
Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.744.mcz

==================== Summary ====================

Name: Collections-eem.744
Author: eem
Time: 3 April 2017, 4:06:10.757097 pm
UUID: a4dd8fb1-e4df-4031-b093-12296c5862f8
Ancestors: Collections-eem.743

Regularize literal printing for the Collection literal classes (which include Character).  Replace the idiosyncratic forms storeAsLiteralByteArrayOn: and printAsLiteralFormOn: with printAsLiteralOn:.

Assums Kernel-eem.1082 or later.

=============== Diff against Collections-eem.743 ===============

Item was changed:
+ ----- Method: Array>>printAsBraceFormOn: (in category 'printing') -----
- ----- Method: Array>>printAsBraceFormOn: (in category 'self evaluating') -----
  printAsBraceFormOn: aStream
-
  aStream nextPut: ${.
+ self do: [:el | el printOn: aStream] separatedBy: [ aStream nextPutAll: ' . '].
- self do: [:el | aStream print: el] separatedBy: [ aStream nextPutAll: ' . '].
  aStream nextPut: $}!

Item was removed:
- ----- Method: Array>>printAsLiteralFormOn: (in category 'self evaluating') -----
- printAsLiteralFormOn: aStream
- aStream nextPut: $#.
- self printElementsOn: aStream
- !

Item was added:
+ ----- Method: Array>>printAsLiteralOn: (in category 'printing') -----
+ printAsLiteralOn: aStream
+ aStream nextPut: $#; nextPut: $(.
+ self do: [:each| each printAsLiteralOn: aStream] separatedBy: [aStream space].
+ aStream nextPut: $)
+ !

Item was changed:
  ----- Method: Array>>printOn: (in category 'printing') -----
  printOn: aStream
+ self class == Array ifFalse:
+ [^super printOn: aStream].
+ self shouldBePrintedAsLiteral
+ ifTrue: [self printAsLiteralOn: aStream]
+ ifFalse: [self printAsBraceFormOn: aStream]!
- self shouldBePrintedAsLiteral ifTrue: [^self printAsLiteralFormOn: aStream].
- self class = Array ifTrue: [^self printAsBraceFormOn: aStream].
- ^super printOn: aStream!

Item was changed:
  ----- Method: Array>>storeOn: (in category 'printing') -----
+ storeOn: aStream
- storeOn: aStream
  "Use the literal form if possible."
-
  self shouldBePrintedAsLiteral
+ ifTrue:  [self printAsLiteralOn: aStream]
- ifTrue:
- [aStream nextPut: $#; nextPut: $(.
- self do:
- [:element |
- element storeOn: aStream.
- aStream space].
- aStream nextPut: $)]
  ifFalse: [super storeOn: aStream]!

Item was removed:
- ----- Method: ByteArray>>printAsLiteralByteArrayOn: (in category 'printing') -----
- printAsLiteralByteArrayOn: aStream
-
- aStream nextPutAll: '#['.
- self
- do: [ :each | each printOn: aStream ]
- separatedBy: [ aStream nextPut: $ ].
- aStream nextPut: $]!

Item was added:
+ ----- Method: ByteArray>>printAsLiteralOn: (in category 'printing') -----
+ printAsLiteralOn: aStream
+ aStream nextPut: $#; nextPut: $[.
+ self do: [:each| each storeOn: aStream]
+ separatedBy: [aStream nextPut: $ ].
+ aStream nextPut: $]!

Item was changed:
  ----- Method: ByteArray>>printOn: (in category 'printing') -----
  printOn: aStream
-
  self shouldBePrintedAsLiteral ifFalse:
  [super printOn: aStream.
  aStream space].
+ self printAsLiteralOn: aStream!
- self printAsLiteralByteArrayOn: aStream!

Item was removed:
- ----- Method: ByteArray>>storeAsLiteralByteArrayOn: (in category 'printing') -----
- storeAsLiteralByteArrayOn: aStream
- aStream nextPutAll: '#['.
- self
- do: [ :each | each storeOn: aStream ]
- separatedBy: [ aStream nextPut: $ ].
- aStream nextPut: $]!

Item was changed:
  ----- Method: ByteArray>>storeOn: (in category 'printing') -----
  storeOn: aStream
  self shouldBePrintedAsLiteral
+ ifTrue: [self printAsLiteralOn: aStream]
- ifTrue: [self storeAsLiteralByteArrayOn: aStream]
  ifFalse: [super storeOn: aStream]!

Item was added:
+ ----- Method: Character>>printAsLiteralOn: (in category 'printing') -----
+ printAsLiteralOn: aStream
+ aStream nextPut: $$; nextPut: self!

Item was changed:
  ----- Method: Character>>printOn: (in category 'printing') -----
  printOn: aStream
-
  | integerValue |
+ ((integerValue := self asInteger) > 32 and: [integerValue ~= 127]) ifTrue:
+ [^self printAsLiteralOn: aStream].
- ((integerValue := self asInteger) > 32 and: [ integerValue ~= 127 ]) ifTrue: [
- aStream nextPut: $$; nextPut: self.
- ^self ].
  (self class constantNameFor: self)
  ifNotNil: [ :name | aStream nextPutAll: self class name; space; nextPutAll: name ]
  ifNil: [ aStream nextPutAll: self class name; nextPutAll: ' value: '; print: integerValue ]!

Item was changed:
  ----- Method: Character>>storeOn: (in category 'printing') -----
  storeOn: aStream
  "Common character literals are preceded by '$', however special need to be encoded differently: for some this might be done by using one of the shortcut constructor methods for the rest we have to create them by ascii-value."
 
+ self shouldBePrintedAsLiteral ifTrue:
+ [^self printAsLiteralOn: aStream].
- self shouldBePrintedAsLiteral ifTrue: [
- aStream nextPut: $$; nextPut: self.
- ^self ].
  (self class constantNameFor: self) ifNotNil: [ :name |
  aStream nextPutAll: self class name; space; nextPutAll: name.
  ^self ].
  aStream
  nextPut: $(; nextPutAll: self class name;
  nextPutAll: ' value: '; print: self asInteger; nextPut: $)!

Item was added:
+ ----- Method: String>>printAsLiteralOn: (in category 'printing') -----
+ printAsLiteralOn: aStream
+ "Print inside string quotes, doubling embedded quotes."
+ self storeOn: aStream!

Item was changed:
  ----- Method: String>>printOn: (in category 'printing') -----
+ printOn: aStream
+ "Print inside string quotes, doubling embedded quotes."
- printOn: aStream
- "Print inside string quotes, doubling inbedded quotes."
   
  self storeOn: aStream!

Item was changed:
  ----- Method: String>>storeOn: (in category 'printing') -----
+ storeOn: aStream
+ "Print inside string quotes, doubling embedded quotes."
- storeOn: aStream
- "Print inside string quotes, doubling inbedded quotes."
  | x |
  aStream nextPut: $'.
  1 to: self size do:
  [:i |
  aStream nextPut: (x := self at: i).
  x = $' ifTrue: [aStream nextPut: x]].
  aStream nextPut: $'!