Levente Uzonyi uploaded a new version of Services-Base to project The Trunk:
http://source.squeak.org/trunk/Services-Base-ul.62.mcz
==================== Summary ====================
Name: Services-Base-ul.62
Author: ul
Time: 24 April 2017, 1:11:43.659972 pm
UUID: 7b52364a-ab0b-498c-9704-a716eef0e8ed
Ancestors: Services-Base-ul.61
- ServiceAction's #execute and #executeCondition don't have to clone their blocks anymore
- BlockContext >> #valueWithRequestor: was an extension method, but without BlockContext it got auto-removed.
=============== Diff against Services-Base-ul.61 ===============
Item was removed:
- ----- Method: BlockContext>>valueWithRequestor: (in category '*services-base') -----
- valueWithRequestor: aRequestor
- "To do later: make the fillInTheBlank display more informative captions.
- Include the description of the service, and maybe record steps"
-
- ^ self numArgs isZero
- ifTrue: [self value]
- ifFalse: [self value: aRequestor]!
Item was changed:
----- Method: ServiceAction>>execute (in category 'executing') -----
execute
+ ^ action valueWithRequestor: World focusedRequestor!
- ^ action clone valueWithRequestor: World focusedRequestor!
Item was changed:
----- Method: ServiceAction>>executeCondition (in category 'executing') -----
executeCondition
+ ^ [condition valueWithRequestor: World focusedRequestor]
- ^ [condition clone valueWithRequestor: World focusedRequestor]
on: Error
do: [false]!
Levente Uzonyi uploaded a new version of MorphicExtras to project The Trunk:
http://source.squeak.org/trunk/MorphicExtras-ul.205.mcz
==================== Summary ====================
Name: MorphicExtras-ul.205
Author: ul
Time: 24 April 2017, 1:05:03.685277 pm
UUID: fe46b749-0a60-4228-958e-7072da23108c
Ancestors: MorphicExtras-dtl.204
- rewrote senders of #clone to use #shallowCopy
=============== Diff against MorphicExtras-dtl.204 ===============
Item was changed:
----- Method: BookPageThumbnailMorph>>objectForDataStream: (in category 'fileIn/Out') -----
objectForDataStream: refStrm
"I am about to be written on an object file. It would be bad to write a whole BookMorph out. Store a string that is the url of the book or page in my inst var."
| clone bookUrl bb stem ind |
(bookMorph isString) & (page isString) ifTrue: [
^ super objectForDataStream: refStrm].
(bookMorph isNil) & (page isString) ifTrue: [
^ super objectForDataStream: refStrm].
(bookMorph isNil) & (page url notNil) ifTrue: [
^ super objectForDataStream: refStrm].
(bookMorph isNil) & (page url isNil) ifTrue: [
self error: 'page should already have a url' translated.
"find page's book, and remember it"
"bookMorph := "].
+ clone := self shallowCopy.
- clone := self clone.
(bookUrl := bookMorph url)
ifNil: [bookUrl := self valueOfProperty: #futureUrl].
bookUrl
ifNil: [ bb := RectangleMorph new. "write out a dummy"
bb bounds: bounds.
refStrm replace: self with: bb.
^ bb]
ifNotNil: [clone instVarNamed: 'bookMorph' put: bookUrl].
page url ifNil: [
"Need to assign a url to a page that will be written later.
It might have bookmarks too. Don't want to recurse deeply.
Have that page write out a dummy morph to save its url on the server."
stem := SqueakPage stemUrl: bookUrl.
ind := bookMorph pages identityIndexOf: page.
page reserveUrl: stem,(ind printString),'.sp'].
clone instVarNamed: 'page' put: page url.
refStrm replace: self with: clone.
^ clone!
Item was changed:
----- Method: SketchEditorMorph>>mouseDown: (in category 'morphic') -----
mouseDown: evt
"Start a new stroke. Check if any palette setting have changed. 6/11/97 20:30 tk"
| cur pfPen myAction |
"verify that we are in a good state"
self verifyState: evt. "includes prepareToPaint and #scalingOrRotate"
pfPen := self get: #paintingFormPen for: evt.
paintingForm extent = undoBuffer extent ifTrue: [
paintingForm displayOn: undoBuffer at: 0@0 rule: Form over.
] ifFalse: [
undoBuffer := paintingForm deepCopy. "know we will draw something"
].
pfPen place: (evt cursorPoint - bounds origin).
myAction := self getActionFor: evt.
palette colorable ifTrue:[
palette recentColor: (self getColorFor: evt)].
self set: #strokeOrigin for: evt to: evt cursorPoint.
"origin point for pickup: rect: ellispe: polygon: line: star:. Always take it."
myAction == #pickup: ifTrue: [
+ cur := Cursor corner shallowCopy.
- cur := Cursor corner clone.
cur offset: 0@0 "cur offset abs".
evt hand showTemporaryCursor: cur].
myAction == #polygon: ifTrue: [self polyNew: evt]. "a mode lets you drag vertices"
self mouseMove: evt.!
Item was changed:
----- Method: SqueakPage>>copyForSaving (in category 'accessing') -----
copyForSaving
"Make a copy and configure me to be put out on the disk. When it is brought in and touched, it will turn into the object at the url."
| forDisk holder |
+ forDisk := self shallowCopy.
- forDisk := self clone.
holder := MorphObjectOut new xxxSetUrl: url page: forDisk.
forDisk contentsMorph: holder.
^ holder "directly representing the object"!
Levente Uzonyi uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-ul.1335.mcz
==================== Summary ====================
Name: Morphic-ul.1335
Author: ul
Time: 24 April 2017, 1:04:42.9817 pm
UUID: 9e7af827-2124-49b6-b910-9cbdfc12a867
Ancestors: Morphic-eem.1334
- rewrote senders of #clone to use #shallowCopy
- removed some unnecessary #copy implementations
- use #postCopy in BalloonCanvas and FormCanvas for additional post-copy actions
=============== Diff against Morphic-eem.1334 ===============
Item was changed:
----- Method: BalloonCanvas>>copy (in category 'copying') -----
copy
+
self flush.
+ ^super copy!
- ^super copy resetEngine!
Item was added:
+ ----- Method: BalloonCanvas>>postCopy (in category 'copying') -----
+ postCopy
+
+ super postCopy.
+ ^self resetEngine!
Item was removed:
- ----- Method: Canvas>>copy (in category 'copying') -----
- copy
-
- ^ self clone
- !
Item was changed:
----- Method: ComplexBorder>>drawPolyPatchFrom:to:on:usingEnds: (in category 'drawing') -----
drawPolyPatchFrom: startPoint to: stopPoint on: aCanvas usingEnds: endsArray
| cos sin tfm fill dir fsOrigin fsDirection points x y |
dir := (stopPoint - startPoint) normalized.
"Compute the rotational transform from (0@0) -> (1@0) to startPoint -> stopPoint"
cos := dir dotProduct: (1@0).
sin := dir crossProduct: (1@0).
"Now get the fill style appropriate for the given direction"
fill := self fillStyleForDirection: dir.
false ifTrue:[
"Transform the fill appropriately"
+ fill := fill shallowCopy.
- fill := fill clone.
"Note: Code below is inlined from tfm transformPoint:/transformDirection:"
x := fill origin x. y := fill origin y.
fsOrigin := ((x * cos) + (y * sin) + startPoint x) @
((y * cos) - (x * sin) + startPoint y).
x := fill direction x. y := fill direction y.
fsDirection := ((x * cos) + (y * sin)) @ ((y * cos) - (x * sin)).
fill origin: fsOrigin;
direction: fsDirection rounded; "NOTE: This is a bug in the balloon engine!!!!!!"
normal: nil.
aCanvas asBalloonCanvas drawPolygon: endsArray fillStyle: fill.
] ifFalse:[
"Transform the points rather than the fills"
tfm := (MatrixTransform2x3 new) a11: cos; a12: sin; a21: sin negated; a22: cos.
"Install the start point offset"
tfm offset: startPoint.
points := endsArray collect:[:pt| tfm invertPoint: pt].
aCanvas asBalloonCanvas transformBy: tfm during:[:cc|
cc drawPolygon: points fillStyle: fill.
].
].!
Item was removed:
- ----- Method: FormCanvas>>copy (in category 'copying') -----
- copy
- "Make a copy the receiver on the same underlying Form but with its own grafPort."
-
- ^ self clone resetGrafPort
- !
Item was added:
+ ----- Method: FormCanvas>>postCopy (in category 'copying') -----
+ postCopy
+ "Let the copy have its own grafPort."
+
+ super postCopy.
+ self resetGrafPort
+ !
Item was changed:
----- Method: GrafPort>>displayScannerFor:foreground:background:ignoreColorChanges: (in category 'accessing') -----
displayScannerFor: para foreground: foreColor background: backColor ignoreColorChanges: shadowMode
^ (DisplayScanner new text: para text textStyle: para textStyle
foreground: foreColor background: backColor fillBlt: self
ignoreColorChanges: shadowMode)
+ setPort: self shallowCopy
- setPort: self clone
!
Item was changed:
----- Method: Morph>>copyWithoutSubmorph: (in category 'submorphs-add/remove') -----
copyWithoutSubmorph: sub
"Needed to get a morph to draw without one of its submorphs.
NOTE: This must be thrown away immediately after use."
+ ^ self shallowCopy privateSubmorphs: (submorphs copyWithout: sub)!
- ^ self clone privateSubmorphs: (submorphs copyWithout: sub)!
Item was changed:
----- Method: Morph>>veryDeepInner: (in category 'copying') -----
veryDeepInner: deepCopier
"The inner loop, so it can be overridden when a field should not
be traced."
"super veryDeepInner: deepCopier. know Object has no inst vars"
+ bounds := bounds shallowCopy.
- bounds := bounds clone.
"Points are shared with original"
"owner := owner. special, see veryDeepFixupWith:"
submorphs := submorphs veryDeepCopyWith: deepCopier.
"each submorph's fixup will install me as the owner"
"fullBounds := fullBounds. fullBounds is shared with original!!"
color := color veryDeepCopyWith: deepCopier.
"color, if simple, will return self. may be complex"
extension := (extension veryDeepCopyWith: deepCopier)!
Item was changed:
----- Method: MouseEvent>>asMouseEnter (in category 'converting') -----
asMouseEnter
+ ^self shallowCopy setType: #mouseEnter!
- ^self clone setType: #mouseEnter!
Item was changed:
----- Method: MouseEvent>>asMouseLeave (in category 'converting') -----
asMouseLeave
+ ^self shallowCopy setType: #mouseLeave!
- ^self clone setType: #mouseLeave!
Item was changed:
----- Method: TransformationMorph>>flexing:byTransformation: (in category 'initialization') -----
flexing: aMorph byTransformation: tfm
"Initialize me with position and bounds of aMorph,
and with an offset that provides centered rotation."
(aMorph isKindOf: TransformationMorph)
+ ifTrue: [aMorph submorphsDo: [:m | self addMorph: m shallowCopy]]
- ifTrue: [aMorph submorphsDo: [:m | self addMorph: m clone]]
ifFalse: [self addMorph: aMorph].
transform := tfm.
self chooseSmoothing.
self layoutChanged.!
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.1098.mcz
==================== Summary ====================
Name: Kernel-ul.1098
Author: ul
Time: 24 April 2017, 12:59:49.967288 pm
UUID: f803e743-6f80-4bd8-9d1b-192f56d70de6
Ancestors: Kernel-eem.1097
- rewrote senders of #clone to use #shallowCopy
- Object >> #shallowCopy uses the fallback code of #clone, because that one is simpler (copying is done by #copyFrom:) and can copy CompiledMethods too.
=============== Diff against Kernel-eem.1097 ===============
Item was changed:
----- Method: ClassBuilder>>newSubclassOf:type:instanceVariables:from: (in category 'class definition') -----
newSubclassOf: newSuper type: type instanceVariables: instVars from: oldClass
"Create a new subclass of the given superclass with the given specification."
| newFormat newClass |
"Compute the format of the new class"
newFormat := self computeFormat: type instSize: instVars size forSuper: newSuper.
newFormat ifNil: [^nil].
(oldClass == nil or:[oldClass isMeta not])
ifTrue:[newClass := self privateNewSubclassOf: newSuper from: oldClass]
+ ifFalse:[newClass := oldClass shallowCopy].
- ifFalse:[newClass := oldClass clone].
newClass
superclass: newSuper
methodDictionary: (oldClass ifNil: [MethodDictionary new] ifNotNil: [oldClass methodDict copy])
format: newFormat;
setInstVarNames: instVars.
oldClass ifNotNil:[
newClass organization: oldClass organization.
"Recompile the new class"
oldClass hasMethods
ifTrue:[newClass compileAllFrom: oldClass].
oldClass hasTraitComposition ifTrue: [
newClass setTraitComposition: oldClass traitComposition copyTraitExpression ].
oldClass class hasTraitComposition ifTrue: [
newClass class setTraitComposition: oldClass class traitComposition copyTraitExpression ].
self recordClass: oldClass replacedBy: newClass.
].
(oldClass == nil or:[oldClass isObsolete not])
ifTrue:[newSuper addSubclass: newClass]
ifFalse:[newSuper addObsoleteSubclass: newClass].
^newClass!
Item was changed:
----- Method: ClassBuilder>>privateNewSubclassOf:from: (in category 'private') -----
privateNewSubclassOf: newSuper from: oldClass
"Create a new meta and non-meta subclass of newSuper using oldClass as template"
"WARNING: This method does not preserve the superclass/subclass invariant!!"
| newSuperMeta oldMeta newMeta |
oldClass ifNil:[^self privateNewSubclassOf: newSuper].
newSuperMeta := newSuper ifNil:[Class] ifNotNil:[newSuper class].
oldMeta := oldClass class.
+ newMeta := oldMeta shallowCopy.
- newMeta := oldMeta clone.
newMeta
superclass: newSuperMeta
methodDictionary: oldMeta methodDict copy
format: (self computeFormat: oldMeta typeOfClass
instSize: oldMeta instVarNames size
forSuper: newSuperMeta);
setInstVarNames: oldMeta instVarNames;
organization: oldMeta organization.
"Recompile the meta class"
oldMeta hasMethods
ifTrue:[newMeta compileAllFrom: oldMeta].
"Record the meta class change"
self recordClass: oldMeta replacedBy: newMeta.
"And create a new instance"
^newMeta adoptInstance: oldClass from: oldMeta!
Item was changed:
----- Method: EventSensor>>queueEvent: (in category 'private-I/O') -----
queueEvent: evt
"Queue the given event in the event queue (if any).
Note that the event buffer must be copied since it
will be reused later on."
self eventQueue ifNotNil: [:queue |
+ queue nextPut: evt shallowCopy].!
- queue nextPut: evt clone].!
Item was changed:
----- Method: Float>>veryDeepCopyWith: (in category 'copying') -----
veryDeepCopyWith: deepCopier
"Return self. Do not record me."
+ ^self shallowCopy!
- ^ self clone!
Item was changed:
----- Method: Object>>copyTwoLevel (in category 'copying') -----
copyTwoLevel
"one more level than a shallowCopy"
| newObject class index |
class := self class.
+ newObject := self shallowCopy.
- newObject := self clone.
newObject == self ifTrue: [^ self].
class isVariable
ifTrue:
[index := self basicSize.
[index > 0]
whileTrue:
[newObject basicAt: index put: (self basicAt: index) shallowCopy.
index := index - 1]].
index := class instSize.
[index > 0]
whileTrue:
[newObject instVarAt: index put: (self instVarAt: index) shallowCopy.
index := index - 1].
^newObject!
Item was changed:
----- Method: Object>>shallowCopy (in category 'copying') -----
shallowCopy
"Answer a copy of the receiver which shares the receiver's instance variables."
+
- | class newObject index |
<primitive: 148 error: ec>
+ | class newObject |
ec == #'insufficient object memory' ifFalse:
[^self primitiveFailed].
+ "If the primitive fails due to insufficient memory, instantiate via basicNew: to invoke
+ the garbage collector before retrying, and use copyFrom: to copy state."
+ newObject := (class := self class) isVariable
+ ifTrue:
+ [class isCompiledMethodClass
+ ifTrue:
+ [class newMethod: self basicSize - self initialPC + 1 header: self header]
+ ifFalse:
+ [class basicNew: self basicSize]]
+ ifFalse:
+ [class basicNew].
+ ^newObject copyFrom: self!
- class := self class.
- class isVariable
- ifTrue:
- [index := self basicSize.
- newObject := class basicNew: index.
- [index > 0] whileTrue:
- [newObject basicAt: index put: (self basicAt: index).
- index := index - 1]]
- ifFalse: [newObject := class basicNew].
- index := class instSize.
- [index > 0] whileTrue:
- [newObject instVarAt: index put: (self instVarAt: index).
- index := index - 1].
- ^newObject!
Item was changed:
----- Method: Object>>veryDeepCopyWith: (in category 'copying') -----
veryDeepCopyWith: deepCopier
"Copy me and the entire tree of objects I point to. An object in the tree twice is copied once, and both references point to him. deepCopier holds a dictionary of objects we have seen. Some classes refuse to be copied. Some classes are picky about which fields get deep copied."
| class index sub subAss new uc sup has mine |
deepCopier references at: self ifPresent: [:newer | ^ newer]. "already did him"
class := self class.
class isMeta ifTrue: [^ self]. "a class"
+ new := self shallowCopy.
- new := self clone.
(class isSystemDefined not and: [deepCopier newUniClasses "allowed"]) ifTrue: [
uc := deepCopier uniClasses at: class ifAbsent: [nil].
uc ifNil: [
deepCopier uniClasses at: class put: (uc := self copyUniClassWith: deepCopier).
deepCopier references at: class put: uc]. "remember"
new := uc new.
new copyFrom: self]. "copy inst vars in case any are weak"
deepCopier references at: self put: new. "remember"
(class isVariable and: [class isPointers]) ifTrue:
[index := self basicSize.
[index > 0] whileTrue:
[sub := self basicAt: index.
(subAss := deepCopier references associationAt: sub ifAbsent: [nil])
ifNil: [new basicAt: index put: (sub veryDeepCopyWith: deepCopier)]
ifNotNil: [new basicAt: index put: subAss value].
index := index - 1]].
"Ask each superclass if it wants to share (weak copy) any inst vars"
new veryDeepInner: deepCopier. "does super a lot"
"other superclasses want all inst vars deep copied"
sup := class. index := class instSize.
[has := sup compiledMethodAt: #veryDeepInner: ifAbsent: [nil].
has := has ifNil: [class isSystemDefined not "is a uniClass"] ifNotNil: [true].
mine := sup instVarNames.
has ifTrue: [index := index - mine size] "skip inst vars"
ifFalse: [1 to: mine size do: [:xx |
sub := self instVarAt: index.
(subAss := deepCopier references associationAt: sub ifAbsent: [nil])
"use association, not value, so nil is an exceptional value"
ifNil: [new instVarAt: index put:
(sub veryDeepCopyWith: deepCopier)]
ifNotNil: [new instVarAt: index put: subAss value].
index := index - 1]].
(sup := sup superclass) == nil] whileFalse.
new rehash. "force Sets and Dictionaries to rehash"
^ new
!