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
The programmer must edit the method
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:
- noticing that a current inst var is nil when it should have data,
- noticing that there is an older inst var name in the variable dictionary (varDict),
- checking kinds of objects in one or more inst vars,
- or retrieving the classVersion of the incoming object from the ref stream.
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