'From Squeak3.1alpha of 4 February 2001 [latest update: #3811] on 7 March 2001 at 9:44:03 pm'! "Change Set: StoreWordArr2-tk Date: 7 March 2001 Author: Ted Kaehler Those pesky ColorArrays hold raw bits but return Colors when you use at:. We must use basicAt: when writing them to disk."! !ArrayedCollection methodsFor: 'objects from disk' stamp: 'tk 3/7/2001 21:41'! writeOn: aStream | reversed convertToBytes | "Store the array of bits onto the argument, aStream. (leading byte ~= 16r80) identifies this as raw bits (uncompressed). Always store in Big Endian (Mac) byte order. Do the writing at BitBlt speeds. We only intend this for non-pointer arrays. Do nothing if I contain pointers." self class isPointers | self class isWords not ifTrue: [^ super writeOn: aStream]. "super may cause an error, but will not be called." self flag: #bob. "clean up the first part of this" convertToBytes _ aStream originalContents "collection" class isBytes. ((aStream isKindOf: FileStream) or: [aStream isKindOf: GZipSurrogateStream]) ifTrue: [convertToBytes _ false]. "it knows how" (aStream isKindOf: FileStream) ifTrue: [convertToBytes _ false]. "knows how" Smalltalk endianness == #big ifTrue: ["no change" aStream nextInt32Put: self size. convertToBytes ifTrue: [ 1 to: self basicSize do: [:ii | aStream nextNumber: 4 put: (self basicAt: ii)]] "use basicAt: because do: on ColorArray returns Colors!!" "Later define (aStream nextPutWordsAll:) that uses BitBlt to put words on a byteStream quickly" ifFalse: [aStream nextPutAll: self]] ifFalse: [ reversed _ self clone. reversed swapBytesFrom: 1 to: reversed size. aStream nextInt32Put: reversed size. convertToBytes ifTrue: [ 1 to: reversed basicSize do: [:ii | aStream nextNumber: 4 put: (reversed basicAt: ii)]] "use basicAt:" ifFalse: [aStream nextPutAll: reversed]] ! !