[KCP] another question

Andreas Raab andreas.raab at gmx.de
Fri Jun 27 23:33:47 UTC 2003


Steph,

Move it to Bitmap class and, while you're at it, remove its duplicate
implementation from ArrayedCollection>>swapBytesFrom:to:.

Cheers,
  - Andreas

> -----Original Message-----
> From: squeak-dev-bounces at lists.squeakfoundation.org 
> [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On 
> Behalf Of Stephane Ducasse
> Sent: Friday, June 27, 2003 11:52 PM
> To: The list
> Subject: [KCP] another question
> 
> 
> SystemDictionary>>swapBytesIn: aNonPointerThing from: start to: stop
> 	"Perform a bigEndian/littleEndian byte reversal of my words.
> 	We only intend this for non-pointer arrays.  Do nothing 
> if I contain 
> pointers."
> 	| hack blt |
> 	"The implementation is a hack, but fast for large ranges"
> 	hack _ Form new hackBits: aNonPointerThing.
> 	blt _ (BitBlt toForm: hack) sourceForm: hack.
> 	blt combinationRule: Form reverse.  "XOR"
> 	blt sourceY: start-1; destY: start-1; height: 
> stop-start+1; width: 1.
> 	blt sourceX: 0; destX: 3; copyBits.  "Exchange bytes 0 and 3"
> 	blt sourceX: 3; destX: 0; copyBits.
> 	blt sourceX: 0; destX: 3; copyBits.
> 	blt sourceX: 1; destX: 2; copyBits.  "Exchange bytes 1 and 2"
> 	blt sourceX: 2; destX: 1; copyBits.
> 	blt sourceX: 1; destX: 2; copyBits.
> 
> Should not be there. I was thinking that it could be moved in the 
> SmalltalkImage class.
> 
> Then I looked and saw that there is only one sender:
> 
> StandardFileStream>>nextWordsPutAll: aCollection
> 	"Write the argument a word-like object in big endian 
> format on the 
> receiver.
> 	May be used to write other than plain word-like objects 
> (such as 
> ColorArray)."
> 	| reversed |
> 	aCollection class isPointers | aCollection class isWords not
> 		ifTrue: [^self error: aCollection class name,' 
> is not word-like'].
> 	Smalltalk isLittleEndian ifTrue:[
> 		reversed _ aCollection clone.
> 		Smalltalk swapBytesIn: reversed from: 1 to: 
> aCollection basicSize.
> 		self nextPutAll: reversed.
> 	] ifFalse:[
> 		self nextPutAll: aCollection.
> 	].
> 	^aCollection
> 
> So I was thinking that moving that in the private protocol of 
> StandardFileStream
> 
> Any idea suggestion
> 
> stef
> 
> 



More information about the Squeak-dev mailing list