[etoys-dev] Etoys Inbox: Morphic-Richo.30.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jul 20 09:53:52 EDT 2010


A new version of Morphic was added to project Etoys Inbox:
http://source.squeak.org/etoysinbox/Morphic-Richo.30.mcz

==================== Summary ====================

Name: Morphic-Richo.30
Author: Richo
Time: 20 July 2010, 10:51:29 am
UUID: 7e9c6b0d-e8f7-f044-8b69-488c9f5ac264
Ancestors: Morphic-bf.29

* Changed Morph>>#saveOnFile method and a few methods related. The older implementation didn't work when the morph had scripts.

=============== Diff against Morphic-bf.29 ===============

Item was added:
+ ----- Method: Morph class>>fromStreamedRepresentation: (in category 'fileIn/Out') -----
+ fromStreamedRepresentation: aString
+ 	^SmartRefStream objectFromStreamedRepresentation: aString!

Item was changed:
  ----- Method: Morph>>saveOnFile (in category 'fileIn/out') -----
  saveOnFile
  	"Ask the user for a filename and save myself on a SmartReferenceStream file.  Writes out the version and class structure.  The file is fileIn-able.  UniClasses will be filed out."
  
+ 	| aFileName ok |
- 	| aFileName fileStream ok |
  	aFileName := self knownName ifNil: 
  		[('my {1}' translated format: {self class name})].
  	aFileName := aFileName asFileName.
  	aFileName _ FillInTheBlank request: 'File name? (".morph" will be added to end)' translated 
  			initialAnswer: aFileName.
  	aFileName isEmpty ifTrue: [^ Beeper beep].
  	self allMorphsDo: [:m | m prepareToBeSaved].
  
  	ok _ aFileName endsWith: '.morph'.	"don't double them"
  	ok _ ok | (aFileName endsWith: '.sp').
  	ok ifFalse: [aFileName _ aFileName,'.morph'].
+ 	self saveOnFile: aFileName.!
- 	fileStream _ FileStream newFileNamed: aFileName asFileName.
- 	fileStream fileOutClass: nil andObject: self.	"Puts UniClass definitions out anyway"!

Item was added:
+ ----- Method: Morph>>saveOnFile: (in category 'fileIn/out') -----
+ saveOnFile: fileName
+ | file |
+ file := (FileStream forceNewFileNamed: fileName).
+ [file nextPutAll: (SmartRefStream streamedRepresentationOf: self topRendererOrSelf)] ensure: [file close]!

Item was changed:
  ----- Method: Morph class>>fromFileName: (in category 'fileIn/Out') -----
  fromFileName: fullName
+ 	| file |
+ 	[file := FileStream readOnlyFileNamed: fullName.
+ 	[(Morph fromStreamedRepresentation: file contents) openInWorld] ensure: [file close].
+ 	] on: Error do: [self inform: 'The file doesn''t exists']!
- 	"Reconstitute a Morph from the file, presumed to be represent a Morph saved
- 	via the SmartRefStream mechanism, and open it in an appropriate Morphic world"
- 
-  	| aFileStream morphOrList |
- 	aFileStream _ (MultiByteBinaryOrTextStream with: ((FileStream readOnlyFileNamed: fullName) binary contentsOfEntireFile)) binary reset.
- 	morphOrList _ aFileStream fileInObjectAndCode.
- 	(morphOrList isKindOf: SqueakPage) ifTrue: [morphOrList _ morphOrList contentsMorph].
- 	Smalltalk isMorphic
- 		ifTrue: [ActiveWorld addMorphsAndModel: morphOrList]
- 		ifFalse:
- 			[morphOrList isMorph ifFalse: [self inform: 'Can only load a single morph
- into an mvc project via this mechanism.' translated].
- 			morphOrList openInWorld].
- 	^ morphOrList.
- !



More information about the etoys-dev mailing list