Class.st
changeset 689 d8f2044c6634
parent 686 5cde213f9093
child 702 6a5a2ebff51b
equal deleted inserted replaced
688:e3c8dbff09b0 689:d8f2044c6634
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 ClassDescription subclass:#Class
    13 ClassDescription subclass:#Class
    14 	 instanceVariableNames:'classvars comment subclasses classFilename package revision
    14 	 instanceVariableNames:'classvars comment subclasses classFilename package revision
    15                 history'
    15 		history'
    16 	 classVariableNames:'UpdatingChanges LockChangesFile FileOutErrorSignal
    16 	 classVariableNames:'UpdatingChanges LockChangesFile FileOutErrorSignal
    17                 CatchMethodRedefinitions MethodRedefinitionSignal
    17 		CatchMethodRedefinitions MethodRedefinitionSignal
    18                 UpdateChangeFileQuerySignal'
    18 		UpdateChangeFileQuerySignal'
    19 	 poolDictionaries:''
    19 	 poolDictionaries:''
    20 	 category:'Kernel-Classes'
    20 	 category:'Kernel-Classes'
    21 !
    21 !
    22 
    22 
    23 !Class class methodsFor:'documentation'!
    23 !Class class methodsFor:'documentation'!
   253 
   253 
   254 revisionInfoFromString:aString
   254 revisionInfoFromString:aString
   255     "return a dictionary filled with revision info.
   255     "return a dictionary filled with revision info.
   256      This extracts the relevant info from aString."
   256      This extracts the relevant info from aString."
   257 
   257 
   258     |words info nm|
   258     |words info nm mgr|
   259 
   259 
   260     info := IdentityDictionary new.
   260     info := IdentityDictionary new.
   261     words := aString asCollectionOfWords.
   261     words := aString asCollectionOfWords.
   262 
   262 
   263     "/
   263     "/
   297     ].
   297     ].
   298 
   298 
   299     "/
   299     "/
   300     "/ mhmh - maybe its some other source code system
   300     "/ mhmh - maybe its some other source code system
   301     "/
   301     "/
   302     SourceCodeManager notNil ifTrue:[
   302     (mgr := Smalltalk at:SourceCodeManager) notNil ifTrue:[
   303 	^ SourceCodeManager revisionInfoFromString:aString
   303 	^ mgr revisionInfoFromString:aString
   304     ].
   304     ].
   305     ^ nil
   305     ^ nil
   306 
   306 
   307     "Created: 15.11.1995 / 14:58:35 / cg"
   307     "Created: 15.11.1995 / 14:58:35 / cg"
       
   308     "Modified: 7.12.1995 / 13:21:40 / cg"
   308 ! !
   309 ! !
   309 
   310 
   310 !Class methodsFor:'ST/V subclass creation'!
   311 !Class methodsFor:'ST/V subclass creation'!
   311 
   312 
   312 subclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s
   313 subclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s
   934     aStream close.
   935     aStream close.
   935     OperatingSystem removeFile:'__temp'.
   936     OperatingSystem removeFile:'__temp'.
   936     ^ code
   937     ^ code
   937 !
   938 !
   938 
   939 
       
   940 sourceCodeManager
       
   941     "return my source code manager.
       
   942      For now, all classes return the same global manager.
       
   943      But future versions may support mixed reporitories"
       
   944 
       
   945     ^ Smalltalk at:#SourceCodeManager
       
   946 
       
   947     "Created: 7.12.1995 / 13:16:46 / cg"
       
   948 !
       
   949 
   939 sourceStream
   950 sourceStream
   940     "return an open stream on my sourcefile, nil if that is not available"
   951     "return an open stream on my sourcefile, nil if that is not available"
   941 
   952 
   942     |source fileName aStream cls|
   953     |source fileName aStream cls mgr|
   943 
   954 
   944     self isMeta ifTrue:[
   955     self isMeta ifTrue:[
   945 	cls := self soleInstance
   956 	cls := self soleInstance
   946     ] ifFalse:[
   957     ] ifFalse:[
   947 	cls := self
   958 	cls := self
   954 
   965 
   955     "/
   966     "/
   956     "/ if there is no SourceCodeManager, look in
   967     "/ if there is no SourceCodeManager, look in
   957     "/ standard places first
   968     "/ standard places first
   958     "/
   969     "/
   959     SourceCodeManager isNil ifTrue:[
   970     (mgr := self sourceCodeManager) isNil ifTrue:[
   960 	fileName := Smalltalk getSourceFileName:source.
   971 	fileName := Smalltalk getSourceFileName:source.
   961 	fileName notNil ifTrue:[
   972 	fileName notNil ifTrue:[
   962 	    aStream := fileName asFilename readStream.
   973 	    aStream := fileName asFilename readStream.
   963 	]
   974 	]
   964     ].
   975     ].
  1000 	"/ If there is a SourceCodeManager, ask it to aquire the
  1011 	"/ If there is a SourceCodeManager, ask it to aquire the
  1001 	"/ the source for my class, and return an open stream on it. 
  1012 	"/ the source for my class, and return an open stream on it. 
  1002 	"/ if that one does not know about the source, look in
  1013 	"/ if that one does not know about the source, look in
  1003 	"/ standard places
  1014 	"/ standard places
  1004 
  1015 
  1005 	SourceCodeManager notNil ifTrue:[
  1016 	mgr notNil ifTrue:[
  1006 	    aStream := SourceCodeManager sourceStreamFor:cls.
  1017 	    aStream := mgr sourceStreamFor:cls.
  1007 	    aStream isNil ifTrue:[
  1018 	    aStream isNil ifTrue:[
  1008 		fileName := Smalltalk getSourceFileName:cls name.
  1019 		fileName := Smalltalk getSourceFileName:cls name.
  1009 		fileName notNil ifTrue:[
  1020 		fileName notNil ifTrue:[
  1010 		    aStream := fileName asFilename readStream.
  1021 		    aStream := fileName asFilename readStream.
  1011 		]
  1022 		]
  1027      Clock sourceStream
  1038      Clock sourceStream
  1028      Autoload sourceStream
  1039      Autoload sourceStream
  1029     "
  1040     "
  1030 
  1041 
  1031     "Created: 10.11.1995 / 21:05:13 / cg"
  1042     "Created: 10.11.1995 / 21:05:13 / cg"
  1032     "Modified: 25.11.1995 / 16:55:17 / cg"
  1043     "Modified: 7.12.1995 / 13:21:16 / cg"
  1033 ! !
  1044 ! !
  1034 
  1045 
  1035 !Class methodsFor:'adding/removing'!
  1046 !Class methodsFor:'adding/removing'!
  1036 
  1047 
  1037 addSelector:newSelector withMethod:newMethod
  1048 addSelector:newSelector withMethod:newMethod
  2871 
  2882 
  2872 revisionInfo
  2883 revisionInfo
  2873     "return a dictionary filled with revision info.
  2884     "return a dictionary filled with revision info.
  2874      This extracts the relevant info from the revisionString.
  2885      This extracts the relevant info from the revisionString.
  2875      The revisionInfo contains all or a subset of:
  2886      The revisionInfo contains all or a subset of:
  2876         #binaryRevision - the revision upon which the binary of this class is based
  2887 	#binaryRevision - the revision upon which the binary of this class is based
  2877         #revision       - the revision upon which the class is based logically
  2888 	#revision       - the revision upon which the class is based logically
  2878                           (different, if a changed class was checked in, but not yet recompiled)
  2889 			  (different, if a changed class was checked in, but not yet recompiled)
  2879         #user           - the user who checked in the logical revision
  2890 	#user           - the user who checked in the logical revision
  2880         #date           - the date when the logical revision was checked in
  2891 	#date           - the date when the logical revision was checked in
  2881         #time           - the time when the logical revision was checked in
  2892 	#time           - the time when the logical revision was checked in
  2882         #fileName       - the classes source file name
  2893 	#fileName       - the classes source file name
  2883         #repositoryPath - the classes source container
  2894 	#repositoryPath - the classes source container
  2884     "
  2895     "
  2885 
  2896 
  2886     |vsnString info|
  2897     |vsnString info|
  2887 
  2898 
  2888     vsnString := self revisionString.
  2899     vsnString := self revisionString.
  2889     vsnString notNil ifTrue:[
  2900     vsnString notNil ifTrue:[
  2890         info := Class revisionInfoFromString:vsnString.
  2901 	info := Class revisionInfoFromString:vsnString.
  2891         info at:#binaryRevision put:revision.
  2902 	info at:#binaryRevision put:revision.
  2892     ].
  2903     ].
  2893     ^ info
  2904     ^ info
  2894 
  2905 
  2895     "
  2906     "
  2896      Object revisionString 
  2907      Object revisionString 
  3009 
  3020 
  3010     |cls vs m idx leftPart rightPart vsnString newVsn|
  3021     |cls vs m idx leftPart rightPart vsnString newVsn|
  3011 
  3022 
  3012     cls := self.
  3023     cls := self.
  3013     self isMeta ifFalse:[
  3024     self isMeta ifFalse:[
  3014         cls := self class
  3025 	cls := self class
  3015     ].
  3026     ].
  3016     m := cls compiledMethodAt:#version.
  3027     m := cls compiledMethodAt:#version.
  3017     m isNil ifTrue:[^ false].
  3028     m isNil ifTrue:[^ false].
  3018     vs := self revisionString.
  3029     vs := self revisionString.
  3019     vs isNil ifTrue:[^ false].
  3030     vs isNil ifTrue:[^ false].
  3027     idx == 0 ifTrue:[^ false].
  3038     idx == 0 ifTrue:[^ false].
  3028     vsnString := rightPart copyTo:idx - 1.
  3039     vsnString := rightPart copyTo:idx - 1.
  3029     rightPart := rightPart copyFrom:idx + 1.
  3040     rightPart := rightPart copyFrom:idx + 1.
  3030 
  3041 
  3031     newRevision isNil ifTrue:[
  3042     newRevision isNil ifTrue:[
  3032         (vsnString endsWith:'mod') ifTrue:[
  3043 	(vsnString endsWith:'mod') ifTrue:[
  3033              "/ alread a modified class
  3044 	     "/ alread a modified class
  3034 "/            ('already modified: ' , vsnString) printNL.
  3045 "/            ('already modified: ' , vsnString) printNL.
  3035             ^ false
  3046 	    ^ false
  3036         ].
  3047 	].
  3037         newVsn := vsnString , 'mod'
  3048 	newVsn := vsnString , 'mod'
  3038     ] ifFalse:[
  3049     ] ifFalse:[
  3039         newVsn := newRevision
  3050 	newVsn := newRevision
  3040     ].
  3051     ].
  3041     m source:'version
  3052     m source:'version
  3042     ^ ''' , leftPart , ' ' , newVsn , ' ' , rightPart , ''''.
  3053     ^ ''' , leftPart , ' ' , newVsn , ' ' , rightPart , '''
       
  3054 '.
  3043 
  3055 
  3044 "/ ('updated to :' , newVsn) printNL.
  3056 "/ ('updated to :' , newVsn) printNL.
  3045 
  3057 
  3046     cls recompile:#version.
  3058     cls recompile:#version.
  3047     ^ true
  3059     ^ true
  3048 
  3060 
  3049     "Created: 29.10.1995 / 19:25:15 / cg"
  3061     "Created: 29.10.1995 / 19:25:15 / cg"
  3050     "Modified: 7.12.1995 / 12:29:01 / cg"
  3062     "Modified: 7.12.1995 / 13:12:21 / cg"
  3051 ! !
  3063 ! !
  3052 
  3064 
  3053 !Class methodsFor:'queries'!
  3065 !Class methodsFor:'queries'!
  3054 
  3066 
  3055 allCategories
  3067 allCategories
  3384 ! !
  3396 ! !
  3385 
  3397 
  3386 !Class class methodsFor:'documentation'!
  3398 !Class class methodsFor:'documentation'!
  3387 
  3399 
  3388 version
  3400 version
  3389 ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.96 1995-12-07 11:46:07 cg Exp $'! !
  3401 ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.97 1995-12-07 15:15:02 cg Exp $'! !
  3390 Class initialize!
  3402 Class initialize!