--- a/Class.st Tue Oct 15 13:29:55 1996 +0200
+++ b/Class.st Tue Oct 15 20:00:43 1996 +0200
@@ -373,6 +373,25 @@
"Created: 15.11.1995 / 14:58:35 / cg"
"Modified: 13.12.1995 / 17:11:28 / cg"
+!
+
+revisionStringFromSource:aMethodSourceString
+ "extract a revision string from a methods source string"
+
+ |lines|
+
+ lines := aMethodSourceString asCollectionOfLines.
+ lines do:[:l |
+ |i|
+
+ i := l indexOfSubCollection:'$Header: '.
+ i ~~ 0 ifTrue:[
+ ^ l copyFrom:i
+ ]
+ ].
+ ^ nil
+
+ "Created: 15.10.1996 / 18:57:57 / cg"
! !
!Class class methodsFor:'queries'!
@@ -442,7 +461,12 @@
"return the name of the file from which the class was compiled.
This is currently NOT used."
+ |owner|
+
+ (owner := self owningClass) notNil ifTrue:[^ owner classFilename].
^ classFilename
+
+ "Modified: 15.10.1996 / 18:53:21 / cg"
!
classVarAt:aSymbol
@@ -608,11 +632,16 @@
package
"return the package of the class"
+ |owner|
+
+ (owner := self owningClass) notNil ifTrue:[^ owner package].
^ package
"
Object package
"
+
+ "Modified: 15.10.1996 / 18:53:36 / cg"
!
package:aStringOrSymbol
@@ -863,10 +892,13 @@
For now, all classes return the same global manager.
But future versions may support mixed reporitories"
+ |owner|
+
+ (owner := self owningClass) notNil ifTrue:[^ owner sourceCodeManager].
^ Smalltalk at:#SourceCodeManager
"Created: 7.12.1995 / 13:16:46 / cg"
- "Modified: 1.10.1996 / 15:47:35 / cg"
+ "Modified: 15.10.1996 / 18:54:02 / cg"
! !
!Class methodsFor:'adding/removing'!
@@ -3390,10 +3422,12 @@
!
owningClass
+ "return my owning class - nil if I am a public class"
+
^ self class owningClass
"Created: 11.10.1996 / 18:45:59 / cg"
- "Modified: 12.10.1996 / 20:11:28 / cg"
+ "Modified: 15.10.1996 / 18:54:56 / cg"
!
wasAutoloaded
@@ -3458,6 +3492,9 @@
If a classes binary is up-to-date w.r.t. the source repository,
the returned string is the same as the one returned by #revision."
+ |owner|
+
+ (owner := self owningClass) notNil ifTrue:[^ owner binaryRevision].
self isMeta ifTrue:[
^ self soleInstance binaryRevision
].
@@ -3479,7 +3516,7 @@
"
"Created: 7.12.1995 / 10:58:47 / cg"
- "Modified: 9.2.1996 / 17:04:39 / cg"
+ "Modified: 15.10.1996 / 18:55:28 / cg"
!
packageSourceCodeInfo
@@ -3507,10 +3544,10 @@
(this is done for backward compatibility,)
For example:
- '....(libbasic)' -> module: stx directory: libbasic library: libbasic
- '....(stx:libbasic)' -> module: stx directory: libbasic library: libbasic
- '....(aeg:libIECInterface)' -> module: aeg directory: libIECInterface library:libIECInterface
- '....(stx:goodies/persistency:libdbase)' -> module: stx directory: goodies/persistency library:libdbase
+ '....(libbasic)' -> module: stx directory: libbasic library: libbasic
+ '....(stx:libbasic)' -> module: stx directory: libbasic library: libbasic
+ '....(aeg:libIECInterface)' -> module: aeg directory: libIECInterface library:libIECInterface
+ '....(stx:goodies/persistency:libdbase)' -> module: stx directory: goodies/persistency library:libdbase
The way how the sourceCodeManager uses this to find the source location
depends on the scheme used. For CVS, the module is taken as the -d arg,
@@ -3518,81 +3555,83 @@
Other schemes may do things differently - these are not yet specified.
Caveat:
- Encoding this info in the package string seems somewhat kludgy.
+ Encoding this info in the package string seems somewhat kludgy.
"
- |sourceInfo packageString idx1 idx2
+ |owner sourceInfo packageString idx1 idx2
moduleString directoryString libraryString components|
+ (owner := self owningClass) notNil ifTrue:[^ owner packageSourceCodeInfo].
+
package isNil ifTrue:[^ nil].
packageString := package asString.
idx1 := packageString lastIndexOf:$(.
idx1 ~~ 0 ifTrue:[
- idx2 := packageString indexOf:$) startingAt:idx1+1.
- idx2 ~~ 0 ifTrue:[
- sourceInfo := packageString copyFrom:idx1 + 1 to:idx2 - 1
- ]
+ idx2 := packageString indexOf:$) startingAt:idx1+1.
+ idx2 ~~ 0 ifTrue:[
+ sourceInfo := packageString copyFrom:idx1 + 1 to:idx2 - 1
+ ]
].
sourceInfo isNil ifTrue:[^ nil].
components := sourceInfo asCollectionOfSubstringsSeparatedBy:$:.
components size == 0 ifTrue:[
- moduleString := 'stx'.
- directoryString := libraryString := ''.
- ^ nil
+ moduleString := 'stx'.
+ directoryString := libraryString := ''.
+ ^ nil
] ifFalse:[
- components size == 1 ifTrue:[
- "/ a single name given - the module becomes 'stx',
- "/ if the component includes slashes, its the directory
- "/ otherwise the library
- "/
- moduleString := 'stx'.
- directoryString := libraryString := components at:1.
- (libraryString includes:$/) ifTrue:[
- libraryString := libraryString asFilename baseName
- ]
- ] ifFalse:[
- components size == 2 ifTrue:[
- "/ two components - assume its the module and the directory;
- "/ the library is assumed to be named after the directory
- "/ except, if slashes are in the name; then the libraryname
- "/ is the last component.
- "/
- moduleString := components at:1.
- directoryString := libraryString := components at:2.
- (libraryString includes:$/) ifTrue:[
- libraryString := libraryString asFilename baseName
- ]
- ] ifFalse:[
- "/ all components given
- moduleString := components at:1.
- directoryString := components at:2.
- libraryString := components at:3.
- ]
- ]
+ components size == 1 ifTrue:[
+ "/ a single name given - the module becomes 'stx',
+ "/ if the component includes slashes, its the directory
+ "/ otherwise the library
+ "/
+ moduleString := 'stx'.
+ directoryString := libraryString := components at:1.
+ (libraryString includes:$/) ifTrue:[
+ libraryString := libraryString asFilename baseName
+ ]
+ ] ifFalse:[
+ components size == 2 ifTrue:[
+ "/ two components - assume its the module and the directory;
+ "/ the library is assumed to be named after the directory
+ "/ except, if slashes are in the name; then the libraryname
+ "/ is the last component.
+ "/
+ moduleString := components at:1.
+ directoryString := libraryString := components at:2.
+ (libraryString includes:$/) ifTrue:[
+ libraryString := libraryString asFilename baseName
+ ]
+ ] ifFalse:[
+ "/ all components given
+ moduleString := components at:1.
+ directoryString := components at:2.
+ libraryString := components at:3.
+ ]
+ ]
].
libraryString isEmpty ifTrue:[
- directoryString notEmpty ifTrue:[
- libraryString := directoryString asFilename baseName
- ].
- libraryString isEmpty ifTrue:[
- "/ lets extract the library from the liblist file ...
- libraryString := Smalltalk libraryFileNameOfClass:self.
- libraryString isNil ifTrue:[^ nil].
- ]
+ directoryString notEmpty ifTrue:[
+ libraryString := directoryString asFilename baseName
+ ].
+ libraryString isEmpty ifTrue:[
+ "/ lets extract the library from the liblist file ...
+ libraryString := Smalltalk libraryFileNameOfClass:self.
+ libraryString isNil ifTrue:[^ nil].
+ ]
].
moduleString isEmpty ifTrue:[
- moduleString := 'stx'.
+ moduleString := 'stx'.
].
directoryString isEmpty ifTrue:[
- directoryString := libraryString.
+ directoryString := libraryString.
].
^ IdentityDictionary
- with:(#module->moduleString)
- with:(#directory->directoryString)
- with:(#library->libraryString)
+ with:(#module->moduleString)
+ with:(#directory->directoryString)
+ with:(#library->libraryString)
"
Object packageSourceCodeInfo
@@ -3604,7 +3643,7 @@
"
"Created: 4.11.1995 / 20:36:53 / cg"
- "Modified: 7.2.1996 / 14:26:31 / cg"
+ "Modified: 15.10.1996 / 18:56:03 / cg"
!
revision
@@ -3636,24 +3675,24 @@
"return a dictionary filled with revision info.
This extracts the relevant info from the revisionString.
The revisionInfo contains all or a subset of:
- #binaryRevision - the revision upon which the binary of this class is based
- #revision - the revision upon which the class is based logically
- (different, if a changed class was checked in, but not yet recompiled)
- #user - the user who checked in the logical revision
- #date - the date when the logical revision was checked in
- #time - the time when the logical revision was checked in
- #fileName - the classes source file name
- #repositoryPath - the classes source container
+ #binaryRevision - the revision upon which the binary of this class is based
+ #revision - the revision upon which the class is based logically
+ (different, if a changed class was checked in, but not yet recompiled)
+ #user - the user who checked in the logical revision
+ #date - the date when the logical revision was checked in
+ #time - the time when the logical revision was checked in
+ #fileName - the classes source file name
+ #repositoryPath - the classes source container
"
|vsnString info|
vsnString := self revisionString.
vsnString notNil ifTrue:[
- info := Class revisionInfoFromString:vsnString.
- info notNil ifTrue:[
- info at:#binaryRevision put:revision.
- ]
+ info := Class revisionInfoFromString:vsnString.
+ info notNil ifTrue:[
+ info at:#binaryRevision put:revision.
+ ]
].
^ info
@@ -3664,7 +3703,7 @@
"
"Created: 11.11.1995 / 14:27:20 / cg"
- "Modified: 9.12.1995 / 21:35:26 / cg"
+ "Modified: 15.10.1996 / 18:56:44 / cg"
!
revisionString
@@ -3674,7 +3713,9 @@
If the source is not accessable or no such method exists,
nil is returned."
- |cls meta m src val|
+ |owner cls meta m src val|
+
+ (owner := self owningClass) notNil ifTrue:[^ owner revisionString].
thisContext isRecursive ifTrue:[^ nil ].
@@ -3708,7 +3749,7 @@
"/
src := m source.
src isNil ifTrue:[^ nil].
- ^ self revisionStringFromSource:src
+ ^ self class revisionStringFromSource:src
"
Smalltalk allClassesDo:[:cls |
@@ -3720,24 +3761,7 @@
"
"Created: 29.10.1995 / 19:28:03 / cg"
- "Modified: 18.3.1996 / 15:39:36 / cg"
-!
-
-revisionStringFromSource:aMethodSourceString
- "extract a revision string from a methods source string"
-
- |lines|
-
- lines := aMethodSourceString asCollectionOfLines.
- lines do:[:l |
- |i|
-
- i := l indexOfSubCollection:'$Header: '.
- i ~~ 0 ifTrue:[
- ^ l copyFrom:i
- ]
- ].
- ^ nil
+ "Modified: 15.10.1996 / 18:57:43 / cg"
!
setBinaryRevision:aString
@@ -3814,25 +3838,31 @@
sourceStream
"return an open stream on my sourcefile, nil if that is not available"
- |source cls|
+ |owner source cls|
+
+ (owner := self owningClass) notNil ifTrue:[^ owner sourceStream].
self isMeta ifTrue:[
- cls := self soleInstance
+ cls := self soleInstance
] ifFalse:[
- cls := self
+ cls := self
].
classFilename notNil ifTrue:[
- source := classFilename
+ source := classFilename
] ifFalse:[
- source := (Smalltalk fileNameForClass:cls) , '.st'
+ source := (Smalltalk fileNameForClass:cls) , '.st'
].
^ cls sourceStreamFor:source
+
+ "Modified: 15.10.1996 / 18:59:40 / cg"
!
sourceStreamFor:source
"return an open stream on a sourcefile, nil if that is not available"
- |fileName aStream mgr|
+ |owner fileName aStream mgr|
+
+ (owner := self owningClass) notNil ifTrue:[^ owner sourceStreamFor:source].
"/
"/ if there is no SourceCodeManager,
@@ -3913,7 +3943,7 @@
"
"Created: 10.11.1995 / 21:05:13 / cg"
- "Modified: 12.10.1996 / 17:21:10 / cg"
+ "Modified: 15.10.1996 / 18:59:53 / cg"
!
updateVersionMethodFor:newRevisionString
@@ -3924,8 +3954,9 @@
cls := self.
self isMeta ifFalse:[
- cls := self class
+ cls := self class
].
+
"/ m := cls compiledMethodAt:#version.
"/ m isNil ifTrue:[^ false].
"/ vs := self revisionString.
@@ -3936,23 +3967,23 @@
"/ newString isNil ifTrue:[^ false].
Class withoutUpdatingChangesDo:[
- Compiler compile:'version
+ Compiler compile:'version
^ ''' , newRevisionString , '''
'
- forClass:cls inCategory:#documentation notifying:nil
- install:true skipIfSame:false silent:true.
+ forClass:cls inCategory:#documentation notifying:nil
+ install:true skipIfSame:false silent:true.
].
"/ ('updated to :' , newRevisionString) printNL.
^ true
"Created: 7.12.1995 / 20:42:22 / cg"
- "Modified: 7.12.1995 / 23:34:43 / cg"
+ "Modified: 15.10.1996 / 18:59:58 / cg"
! !
!Class class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.186 1996-10-15 11:29:55 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.187 1996-10-15 18:00:43 cg Exp $'
! !
Class initialize!