[Cuis-dev] Importing String objects from Squeak (was Re: ReferenceStream class >> dumpOnFile: aFileEntry object: anObject)

H. Hirzel hannes.hirzel at gmail.com
Sat Nov 30 10:52:24 PST 2024


Hi Juan

I suggest to add a comment on

ReferenceStream class  restoreFromFile: aFileEntry

would have wished would be included.

"
  Note about importing String objects from Squeak:

To make sure Strings can be moved from Squeak use
            aString utf8Encoded
to convert the strings to ByteArrays in Squeak before you export the 
object collection.

In Cuis you need to do then
            UnicodeString fromUtf8Bytes: aByteArray
to get them back.

It took me quite some time to figure out this simple solution.

For data classes  ('dumb data objects', Value hierarchy) I can hide this 
conversion if I store the strings in a properties dictionary and have 
the conversion in a superclass. This allows me to move these objects 
from Squeak to Cuis.

A better solution would be to have SmartRefStream deal with ByteString 
and WideString objects (when importing from Squeak) as both are not in 
Cuis. But at the moment I am fine using the UTF8 conversion approach.

Regards

Hannes


On 11/27/2024 1:31 PM, H. Hirzel wrote:
> Hello
>
> Attached is an updated comment of
>
>   ReferenceStream class >> dumpOnFile: aFileEntry object: anObject
>
> --Hannes
-------------- next part --------------
'From Cuis7.1 [latest update: #6858] on 30 November 2024 at 6:39:45 pm'!

!ReferenceStream class methodsFor: 'as yet unclassified' stamp: 'hjh 11/30/2024 18:38:35'!
dumpOnFile: aFileEntry object: anObject
	"Warning: If the file given by aFileEntry exists, it will be overwritten."
	
	aFileEntry forceWriteStreamDo: [ :stream |
		(self on: stream) nextPut: anObject ].! !

!ReferenceStream class methodsFor: 'as yet unclassified' stamp: 'hjh 11/30/2024 18:37:58'!
restoreFromFile: aFileEntry
"
 Note about importing String objects from Squeak: 
	
To make sure Strings can be moved from Squeak use 
           aString utf8Encoded 
to convert the strings to ByteArrays in Squeak before you export the object collection.

In Cuis you need to do then
           UnicodeString fromUtf8Bytes: aByteArray
to get them back.
"
	| answer |
	aFileEntry readStreamDo: [ :stream |
		answer := (self on: stream) next ].
	^answer! !



More information about the Cuis-dev mailing list