Renaming classes

Ross Boylan RossBoylan at stanfordalumni.org
Sat Aug 27 06:53:44 UTC 2005


To migrate to the newer versions of squeak I'm going to need to play
some games with class definitions.  There are various scenarios;
basically I need a good understanding of class definitions, renames,
and the relation of these to class instances.  I'm hoping for some
tips that might save me some time pouring through the code; I don't
see much about this on the wiki.

First scenario: I have a class A and instances.  I file in a changeset
which defines A (suppose its the same definition).  Does everything
just work?  Do I end up with instances pointing at an object which is
the old class A?

Second scenario: I file in a new class B, which is identical to A
except in name.  I want to make all the A instances become B
instances.  I want to make methods that refer to B refer to A.  How?

This involves DateAndTime and friends; the file-ins also do clever
things to swap new and old definitions of, e.g., Date (e.g., changeset
5668).  I notice they
do some hunting around through (compiled?) methods too.  My image has
a DateAndTime class that is similar, though maybe not identical, to
the one in the official file-ins.  It also includes classes like
DTDate which are similar to the "new" Date after the fileins.

For reference, here's the postscript of 5668:
"Postscript:
Rename temporary classes TDate, TTime andTTimeStamp to Date, Time and TimeStamp."

| jdn |
jdn _ SystemVersion current date asDate julianDayNumber.

#(#Date #Time #TimeStamp) 	
	do: 	[ :s | | zname tname |
		Transcript show: (Smalltalk at: s) allInstances; cr.
		zname  _ ('Z', s) asSymbol.
		tname  _ ('T', s) asSymbol.
		(Smalltalk at: s) rename: zname.
		(Smalltalk at: tname) rename: s.
		(Smalltalk systemNavigation allCallsOn: (Smalltalk associationAt: zname))
			do: [ :ref | ref actualClass ifNotNilDo: [ :ac | ac recompile: ref methodSymbol ] ].
		Smalltalk forgetClass: (Smalltalk at: zname) logged: false.
		Transcript show: 'replaced ', s; cr ].

Transcript show: 'removing subclasses....'.
(Magnitude subclasses select: [ :sc | sc name beginsWith: 'Z' ]) 
	do:  [ :sc | Magnitude  removeSubclass: sc ].
Transcript tab; show: 'removed.'; cr.

Smalltalk removeKey: #ChronologyMigrationInProgress.
(Smalltalk at: #Date) initialize.
Duration initialize.
Month initialize.
Timespan initialize.
SystemVersion current date: ((Smalltalk at: #Date) julianDayNumber: jdn).

Undeclared removeUnreferencedKeys.



More information about the Squeak-dev mailing list