'From etoys3.0 of 24 February 2008 [latest update: #2125] on 3 September 2008 at 1:09:13 am'! "Change Set: fixLayoutSep2-yo Date: 3 September 2008 Author: Yoshiki Ohshima Fix the layout of tiles upon loading in a much better way. the recursive call with nonsense tests and intermediate collection is simplified. There is still a room to unify the unhibernate and localeChanged, but not this time around."! !ImageSegment methodsFor: 'fileIn/Out' stamp: 'yo 9/3/2008 00:46'! comeFullyUpOnReload: smartRefStream "fix up the objects in the segment that changed size. An object in the segment is the wrong size for the modern version of the class. Construct a fake class that is the old size. Replace the modern class with the old one in outPointers. Load the segment. Traverse the instances, making new instances by copying fields, and running conversion messages. Keep the new instances. Bulk forward become the old to the new. Let go of the fake objects and classes. After the install (below), arrayOfRoots is filled in. Globalize new classes. Caller may want to do some special install on certain objects in arrayOfRoots. May want to write the segment out to disk in its new form." | mapFakeClassesToReal ccFixups receiverClasses rootsToUnhiberhate myProject existing forgetDoItsClass | forgetDoItsClass _ Set new. RecentlyRenamedClasses _ nil. "in case old data hanging around" mapFakeClassesToReal _ smartRefStream reshapedClassesIn: outPointers. "Dictionary of just the ones that change shape. Substitute them in outPointers." ccFixups _ self remapCompactClasses: mapFakeClassesToReal refStrm: smartRefStream. ccFixups ifFalse: [^ self error: 'A class in the file is not compatible']. endMarker _ segment nextObject. "for enumeration of objects" endMarker == 0 ifTrue: [endMarker _ 'End' clone]. self fixCapitalizationOfSymbols. arrayOfRoots _ self loadSegmentFrom: segment outPointers: outPointers. "Can't use install. Not ready for rehashSets" mapFakeClassesToReal isEmpty ifFalse: [ self reshapeClasses: mapFakeClassesToReal refStream: smartRefStream ]. "When a Project is stored, arrayOfRoots has all objects in the project, except those in outPointers" arrayOfRoots do: [:importedObject | ((importedObject isMemberOf: WideString) or: [importedObject isMemberOf: WideSymbol]) ifTrue: [ importedObject mutateJISX0208StringToUnicode. importedObject class = WideSymbol ifTrue: [ "self halt." Symbol hasInterned: importedObject asString ifTrue: [:multiSymbol | multiSymbol == importedObject ifFalse: [ importedObject becomeForward: multiSymbol. ]. ]. ]. ]. (importedObject isMemberOf: TTCFontSet) ifTrue: [ existing _ TTCFontSet familyName: importedObject familyName pointSize: importedObject pointSize. "supplies default" existing == importedObject ifFalse: [importedObject becomeForward: existing]. ]. ]. receiverClasses _ self restoreEndianness. "rehash sets" smartRefStream checkFatalReshape: receiverClasses. "Classes in this segment." arrayOfRoots do: [:importedObject | importedObject class class == Metaclass ifTrue: [forgetDoItsClass add: importedObject. self declare: importedObject]]. rootsToUnhiberhate := OrderedCollection new. arrayOfRoots do: [:importedObject | ((importedObject isMemberOf: ScriptEditorMorph) or: [(importedObject isKindOf: TileMorph) or: [(importedObject isMemberOf: ScriptingTileHolder) or: [importedObject isKindOf: CompoundTileMorph]]]) ifTrue: [ rootsToUnhiberhate add: importedObject ]. (importedObject isMemberOf: CompiledMethod) ifTrue: [ importedObject sourcePointer > 0 ifTrue: [importedObject zapSourcePointer]]. (importedObject isMemberOf: Project) ifTrue: [ myProject _ importedObject. importedObject ensureChangeSetNameUnique. Project addingProject: importedObject. importedObject restoreReferences. self dependentsRestore: importedObject. ScriptEditorMorph writingUniversalTiles: ((importedObject projectPreferenceAt: #universalTiles) ifNil: [false])]]. myProject ifNotNil: [ myProject world setProperty: #thingsToUnhibernate toValue: rootsToUnhiberhate asArray. ]. mapFakeClassesToReal isEmpty ifFalse: [ mapFakeClassesToReal keys do: [:aFake | aFake indexIfCompact > 0 ifTrue: [aFake becomeUncompact]. aFake removeFromSystemUnlogged]. SystemOrganization removeEmptyCategories]. forgetDoItsClass do: [:c | c forgetDoIts]. "^ self" ! ! !Morph methodsFor: 'e-toy support' stamp: 'yo 9/3/2008 00:58'! fixLayoutOfSubmorphs self layoutChanged; fullBounds. ! ! !ScriptEditorMorph methodsFor: 'menu' stamp: 'yo 9/3/2008 00:59'! fixLayout self allMorphsDo: [:m |m fixLayoutOfSubmorphs]. ! ! !ScriptEditorMorph methodsFor: 'other' stamp: 'yo 9/3/2008 00:40'! unhibernate "I have been loaded as part of an ImageSegment. Make sure that I am fixed up properly." self topEditor == self ifFalse: [^ self]. "Part of a compound test" self updateHeader. self fixLayout. "Recreate my tiles from my method if i have new universal tiles." self world ifNil: [(playerScripted isNil or: [playerScripted isUniversalTiles not]) ifTrue: [^ self]] ifNotNil: [Preferences universalTiles ifFalse: [^ self]]. self insertUniversalTiles. self showingMethodPane: false! ! !ScriptingTileHolder methodsFor: 'initialization' stamp: 'yo 9/3/2008 01:00'! fixLayout self allMorphsDo: [:m | m fixLayoutOfSubmorphs]. ! ! !ScriptingTileHolder methodsFor: 'initialization' stamp: 'yo 9/3/2008 00:56'! localeChanged self fixLayout. ! ! !ScriptingTileHolder methodsFor: 'initialization' stamp: 'yo 9/3/2008 00:56'! unhibernate self fixLayout. ! ! !TileLikeMorph methodsFor: 'initialization' stamp: 'yo 9/3/2008 00:20'! localeChanged "Update myself to reflect the change in locale" self updateWordingToMatchVocabulary. self fullBounds. ! ! !TileLikeMorph methodsFor: 'user interface' stamp: 'yo 9/3/2008 00:58'! fixLayoutOfSubmorphs self minCellSize: 0 @ (TileMorph defaultH). super fixLayoutOfSubmorphs.! ! !PhraseTileMorph methodsFor: 'initialization' stamp: 'yo 9/3/2008 01:00'! fixLayoutOfSubmorphs self minCellSize: 0 @ (TileMorph defaultH). super fixLayoutOfSubmorphs. ! ! !TileMorph methodsFor: 'as yet unclassified' stamp: 'yo 9/3/2008 01:04'! fixLayoutOfSubmorphs self minCellSize: 0 @ (TileMorph defaultH). super fixLayoutOfSubmorphs.! ! !TileMorph methodsFor: 'e-toy support' stamp: 'yo 9/3/2008 00:20'! localeChanged "Update myself to reflect the change in locale" self updateWordingToMatchVocabulary. self fullBounds.! ! !AssignmentTileMorph methodsFor: 'as yet unclassified' stamp: 'yo 9/3/2008 01:00'! fixLayoutOfSubmorphs self updateLiteralLabel; updateWordingToMatchVocabulary; layoutChanged; fullBounds! ! AssignmentTileMorph removeSelector: #fixLayoutOfSubmorphsNotIn:! TileMorph removeSelector: #fixLayoutOfSubmorphsNotIn:! PhraseTileMorph removeSelector: #fixLayoutOfSubmorphsNotIn:! TileLikeMorph removeSelector: #fixLayoutOfSubmorphsNotIn:! ScriptEditorMorph removeSelector: #fixLayoutOfSubmorphsNotIn:!