Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
SmartRefStream conversion methods
Last updated at 12:31 pm UTC on 16 June 2018
There might be a method in particular classes which help convert an object instance stored in an older version of the class into a newer version of the class when the object is loaded into a different image.

The method is
 convertToCurrentVersion: varDict refStream: aSmartRefStream 


This is used when loading project files:
How is an incoming object from a project file converted to the current version?


At fileOut time, ChangeSet>>checkForConversionMethods creates a prototype of this method. This happens only if
 Preference #conversionMethodsAtFileOut 
is true.

The programmer must edit the method
convertToCurrentVersion:refStream:
to
1. test if the incoming object needs conversion,
2. put non-nil values into any new inst vars that need them, and
3. save the data of any inst vars that are being deleted.

Determining which old version is represented by the incoming object can be done in several ways:

If a class is renamed, a method goes into SmartRefStream telling the new name.

The conversion method of the new class must be prepared to accept instances of the old class also.
If no inst var names have changed, the conversion method does nothing.


This is illustrated by a SmartRefStream renaming example.



Note: The burden is on the programmer to provide a conversion method. The open question is if a web site could provide information about the evolution of objects
http://lists.squeakfoundation.org/pipermail/squeak-dev/1999-March.txt