'From etoys3.0 of 18 March 2008 [latest update: #2059] on 25 July 2008 at 11:03:54 pm'! "Change Set: MorphInFile2-tk Date: 25 July 2008 Author: Ted Kaehler In cases where the structures in a SmartRefStream happen to miss a class, and the class is found in the receiving system, and the instSize is correct, go ahead and make an instance of the class anyway. A class is left out when progress bar displayWorld unhibernates something that was not present when objects were counted."! !SmartRefStream methodsFor: 'read write' stamp: 'tk 7/25/2008 22:56'! readInstanceSize: instSize clsname: className refPosn: refPosn "The common code to read the contents of an arbitrary instance. ASSUMES: readDataFrom:size: sends me beginReference: after it instantiates the new object but before reading nested objects. NOTE: We must restore the current reference position after recursive calls to next. Three cases for files from older versions of the system: 1) Class has not changed shape, read it straight. 2) Class has changed instance variables (or needs fixup). Call a particular method to do it. 3) There is a new class instead. Find it, call a particular method to read. All classes used to construct the structures dictionary *itself* need to be in 'steady' and they must not change!! See setStream:" | anObject newName newClass dict oldInstVars isMultiSymbol | self flag: #bobconv. self setCurrentReference: refPosn. "remember pos before readDataFrom:size:" newName _ renamed at: className ifAbsent: [className]. isMultiSymbol _ newName = #MultiSymbol or: [newName = #WideSymbol]. "isMultiSymbol ifTrue: [self halt]." newClass _ Smalltalk at: newName asSymbol. (steady includes: newClass) & (newName == className) ifTrue: [ anObject _ newClass isVariable "Create it here" ifFalse: [newClass basicNew] ifTrue: [newClass basicNew: instSize - (newClass instSize)]. anObject _ anObject readDataFrom: self size: instSize. self setCurrentReference: refPosn. "before returning to next" isMultiSymbol ifTrue: [^ Symbol intern: anObject asString]. ^ anObject]. oldInstVars _ structures at: className ifAbsent: [ instSize = newClass instSize ifFalse: [ self error: 'class is not in structures list']. "Missing in object file" "If class present, and instSize the same, assume it is OK" structures at: className put: ((Array with: newClass classVersion), (newClass allInstVarNames))]. anObject _ newClass createFrom: self size: instSize version: oldInstVars. "only create the instance" self beginReference: anObject. dict _ self catalogValues: oldInstVars size: instSize. "indexed vars as (1 -> val) etc." dict at: #ClassName put: className. "so conversion method can know it" "Give each superclass a chance to make its changes" self storeInstVarsIn: anObject from: dict. "ones with the same names" anObject _ self applyConversionMethodsTo: anObject className: className varMap: dict. self setCurrentReference: refPosn. "before returning to next" isMultiSymbol ifTrue: [^ Symbol intern: anObject asString]. ^ anObject! !