[BUG?][FIX?] Conversion methods at file out

Bob Arning arning at charm.net
Fri May 5 15:28:31 UTC 2000


On Fri, 5 May 2000 16:19:11 +0200 (CEST) Bert Freudenberg <bert at isgnw.CS.Uni-Magdeburg.De> wrote:
>As I wrote, it had to do with changing the superclass:
>
>1. Object subclass: #Bla instVars: 'a b'
>2. Bla subclass: #Blabla instVars: 'c'
>3. New Changeset
>4. Object subclass: #Blabla instVars: 'c'
>5. File out. 
>
>Although I'm beeing asked, no conversion method prototype is
>actually generated.

Bert,

SmartRefStream>>verifyStructure assumed that superclasses handled the conversion of their variables and so assumed that BlaBla itself was ok. Here is a change that notices 'a' and 'b' are no longer present and writes the method for BlaBla.

Cheers,
Bob

===== code follows =====
'From Squeak2.8alpha of 13 January 2000 [latest update: #2052] on 5 May 2000 at 11:16:07 am'!

!SmartRefStream methodsFor: 'read write' stamp: 'RAA 5/5/2000 11:16'!
verifyStructure
	"Compare the incoming inst var name lists with the existing classes.  Prepare tables that will help to restructure those who need it (renamed, reshaped, steady).    If all superclasses are recorded in the file, only compare inst vars of this class, not of superclasses.  They will get their turn.  "

| sel newClass oldVer newList newVer oldList ans newShort oldShort sup converting newlyConverting |
converting _ OrderedCollection new.
newlyConverting _ OrderedCollection new.
structures keysDo: [:nm "an old className (symbol)" |

	"For missing classes, there needs to be a method in SmartRefStream like 
		#rectangleoc2 that returns the new class."
	newClass _ self mapClass: nm.		"does (renamed at: nm put: newClass name)"
	newClass class == String ifTrue: [^ newClass].	"error, fileIn needed"

	oldVer _ self versionSymbol: (structures at: nm).
	newList _ (Array with: newClass classVersion), (newClass allInstVarNames).
	newVer _ self versionSymbol: newList.
	sel _ 'convert',oldVer,':',newVer, ':'.	
		"method name of conversion routine that is send after the object is created."
	oldList _ structures at: nm.
	superclasses ifNil: [newShort _ newList.  oldShort _ oldList]
		ifNotNil: ["just compare inst vars for this class"
			sup _ superclasses at: nm.
			oldShort _ (sup = 'nil' or: [sup ~~ newClass superclass]) 
				ifFalse: [oldList copyFrom: (structures at: sup) size + 1 to: oldList size]
				ifTrue: [oldList copyFrom: 2 to: oldList size].
			oldShort _ (Array with: (oldList at: 1)), oldShort.	"put version back".
			newShort _ (Array with: newClass classVersion), (newClass instVarNames)].
	newList = oldList 
		ifTrue: [steady add: newClass]	"read it in as written"
		ifFalse: [ans _ self verifyClass: newClass was: nm 
					selector: sel newList: newShort oldList: oldShort.
				ans == #exists ifTrue: [converting add: newClass name].
				ans == #new ifTrue: [newlyConverting add: newClass name].
				]].
false & converting isEmpty not ifTrue: ["debug" 
		self inform: 'These classes are being converted from existing methods:\' withCRs,
			converting asArray printString].
newlyConverting isEmpty not ifTrue: [
		self inform: 'Making up new conversion methods for these changed classes\' withCRs,
			newlyConverting asArray printString].! !





More information about the Squeak-dev mailing list