[squeak-dev] The Trunk: Kernel-laza.661.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Dec 14 15:54:34 UTC 2011


Alexander Lazarević uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-laza.661.mcz

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

Name: Kernel-laza.661
Author: laza
Time: 14 December 2011, 4:53:54.778 pm
UUID: e2deef86-7fa0-48f6-80a8-256b68e45a1a
Ancestors: Kernel-dtl.658
Backported From: Kernel-laza.660

Make the recategorization of a class be recorded in the changes file

=============== Diff against Kernel-dtl.658 ===============

Item was changed:
  ----- Method: Class>>category: (in category 'organization') -----
  category: aString 
  	"Categorize the receiver under the system category, aString, removing it from 
  	any previous categorization."
  
  	| oldCategory |
  	oldCategory := category.
  	aString isString
  		ifTrue: [
  			category := aString asSymbol.
  			SystemOrganization classify: self name under: category ]
+ 		ifFalse: [self errorCategoryName]!
- 		ifFalse: [self errorCategoryName].
- 	SystemChangeNotifier uniqueInstance
- 		class: self recategorizedFrom: oldCategory to: category!

Item was changed:
  ----- Method: ClassBuilder>>name:inEnvironment:subclassOf:type:instanceVariableNames:classVariableNames:poolDictionaries:category:unsafe: (in category 'class definition') -----
  name: className inEnvironment: env subclassOf: newSuper type: type instanceVariableNames: instVarString classVariableNames: classVarString poolDictionaries: poolString category: category unsafe: unsafe
  	"Define a new class in the given environment.
  	If unsafe is true do not run any validation checks.
  	This facility is provided to implement important system changes."
  	| oldClass instVars classVars copyOfOldClass newClass |
   
  	environ := env.
  	instVars := Scanner new scanFieldNames: instVarString.
  	classVars := (Scanner new scanFieldNames: classVarString) collect: [:x | x asSymbol].
  
  	"Validate the proposed name"
  	unsafe ifFalse:[(self validateClassName: className) ifFalse:[^nil]].
  	oldClass := env at: className ifAbsent:[nil].
  	oldClass isBehavior 
  		ifFalse: [oldClass := nil]  "Already checked in #validateClassName:"
  		ifTrue: [
  			copyOfOldClass := oldClass copy.
  			copyOfOldClass superclass addSubclass: copyOfOldClass].
  	
  	
  	[ | newCategory needNew force organization oldCategory |
  	unsafe ifFalse:[
  		"Run validation checks so we know that we have a good chance for recompilation"
  		(self validateSuperclass: newSuper forSubclass: oldClass) ifFalse:[^nil].
  		(self validateInstvars: instVars from: oldClass forSuper: newSuper) ifFalse:[^nil].
  		(self validateClassvars: classVars from: oldClass forSuper: newSuper) ifFalse:[^nil].
  		(self validateSubclassFormat: type from: oldClass forSuper: newSuper extra: instVars size) ifFalse:[^nil]].
  
  	"See if we need a new subclass"
  	needNew := self needsSubclassOf: newSuper type: type instanceVariables: instVars from: oldClass.
  	needNew == nil ifTrue:[^nil]. "some error"
  
  	(needNew and:[unsafe not]) ifTrue:[
  		"Make sure we don't redefine any dangerous classes"
  		(self tooDangerousClasses includes: oldClass name) ifTrue:[
  			self error: oldClass name, ' cannot be changed'.
  		].
  		"Check if the receiver should not be redefined"
  		(oldClass ~~ nil and:[oldClass shouldNotBeRedefined]) ifTrue:[
  			self notify: oldClass name asText allBold, 
  						' should not be redefined. \Proceed to store over it.' withCRs]].
  
  	needNew ifTrue:[
  		"Create the new class"
  		newClass := self 
  			newSubclassOf: newSuper 
  			type: type 
  			instanceVariables: instVars
  			from: oldClass.
  		newClass == nil ifTrue:[^nil]. "Some error"
  		newClass setName: className.
  	] ifFalse:[
  		"Reuse the old class"
  		newClass := oldClass.
  	].
  
  	"Install the class variables and pool dictionaries... "
  	force := (newClass declare: classVarString) | (newClass sharing: poolString).
  
  	"... classify ..."
  	newCategory := category asSymbol.
  	organization := environ ifNotNil:[environ organization].
  	oldClass isNil ifFalse: [oldCategory := (organization categoryOfElement: oldClass name) asSymbol].
+ 	organization classify: newClass name under: newCategory suppressIfDefault: true.
- 	organization classify: newClass name under: newCategory.
  	newClass environment: environ.
  
  	"... recompile ..."
  	newClass := self recompile: force from: oldClass to: newClass mutate: false.
  
  	"... export if not yet done ..."
  	(environ at: newClass name ifAbsent:[nil]) == newClass ifFalse:[
  		[environ at: newClass name put: newClass]
  			on: AttemptToWriteReadOnlyGlobal do:[:ex| ex resume: true].
  		environ flushClassNameCache.
  	].
  
  
  	newClass doneCompiling.
  	"... notify interested clients ..."
  	oldClass isNil ifTrue: [
  		SystemChangeNotifier uniqueInstance classAdded: newClass inCategory: newCategory.
  		^ newClass].
  	newCategory ~= oldCategory 
  		ifTrue: [SystemChangeNotifier uniqueInstance class: newClass recategorizedFrom: oldCategory to: category]
  		ifFalse: [SystemChangeNotifier uniqueInstance classDefinitionChangedFrom: copyOfOldClass to: newClass.].
  ] ensure: 
  		[copyOfOldClass ifNotNil: [copyOfOldClass superclass removeSubclass: copyOfOldClass].
  		Behavior flushObsoleteSubclasses.
  		].
  	^newClass!

