--- a/Class.st Thu Nov 23 18:42:43 1995 +0100
+++ b/Class.st Thu Nov 23 18:50:57 1995 +0100
@@ -106,7 +106,7 @@
!
version
-^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.82 1995-11-23 14:27:53 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.83 1995-11-23 17:50:57 cg Exp $'! !
!Class class methodsFor:'initialization'!
@@ -2022,13 +2022,34 @@
fileOutCategory:aCategory on:aStream
"file out all methods belonging to aCategory, aString onto aStream"
+ self fileOutCategory:aCategory except:nil only:nil on:aStream
+!
+
+fileOutCategory:aCategory except:skippedMethods only:savedMethods on:aStream
+ "file out all methods belonging to aCategory, aString onto aStream.
+ If skippedMethods is nonNil, those are not saved.
+ If savedMethods is nonNil, only those are saved.
+ If both are nil, all are saved. See version-method handling in
+ fileOut for what this is needed."
+
|source sortedSelectors first privacy interrestingMethods|
methodArray notNil ifTrue:[
interrestingMethods := OrderedCollection new.
methodArray do:[:aMethod |
+ |wanted|
+
(aCategory = aMethod category) ifTrue:[
- interrestingMethods add:aMethod.
+ skippedMethods notNil ifTrue:[
+ wanted := (skippedMethods includesIdentical:aMethod) not
+ ] ifFalse:[
+ savedMethods notNil ifTrue:[
+ wanted := (savedMethods includesIdentical:aMethod).
+ ] ifFalse:[
+ wanted := true
+ ]
+ ].
+ wanted ifTrue:[interrestingMethods add:aMethod].
]
].
interrestingMethods notEmpty ifTrue:[
@@ -2227,7 +2248,7 @@
fileOutOn:aStream withTimeStamp:stampIt
"file out my definition and all methods onto aStream"
- |collectionOfCategories copyrightText comment cls|
+ |collectionOfCategories copyrightText comment cls versionMethod skippedMethods|
self isLoaded ifFalse:[
^ FileOutErrorSignal
@@ -2264,32 +2285,33 @@
].
stampIt ifTrue:[
- "
- first, a timestamp
- "
+ "/
+ "/ first, a timestamp
+ "/
aStream nextPutAll:(Smalltalk timeStamp).
aStream nextPutChunkSeparator.
aStream cr; cr.
].
- "
- then the definition
- "
+ "/
+ "/ then the definition
+ "/
self fileOutDefinitionOn:aStream.
aStream nextPutChunkSeparator.
aStream cr; cr.
- "
- optional classInstanceVariables
- "
+
+ "/
+ "/ optional classInstanceVariables
+ "/
self class instanceVariableString isBlank ifFalse:[
self fileOutClassInstVarDefinitionOn:aStream.
aStream nextPutChunkSeparator.
aStream cr; cr
].
- "
- a comment - if any
- "
+ "/
+ "/ a comment - if any
+ "/
(comment := self comment) notNil ifTrue:[
aStream nextPutAll:name; nextPutAll:' comment:'.
aStream nextPutAll:(comment storeString).
@@ -2297,33 +2319,41 @@
aStream cr; cr
].
- "
- primitive definitions - if any
- "
+ "/
+ "/ primitive definitions - if any
+ "/
self fileOutPrimitiveSpecsOn:aStream.
- "
- methods from all categories in metaclass
- "
+ "/
+ "/ methods from all categories in metaclass (i.e. class methods)
+ "/ EXCEPT: the version method is placed at the very end, to
+ "/ avoid sourcePosition-shifts when checked out later.
+ "/
collectionOfCategories := self class categories asSortedCollection.
collectionOfCategories notNil ifTrue:[
- "
- documentation first (if any)
- "
+ "/
+ "/ documentation first (if any), but not the version method
+ "/
(collectionOfCategories includes:'documentation') ifTrue:[
- self class fileOutCategory:'documentation' on:aStream.
+ versionMethod := self class compiledMethodAt:#version.
+ versionMethod notNil ifTrue:[
+ skippedMethods := Array with:versionMethod
+ ].
+ self class fileOutCategory:'documentation' except:skippedMethods only:nil on:aStream.
aStream cr.
].
- "
- initialization next (if any)
- "
+
+ "/
+ "/ initialization next (if any)
+ "/
(collectionOfCategories includes:'initialization') ifTrue:[
self class fileOutCategory:'initialization' on:aStream.
aStream cr.
].
- "
- instance creation next (if any)
- "
+
+ "/
+ "/ instance creation next (if any)
+ "/
(collectionOfCategories includes:'instance creation') ifTrue:[
self class fileOutCategory:'instance creation' on:aStream.
aStream cr.
@@ -2337,9 +2367,10 @@
]
]
].
- "
- methods from all categories in myself
- "
+
+ "/
+ "/ methods from all categories in myself
+ "/
collectionOfCategories := self categories asSortedCollection.
collectionOfCategories notNil ifTrue:[
collectionOfCategories do:[:aCategory |
@@ -2347,9 +2378,17 @@
aStream cr
]
].
- "
- optionally an initialize message
- "
+
+ "/
+ "/ finally, the previously skipped version method
+ "/
+ versionMethod notNil ifTrue:[
+ self class fileOutCategory:'documentation' except:nil only:skippedMethods on:aStream.
+ ].
+
+ "/
+ "/ optionally an initialize message
+ "/
(self class implements:#initialize) ifTrue:[
aStream nextPutAll:(name , ' initialize').
aStream nextPutChunkSeparator.