Item was changed:
  ----- Method: ClassOrganizer>>addCategory:before: (in category 'accessing') -----
  addCategory: catString before: nextCategory
+ 	SystemChangeNotifier uniqueInstance
+ 		doSilently: [super addCategory: catString before: nextCategory];
+ 		protocolAdded: catString inClass: self subject!
- 	SystemChangeNotifier uniqueInstance doSilently: [
- 		super addCategory: catString before: nextCategory].
- 	self notifyOfChangedCategoryFrom: nil to: catString.!

Item was removed:
- ----- Method: ClassOrganizer>>notifyOfChangedCategoryFrom:to: (in category 'private') -----
- notifyOfChangedCategoryFrom: oldNameOrNil to: newNameOrNil
- 	(self hasSubject and: [oldNameOrNil ~= newNameOrNil]) 
- 		ifTrue: [
- 			oldNameOrNil
- 				ifNil: [
- 					newNameOrNil ifNotNil: [
- 						SystemChangeNotifier uniqueInstance
- 							protocolAdded: newNameOrNil inClass: self subject.
- 					]
- 				]
- 				ifNotNil: [
- 					newNameOrNil ifNil: [
- 						SystemChangeNotifier uniqueInstance
- 							protocolRemoved: oldNameOrNil inClass: self subject.
- 					]
- 					ifNotNil: [
- 						SystemChangeNotifier uniqueInstance
- 							protocolRenamedFrom: oldNameOrNil to: newNameOrNil inClass: self subject.
- 					]
- 				]. 	
- 		].!

Item was changed:
  ----- Method: ClassOrganizer>>removeCategory: (in category 'accessing') -----
  removeCategory: cat 
+ 	SystemChangeNotifier uniqueInstance
+ 		doSilently: [super removeCategory: cat];
+ 		protocolRemoved: cat inClass: self subject!
- 	SystemChangeNotifier uniqueInstance doSilently: [
- 		super removeCategory: cat].
- 	self notifyOfChangedCategoryFrom: cat to: nil.!

Item was changed:
  ----- Method: ClassOrganizer>>renameCategory:toBe: (in category 'accessing') -----
  renameCategory: oldCatString toBe: newCatString
+ 	SystemChangeNotifier uniqueInstance
+ 		doSilently: [super renameCategory: oldCatString toBe: newCatString];
+ 		protocolRenamedFrom: oldCatString asSymbol to: newCatString asSymbol inClass: self subject!
- 	| oldCat newCat |
- 	oldCat := oldCatString asSymbol.
- 	newCat := newCatString asSymbol.
- 	SystemChangeNotifier uniqueInstance doSilently: [
- 		super renameCategory: oldCatString toBe: newCatString].
- 	self notifyOfChangedCategoryFrom: oldCat to: newCat.!




More information about the Squeak-dev mailing list