Class.st
changeset 3165 b6bde90005a8
parent 3064 59c97d974936
child 3180 1c225dd8c5b2
equal deleted inserted replaced
3164:4f37ae9c8961 3165:b6bde90005a8
    39     Class adds more functionality to classes; minimum stuff has already
    39     Class adds more functionality to classes; minimum stuff has already
    40     been defined in Behavior and ClassDescription; this adds naming, categories etc.
    40     been defined in Behavior and ClassDescription; this adds naming, categories etc.
    41 
    41 
    42     [Instance variables:]
    42     [Instance variables:]
    43 
    43 
    44         name            <Symbol>        the classes name
    44 	name            <Symbol>        the classes name
    45 
    45 
    46         category        <Symbol>        the classes category
    46 	category        <Symbol>        the classes category
    47 
    47 
    48         classvars       <String>        the names of the class variables
    48 	classvars       <String>        the names of the class variables
    49 
    49 
    50         comment         <String>        the classes comment; either a string,
    50 	comment         <String>        the classes comment; either a string,
    51                                         a number specifying the offset in classFilename, or nil
    51 					a number specifying the offset in classFilename, or nil
    52 
    52 
    53         subclasses      <Collection>    cached collection of subclasses
    53 	subclasses      <Collection>    cached collection of subclasses
    54                                         (currently unused - but will be soon)
    54 					(currently unused - but will be soon)
    55 
    55 
    56         classFilename   <String>        the file (or nil) where the classes
    56 	classFilename   <String>        the file (or nil) where the classes
    57                                         sources are found 
    57 					sources are found 
    58 
    58 
    59         package         <Symbol>        the package, in which the class was defined
    59 	package         <Symbol>        the package, in which the class was defined
    60                                         (inserted by compilers)
    60 					(inserted by compilers)
    61 
    61 
    62         revision        <String>        revision string - inserted by stc
    62 	revision        <String>        revision string - inserted by stc
    63 
    63 
    64         primitiveSpec   <Array | nil>   describes primitiveIncludes, primitiveFunctions etc.
    64 	primitiveSpec   <Array | nil>   describes primitiveIncludes, primitiveFunctions etc.
    65 
    65 
    66         environment     <Symbol | nil>  cached environment (i.e. Smalltalk or a namespace)
    66 	environment     <Symbol | nil>  cached environment (i.e. Smalltalk or a namespace)
    67                                         of class
    67 					of class
    68 
    68 
    69         signature       <SmallInteger>  the classes signature (used to detect obsolete
    69 	signature       <SmallInteger>  the classes signature (used to detect obsolete
    70                                         or changed classes with binaryStorage)
    70 					or changed classes with binaryStorage)
    71                                         This is filled in lazy - i.e. upon the first signature query.
    71 					This is filled in lazy - i.e. upon the first signature query.
    72 
    72 
    73         hook            <any>           reserved: a place to add additional attributes,
    73 	hook            <any>           reserved: a place to add additional attributes,
    74                                         without a need to recompile all classes.
    74 					without a need to recompile all classes.
    75                                         Currently unused.
    75 					Currently unused.
    76 
    76 
    77     [Class variables:]
    77     [Class variables:]
    78 
    78 
    79         OldMethods                      if nonNil, this must be an IdentityDictionary,
    79 	OldMethods                      if nonNil, this must be an IdentityDictionary,
    80                                         which is filled with method->previousversionMethod
    80 					which is filled with method->previousversionMethod
    81                                         associations. Can be used for undo-last-method-change
    81 					associations. Can be used for undo-last-method-change
    82                                         Notice: this may fillup your memory over time.
    82 					Notice: this may fillup your memory over time.
    83 
    83 
    84 
    84 
    85     WARNING: layout known by compiler and runtime system
    85     WARNING: layout known by compiler and runtime system
    86 
    86 
    87     [author:]
    87     [author:]
    88         Claus Gittinger
    88 	Claus Gittinger
    89 
    89 
    90     [see also:]
    90     [see also:]
    91         Behavior ClassDescription Metaclass
    91 	Behavior ClassDescription Metaclass
    92 "
    92 "
    93 ! !
    93 ! !
    94 
    94 
    95 !Class class methodsFor:'Signal constants'!
    95 !Class class methodsFor:'Signal constants'!
    96 
    96 
   174 keepMethodHistory:aBoolean
   174 keepMethodHistory:aBoolean
   175     "turn on/off oldMethod remembering. If on, a methods previous version
   175     "turn on/off oldMethod remembering. If on, a methods previous version
   176      is kept locally, for later undo (or compare)."
   176      is kept locally, for later undo (or compare)."
   177 
   177 
   178     aBoolean ifTrue:[
   178     aBoolean ifTrue:[
   179         OldMethods isNil ifTrue:[
   179 	OldMethods isNil ifTrue:[
   180             OldMethods := IdentityDictionary new.
   180 	    OldMethods := IdentityDictionary new.
   181         ]
   181 	]
   182     ] ifFalse:[
   182     ] ifFalse:[
   183         OldMethods := nil
   183 	OldMethods := nil
   184     ].
   184     ].
   185 
   185 
   186     "
   186     "
   187      Class keepMethodHistory:true
   187      Class keepMethodHistory:true
   188      Class keepMethodHistory:false
   188      Class keepMethodHistory:false
   245 flushMethodHistory
   245 flushMethodHistory
   246     "flush any method->previousVersion associations,
   246     "flush any method->previousVersion associations,
   247      all history is lost."
   247      all history is lost."
   248 
   248 
   249     OldMethods notNil ifTrue:[
   249     OldMethods notNil ifTrue:[
   250         OldMethods := IdentityDictionary new
   250 	OldMethods := IdentityDictionary new
   251     ].
   251     ].
   252 
   252 
   253     "Created: 7.11.1996 / 19:07:25 / cg"
   253     "Created: 7.11.1996 / 19:07:25 / cg"
   254 !
   254 !
   255 
   255 
   288 
   288 
   289     "/
   289     "/
   290     "/ mhmh - ask the default manager
   290     "/ mhmh - ask the default manager
   291     "/
   291     "/
   292     (mgr := Smalltalk at:#SourceCodeManager) notNil ifTrue:[
   292     (mgr := Smalltalk at:#SourceCodeManager) notNil ifTrue:[
   293         info := mgr revisionInfoFromString:aString.
   293 	info := mgr revisionInfoFromString:aString.
   294         info notNil ifTrue:[
   294 	info notNil ifTrue:[
   295             ^ info
   295 	    ^ info
   296         ]
   296 	]
   297     ].
   297     ].
   298 
   298 
   299     "/
   299     "/
   300     "/ fallBack - handles some RCS headers only
   300     "/ fallBack - handles some RCS headers only
   301     "/ is this really needed ?
   301     "/ is this really needed ?
   302     "/
   302     "/
   303     info := IdentityDictionary new.
   303     info := IdentityDictionary new.
   304     words := aString asCollectionOfWords.
   304     words := aString asCollectionOfWords.
   305 
   305 
   306     words notEmpty ifTrue:[
   306     words notEmpty ifTrue:[
   307         "/
   307 	"/
   308         "/ supported formats:
   308 	"/ supported formats:
   309         "/
   309 	"/
   310         "/ $-Header: pathName rev date time user state $
   310 	"/ $-Header: pathName rev date time user state $
   311         "/ $-Revision: rev $
   311 	"/ $-Revision: rev $
   312         "/ $-Id: fileName rev date time user state $
   312 	"/ $-Id: fileName rev date time user state $
   313         "/
   313 	"/
   314 
   314 
   315         ((words at:1) = '$Header:') ifTrue:[
   315 	((words at:1) = '$Header:') ifTrue:[
   316             nm := words at:2.
   316 	    nm := words at:2.
   317             info at:#repositoryPathName put:nm.
   317 	    info at:#repositoryPathName put:nm.
   318             (nm endsWith:',v') ifTrue:[
   318 	    (nm endsWith:',v') ifTrue:[
   319                 nm := nm copyWithoutLast:2
   319 		nm := nm copyWithoutLast:2
   320             ].
   320 	    ].
   321             info at:#fileName put:nm asFilename baseName.
   321 	    info at:#fileName put:nm asFilename baseName.
   322             words size > 2 ifTrue:[
   322 	    words size > 2 ifTrue:[
   323                 (words at:3) = '$' ifFalse:[
   323 		(words at:3) = '$' ifFalse:[
   324                     info at:#revision put:(words at:3).
   324 		    info at:#revision put:(words at:3).
   325                     (words at:4) = '$' ifFalse:[
   325 		    (words at:4) = '$' ifFalse:[
   326                         info at:#date put:(words at:4).
   326 			info at:#date put:(words at:4).
   327                         info at:#time put:(words at:5).
   327 			info at:#time put:(words at:5).
   328                         info at:#user put:(words at:6).
   328 			info at:#user put:(words at:6).
   329                         info at:#state put:(words at:7).
   329 			info at:#state put:(words at:7).
   330                     ]
   330 		    ]
   331                 ].
   331 		].
   332             ].
   332 	    ].
   333             ^ info
   333 	    ^ info
   334         ].
   334 	].
   335         ((words at:1) = '$Revision:') ifTrue:[
   335 	((words at:1) = '$Revision:') ifTrue:[
   336             info at:#revision put:(words at:2).
   336 	    info at:#revision put:(words at:2).
   337             ^ info
   337 	    ^ info
   338         ].
   338 	].
   339         ((words at:1) = '$Id:') ifTrue:[
   339 	((words at:1) = '$Id:') ifTrue:[
   340             info at:#fileName put:(words at:2).
   340 	    info at:#fileName put:(words at:2).
   341             info at:#revision put:(words at:3).
   341 	    info at:#revision put:(words at:3).
   342             info at:#date put:(words at:4).
   342 	    info at:#date put:(words at:4).
   343             info at:#time put:(words at:5).
   343 	    info at:#time put:(words at:5).
   344             info at:#user put:(words at:6).
   344 	    info at:#user put:(words at:6).
   345             info at:#state put:(words at:7).
   345 	    info at:#state put:(words at:7).
   346             ^ info
   346 	    ^ info
   347         ].
   347 	].
   348     ].
   348     ].
   349 
   349 
   350     ^ nil
   350     ^ nil
   351 
   351 
   352     "Created: 15.11.1995 / 14:58:35 / cg"
   352     "Created: 15.11.1995 / 14:58:35 / cg"
   360 
   360 
   361     |lines line|
   361     |lines line|
   362 
   362 
   363     lines := aMethodSourceString asCollectionOfLines.
   363     lines := aMethodSourceString asCollectionOfLines.
   364     lines do:[:l |
   364     lines do:[:l |
   365         |i|
   365 	|i|
   366 
   366 
   367         i := l indexOfSubCollection:'$Header: '.
   367 	i := l indexOfSubCollection:'$Header: '.
   368         i ~~ 0 ifTrue:[
   368 	i ~~ 0 ifTrue:[
   369             line := l copyFrom:i.
   369 	    line := l copyFrom:i.
   370             i := line lastIndexOf:$$.
   370 	    i := line lastIndexOf:$$.
   371             i > 1 ifTrue:[
   371 	    i > 1 ifTrue:[
   372                 line := line copyTo:i.
   372 		line := line copyTo:i.
   373             ].
   373 	    ].
   374             ^ line
   374 	    ^ line
   375         ]
   375 	]
   376     ].
   376     ].
   377     ^ nil
   377     ^ nil
   378 
   378 
   379     "Created: 15.10.1996 / 18:57:57 / cg"
   379     "Created: 15.10.1996 / 18:57:57 / cg"
   380     "Modified: 16.10.1996 / 16:54:40 / cg"
   380     "Modified: 16.10.1996 / 16:54:40 / cg"
   399 
   399 
   400     "this method allows fileIn of ST/V classes 
   400     "this method allows fileIn of ST/V classes 
   401      (which seem to have no category)"
   401      (which seem to have no category)"
   402 
   402 
   403     ^ self subclass:t 
   403     ^ self subclass:t 
   404            instanceVariableNames:f
   404 	   instanceVariableNames:f
   405            classVariableNames:d
   405 	   classVariableNames:d
   406            poolDictionaries:s
   406 	   poolDictionaries:s
   407            category:'ST/V classes'
   407 	   category:'ST/V classes'
   408 
   408 
   409     "Modified: 5.1.1997 / 19:59:30 / cg"
   409     "Modified: 5.1.1997 / 19:59:30 / cg"
   410 !
   410 !
   411 
   411 
   412 variableByteSubclass:t classVariableNames:d poolDictionaries:s
   412 variableByteSubclass:t classVariableNames:d poolDictionaries:s
   414 
   414 
   415     "this method allows fileIn of ST/V variable byte classes 
   415     "this method allows fileIn of ST/V variable byte classes 
   416      (which seem to have no category and no instvars)"
   416      (which seem to have no category and no instvars)"
   417 
   417 
   418     ^ self variableByteSubclass:t 
   418     ^ self variableByteSubclass:t 
   419            instanceVariableNames:''
   419 	   instanceVariableNames:''
   420            classVariableNames:d
   420 	   classVariableNames:d
   421            poolDictionaries:s
   421 	   poolDictionaries:s
   422            category:'ST/V classes'
   422 	   category:'ST/V classes'
   423 
   423 
   424     "Modified: 5.1.1997 / 19:59:33 / cg"
   424     "Modified: 5.1.1997 / 19:59:33 / cg"
   425 !
   425 !
   426 
   426 
   427 variableSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s
   427 variableSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s
   429 
   429 
   430     "this method allows fileIn of ST/V variable pointer classes 
   430     "this method allows fileIn of ST/V variable pointer classes 
   431      (which seem to have no category)"
   431      (which seem to have no category)"
   432 
   432 
   433     ^ self variableSubclass:t 
   433     ^ self variableSubclass:t 
   434            instanceVariableNames:f
   434 	   instanceVariableNames:f
   435            classVariableNames:d
   435 	   classVariableNames:d
   436            poolDictionaries:s
   436 	   poolDictionaries:s
   437            category:'ST/V classes'
   437 	   category:'ST/V classes'
   438 
   438 
   439     "Modified: 5.1.1997 / 19:59:36 / cg"
   439     "Modified: 5.1.1997 / 19:59:36 / cg"
   440 ! !
   440 ! !
   441 
   441 
   442 !Class methodsFor:'ST80 compatibility'!
   442 !Class methodsFor:'ST80 compatibility'!
   524 
   524 
   525     |d|
   525     |d|
   526 
   526 
   527     d := IdentityDictionary new.
   527     d := IdentityDictionary new.
   528     self classVarNames do:[:nm |
   528     self classVarNames do:[:nm |
   529         |sym|
   529 	|sym|
   530 
   530 
   531         sym := nm asSymbol.
   531 	sym := nm asSymbol.
   532         d at:sym put:(self classVarAt:sym)
   532 	d at:sym put:(self classVarAt:sym)
   533     ].
   533     ].
   534     ^ d
   534     ^ d
   535 
   535 
   536     "
   536     "
   537      Button classPool
   537      Button classPool
   604      No change record is written and no classes are recompiled."
   604      No change record is written and no classes are recompiled."
   605 
   605 
   606     |prevVarNames varNames any|
   606     |prevVarNames varNames any|
   607 
   607 
   608     (classvars = aString) ifFalse:[
   608     (classvars = aString) ifFalse:[
   609         prevVarNames := self classVarNames.
   609 	prevVarNames := self classVarNames.
   610         classvars := aString.
   610 	classvars := aString.
   611         varNames := self classVarNames.
   611 	varNames := self classVarNames.
   612 
   612 
   613         "new ones get initialized to nil;
   613 	"new ones get initialized to nil;
   614          - old ones are nilled and removed from Smalltalk"
   614 	 - old ones are nilled and removed from Smalltalk"
   615         any := false.
   615 	any := false.
   616 
   616 
   617         varNames do:[:aName |
   617 	varNames do:[:aName |
   618             (prevVarNames includes:aName) ifFalse:[
   618 	    (prevVarNames includes:aName) ifFalse:[
   619                 "a new one"
   619 		"a new one"
   620                 self classVarAt:aName put:nil.
   620 		self classVarAt:aName put:nil.
   621                 any := true.
   621 		any := true.
   622             ] ifTrue:[
   622 	    ] ifTrue:[
   623                 prevVarNames remove:aName
   623 		prevVarNames remove:aName
   624             ]
   624 	    ]
   625         ].
   625 	].
   626         "left overs are gone"
   626 	"left overs are gone"
   627         prevVarNames do:[:aName |
   627 	prevVarNames do:[:aName |
   628             self classVarAt:aName put:nil.
   628 	    self classVarAt:aName put:nil.
   629             Smalltalk removeKey:(self name , ':' , aName) asSymbol.
   629 	    Smalltalk removeKey:(self name , ':' , aName) asSymbol.
   630         ].
   630 	].
   631         any ifTrue:[
   631 	any ifTrue:[
   632             Smalltalk changed:#classVariables with:self
   632 	    Smalltalk changed:#classVariables with:self
   633         ].
   633 	].
   634     ]
   634     ]
   635 
   635 
   636     "Modified: 2.4.1997 / 00:16:05 / stefan"
   636     "Modified: 2.4.1997 / 00:16:05 / stefan"
   637 !
   637 !
   638 
   638 
   725     "/ due to the implementation, extract this from my name
   725     "/ due to the implementation, extract this from my name
   726     "/ (physically, all classes are found in Smalltalk)
   726     "/ (physically, all classes are found in Smalltalk)
   727 
   727 
   728     idx := name lastIndexOf:$:.
   728     idx := name lastIndexOf:$:.
   729     idx == 0 ifTrue:[
   729     idx == 0 ifTrue:[
   730         environment := Smalltalk.
   730 	environment := Smalltalk.
   731         ^ Smalltalk
   731 	^ Smalltalk
   732     ].
   732     ].
   733 
   733 
   734     (name at:idx-1) ~~ $: ifTrue:[
   734     (name at:idx-1) ~~ $: ifTrue:[
   735         environment := Smalltalk.
   735 	environment := Smalltalk.
   736         ^ Smalltalk
   736 	^ Smalltalk
   737     ].
   737     ].
   738     nsName := name copyTo:(idx - 2).
   738     nsName := name copyTo:(idx - 2).
   739     environment := Smalltalk at:nsName asSymbol.
   739     environment := Smalltalk at:nsName asSymbol.
   740     ^ environment
   740     ^ environment
   741 
   741 
   742     "Modified: 24.3.1997 / 11:12:09 / cg"
   742     "Modified: 24.3.1997 / 11:12:09 / cg"
   743 !
   743 !
   744 
   744 
   745 package
   745 package
   746     "return the package of the class"
   746     "return the package-id of the class"
   747 
   747 
   748     |owner|
   748     |owner|
   749 
   749 
   750     (owner := self owningClass) notNil ifTrue:[^ owner package].
   750     (owner := self owningClass) notNil ifTrue:[^ owner package].
   751     ^ package
   751     ^ package
   852     classes := IdentitySet new.
   852     classes := IdentitySet new.
   853     myName := self name.
   853     myName := self name.
   854     myNamePrefix := myName , '::'.
   854     myNamePrefix := myName , '::'.
   855 
   855 
   856     Smalltalk allBehaviorsDo:[:aClass |
   856     Smalltalk allBehaviorsDo:[:aClass |
   857         |nm owner|
   857 	|nm owner|
   858 
   858 
   859         aClass isBehavior ifTrue:[
   859 	aClass isBehavior ifTrue:[
   860             (owner := aClass owningClass) notNil ifTrue:[
   860 	    (owner := aClass owningClass) notNil ifTrue:[
   861 "/                owner == self ifTrue:[
   861 "/                owner == self ifTrue:[
   862 "/                    classes add:aClass.
   862 "/                    classes add:aClass.
   863 "/                ].
   863 "/                ].
   864 
   864 
   865                 nm := aClass name.
   865 		nm := aClass name.
   866                 (nm startsWith:myNamePrefix) ifTrue:[
   866 		(nm startsWith:myNamePrefix) ifTrue:[
   867                     "/ care for private-privateClasses
   867 		    "/ care for private-privateClasses
   868                     (nm indexOf:$: startingAt:myName size + 3) == 0 ifTrue:[
   868 		    (nm indexOf:$: startingAt:myName size + 3) == 0 ifTrue:[
   869                         classes add:aClass.
   869 			classes add:aClass.
   870                     ]
   870 		    ]
   871                 ]
   871 		]
   872             ]
   872 	    ]
   873         ]
   873 	]
   874     ].
   874     ].
   875     ^ classes asSortedCollection:[:a :b | a name < b name].
   875     ^ classes asSortedCollection:[:a :b | a name < b name].
   876 
   876 
   877     "
   877     "
   878      Object privateClasses
   878      Object privateClasses
   890 
   890 
   891     |nmSym|
   891     |nmSym|
   892 
   892 
   893     nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned.
   893     nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned.
   894     nmSym isNil ifTrue:[
   894     nmSym isNil ifTrue:[
   895         "/ no such symbol - there cannot be a corresponding private class
   895 	"/ no such symbol - there cannot be a corresponding private class
   896         ^ nil
   896 	^ nil
   897     ].
   897     ].
   898 
   898 
   899     ^ Smalltalk at:nmSym.
   899     ^ Smalltalk at:nmSym.
   900 
   900 
   901     "Modified: 26.6.1997 / 11:44:04 / cg"
   901     "Modified: 26.6.1997 / 11:44:04 / cg"
   919 
   919 
   920     |classes|
   920     |classes|
   921 
   921 
   922     classes := self privateClasses.
   922     classes := self privateClasses.
   923     (classes notNil and:[classes notEmpty]) ifTrue:[
   923     (classes notNil and:[classes notEmpty]) ifTrue:[
   924         classes := classes asOrderedCollection topologicalSort:[:a :b | b isSubclassOf:a].
   924 	classes := classes asOrderedCollection topologicalSort:[:a :b | b isSubclassOf:a].
   925     ].
   925     ].
   926     ^ classes.
   926     ^ classes.
   927 
   927 
   928     "
   928     "
   929      Object privateClassesSorted
   929      Object privateClassesSorted
  1076       is gone ...)"
  1076       is gone ...)"
  1077 
  1077 
  1078     |nm|
  1078     |nm|
  1079 
  1079 
  1080     self wasAutoloaded ifFalse:[
  1080     self wasAutoloaded ifFalse:[
  1081         "
  1081 	"
  1082          can it be done ?
  1082 	 can it be done ?
  1083          (all of my methods must have a source)
  1083 	 (all of my methods must have a source)
  1084         "
  1084 	"
  1085         self methodDictionary do:[:aMethod |
  1085 	self methodDictionary do:[:aMethod |
  1086             aMethod source isNil ifTrue:[^false].
  1086 	    aMethod source isNil ifTrue:[^false].
  1087             aMethod hasPrimitiveCode ifTrue:[^ false].
  1087 	    aMethod hasPrimitiveCode ifTrue:[^ false].
  1088         ].
  1088 	].
  1089         self class methodDictionary do:[:aMethod |
  1089 	self class methodDictionary do:[:aMethod |
  1090             aMethod source isNil ifTrue:[^false].
  1090 	    aMethod source isNil ifTrue:[^false].
  1091             aMethod hasPrimitiveCode ifTrue:[^ false].
  1091 	    aMethod hasPrimitiveCode ifTrue:[^ false].
  1092         ].
  1092 	].
  1093     ].
  1093     ].
  1094 
  1094 
  1095     self allSubclassesDo:[:aClass |
  1095     self allSubclassesDo:[:aClass |
  1096         aClass unload
  1096 	aClass unload
  1097     ].
  1097     ].
  1098     Transcript showCR:'unloading ' , name , ' ...'.
  1098     Transcript showCR:'unloading ' , name , ' ...'.
  1099 
  1099 
  1100     Autoload removeClass:self.    
  1100     Autoload removeClass:self.    
  1101     nm := name.
  1101     nm := name.
  1122 !Class methodsFor:'binary storage'!
  1122 !Class methodsFor:'binary storage'!
  1123 
  1123 
  1124 addGlobalsForBinaryStorageTo:globalDictionary
  1124 addGlobalsForBinaryStorageTo:globalDictionary
  1125 "
  1125 "
  1126     classPool == nil ifFalse: [
  1126     classPool == nil ifFalse: [
  1127         classPool associationsDo: [:assoc|
  1127 	classPool associationsDo: [:assoc|
  1128             globalDictionary at: assoc put: self
  1128 	    globalDictionary at: assoc put: self
  1129         ]
  1129 	]
  1130     ]
  1130     ]
  1131 "
  1131 "
  1132 
  1132 
  1133     "Created: 21.3.1997 / 15:40:45 / cg"
  1133     "Created: 21.3.1997 / 15:40:45 / cg"
  1134 !
  1134 !
  1166     "/   number of private classes
  1166     "/   number of private classes
  1167     "/   private classes, if any
  1167     "/   private classes, if any
  1168 
  1168 
  1169     formatID := manager nextObject.
  1169     formatID := manager nextObject.
  1170     formatID isInteger ifFalse:[       "/ backward compatibilty
  1170     formatID isInteger ifFalse:[       "/ backward compatibilty
  1171         formatID := nil.
  1171 	formatID := nil.
  1172         superclassName := formatID
  1172 	superclassName := formatID
  1173     ] ifTrue:[
  1173     ] ifTrue:[
  1174         superclassName := manager nextObject.
  1174 	superclassName := manager nextObject.
  1175     ].
  1175     ].
  1176     superclassSig := manager nextObject.
  1176     superclassSig := manager nextObject.
  1177 
  1177 
  1178     superclassName notNil ifTrue:[
  1178     superclassName notNil ifTrue:[
  1179         superClass := Smalltalk at:superclassName ifAbsent:nil.
  1179 	superClass := Smalltalk at:superclassName ifAbsent:nil.
  1180 
  1180 
  1181         superClass isNil ifTrue:[
  1181 	superClass isNil ifTrue:[
  1182             BinaryIOManager nonexistingClassSignal
  1182 	    BinaryIOManager nonexistingClassSignal
  1183                 raiseRequestWith:'non existent superclass (in binaryLoad)'.
  1183 		raiseRequestWith:'non existent superclass (in binaryLoad)'.
  1184             ^ nil
  1184 	    ^ nil
  1185         ].
  1185 	].
  1186 
  1186 
  1187         "/ ('loading superclass: ' ,  superclassName ) printNL.
  1187 	"/ ('loading superclass: ' ,  superclassName ) printNL.
  1188         superClass autoload.
  1188 	superClass autoload.
  1189         superClass := Smalltalk at:superclassName.
  1189 	superClass := Smalltalk at:superclassName.
  1190 
  1190 
  1191         superclassSig ~= superClass signature ifTrue:[
  1191 	superclassSig ~= superClass signature ifTrue:[
  1192             BinaryIOManager changedInstLayoutSignal
  1192 	    BinaryIOManager changedInstLayoutSignal
  1193                 raiseRequestWith:'incompatible superclass (in binaryLoad)'.
  1193 		raiseRequestWith:'incompatible superclass (in binaryLoad)'.
  1194             ^ nil
  1194 	    ^ nil
  1195         ]
  1195 	]
  1196     ].
  1196     ].
  1197 
  1197 
  1198     name := manager nextObject.
  1198     name := manager nextObject.
  1199     flags := manager nextObject.
  1199     flags := manager nextObject.
  1200     instvars := manager nextObject.
  1200     instvars := manager nextObject.
  1205     classInstVars := manager nextObject.
  1205     classInstVars := manager nextObject.
  1206     classInstVars isNil ifTrue:[classInstVars := ''].
  1206     classInstVars isNil ifTrue:[classInstVars := ''].
  1207     comment := manager nextObject.
  1207     comment := manager nextObject.
  1208     package := manager nextObject.
  1208     package := manager nextObject.
  1209     formatID == 1 ifTrue:[
  1209     formatID == 1 ifTrue:[
  1210         rev := manager nextObject.
  1210 	rev := manager nextObject.
  1211         ownerName := manager nextObject.
  1211 	ownerName := manager nextObject.
  1212         ownerName notNil ifTrue:[
  1212 	ownerName notNil ifTrue:[
  1213             name := name copyFrom:(ownerName size + 2 + 1).
  1213 	    name := name copyFrom:(ownerName size + 2 + 1).
  1214             owner := Smalltalk at:ownerName.
  1214 	    owner := Smalltalk at:ownerName.
  1215         ]
  1215 	]
  1216     ].
  1216     ].
  1217 
  1217 
  1218 "/    'got superName:' print. superclassName printNL.
  1218 "/    'got superName:' print. superclassName printNL.
  1219 "/    'got name:' print. name printNL.
  1219 "/    'got name:' print. name printNL.
  1220 "/    'got flags: ' print. flags printNL.
  1220 "/    'got flags: ' print. flags printNL.
  1224 "/    'got classInstvars: ' print. classInstVars printNL.
  1224 "/    'got classInstvars: ' print. classInstVars printNL.
  1225 
  1225 
  1226 "/ ('create class: ' ,  name ) printNL.
  1226 "/ ('create class: ' ,  name ) printNL.
  1227 
  1227 
  1228     owner notNil ifTrue:[
  1228     owner notNil ifTrue:[
  1229         environment := owner
  1229 	environment := owner
  1230     ] ifFalse:[
  1230     ] ifFalse:[
  1231         environment := Class nameSpaceQuerySignal raise.
  1231 	environment := Class nameSpaceQuerySignal raise.
  1232     ].
  1232     ].
  1233 
  1233 
  1234     cls := superClass.
  1234     cls := superClass.
  1235     superClass isNil ifTrue:[
  1235     superClass isNil ifTrue:[
  1236         cls := Object
  1236 	cls := Object
  1237     ].
  1237     ].
  1238 
  1238 
  1239     newClass := cls class
  1239     newClass := cls class
  1240             name:name asSymbol
  1240 	    name:name asSymbol
  1241             in:environment
  1241 	    in:environment
  1242             subclassOf:cls
  1242 	    subclassOf:cls
  1243             instanceVariableNames:instvars
  1243 	    instanceVariableNames:instvars
  1244             variable:false
  1244 	    variable:false
  1245             words:false 
  1245 	    words:false 
  1246             pointers:true
  1246 	    pointers:true
  1247             classVariableNames:classvars
  1247 	    classVariableNames:classvars
  1248             poolDictionaries:'' 
  1248 	    poolDictionaries:'' 
  1249             category:category
  1249 	    category:category
  1250             comment:comment 
  1250 	    comment:comment 
  1251             changed:false 
  1251 	    changed:false 
  1252             classInstanceVariableNames:classInstVars.
  1252 	    classInstanceVariableNames:classInstVars.
  1253 
  1253 
  1254     newClass isNil ifTrue:[
  1254     newClass isNil ifTrue:[
  1255         ^ nil.
  1255 	^ nil.
  1256     ].
  1256     ].
  1257 
  1257 
  1258     superClass isNil ifTrue:[
  1258     superClass isNil ifTrue:[
  1259         newClass setSuperclass:nil.
  1259 	newClass setSuperclass:nil.
  1260         newClass class setSuperclass:Class.
  1260 	newClass class setSuperclass:Class.
  1261     ].
  1261     ].
  1262 
  1262 
  1263 "/ Transcript showCR:'loaded ' , name , ' in ' , environment name.
  1263 "/ Transcript showCR:'loaded ' , name , ' in ' , environment name.
  1264 
  1264 
  1265     newClass flags:flags.
  1265     newClass flags:flags.
  1268     cmethods := MethodDictionary binaryFullDefinitionFrom:stream manager:manager.
  1268     cmethods := MethodDictionary binaryFullDefinitionFrom:stream manager:manager.
  1269     "/ retrieve inst methods
  1269     "/ retrieve inst methods
  1270     methods := MethodDictionary binaryFullDefinitionFrom:stream manager:manager.
  1270     methods := MethodDictionary binaryFullDefinitionFrom:stream manager:manager.
  1271 
  1271 
  1272     formatID == 1 ifTrue:[
  1272     formatID == 1 ifTrue:[
  1273         "/ privateClasses
  1273 	"/ privateClasses
  1274         nPrivate := manager nextObject.
  1274 	nPrivate := manager nextObject.
  1275         nPrivate timesRepeat:[
  1275 	nPrivate timesRepeat:[
  1276             Class nameSpaceQuerySignal
  1276 	    Class nameSpaceQuerySignal
  1277                 answer:newClass
  1277 		answer:newClass
  1278                 do:[
  1278 		do:[
  1279                     privateClass := manager nextObject
  1279 		    privateClass := manager nextObject
  1280                 ]
  1280 		]
  1281         ]
  1281 	]
  1282     ].
  1282     ].
  1283 
  1283 
  1284     (superClass isNil and:[superclassName notNil]) ifTrue:[^ nil].
  1284     (superClass isNil and:[superclassName notNil]) ifTrue:[^ nil].
  1285     newClass isNil ifTrue:[
  1285     newClass isNil ifTrue:[
  1286         ^ nil
  1286 	^ nil
  1287     ].
  1287     ].
  1288 
  1288 
  1289     owner notNil ifTrue:[
  1289     owner notNil ifTrue:[
  1290         newClass category:nil.
  1290 	newClass category:nil.
  1291     ] ifFalse:[
  1291     ] ifFalse:[
  1292         newClass package:package.
  1292 	newClass package:package.
  1293     ].
  1293     ].
  1294 
  1294 
  1295     newClass methodDictionary:methods.
  1295     newClass methodDictionary:methods.
  1296     newClass class methodDictionary:cmethods.
  1296     newClass class methodDictionary:cmethods.
  1297     ^ newClass
  1297     ^ newClass
  1335     1 storeBinaryOn:stream manager:manager.  "/ formatID
  1335     1 storeBinaryOn:stream manager:manager.  "/ formatID
  1336 
  1336 
  1337     owner := self owningClass.
  1337     owner := self owningClass.
  1338 
  1338 
  1339     superclass isNil ifTrue:[
  1339     superclass isNil ifTrue:[
  1340         s := nil.
  1340 	s := nil.
  1341         sig := 0.
  1341 	sig := 0.
  1342     ] ifFalse:[
  1342     ] ifFalse:[
  1343         s := superclass name.
  1343 	s := superclass name.
  1344         sig := superclass signature.
  1344 	sig := superclass signature.
  1345     ].
  1345     ].
  1346     s storeBinaryOn:stream manager:manager.
  1346     s storeBinaryOn:stream manager:manager.
  1347     sig storeBinaryOn:stream manager:manager.
  1347     sig storeBinaryOn:stream manager:manager.
  1348 
  1348 
  1349     name storeBinaryOn:stream manager:manager.
  1349     name storeBinaryOn:stream manager:manager.
  1350     flags storeBinaryOn:stream manager:manager.
  1350     flags storeBinaryOn:stream manager:manager.
  1351     (instvars notNil and:[instvars isEmpty]) ifTrue:[
  1351     (instvars notNil and:[instvars isEmpty]) ifTrue:[
  1352         s := nil
  1352 	s := nil
  1353     ] ifFalse:[
  1353     ] ifFalse:[
  1354         s := instvars
  1354 	s := instvars
  1355     ].
  1355     ].
  1356     s storeBinaryOn:stream manager:manager.
  1356     s storeBinaryOn:stream manager:manager.
  1357 
  1357 
  1358     (classvars notNil and:[classvars isEmpty]) ifTrue:[
  1358     (classvars notNil and:[classvars isEmpty]) ifTrue:[
  1359         s := nil
  1359 	s := nil
  1360     ] ifFalse:[
  1360     ] ifFalse:[
  1361         s := classvars
  1361 	s := classvars
  1362     ].
  1362     ].
  1363     s storeBinaryOn:stream manager:manager.
  1363     s storeBinaryOn:stream manager:manager.
  1364 
  1364 
  1365     "/ the category
  1365     "/ the category
  1366     owner notNil ifTrue:[
  1366     owner notNil ifTrue:[
  1367         nil storeBinaryOn:stream manager:manager.
  1367 	nil storeBinaryOn:stream manager:manager.
  1368     ] ifFalse:[
  1368     ] ifFalse:[
  1369         category storeBinaryOn:stream manager:manager.
  1369 	category storeBinaryOn:stream manager:manager.
  1370     ].
  1370     ].
  1371 
  1371 
  1372     "/ the classInstVarString
  1372     "/ the classInstVarString
  1373     s := self class instanceVariableString.
  1373     s := self class instanceVariableString.
  1374     (s notNil and:[s isEmpty]) ifTrue:[
  1374     (s notNil and:[s isEmpty]) ifTrue:[
  1375         s := nil
  1375 	s := nil
  1376     ].
  1376     ].
  1377     s storeBinaryOn:stream manager:manager.
  1377     s storeBinaryOn:stream manager:manager.
  1378 
  1378 
  1379     "/ the comment
  1379     "/ the comment
  1380     s := comment.
  1380     s := comment.
  1381     manager sourceMode == #discard ifTrue:[
  1381     manager sourceMode == #discard ifTrue:[
  1382         s := nil
  1382 	s := nil
  1383     ].
  1383     ].
  1384     s storeBinaryOn:stream manager:manager.
  1384     s storeBinaryOn:stream manager:manager.
  1385 
  1385 
  1386     "/ the revision, package & owner
  1386     "/ the revision, package & owner
  1387     owner notNil ifTrue:[
  1387     owner notNil ifTrue:[
  1388         nil storeBinaryOn:stream manager:manager.
  1388 	nil storeBinaryOn:stream manager:manager.
  1389         nil storeBinaryOn:stream manager:manager.
  1389 	nil storeBinaryOn:stream manager:manager.
  1390         owner name storeBinaryOn:stream manager:manager.
  1390 	owner name storeBinaryOn:stream manager:manager.
  1391     ] ifFalse:[
  1391     ] ifFalse:[
  1392         package storeBinaryOn:stream manager:manager.
  1392 	package storeBinaryOn:stream manager:manager.
  1393         revision storeBinaryOn:stream manager:manager.
  1393 	revision storeBinaryOn:stream manager:manager.
  1394         nil storeBinaryOn:stream manager:manager.
  1394 	nil storeBinaryOn:stream manager:manager.
  1395     ].
  1395     ].
  1396 
  1396 
  1397     "/
  1397     "/
  1398     "/ store class method dictionary and methods
  1398     "/ store class method dictionary and methods
  1399     "/ 
  1399     "/ 
  1405     "/ names of private classes
  1405     "/ names of private classes
  1406     "/
  1406     "/
  1407     privateClasses := self privateClassesSorted.
  1407     privateClasses := self privateClassesSorted.
  1408     privateClasses size storeBinaryOn:stream manager:manager.
  1408     privateClasses size storeBinaryOn:stream manager:manager.
  1409     privateClasses size > 0 ifTrue:[
  1409     privateClasses size > 0 ifTrue:[
  1410         privateClasses do:[:aClass |
  1410 	privateClasses do:[:aClass |
  1411             aClass storeBinaryClassOn:stream manager:manager
  1411 	    aClass storeBinaryClassOn:stream manager:manager
  1412         ]
  1412 	]
  1413     ].
  1413     ].
  1414 
  1414 
  1415     "
  1415     "
  1416      |bos|
  1416      |bos|
  1417 
  1417 
  1469      output the instance variable name string
  1469      output the instance variable name string
  1470     "
  1470     "
  1471     varnames := self allInstVarNames.
  1471     varnames := self allInstVarNames.
  1472     n := varnames size.
  1472     n := varnames size.
  1473     n == 0 ifTrue:[
  1473     n == 0 ifTrue:[
  1474         sz := 0
  1474 	sz := 0
  1475     ] ifFalse:[
  1475     ] ifFalse:[
  1476         sz := varnames inject:0 into:[:sum :nm | sum + nm size].
  1476 	sz := varnames inject:0 into:[:sum :nm | sum + nm size].
  1477         sz := sz + n - 1.
  1477 	sz := sz + n - 1.
  1478     ].
  1478     ].
  1479     stream nextNumber:2 put:sz.
  1479     stream nextNumber:2 put:sz.
  1480     varnames keysAndValuesDo:[:i :nm |
  1480     varnames keysAndValuesDo:[:i :nm |
  1481         stream nextPutBytes:(nm size) from:nm startingAt:1.
  1481 	stream nextPutBytes:(nm size) from:nm startingAt:1.
  1482 "/        nm do:[:c |
  1482 "/        nm do:[:c |
  1483 "/            stream nextPut:c asciiValue
  1483 "/            stream nextPut:c asciiValue
  1484 "/        ].
  1484 "/        ].
  1485         i ~~ n ifTrue:[stream nextPut:(Character space asciiValue)]
  1485 	i ~~ n ifTrue:[stream nextPut:(Character space asciiValue)]
  1486     ].
  1486     ].
  1487 
  1487 
  1488     "
  1488     "
  1489      output my name
  1489      output my name
  1490     "
  1490     "
  1510     "{ Pragma: +optSpace }"
  1510     "{ Pragma: +optSpace }"
  1511 
  1511 
  1512     "add a category change record to the changes file"
  1512     "add a category change record to the changes file"
  1513 
  1513 
  1514     Class updateChangeFileQuerySignal raise ifTrue:[
  1514     Class updateChangeFileQuerySignal raise ifTrue:[
  1515         self writingChangePerform:#addChangeRecordForChangeCategory:to: with:category.
  1515 	self writingChangePerform:#addChangeRecordForChangeCategory:to: with:category.
  1516     ]
  1516     ]
  1517 
  1517 
  1518     "Modified: 4.6.1997 / 14:56:13 / cg"
  1518     "Modified: 4.6.1997 / 14:56:13 / cg"
  1519 !
  1519 !
  1520 
  1520 
  1522     "{ Pragma: +optSpace }"
  1522     "{ Pragma: +optSpace }"
  1523 
  1523 
  1524     "add a class-definition-record to the changes file"
  1524     "add a class-definition-record to the changes file"
  1525 
  1525 
  1526     UpdateChangeFileQuerySignal raise ifTrue:[
  1526     UpdateChangeFileQuerySignal raise ifTrue:[
  1527         self writingChangePerform:#addChangeRecordForClass:to: with:aClass.
  1527 	self writingChangePerform:#addChangeRecordForClass:to: with:aClass.
  1528     ]
  1528     ]
  1529 
  1529 
  1530     "Modified: 24.1.1997 / 19:09:41 / cg"
  1530     "Modified: 24.1.1997 / 19:09:41 / cg"
  1531 !
  1531 !
  1532 
  1532 
  1536     "append a class-was-checkedIn-record to the changes file"
  1536     "append a class-was-checkedIn-record to the changes file"
  1537 
  1537 
  1538     |rv|
  1538     |rv|
  1539 
  1539 
  1540     UpdateChangeFileQuerySignal raise ifTrue:[
  1540     UpdateChangeFileQuerySignal raise ifTrue:[
  1541         rv := aClass revision.
  1541 	rv := aClass revision.
  1542         rv isNil ifTrue:[rv := '???'].
  1542 	rv isNil ifTrue:[rv := '???'].
  1543 
  1543 
  1544         self 
  1544 	self 
  1545             writingChangeWithTimeStamp:false 
  1545 	    writingChangeWithTimeStamp:false 
  1546             perform:#addInfoRecord:to: 
  1546 	    perform:#addInfoRecord:to: 
  1547             with:('checkin ' , aClass name , ' (' , rv , ')').
  1547 	    with:('checkin ' , aClass name , ' (' , rv , ')').
  1548     ]
  1548     ]
  1549 
  1549 
  1550     "Created: 18.11.1995 / 17:04:58 / cg"
  1550     "Created: 18.11.1995 / 17:04:58 / cg"
  1551     "Modified: 24.1.1997 / 19:11:55 / cg"
  1551     "Modified: 24.1.1997 / 19:11:55 / cg"
  1552 !
  1552 !
  1555     "{ Pragma: +optSpace }"
  1555     "{ Pragma: +optSpace }"
  1556 
  1556 
  1557     "add a class-comment-record to the changes file"
  1557     "add a class-comment-record to the changes file"
  1558 
  1558 
  1559     UpdateChangeFileQuerySignal raise ifTrue:[
  1559     UpdateChangeFileQuerySignal raise ifTrue:[
  1560         self writingChangePerform:#addChangeRecordForClassComment:to: with:aClass.
  1560 	self writingChangePerform:#addChangeRecordForClassComment:to: with:aClass.
  1561     ]
  1561     ]
  1562 
  1562 
  1563     "Modified: 24.1.1997 / 19:09:59 / cg"
  1563     "Modified: 24.1.1997 / 19:09:59 / cg"
  1564 !
  1564 !
  1565 
  1565 
  1567     "{ Pragma: +optSpace }"
  1567     "{ Pragma: +optSpace }"
  1568 
  1568 
  1569     "append a container-was-removed-record to the changes file"
  1569     "append a container-was-removed-record to the changes file"
  1570 
  1570 
  1571     UpdateChangeFileQuerySignal raise ifTrue:[
  1571     UpdateChangeFileQuerySignal raise ifTrue:[
  1572         self 
  1572 	self 
  1573             writingChangeWithTimeStamp:false 
  1573 	    writingChangeWithTimeStamp:false 
  1574             perform:#addInfoRecord:to: 
  1574 	    perform:#addInfoRecord:to: 
  1575             with:('removed source container of ' , aClass name).
  1575 	    with:('removed source container of ' , aClass name).
  1576     ]
  1576     ]
  1577 
  1577 
  1578     "Created: 11.9.1996 / 15:37:19 / cg"
  1578     "Created: 11.9.1996 / 15:37:19 / cg"
  1579     "Modified: 24.1.1997 / 19:12:05 / cg"
  1579     "Modified: 24.1.1997 / 19:12:05 / cg"
  1580 !
  1580 !
  1583     "{ Pragma: +optSpace }"
  1583     "{ Pragma: +optSpace }"
  1584 
  1584 
  1585     "append a class-was-filedOut-record to the changes file"
  1585     "append a class-was-filedOut-record to the changes file"
  1586 
  1586 
  1587     UpdateChangeFileQuerySignal raise ifTrue:[
  1587     UpdateChangeFileQuerySignal raise ifTrue:[
  1588         self 
  1588 	self 
  1589             writingChangeWithTimeStamp:false 
  1589 	    writingChangeWithTimeStamp:false 
  1590             perform:#addInfoRecord:to: 
  1590 	    perform:#addInfoRecord:to: 
  1591             with:('fileOut ' , aClass name).
  1591 	    with:('fileOut ' , aClass name).
  1592     ]
  1592     ]
  1593 
  1593 
  1594     "Modified: 24.1.1997 / 19:12:14 / cg"
  1594     "Modified: 24.1.1997 / 19:12:14 / cg"
  1595 !
  1595 !
  1596 
  1596 
  1598     "{ Pragma: +optSpace }"
  1598     "{ Pragma: +optSpace }"
  1599 
  1599 
  1600     "add a class-instvars-record to the changes file"
  1600     "add a class-instvars-record to the changes file"
  1601 
  1601 
  1602     UpdateChangeFileQuerySignal raise ifTrue:[
  1602     UpdateChangeFileQuerySignal raise ifTrue:[
  1603         self writingChangePerform:#addChangeRecordForClassInstvars:to: with:aClass.
  1603 	self writingChangePerform:#addChangeRecordForClassInstvars:to: with:aClass.
  1604     ]
  1604     ]
  1605 
  1605 
  1606     "Modified: 24.1.1997 / 19:10:18 / cg"
  1606     "Modified: 24.1.1997 / 19:10:18 / cg"
  1607 !
  1607 !
  1608 
  1608 
  1610     "{ Pragma: +optSpace }"
  1610     "{ Pragma: +optSpace }"
  1611 
  1611 
  1612     "add a class-remove-record to the changes file"
  1612     "add a class-remove-record to the changes file"
  1613 
  1613 
  1614     UpdateChangeFileQuerySignal raise ifTrue:[
  1614     UpdateChangeFileQuerySignal raise ifTrue:[
  1615         self writingChangePerform:#addChangeRecordForClassRemove:to: with:oldName.
  1615 	self writingChangePerform:#addChangeRecordForClassRemove:to: with:oldName.
  1616     ]
  1616     ]
  1617 
  1617 
  1618     "Modified: 24.1.1997 / 19:10:25 / cg"
  1618     "Modified: 24.1.1997 / 19:10:25 / cg"
  1619 !
  1619 !
  1620 
  1620 
  1622     "{ Pragma: +optSpace }"
  1622     "{ Pragma: +optSpace }"
  1623 
  1623 
  1624     "add a class-rename-record to the changes file"
  1624     "add a class-rename-record to the changes file"
  1625 
  1625 
  1626     UpdateChangeFileQuerySignal raise ifTrue:[
  1626     UpdateChangeFileQuerySignal raise ifTrue:[
  1627         self writingChangeDo:[:aStream |
  1627 	self writingChangeDo:[:aStream |
  1628             self addChangeRecordForClassRename:oldName to:newName to:aStream
  1628 	    self addChangeRecordForClassRename:oldName to:newName to:aStream
  1629         ]
  1629 	]
  1630     ]
  1630     ]
  1631 
  1631 
  1632     "Modified: 24.1.1997 / 19:10:35 / cg"
  1632     "Modified: 24.1.1997 / 19:10:35 / cg"
  1633 !
  1633 !
  1634 
  1634 
  1636     "{ Pragma: +optSpace }"
  1636     "{ Pragma: +optSpace }"
  1637 
  1637 
  1638     "add a primitiveDefinitions-record to the changes file"
  1638     "add a primitiveDefinitions-record to the changes file"
  1639 
  1639 
  1640     UpdateChangeFileQuerySignal raise ifTrue:[
  1640     UpdateChangeFileQuerySignal raise ifTrue:[
  1641         self writingChangePerform:#addChangeRecordForPrimitiveDefinitions:to: with:aClass.
  1641 	self writingChangePerform:#addChangeRecordForPrimitiveDefinitions:to: with:aClass.
  1642         Project notNil ifTrue:[
  1642 	Project notNil ifTrue:[
  1643             Project addPrimitiveDefinitionsChangeFor:aClass
  1643 	    Project addPrimitiveDefinitionsChangeFor:aClass
  1644         ]
  1644 	]
  1645     ]
  1645     ]
  1646 
  1646 
  1647     "Modified: 20.1.1997 / 12:36:10 / cg"
  1647     "Modified: 20.1.1997 / 12:36:10 / cg"
  1648 !
  1648 !
  1649 
  1649 
  1651     "{ Pragma: +optSpace }"
  1651     "{ Pragma: +optSpace }"
  1652 
  1652 
  1653     "add a primitiveFunctions-record to the changes file"
  1653     "add a primitiveFunctions-record to the changes file"
  1654 
  1654 
  1655     UpdateChangeFileQuerySignal raise ifTrue:[
  1655     UpdateChangeFileQuerySignal raise ifTrue:[
  1656         self writingChangePerform:#addChangeRecordForPrimitiveFunctions:to: with:aClass.
  1656 	self writingChangePerform:#addChangeRecordForPrimitiveFunctions:to: with:aClass.
  1657         Project notNil ifTrue:[
  1657 	Project notNil ifTrue:[
  1658             Project addPrimitiveFunctionsChangeFor:aClass
  1658 	    Project addPrimitiveFunctionsChangeFor:aClass
  1659         ]
  1659 	]
  1660     ]
  1660     ]
  1661 
  1661 
  1662     "Modified: 20.1.1997 / 12:36:13 / cg"
  1662     "Modified: 20.1.1997 / 12:36:13 / cg"
  1663 !
  1663 !
  1664 
  1664 
  1666     "{ Pragma: +optSpace }"
  1666     "{ Pragma: +optSpace }"
  1667 
  1667 
  1668     "add a primitiveVariables-record to the changes file"
  1668     "add a primitiveVariables-record to the changes file"
  1669 
  1669 
  1670     UpdateChangeFileQuerySignal raise ifTrue:[
  1670     UpdateChangeFileQuerySignal raise ifTrue:[
  1671         self writingChangePerform:#addChangeRecordForPrimitiveVariables:to: with:aClass.
  1671 	self writingChangePerform:#addChangeRecordForPrimitiveVariables:to: with:aClass.
  1672         Project notNil ifTrue:[
  1672 	Project notNil ifTrue:[
  1673             Project addPrimitiveVariablesChangeFor:aClass
  1673 	    Project addPrimitiveVariablesChangeFor:aClass
  1674         ]
  1674 	]
  1675     ]
  1675     ]
  1676 
  1676 
  1677     "Modified: 20.1.1997 / 12:36:16 / cg"
  1677     "Modified: 20.1.1997 / 12:36:16 / cg"
  1678 !
  1678 !
  1679 
  1679 
  1681     "{ Pragma: +optSpace }"
  1681     "{ Pragma: +optSpace }"
  1682 
  1682 
  1683     "add a snapshot-record to the changes file"
  1683     "add a snapshot-record to the changes file"
  1684 
  1684 
  1685     UpdateChangeFileQuerySignal raise ifTrue:[
  1685     UpdateChangeFileQuerySignal raise ifTrue:[
  1686         self 
  1686 	self 
  1687             writingChangeWithTimeStamp:false 
  1687 	    writingChangeWithTimeStamp:false 
  1688             perform:#addInfoRecord:to: 
  1688 	    perform:#addInfoRecord:to: 
  1689             with:('snapshot ' , aFileName).
  1689 	    with:('snapshot ' , aFileName).
  1690     ]
  1690     ]
  1691 
  1691 
  1692     "Modified: 24.1.1997 / 19:12:25 / cg"
  1692     "Modified: 24.1.1997 / 19:12:25 / cg"
  1693 !
  1693 !
  1694 
  1694 
  1696     "{ Pragma: +optSpace }"
  1696     "{ Pragma: +optSpace }"
  1697 
  1697 
  1698     "add a snapshot-record to aStream"
  1698     "add a snapshot-record to aStream"
  1699 
  1699 
  1700     UpdateChangeFileQuerySignal raise ifTrue:[
  1700     UpdateChangeFileQuerySignal raise ifTrue:[
  1701         self addInfoRecord:('snapshot ' , aFileName) to:aStream
  1701 	self addInfoRecord:('snapshot ' , aFileName) to:aStream
  1702     ]
  1702     ]
  1703 
  1703 
  1704     "Modified: 24.1.1997 / 19:11:08 / cg"
  1704     "Modified: 24.1.1997 / 19:11:08 / cg"
  1705 ! !
  1705 ! !
  1706 
  1706 
  1710     "evaluate aBlock on all of my private classes (if any)"
  1710     "evaluate aBlock on all of my private classes (if any)"
  1711 
  1711 
  1712     |classes|
  1712     |classes|
  1713 
  1713 
  1714     (classes := self privateClasses) size > 0 ifTrue:[
  1714     (classes := self privateClasses) size > 0 ifTrue:[
  1715         classes do:aBlock
  1715 	classes do:aBlock
  1716     ].
  1716     ].
  1717 
  1717 
  1718     "Created: 26.10.1996 / 12:28:57 / cg"
  1718     "Created: 26.10.1996 / 12:28:57 / cg"
  1719     "Modified: 22.3.1997 / 16:17:36 / cg"
  1719     "Modified: 22.3.1997 / 16:17:36 / cg"
  1720 ! !
  1720 ! !
  1771     syntaxHilighting := Smalltalk syntaxHilighting.
  1771     syntaxHilighting := Smalltalk syntaxHilighting.
  1772 
  1772 
  1773     owner := self owningClass.
  1773     owner := self owningClass.
  1774 
  1774 
  1775     owner isNil ifTrue:[
  1775     owner isNil ifTrue:[
  1776         ns := self nameSpace.
  1776 	ns := self nameSpace.
  1777     ] ifFalse:[
  1777     ] ifFalse:[
  1778         ns := self topOwningClass nameSpace
  1778 	ns := self topOwningClass nameSpace
  1779     ].
  1779     ].
  1780     fullName := FileOutNameSpaceQuerySignal raise == true.
  1780     fullName := FileOutNameSpaceQuerySignal raise == true.
  1781         
  1781         
  1782     ((owner isNil and:[fullName not])
  1782     ((owner isNil and:[fullName not])
  1783     or:[owner notNil and:[forceNameSpace and:[fullName not]]]) ifTrue:[
  1783     or:[owner notNil and:[forceNameSpace and:[fullName not]]]) ifTrue:[
  1784         (ns notNil and:[ns ~~ Smalltalk]) ifTrue:[
  1784 	(ns notNil and:[ns ~~ Smalltalk]) ifTrue:[
  1785             nsName := ns name.
  1785 	    nsName := ns name.
  1786             (nsName includes:$:) ifTrue:[
  1786 	    (nsName includes:$:) ifTrue:[
  1787                 nsName := '''' , nsName , ''''
  1787 		nsName := '''' , nsName , ''''
  1788             ].
  1788 	    ].
  1789 "/            aStream nextPutLine:'"{ NameSpace: ' , nsName , ' }"'; cr.
  1789 "/            aStream nextPutLine:'"{ NameSpace: ' , nsName , ' }"'; cr.
  1790             aStream nextPutAll:'"{ NameSpace: '.
  1790 	    aStream nextPutAll:'"{ NameSpace: '.
  1791             syntaxHilighting ifTrue:[aStream bold].
  1791 	    syntaxHilighting ifTrue:[aStream bold].
  1792             aStream nextPutAll:nsName.
  1792 	    aStream nextPutAll:nsName.
  1793             syntaxHilighting ifTrue:[aStream normal].
  1793 	    syntaxHilighting ifTrue:[aStream normal].
  1794             aStream nextPutAll:' }"'; cr; cr.
  1794 	    aStream nextPutAll:' }"'; cr; cr.
  1795         ]
  1795 	]
  1796     ].
  1796     ].
  1797 
  1797 
  1798     "take care of nil-superclass"
  1798     "take care of nil-superclass"
  1799     superclass isNil ifTrue:[
  1799     superclass isNil ifTrue:[
  1800         s := 'nil'
  1800 	s := 'nil'
  1801     ] ifFalse:[
  1801     ] ifFalse:[
  1802         fullName ifTrue:[
  1802 	fullName ifTrue:[
  1803             s := superclass name
  1803 	    s := superclass name
  1804         ] ifFalse:[
  1804 	] ifFalse:[
  1805             (ns == superclass nameSpace 
  1805 	    (ns == superclass nameSpace 
  1806             and:[superclass owningClass isNil]) ifTrue:[
  1806 	    and:[superclass owningClass isNil]) ifTrue:[
  1807                 s := superclass nameWithoutPrefix
  1807 		s := superclass nameWithoutPrefix
  1808             ] ifFalse:[
  1808 	    ] ifFalse:[
  1809                 "/ a very special (rare) situation:
  1809 		"/ a very special (rare) situation:
  1810                 "/ my superclass resides in another nameSpace,
  1810 		"/ my superclass resides in another nameSpace,
  1811                 "/ but there is something else named like this
  1811 		"/ but there is something else named like this
  1812                 "/ to be found in my nameSpace (or a private class)
  1812 		"/ to be found in my nameSpace (or a private class)
  1813 
  1813 
  1814                 superName := superclass nameWithoutNameSpacePrefix asSymbol.
  1814 		superName := superclass nameWithoutNameSpacePrefix asSymbol.
  1815                 cls := self privateClassesAt:superName.
  1815 		cls := self privateClassesAt:superName.
  1816                 cls isNil ifTrue:[
  1816 		cls isNil ifTrue:[
  1817                     (topOwner := self topOwningClass) isNil ifTrue:[
  1817 		    (topOwner := self topOwningClass) isNil ifTrue:[
  1818                         ns := self nameSpace.
  1818 			ns := self nameSpace.
  1819                         ns notNil ifTrue:[
  1819 			ns notNil ifTrue:[
  1820                             cls := ns privateClassesAt:superName
  1820 			    cls := ns privateClassesAt:superName
  1821                         ] ifFalse:[
  1821 			] ifFalse:[
  1822                             "/ self error:'unexpected nil namespace'
  1822 			    "/ self error:'unexpected nil namespace'
  1823                         ]
  1823 			]
  1824                     ] ifFalse:[
  1824 		    ] ifFalse:[
  1825                         cls := topOwner nameSpace at:superName.
  1825 			cls := topOwner nameSpace at:superName.
  1826                     ]
  1826 		    ]
  1827                 ].
  1827 		].
  1828                 (cls notNil and:[cls ~~ superclass]) ifTrue:[
  1828 		(cls notNil and:[cls ~~ superclass]) ifTrue:[
  1829                     s := superclass nameSpace name , '::' , superName
  1829 		    s := superclass nameSpace name , '::' , superName
  1830                 ] ifFalse:[
  1830 		] ifFalse:[
  1831                     s := superName
  1831 		    s := superName
  1832                 ]
  1832 		]
  1833             ]
  1833 	    ]
  1834         ]
  1834 	]
  1835     ].
  1835     ].
  1836 
  1836 
  1837     syntaxHilighting ifTrue:[aStream bold].
  1837     syntaxHilighting ifTrue:[aStream bold].
  1838     aStream nextPutAll:s.   "/ superclass
  1838     aStream nextPutAll:s.   "/ superclass
  1839     syntaxHilighting ifTrue:[aStream normal].
  1839     syntaxHilighting ifTrue:[aStream normal].
  1840     aStream space.
  1840     aStream space.
  1841     self basicFileOutInstvarTypeKeywordOn:aStream.
  1841     self basicFileOutInstvarTypeKeywordOn:aStream.
  1842 
  1842 
  1843     (fullName and:[owner isNil]) ifTrue:[
  1843     (fullName and:[owner isNil]) ifTrue:[
  1844         aStream nextPutAll:'#'''.
  1844 	aStream nextPutAll:'#'''.
  1845         syntaxHilighting ifTrue:[aStream bold].
  1845 	syntaxHilighting ifTrue:[aStream bold].
  1846         aStream nextPutAll:(self name).
  1846 	aStream nextPutAll:(self name).
  1847         syntaxHilighting ifTrue:[aStream normal].
  1847 	syntaxHilighting ifTrue:[aStream normal].
  1848         aStream nextPutAll:''''.
  1848 	aStream nextPutAll:''''.
  1849     ] ifFalse:[
  1849     ] ifFalse:[
  1850         aStream nextPut:$#.
  1850 	aStream nextPut:$#.
  1851         syntaxHilighting ifTrue:[aStream bold].
  1851 	syntaxHilighting ifTrue:[aStream bold].
  1852         aStream nextPutAll:(self nameWithoutPrefix).
  1852 	aStream nextPutAll:(self nameWithoutPrefix).
  1853         syntaxHilighting ifTrue:[aStream normal].
  1853 	syntaxHilighting ifTrue:[aStream normal].
  1854     ].
  1854     ].
  1855 
  1855 
  1856     aStream crtab. 
  1856     aStream crtab. 
  1857     aStream nextPutAll:'instanceVariableNames:'''.
  1857     aStream nextPutAll:'instanceVariableNames:'''.
  1858     syntaxHilighting ifTrue:[aStream bold].
  1858     syntaxHilighting ifTrue:[aStream bold].
  1870     aStream crtab.
  1870     aStream crtab.
  1871     aStream nextPutAll:'poolDictionaries:'''''.
  1871     aStream nextPutAll:'poolDictionaries:'''''.
  1872 
  1872 
  1873     aStream crtab.
  1873     aStream crtab.
  1874     owner isNil ifTrue:[
  1874     owner isNil ifTrue:[
  1875         "/ a public class
  1875 	"/ a public class
  1876         aStream nextPutAll:'category:'.
  1876 	aStream nextPutAll:'category:'.
  1877         category isNil ifTrue:[
  1877 	category isNil ifTrue:[
  1878             s := ''''''
  1878 	    s := ''''''
  1879         ] ifFalse:[
  1879 	] ifFalse:[
  1880             s := category asString storeString
  1880 	    s := category asString storeString
  1881         ].
  1881 	].
  1882         aStream nextPutAll:s.
  1882 	aStream nextPutAll:s.
  1883     ] ifFalse:[
  1883     ] ifFalse:[
  1884         "/ a private class
  1884 	"/ a private class
  1885         aStream nextPutAll:'privateIn:'.
  1885 	aStream nextPutAll:'privateIn:'.
  1886         syntaxHilighting ifTrue:[aStream bold].
  1886 	syntaxHilighting ifTrue:[aStream bold].
  1887         fullName ifTrue:[
  1887 	fullName ifTrue:[
  1888             s := owner name.
  1888 	    s := owner name.
  1889         ] ifFalse:[
  1889 	] ifFalse:[
  1890             s := owner nameWithoutNameSpacePrefix.
  1890 	    s := owner nameWithoutNameSpacePrefix.
  1891         ].
  1891 	].
  1892         aStream nextPutAll:s.
  1892 	aStream nextPutAll:s.
  1893         syntaxHilighting ifTrue:[aStream normal].
  1893 	syntaxHilighting ifTrue:[aStream normal].
  1894     ].
  1894     ].
  1895     aStream cr
  1895     aStream cr
  1896 
  1896 
  1897     "Created: 4.1.1997 / 20:38:16 / cg"
  1897     "Created: 4.1.1997 / 20:38:16 / cg"
  1898     "Modified: 8.8.1997 / 10:59:50 / cg"
  1898     "Modified: 8.8.1997 / 10:59:50 / cg"
  1902     "a helper for fileOutDefinition"
  1902     "a helper for fileOutDefinition"
  1903 
  1903 
  1904     |isVar s|
  1904     |isVar s|
  1905 
  1905 
  1906     superclass isNil ifTrue:[
  1906     superclass isNil ifTrue:[
  1907         isVar := self isVariable
  1907 	isVar := self isVariable
  1908     ] ifFalse:[
  1908     ] ifFalse:[
  1909         "I cant remember what this is for ?"
  1909 	"I cant remember what this is for ?"
  1910         isVar := (self isVariable and:[superclass isVariable not])
  1910 	isVar := (self isVariable and:[superclass isVariable not])
  1911     ].
  1911     ].
  1912 
  1912 
  1913     isVar ifTrue:[
  1913     isVar ifTrue:[
  1914         self isBytes ifTrue:[
  1914 	self isBytes ifTrue:[
  1915             s := 'variableByteSubclass:'
  1915 	    s := 'variableByteSubclass:'
  1916         ] ifFalse:[
  1916 	] ifFalse:[
  1917             self isWords ifTrue:[
  1917 	    self isWords ifTrue:[
  1918                 s := 'variableWordSubclass:'
  1918 		s := 'variableWordSubclass:'
  1919             ] ifFalse:[
  1919 	    ] ifFalse:[
  1920                 self isLongs ifTrue:[
  1920 		self isLongs ifTrue:[
  1921                     s := 'variableLongSubclass:'
  1921 		    s := 'variableLongSubclass:'
  1922                 ] ifFalse:[
  1922 		] ifFalse:[
  1923                     self isFloats ifTrue:[
  1923 		    self isFloats ifTrue:[
  1924                         s := 'variableFloatSubclass:'
  1924 			s := 'variableFloatSubclass:'
  1925                     ] ifFalse:[
  1925 		    ] ifFalse:[
  1926                         self isDoubles ifTrue:[
  1926 			self isDoubles ifTrue:[
  1927                             s := 'variableDoubleSubclass:'
  1927 			    s := 'variableDoubleSubclass:'
  1928                         ] ifFalse:[
  1928 			] ifFalse:[
  1929                             self isSignedWords ifTrue:[
  1929 			    self isSignedWords ifTrue:[
  1930                                 s := 'variableSignedWordSubclass:'
  1930 				s := 'variableSignedWordSubclass:'
  1931                             ] ifFalse:[
  1931 			    ] ifFalse:[
  1932                                 self isSignedLongs ifTrue:[
  1932 				self isSignedLongs ifTrue:[
  1933                                     s := 'variableSignedLongSubclass:'
  1933 				    s := 'variableSignedLongSubclass:'
  1934                                 ] ifFalse:[
  1934 				] ifFalse:[
  1935                                     s := 'variableSubclass:'
  1935 				    s := 'variableSubclass:'
  1936                                 ]
  1936 				]
  1937                             ]
  1937 			    ]
  1938                         ]
  1938 			]
  1939                     ]
  1939 		    ]
  1940                 ]
  1940 		]
  1941             ]
  1941 	    ]
  1942         ]
  1942 	]
  1943     ] ifFalse:[
  1943     ] ifFalse:[
  1944         s := 'subclass:'
  1944 	s := 'subclass:'
  1945     ].
  1945     ].
  1946     aStream nextPutAll:s.
  1946     aStream nextPutAll:s.
  1947 
  1947 
  1948     "Created: 11.10.1996 / 18:57:29 / cg"
  1948     "Created: 11.10.1996 / 18:57:29 / cg"
  1949 !
  1949 !
  1988 
  1988 
  1989 binaryFileOutWithSourceMode:sourceMode
  1989 binaryFileOutWithSourceMode:sourceMode
  1990     "create a file 'class.cls' (in the current projects fileOut-directory),
  1990     "create a file 'class.cls' (in the current projects fileOut-directory),
  1991      consisting of all methods in myself in a portable binary format. 
  1991      consisting of all methods in myself in a portable binary format. 
  1992      The argument controls how sources are to be saved:
  1992      The argument controls how sources are to be saved:
  1993         #keep - include the source
  1993 	#keep - include the source
  1994         #reference - include a reference to the sourceFile
  1994 	#reference - include a reference to the sourceFile
  1995         #discard - dont save sources.
  1995 	#discard - dont save sources.
  1996 
  1996 
  1997      With #reference, the sourceFile needs to be present after reload 
  1997      With #reference, the sourceFile needs to be present after reload 
  1998      in order to be browsable."
  1998      in order to be browsable."
  1999 
  1999 
  2000     |baseName fileName aStream dirName|
  2000     |baseName fileName aStream dirName|
  2001 
  2001 
  2002     baseName := (Smalltalk fileNameForClass:self name).
  2002     baseName := (Smalltalk fileNameForClass:self name).
  2003     fileName := baseName , '.cls'.
  2003     fileName := baseName , '.cls'.
  2004 
  2004 
  2005     Project notNil ifTrue:[
  2005     Project notNil ifTrue:[
  2006         dirName := Project currentProjectDirectory
  2006 	dirName := Project currentProjectDirectory
  2007     ] ifFalse:[
  2007     ] ifFalse:[
  2008         dirName := '.'
  2008 	dirName := '.'
  2009     ].
  2009     ].
  2010     fileName := dirName asFilename constructString:fileName.
  2010     fileName := dirName asFilename constructString:fileName.
  2011 
  2011 
  2012     aStream := FileStream newFileNamed:fileName.
  2012     aStream := FileStream newFileNamed:fileName.
  2013     aStream isNil ifTrue:[
  2013     aStream isNil ifTrue:[
  2014         ^ FileOutErrorSignal 
  2014 	^ FileOutErrorSignal 
  2015                 raiseRequestWith:fileName
  2015 		raiseRequestWith:fileName
  2016                 errorString:('cannot create file:', fileName)
  2016 		errorString:('cannot create file:', fileName)
  2017     ].
  2017     ].
  2018         
  2018         
  2019     aStream binary.
  2019     aStream binary.
  2020     self binaryFileOutOn:aStream sourceMode:sourceMode.
  2020     self binaryFileOutOn:aStream sourceMode:sourceMode.
  2021     aStream close.
  2021     aStream close.
  2039 
  2039 
  2040     "
  2040     "
  2041      this test allows a smalltalk to be built without Projects/ChangeSets
  2041      this test allows a smalltalk to be built without Projects/ChangeSets
  2042     "
  2042     "
  2043     Project notNil ifTrue:[
  2043     Project notNil ifTrue:[
  2044         dirName := Project currentProjectDirectory
  2044 	dirName := Project currentProjectDirectory
  2045     ] ifFalse:[
  2045     ] ifFalse:[
  2046         dirName := Filename currentDirectory
  2046 	dirName := Filename currentDirectory
  2047     ].
  2047     ].
  2048     fileNameString := (dirName asFilename construct:fileNameString) name.
  2048     fileNameString := (dirName asFilename construct:fileNameString) name.
  2049 
  2049 
  2050     self fileOutAs:fileNameString.
  2050     self fileOutAs:fileNameString.
  2051 
  2051 
  2070 
  2070 
  2071     "/
  2071     "/
  2072     "/ optional classInstanceVariables
  2072     "/ optional classInstanceVariables
  2073     "/
  2073     "/
  2074     self class instanceVariableString isBlank ifFalse:[
  2074     self class instanceVariableString isBlank ifFalse:[
  2075         self fileOutClassInstVarDefinitionOn:aStream.
  2075 	self fileOutClassInstVarDefinitionOn:aStream.
  2076         aStream nextPutChunkSeparator. 
  2076 	aStream nextPutChunkSeparator. 
  2077         aStream cr; cr
  2077 	aStream cr; cr
  2078     ].
  2078     ].
  2079 
  2079 
  2080     self privateClassesSorted do:[:aClass |
  2080     self privateClassesSorted do:[:aClass |
  2081         aClass fileOutAllDefinitionsOn:aStream
  2081 	aClass fileOutAllDefinitionsOn:aStream
  2082     ]
  2082     ]
  2083 
  2083 
  2084     "Created: 15.10.1996 / 11:15:19 / cg"
  2084     "Created: 15.10.1996 / 11:15:19 / cg"
  2085     "Modified: 22.3.1997 / 16:11:56 / cg"
  2085     "Modified: 22.3.1997 / 16:11:56 / cg"
  2086 !
  2086 !
  2088 fileOutAllMethodsOn:aStream
  2088 fileOutAllMethodsOn:aStream
  2089     |collectionOfCategories|
  2089     |collectionOfCategories|
  2090 
  2090 
  2091     collectionOfCategories := self class categories asSortedCollection.
  2091     collectionOfCategories := self class categories asSortedCollection.
  2092     collectionOfCategories notNil ifTrue:[
  2092     collectionOfCategories notNil ifTrue:[
  2093         collectionOfCategories do:[:aCategory |
  2093 	collectionOfCategories do:[:aCategory |
  2094             self class fileOutCategory:aCategory on:aStream.
  2094 	    self class fileOutCategory:aCategory on:aStream.
  2095             aStream cr
  2095 	    aStream cr
  2096         ]
  2096 	]
  2097     ].
  2097     ].
  2098     collectionOfCategories := self categories asSortedCollection.
  2098     collectionOfCategories := self categories asSortedCollection.
  2099     collectionOfCategories notNil ifTrue:[
  2099     collectionOfCategories notNil ifTrue:[
  2100         collectionOfCategories do:[:aCategory |
  2100 	collectionOfCategories do:[:aCategory |
  2101             self fileOutCategory:aCategory on:aStream.
  2101 	    self fileOutCategory:aCategory on:aStream.
  2102             aStream cr
  2102 	    aStream cr
  2103         ]
  2103 	]
  2104     ].
  2104     ].
  2105 
  2105 
  2106     self privateClassesSorted do:[:aClass |
  2106     self privateClassesSorted do:[:aClass |
  2107         aClass fileOutAllMethodsOn:aStream
  2107 	aClass fileOutAllMethodsOn:aStream
  2108     ].
  2108     ].
  2109 
  2109 
  2110     "Created: 15.10.1996 / 11:13:00 / cg"
  2110     "Created: 15.10.1996 / 11:13:00 / cg"
  2111     "Modified: 22.3.1997 / 16:12:17 / cg"
  2111     "Modified: 22.3.1997 / 16:12:17 / cg"
  2112 !
  2112 !
  2130      if file exists, copy the existing to a .sav-file,
  2130      if file exists, copy the existing to a .sav-file,
  2131      create the new file as XXX.new-file,
  2131      create the new file as XXX.new-file,
  2132      and, if that worked rename afterwards ...
  2132      and, if that worked rename afterwards ...
  2133     "
  2133     "
  2134     (fileName exists) ifTrue:[
  2134     (fileName exists) ifTrue:[
  2135         sameFile := false.
  2135 	sameFile := false.
  2136 
  2136 
  2137         "/ check carefully - maybe, my source does not really come from that
  2137 	"/ check carefully - maybe, my source does not really come from that
  2138         "/ file (i.e. all of my methods have their source as string)
  2138 	"/ file (i.e. all of my methods have their source as string)
  2139 
  2139 
  2140         anySourceRef := false.
  2140 	anySourceRef := false.
  2141         self methodDictionary do:[:m|
  2141 	self methodDictionary do:[:m|
  2142             m sourcePosition notNil ifTrue:[
  2142 	    m sourcePosition notNil ifTrue:[
  2143                 anySourceRef := true
  2143 		anySourceRef := true
  2144             ]
  2144 	    ]
  2145         ].
  2145 	].
  2146         self class methodDictionary do:[:m|
  2146 	self class methodDictionary do:[:m|
  2147             m sourcePosition notNil ifTrue:[
  2147 	    m sourcePosition notNil ifTrue:[
  2148                 anySourceRef := true
  2148 		anySourceRef := true
  2149             ]
  2149 	    ]
  2150         ].
  2150 	].
  2151 
  2151 
  2152         anySourceRef ifTrue:[
  2152 	anySourceRef ifTrue:[
  2153             s := self sourceStream.
  2153 	    s := self sourceStream.
  2154             s notNil ifTrue:[
  2154 	    s notNil ifTrue:[
  2155                 mySourceFileID := s pathName asFilename info id.
  2155 		mySourceFileID := s pathName asFilename info id.
  2156                 sameFile := (fileName info id) == mySourceFileID.
  2156 		sameFile := (fileName info id) == mySourceFileID.
  2157                 s close.
  2157 		s close.
  2158             ] ifFalse:[
  2158 	    ] ifFalse:[
  2159                 classFilename notNil ifTrue:[
  2159 		classFilename notNil ifTrue:[
  2160                     "
  2160 		    "
  2161                      check for overwriting my current source file
  2161 		     check for overwriting my current source file
  2162                      this is not allowed, since it would clobber my methods source
  2162 		     this is not allowed, since it would clobber my methods source
  2163                      file ... you have to save it to some other place.
  2163 		     file ... you have to save it to some other place.
  2164                      This happens if you ask for a fileOut into the source-directory
  2164 		     This happens if you ask for a fileOut into the source-directory
  2165                      (from which my methods get their source)
  2165 		     (from which my methods get their source)
  2166                     "
  2166 		    "
  2167                     mySourceFileName := Smalltalk getSourceFileName:classFilename. 
  2167 		    mySourceFileName := Smalltalk getSourceFileName:classFilename. 
  2168                     sameFile := (fileNameString = mySourceFileName).
  2168 		    sameFile := (fileNameString = mySourceFileName).
  2169                     sameFile ifFalse:[
  2169 		    sameFile ifFalse:[
  2170                         mySourceFileName notNil ifTrue:[
  2170 			mySourceFileName notNil ifTrue:[
  2171                             sameFile := (fileName info id) == (mySourceFileName asFilename info id)
  2171 			    sameFile := (fileName info id) == (mySourceFileName asFilename info id)
  2172                         ]
  2172 			]
  2173                     ].
  2173 		    ].
  2174                 ]
  2174 		]
  2175             ].
  2175 	    ].
  2176         ].
  2176 	].
  2177 
  2177 
  2178         sameFile ifTrue:[
  2178 	sameFile ifTrue:[
  2179             ^ FileOutErrorSignal 
  2179 	    ^ FileOutErrorSignal 
  2180                 raiseRequestWith:fileNameString
  2180 		raiseRequestWith:fileNameString
  2181                 errorString:('may not overwrite sourcefile:', fileNameString)
  2181 		errorString:('may not overwrite sourcefile:', fileNameString)
  2182         ].
  2182 	].
  2183 
  2183 
  2184 	savFilename := Filename newTemporary.
  2184 	savFilename := Filename newTemporary.
  2185         fileName copyTo:savFilename.
  2185 	fileName copyTo:savFilename.
  2186         newFileName := fileName withSuffix:'new'.
  2186 	newFileName := fileName withSuffix:'new'.
  2187         needRename := true
  2187 	needRename := true
  2188     ] ifFalse:[
  2188     ] ifFalse:[
  2189         newFileName := fileName.
  2189 	newFileName := fileName.
  2190         needRename := false
  2190 	needRename := false
  2191     ].
  2191     ].
  2192 
  2192 
  2193     aStream := newFileName writeStream.
  2193     aStream := newFileName writeStream.
  2194     aStream isNil ifTrue:[
  2194     aStream isNil ifTrue:[
  2195 	savFilename notNil ifTrue:[
  2195 	savFilename notNil ifTrue:[
  2196 	    savFilename delete
  2196 	    savFilename delete
  2197 	].
  2197 	].
  2198         ^ FileOutErrorSignal 
  2198 	^ FileOutErrorSignal 
  2199                 raiseRequestWith:newFileName
  2199 		raiseRequestWith:newFileName
  2200                 errorString:('cannot create file:', newFileName name)
  2200 		errorString:('cannot create file:', newFileName name)
  2201     ].
  2201     ].
  2202     self fileOutOn:aStream.
  2202     self fileOutOn:aStream.
  2203     aStream close.
  2203     aStream close.
  2204 
  2204 
  2205     "
  2205     "
  2206      finally, replace the old-file
  2206      finally, replace the old-file
  2207      be careful, if the old one is a symbolic link; in this case,
  2207      be careful, if the old one is a symbolic link; in this case,
  2208      we have to do a copy ...
  2208      we have to do a copy ...
  2209     "
  2209     "
  2210     needRename ifTrue:[
  2210     needRename ifTrue:[
  2211         newFileName copyTo:fileName.
  2211 	newFileName copyTo:fileName.
  2212         newFileName delete
  2212 	newFileName delete
  2213     ].
  2213     ].
  2214     savFilename notNil ifTrue:[
  2214     savFilename notNil ifTrue:[
  2215 	savFilename delete
  2215 	savFilename delete
  2216     ].
  2216     ].
  2217 
  2217 
  2237 
  2237 
  2238     "mhmh - good idea; saw this in SmallDraw sourcecode ..."
  2238     "mhmh - good idea; saw this in SmallDraw sourcecode ..."
  2239 
  2239 
  2240     aStream cr; cr; nextPut:(Character doubleQuote); cr.
  2240     aStream cr; cr; nextPut:(Character doubleQuote); cr.
  2241     aStream space; 
  2241     aStream space; 
  2242             nextPutLine:'The following class instance variables are inherited by this class:';
  2242 	    nextPutLine:'The following class instance variables are inherited by this class:';
  2243             cr.
  2243 	    cr.
  2244     self allSuperclassesDo:[:aSuperClass |
  2244     self allSuperclassesDo:[:aSuperClass |
  2245         aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '.
  2245 	aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '.
  2246         aStream nextPutLine:(aSuperClass class instanceVariableString).
  2246 	aStream nextPutLine:(aSuperClass class instanceVariableString).
  2247     ].
  2247     ].
  2248     aStream nextPut:(Character doubleQuote); cr.
  2248     aStream nextPut:(Character doubleQuote); cr.
  2249 
  2249 
  2250     "Created: 10.12.1995 / 16:31:25 / cg"
  2250     "Created: 10.12.1995 / 16:31:25 / cg"
  2251     "Modified: 9.11.1996 / 00:11:07 / cg"
  2251     "Modified: 9.11.1996 / 00:11:07 / cg"
  2258     |comment s|
  2258     |comment s|
  2259 
  2259 
  2260     self printClassNameOn:aStream.
  2260     self printClassNameOn:aStream.
  2261     aStream nextPutAll:' comment:'.
  2261     aStream nextPutAll:' comment:'.
  2262     (comment := self comment) isNil ifTrue:[
  2262     (comment := self comment) isNil ifTrue:[
  2263         s := ''''''
  2263 	s := ''''''
  2264     ] ifFalse:[
  2264     ] ifFalse:[
  2265         s := comment storeString
  2265 	s := comment storeString
  2266     ].
  2266     ].
  2267     aStream nextPutAllAsChunk:s.
  2267     aStream nextPutAllAsChunk:s.
  2268     aStream nextPutChunkSeparator.
  2268     aStream nextPutChunkSeparator.
  2269     aStream cr
  2269     aStream cr
  2270 
  2270 
  2288     |aStream fileName|
  2288     |aStream fileName|
  2289 
  2289 
  2290     fileName := (Smalltalk fileNameForClass:self name), '.st'.
  2290     fileName := (Smalltalk fileNameForClass:self name), '.st'.
  2291     aStream := (aDirectoryName asFilename construct:fileName) writeStream.
  2291     aStream := (aDirectoryName asFilename construct:fileName) writeStream.
  2292     aStream isNil ifTrue:[
  2292     aStream isNil ifTrue:[
  2293         ^ FileOutErrorSignal 
  2293 	^ FileOutErrorSignal 
  2294                 raiseRequestWith:fileName
  2294 		raiseRequestWith:fileName
  2295                 errorString:('cannot create file:', fileName)
  2295 		errorString:('cannot create file:', fileName)
  2296     ].
  2296     ].
  2297     self fileOutOn:aStream.
  2297     self fileOutOn:aStream.
  2298     aStream close
  2298     aStream close
  2299 
  2299 
  2300     "
  2300     "
  2301         self fileOutIn:'/tmp'
  2301 	self fileOutIn:'/tmp'
  2302         self fileOutIn:'/tmp' asFilename
  2302 	self fileOutIn:'/tmp' asFilename
  2303     "
  2303     "
  2304 
  2304 
  2305     "Modified: 19.9.1997 / 00:03:53 / stefan"
  2305     "Modified: 19.9.1997 / 00:03:53 / stefan"
  2306 !
  2306 !
  2307 
  2307 
  2319 
  2319 
  2320     |collectionOfCategories copyrightMethod copyrightText comment versionMethod skippedMethods
  2320     |collectionOfCategories copyrightMethod copyrightText comment versionMethod skippedMethods
  2321      meta|
  2321      meta|
  2322 
  2322 
  2323     self isLoaded ifFalse:[
  2323     self isLoaded ifFalse:[
  2324         ^ FileOutErrorSignal 
  2324 	^ FileOutErrorSignal 
  2325             raiseRequestWith:self
  2325 	    raiseRequestWith:self
  2326                  errorString:'will not fileOut unloaded classes'
  2326 		 errorString:'will not fileOut unloaded classes'
  2327     ].
  2327     ].
  2328 
  2328 
  2329     meta := self class.
  2329     meta := self class.
  2330 
  2330 
  2331     "
  2331     "
  2336      On the other hand: I want every file created by myself to have the
  2336      On the other hand: I want every file created by myself to have the
  2337      copyright string at the beginning be preserved .... even if the
  2337      copyright string at the beginning be preserved .... even if the
  2338      code was edited in the browser and filedOut.
  2338      code was edited in the browser and filedOut.
  2339     "
  2339     "
  2340     (copyrightMethod := meta compiledMethodAt:#copyright) notNil ifTrue:[
  2340     (copyrightMethod := meta compiledMethodAt:#copyright) notNil ifTrue:[
  2341         "
  2341 	"
  2342          get the copyright methods source,
  2342 	 get the copyright methods source,
  2343          and insert at beginning.
  2343 	 and insert at beginning.
  2344         "
  2344 	"
  2345         copyrightText := copyrightMethod source.
  2345 	copyrightText := copyrightMethod source.
  2346         copyrightText isNil ifTrue:[
  2346 	copyrightText isNil ifTrue:[
  2347             "
  2347 	    "
  2348              no source available - trigger an error
  2348 	     no source available - trigger an error
  2349             "
  2349 	    "
  2350             FileOutErrorSignal
  2350 	    FileOutErrorSignal
  2351                 raiseRequestWith:'no source for class ' , self name , ' available. Cannot fileOut'.
  2351 		raiseRequestWith:'no source for class ' , self name , ' available. Cannot fileOut'.
  2352             ^ self
  2352 	    ^ self
  2353         ].
  2353 	].
  2354         "
  2354 	"
  2355          strip off the selector-line
  2355 	 strip off the selector-line
  2356         "
  2356 	"
  2357         copyrightText := copyrightText asCollectionOfLines asStringCollection.
  2357 	copyrightText := copyrightText asCollectionOfLines asStringCollection.
  2358         copyrightText := copyrightText copyFrom:2 to:(copyrightText size).
  2358 	copyrightText := copyrightText copyFrom:2 to:(copyrightText size).
  2359 "/        copyrightText do:[:line | aStream nextPutAll:line. aStream cr.].
  2359 "/        copyrightText do:[:line | aStream nextPutAll:line. aStream cr.].
  2360         copyrightText := copyrightText asString.
  2360 	copyrightText := copyrightText asString.
  2361         aStream nextPutAllAsChunk:copyrightText.
  2361 	aStream nextPutAllAsChunk:copyrightText.
  2362     ].
  2362     ].
  2363 
  2363 
  2364     stampIt ifTrue:[
  2364     stampIt ifTrue:[
  2365         "/
  2365 	"/
  2366         "/ first, a timestamp
  2366 	"/ first, a timestamp
  2367         "/
  2367 	"/
  2368         aStream nextPutAll:(Smalltalk timeStamp).
  2368 	aStream nextPutAll:(Smalltalk timeStamp).
  2369         aStream nextPutChunkSeparator. 
  2369 	aStream nextPutChunkSeparator. 
  2370         aStream cr; cr.
  2370 	aStream cr; cr.
  2371     ].
  2371     ].
  2372 
  2372 
  2373     "/
  2373     "/
  2374     "/ then the definition
  2374     "/ then the definition
  2375     "/
  2375     "/
  2377 
  2377 
  2378     "/
  2378     "/
  2379     "/ a comment - if any
  2379     "/ a comment - if any
  2380     "/
  2380     "/
  2381     (comment := self comment) notNil ifTrue:[
  2381     (comment := self comment) notNil ifTrue:[
  2382         self fileOutCommentOn:aStream.
  2382 	self fileOutCommentOn:aStream.
  2383         aStream cr.
  2383 	aStream cr.
  2384     ].
  2384     ].
  2385 
  2385 
  2386     "/
  2386     "/
  2387     "/ primitive definitions - if any
  2387     "/ primitive definitions - if any
  2388     "/
  2388     "/
  2394     "/         avoid sourcePosition-shifts when checked out later.
  2394     "/         avoid sourcePosition-shifts when checked out later.
  2395     "/         (RCS expands this string, so its size is not constant)
  2395     "/         (RCS expands this string, so its size is not constant)
  2396     "/
  2396     "/
  2397     collectionOfCategories := meta categories asSortedCollection.
  2397     collectionOfCategories := meta categories asSortedCollection.
  2398     collectionOfCategories notNil ifTrue:[
  2398     collectionOfCategories notNil ifTrue:[
  2399         "/
  2399 	"/
  2400         "/ documentation first (if any), but not the version method
  2400 	"/ documentation first (if any), but not the version method
  2401         "/
  2401 	"/
  2402         (collectionOfCategories includes:'documentation') ifTrue:[
  2402 	(collectionOfCategories includes:'documentation') ifTrue:[
  2403             versionMethod := meta compiledMethodAt:#version.
  2403 	    versionMethod := meta compiledMethodAt:#version.
  2404             versionMethod notNil ifTrue:[
  2404 	    versionMethod notNil ifTrue:[
  2405                 skippedMethods := Array with:versionMethod
  2405 		skippedMethods := Array with:versionMethod
  2406             ].
  2406 	    ].
  2407             meta fileOutCategory:'documentation' except:skippedMethods only:nil on:aStream.
  2407 	    meta fileOutCategory:'documentation' except:skippedMethods only:nil on:aStream.
  2408             aStream cr.
  2408 	    aStream cr.
  2409         ].
  2409 	].
  2410 
  2410 
  2411         "/
  2411 	"/
  2412         "/ initialization next (if any)
  2412 	"/ initialization next (if any)
  2413         "/
  2413 	"/
  2414         (collectionOfCategories includes:'initialization') ifTrue:[
  2414 	(collectionOfCategories includes:'initialization') ifTrue:[
  2415             meta fileOutCategory:'initialization' on:aStream.
  2415 	    meta fileOutCategory:'initialization' on:aStream.
  2416             aStream cr.
  2416 	    aStream cr.
  2417         ].
  2417 	].
  2418 
  2418 
  2419         "/
  2419 	"/
  2420         "/ instance creation next (if any)
  2420 	"/ instance creation next (if any)
  2421         "/
  2421 	"/
  2422         (collectionOfCategories includes:'instance creation') ifTrue:[
  2422 	(collectionOfCategories includes:'instance creation') ifTrue:[
  2423             meta fileOutCategory:'instance creation' on:aStream.
  2423 	    meta fileOutCategory:'instance creation' on:aStream.
  2424             aStream cr.
  2424 	    aStream cr.
  2425         ].
  2425 	].
  2426         collectionOfCategories do:[:aCategory |
  2426 	collectionOfCategories do:[:aCategory |
  2427             ((aCategory ~= 'documentation')
  2427 	    ((aCategory ~= 'documentation')
  2428             and:[(aCategory ~= 'initialization')
  2428 	    and:[(aCategory ~= 'initialization')
  2429             and:[aCategory ~= 'instance creation']]) ifTrue:[
  2429 	    and:[aCategory ~= 'instance creation']]) ifTrue:[
  2430                 meta fileOutCategory:aCategory on:aStream.
  2430 		meta fileOutCategory:aCategory on:aStream.
  2431                 aStream cr
  2431 		aStream cr
  2432             ]
  2432 	    ]
  2433         ]
  2433 	]
  2434     ].
  2434     ].
  2435 
  2435 
  2436     "/
  2436     "/
  2437     "/ methods from all categories in myself
  2437     "/ methods from all categories in myself
  2438     "/
  2438     "/
  2439     collectionOfCategories := self categories asSortedCollection.
  2439     collectionOfCategories := self categories asSortedCollection.
  2440     collectionOfCategories notNil ifTrue:[
  2440     collectionOfCategories notNil ifTrue:[
  2441         collectionOfCategories do:[:aCategory |
  2441 	collectionOfCategories do:[:aCategory |
  2442             self fileOutCategory:aCategory on:aStream.
  2442 	    self fileOutCategory:aCategory on:aStream.
  2443             aStream cr
  2443 	    aStream cr
  2444         ]
  2444 	]
  2445     ].
  2445     ].
  2446 
  2446 
  2447     "/
  2447     "/
  2448     "/ any private classes' methods
  2448     "/ any private classes' methods
  2449     "/
  2449     "/
  2450     self privateClassesSorted do:[:aClass |
  2450     self privateClassesSorted do:[:aClass |
  2451         aClass fileOutAllMethodsOn:aStream
  2451 	aClass fileOutAllMethodsOn:aStream
  2452     ].
  2452     ].
  2453 
  2453 
  2454 
  2454 
  2455     "/
  2455     "/
  2456     "/ finally, the previously skipped version method
  2456     "/ finally, the previously skipped version method
  2457     "/
  2457     "/
  2458     versionMethod notNil ifTrue:[
  2458     versionMethod notNil ifTrue:[
  2459         meta fileOutCategory:'documentation' except:nil only:skippedMethods on:aStream.
  2459 	meta fileOutCategory:'documentation' except:nil only:skippedMethods on:aStream.
  2460     ].
  2460     ].
  2461 
  2461 
  2462     "/
  2462     "/
  2463     "/ optionally an initialize message
  2463     "/ optionally an initialize message
  2464     "/
  2464     "/
  2465     (meta implements:#initialize) ifTrue:[
  2465     (meta implements:#initialize) ifTrue:[
  2466         self printClassNameOn:aStream. aStream nextPutAll:' initialize'.
  2466 	self printClassNameOn:aStream. aStream nextPutAll:' initialize'.
  2467         aStream nextPutChunkSeparator.
  2467 	aStream nextPutChunkSeparator.
  2468         aStream cr
  2468 	aStream cr
  2469     ]
  2469     ]
  2470 
  2470 
  2471     "Created: 15.11.1995 / 12:53:06 / cg"
  2471     "Created: 15.11.1995 / 12:53:06 / cg"
  2472     "Modified: 22.3.1997 / 16:12:47 / cg"
  2472     "Modified: 22.3.1997 / 16:12:47 / cg"
  2473     "Modified: 1.4.1997 / 16:01:05 / stefan"
  2473     "Modified: 1.4.1997 / 16:01:05 / stefan"
  2480 
  2480 
  2481     "
  2481     "
  2482      primitive definitions - if any
  2482      primitive definitions - if any
  2483     "
  2483     "
  2484     (s := self primitiveDefinitionsString) notNil ifTrue:[
  2484     (s := self primitiveDefinitionsString) notNil ifTrue:[
  2485         aStream nextPutChunkSeparator.
  2485 	aStream nextPutChunkSeparator.
  2486         self printClassNameOn:aStream.
  2486 	self printClassNameOn:aStream.
  2487         aStream nextPutAll:' primitiveDefinitions';
  2487 	aStream nextPutAll:' primitiveDefinitions';
  2488                 nextPutChunkSeparator;
  2488 		nextPutChunkSeparator;
  2489                 cr.
  2489 		cr.
  2490         aStream nextPutAll:s.
  2490 	aStream nextPutAll:s.
  2491         aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr
  2491 	aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr
  2492     ].
  2492     ].
  2493     (s := self primitiveVariablesString) notNil ifTrue:[
  2493     (s := self primitiveVariablesString) notNil ifTrue:[
  2494         aStream nextPutChunkSeparator.
  2494 	aStream nextPutChunkSeparator.
  2495         self printClassNameOn:aStream.
  2495 	self printClassNameOn:aStream.
  2496         aStream nextPutAll:' primitiveVariables';
  2496 	aStream nextPutAll:' primitiveVariables';
  2497                 nextPutChunkSeparator;
  2497 		nextPutChunkSeparator;
  2498                 cr.
  2498 		cr.
  2499         aStream nextPutAll:s.
  2499 	aStream nextPutAll:s.
  2500         aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr
  2500 	aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr
  2501     ].
  2501     ].
  2502 
  2502 
  2503     "Modified: 8.1.1997 / 17:45:40 / cg"
  2503     "Modified: 8.1.1997 / 17:45:40 / cg"
  2504 !
  2504 !
  2505 
  2505 
  2514     self fileOutPrimitiveDefinitionsOn:aStream.
  2514     self fileOutPrimitiveDefinitionsOn:aStream.
  2515     "
  2515     "
  2516      primitive functions - if any
  2516      primitive functions - if any
  2517     "
  2517     "
  2518     (s := self primitiveFunctionsString) notNil ifTrue:[
  2518     (s := self primitiveFunctionsString) notNil ifTrue:[
  2519         aStream nextPutChunkSeparator.
  2519 	aStream nextPutChunkSeparator.
  2520         self printClassNameOn:aStream.
  2520 	self printClassNameOn:aStream.
  2521         aStream nextPutAll:' primitiveFunctions';
  2521 	aStream nextPutAll:' primitiveFunctions';
  2522                 nextPutChunkSeparator;
  2522 		nextPutChunkSeparator;
  2523                 cr.
  2523 		cr.
  2524         aStream nextPutAll:s.
  2524 	aStream nextPutAll:s.
  2525         aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr
  2525 	aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr
  2526     ].
  2526     ].
  2527 
  2527 
  2528     "Modified: 8.1.1997 / 17:45:51 / cg"
  2528     "Modified: 8.1.1997 / 17:45:51 / cg"
  2529 ! !
  2529 ! !
  2530 
  2530 
  2553     aStream spaces:indent; bold; nextPutAll:nm; normal; nextPutAll:' ('.
  2553     aStream spaces:indent; bold; nextPutAll:nm; normal; nextPutAll:' ('.
  2554     self printInstVarNamesOn:aStream indent:(indent + nm size + 2).
  2554     self printInstVarNamesOn:aStream indent:(indent + nm size + 2).
  2555     aStream nextPutLine:')'.
  2555     aStream nextPutLine:')'.
  2556 
  2556 
  2557     (self subclasses sort:[:a :b | a name < b name]) do:[:aSubclass |
  2557     (self subclasses sort:[:a :b | a name < b name]) do:[:aSubclass |
  2558         aSubclass printFullHierarchyOn:aStream indent:(indent + 2)
  2558 	aSubclass printFullHierarchyOn:aStream indent:(indent + 2)
  2559     ]
  2559     ]
  2560 
  2560 
  2561     "|printStream|
  2561     "|printStream|
  2562      printStream := Printer new.
  2562      printStream := Printer new.
  2563      Object printFullHierarchyOn:printStream indent:0.
  2563      Object printFullHierarchyOn:printStream indent:0.
  2571 
  2571 
  2572     |dict any|
  2572     |dict any|
  2573 
  2573 
  2574     dict := self methodDictionary.
  2574     dict := self methodDictionary.
  2575     dict notNil ifTrue:[
  2575     dict notNil ifTrue:[
  2576         any := false.
  2576 	any := false.
  2577         dict do:[:aMethod |
  2577 	dict do:[:aMethod |
  2578             (aCategory = aMethod category) ifTrue:[
  2578 	    (aCategory = aMethod category) ifTrue:[
  2579                 any := true
  2579 		any := true
  2580             ]
  2580 	    ]
  2581         ].
  2581 	].
  2582         any ifTrue:[
  2582 	any ifTrue:[
  2583              aPrintStream italic.
  2583 	     aPrintStream italic.
  2584              aPrintStream nextPutAll:aCategory.
  2584 	     aPrintStream nextPutAll:aCategory.
  2585              aPrintStream normal.
  2585 	     aPrintStream normal.
  2586              aPrintStream cr; cr.
  2586 	     aPrintStream cr; cr.
  2587              dict do:[:aMethod |
  2587 	     dict do:[:aMethod |
  2588                  (aCategory = aMethod category) ifTrue:[
  2588 		 (aCategory = aMethod category) ifTrue:[
  2589                      self printOutSource:(aMethod source) on:aPrintStream.
  2589 		     self printOutSource:(aMethod source) on:aPrintStream.
  2590                      aPrintStream cr; cr
  2590 		     aPrintStream cr; cr
  2591                  ]
  2591 		 ]
  2592              ].
  2592 	     ].
  2593              aPrintStream cr
  2593 	     aPrintStream cr
  2594          ]
  2594 	 ]
  2595     ]
  2595     ]
  2596 
  2596 
  2597     "Modified: 12.6.1996 / 11:47:36 / stefan"
  2597     "Modified: 12.6.1996 / 11:47:36 / stefan"
  2598 !
  2598 !
  2599 
  2599 
  2603     |comment s|
  2603     |comment s|
  2604 
  2604 
  2605     aPrintStream nextPutAll:'class                '; bold; nextPutLine:self name; normal. 
  2605     aPrintStream nextPutAll:'class                '; bold; nextPutLine:self name; normal. 
  2606     aPrintStream nextPutAll:'superclass           '.
  2606     aPrintStream nextPutAll:'superclass           '.
  2607     superclass isNil ifTrue:[
  2607     superclass isNil ifTrue:[
  2608         s := 'Object'
  2608 	s := 'Object'
  2609     ] ifFalse:[
  2609     ] ifFalse:[
  2610         s := superclass name
  2610 	s := superclass name
  2611     ].
  2611     ].
  2612     aPrintStream nextPutLine:s.
  2612     aPrintStream nextPutLine:s.
  2613 
  2613 
  2614     aPrintStream nextPutAll:'instance Variables   '.
  2614     aPrintStream nextPutAll:'instance Variables   '.
  2615     self printInstVarNamesOn:aPrintStream indent:21.
  2615     self printInstVarNamesOn:aPrintStream indent:21.
  2618     aPrintStream nextPutAll:'class Variables      '.
  2618     aPrintStream nextPutAll:'class Variables      '.
  2619     self printClassVarNamesOn:aPrintStream indent:21.
  2619     self printClassVarNamesOn:aPrintStream indent:21.
  2620     aPrintStream cr.
  2620     aPrintStream cr.
  2621 
  2621 
  2622     category notNil ifTrue:[
  2622     category notNil ifTrue:[
  2623         aPrintStream nextPutAll:'category             '; 
  2623 	aPrintStream nextPutAll:'category             '; 
  2624                      nextPutLine:(category printString).
  2624 		     nextPutLine:(category printString).
  2625     ].
  2625     ].
  2626 
  2626 
  2627     (comment := self comment) notNil ifTrue:[
  2627     (comment := self comment) notNil ifTrue:[
  2628         aPrintStream cr; nextPutLine:'comment:'; italic; nextPutLine:comment; normal
  2628 	aPrintStream cr; nextPutLine:'comment:'; italic; nextPutLine:comment; normal
  2629     ]
  2629     ]
  2630 
  2630 
  2631     "Created: 10.12.1995 / 16:30:47 / cg"
  2631     "Created: 10.12.1995 / 16:30:47 / cg"
  2632     "Modified: 9.11.1996 / 00:13:37 / cg"
  2632     "Modified: 9.11.1996 / 00:13:37 / cg"
  2633     "Modified: 1.4.1997 / 16:01:26 / stefan"
  2633     "Modified: 1.4.1997 / 16:01:26 / stefan"
  2640 
  2640 
  2641     self printOutDefinitionOn:aPrintStream.
  2641     self printOutDefinitionOn:aPrintStream.
  2642     aPrintStream cr.
  2642     aPrintStream cr.
  2643     collectionOfCategories := self class categories.
  2643     collectionOfCategories := self class categories.
  2644     collectionOfCategories notNil ifTrue:[
  2644     collectionOfCategories notNil ifTrue:[
  2645         aPrintStream nextPutLine:'class protocol'.
  2645 	aPrintStream nextPutLine:'class protocol'.
  2646         aPrintStream cr.
  2646 	aPrintStream cr.
  2647         collectionOfCategories do:[:aCategory |
  2647 	collectionOfCategories do:[:aCategory |
  2648             self class printOutCategory:aCategory on:aPrintStream
  2648 	    self class printOutCategory:aCategory on:aPrintStream
  2649         ]
  2649 	]
  2650     ].
  2650     ].
  2651     collectionOfCategories := self categories.
  2651     collectionOfCategories := self categories.
  2652     collectionOfCategories notNil ifTrue:[
  2652     collectionOfCategories notNil ifTrue:[
  2653         aPrintStream nextPutLine:'instance protocol'.
  2653 	aPrintStream nextPutLine:'instance protocol'.
  2654         aPrintStream cr.
  2654 	aPrintStream cr.
  2655         collectionOfCategories do:[:aCategory |
  2655 	collectionOfCategories do:[:aCategory |
  2656             self printOutCategory:aCategory on:aPrintStream
  2656 	    self printOutCategory:aCategory on:aPrintStream
  2657         ]
  2657 	]
  2658     ]
  2658     ]
  2659 
  2659 
  2660     "Modified: 9.11.1996 / 00:14:11 / cg"
  2660     "Modified: 9.11.1996 / 00:14:11 / cg"
  2661 !
  2661 !
  2662 
  2662 
  2783     "{ Pragma: +optSpace }"
  2783     "{ Pragma: +optSpace }"
  2784 
  2784 
  2785     "append a primitiveDefinitions-record to aStream"
  2785     "append a primitiveDefinitions-record to aStream"
  2786 
  2786 
  2787     aStream nextPutAll:aClass name; nextPutLine:' primitiveDefinitions:'''; 
  2787     aStream nextPutAll:aClass name; nextPutLine:' primitiveDefinitions:'''; 
  2788             nextPutAll:(aClass primitiveDefinitionsString storeString copyFrom:2).
  2788 	    nextPutAll:(aClass primitiveDefinitionsString storeString copyFrom:2).
  2789     aStream nextPutChunkSeparator.
  2789     aStream nextPutChunkSeparator.
  2790 
  2790 
  2791     "Modified: 9.11.1996 / 00:09:54 / cg"
  2791     "Modified: 9.11.1996 / 00:09:54 / cg"
  2792 !
  2792 !
  2793 
  2793 
  2795     "{ Pragma: +optSpace }"
  2795     "{ Pragma: +optSpace }"
  2796 
  2796 
  2797     "append a primitiveFunctions-record to aStream"
  2797     "append a primitiveFunctions-record to aStream"
  2798 
  2798 
  2799     aStream nextPutAll:aClass name; nextPutLine:' primitiveFunctions:'''; 
  2799     aStream nextPutAll:aClass name; nextPutLine:' primitiveFunctions:'''; 
  2800             nextPutAll:(aClass primitiveFunctionsString storeString copyFrom:2).
  2800 	    nextPutAll:(aClass primitiveFunctionsString storeString copyFrom:2).
  2801     aStream nextPutChunkSeparator.
  2801     aStream nextPutChunkSeparator.
  2802 
  2802 
  2803     "Modified: 9.11.1996 / 00:10:02 / cg"
  2803     "Modified: 9.11.1996 / 00:10:02 / cg"
  2804 !
  2804 !
  2805 
  2805 
  2807     "{ Pragma: +optSpace }"
  2807     "{ Pragma: +optSpace }"
  2808 
  2808 
  2809     "append a primitiveVariables-record to aStream"
  2809     "append a primitiveVariables-record to aStream"
  2810 
  2810 
  2811     aStream nextPutAll:aClass name; nextPutLine:' primitiveVariables:'''; 
  2811     aStream nextPutAll:aClass name; nextPutLine:' primitiveVariables:'''; 
  2812             nextPutAll:(aClass primitiveVariablesString storeString copyFrom:2).
  2812 	    nextPutAll:(aClass primitiveVariablesString storeString copyFrom:2).
  2813     aStream nextPutChunkSeparator.
  2813     aStream nextPutChunkSeparator.
  2814 
  2814 
  2815     "Modified: 9.11.1996 / 00:10:10 / cg"
  2815     "Modified: 9.11.1996 / 00:10:10 / cg"
  2816 ! !
  2816 ! !
  2817 
  2817 
  2832 
  2832 
  2833     "the primitiveSpec is either a string, or an integer specifying the
  2833     "the primitiveSpec is either a string, or an integer specifying the
  2834      position within the classes sourcefile ...
  2834      position within the classes sourcefile ...
  2835     "
  2835     "
  2836     pos isNumber ifTrue:[
  2836     pos isNumber ifTrue:[
  2837         classFilename notNil ifTrue:[
  2837 	classFilename notNil ifTrue:[
  2838             stream := self sourceStream. 
  2838 	    stream := self sourceStream. 
  2839             stream notNil ifTrue:[
  2839 	    stream notNil ifTrue:[
  2840                 stream position:pos+1.
  2840 		stream position:pos+1.
  2841                 string := stream nextChunk.
  2841 		string := stream nextChunk.
  2842                 stream close.
  2842 		stream close.
  2843                 ^ string
  2843 		^ string
  2844             ]
  2844 	    ]
  2845         ].
  2845 	].
  2846         ^ nil
  2846 	^ nil
  2847     ].
  2847     ].
  2848     ^ pos
  2848     ^ pos
  2849 
  2849 
  2850     "Modified: 15.1.1997 / 15:29:30 / stefan"
  2850     "Modified: 15.1.1997 / 15:29:30 / stefan"
  2851 !
  2851 !
  2870 
  2870 
  2871     self printOutDefinitionOn:aPrintStream.
  2871     self printOutDefinitionOn:aPrintStream.
  2872     aPrintStream cr.
  2872     aPrintStream cr.
  2873     collectionOfCategories := self class categories.
  2873     collectionOfCategories := self class categories.
  2874     collectionOfCategories notNil ifTrue:[
  2874     collectionOfCategories notNil ifTrue:[
  2875         aPrintStream nextPutLine:'class protocol'.
  2875 	aPrintStream nextPutLine:'class protocol'.
  2876         aPrintStream cr.
  2876 	aPrintStream cr.
  2877         collectionOfCategories do:[:aCategory |
  2877 	collectionOfCategories do:[:aCategory |
  2878             self class printOutCategoryProtocol:aCategory on:aPrintStream
  2878 	    self class printOutCategoryProtocol:aCategory on:aPrintStream
  2879         ]
  2879 	]
  2880     ].
  2880     ].
  2881     collectionOfCategories := self categories.
  2881     collectionOfCategories := self categories.
  2882     collectionOfCategories notNil ifTrue:[
  2882     collectionOfCategories notNil ifTrue:[
  2883         aPrintStream nextPutLine:'instance protocol'.
  2883 	aPrintStream nextPutLine:'instance protocol'.
  2884         aPrintStream cr.
  2884 	aPrintStream cr.
  2885         collectionOfCategories do:[:aCategory |
  2885 	collectionOfCategories do:[:aCategory |
  2886             self printOutCategoryProtocol:aCategory on:aPrintStream
  2886 	    self printOutCategoryProtocol:aCategory on:aPrintStream
  2887         ]
  2887 	]
  2888     ]
  2888     ]
  2889 
  2889 
  2890     "Modified: 9.11.1996 / 00:14:26 / cg"
  2890     "Modified: 9.11.1996 / 00:14:26 / cg"
  2891 ! !
  2891 ! !
  2892 
  2892 
  2915 
  2915 
  2916     |set|
  2916     |set|
  2917 
  2917 
  2918     set := IdentitySet new.
  2918     set := IdentitySet new.
  2919     Smalltalk allBehaviorsDo:[:aClass | 
  2919     Smalltalk allBehaviorsDo:[:aClass | 
  2920         aClass superclass isNil ifTrue:[set add:aClass]
  2920 	aClass superclass isNil ifTrue:[set add:aClass]
  2921     ].
  2921     ].
  2922     ^ set asOrderedCollection
  2922     ^ set asOrderedCollection
  2923 
  2923 
  2924     "
  2924     "
  2925      Class rootsOfTheWorld
  2925      Class rootsOfTheWorld
  2968      Returns the new private class."
  2968      Returns the new private class."
  2969 
  2969 
  2970     |sel newClass|
  2970     |sel newClass|
  2971 
  2971 
  2972     self owningClass notNil ifTrue:[
  2972     self owningClass notNil ifTrue:[
  2973         ^ self
  2973 	^ self
  2974     ].
  2974     ].
  2975 
  2975 
  2976     sel := self definitionSelectorPrivate.
  2976     sel := self definitionSelectorPrivate.
  2977 
  2977 
  2978     newClass := self superclass
  2978     newClass := self superclass
  2979         perform:sel
  2979 	perform:sel
  2980         withArguments:(Array 
  2980 	withArguments:(Array 
  2981                         with:(self name asSymbol)
  2981 			with:(self name asSymbol)
  2982                         with:(self instanceVariableString)
  2982 			with:(self instanceVariableString)
  2983                         with:(self classVariableString)
  2983 			with:(self classVariableString)
  2984                         with:''
  2984 			with:''
  2985                         with:newOwner).
  2985 			with:newOwner).
  2986 
  2986 
  2987     "/ copy over methods ...
  2987     "/ copy over methods ...
  2988     self class copyInvalidatedMethodsFrom:self class for:newClass class.
  2988     self class copyInvalidatedMethodsFrom:self class for:newClass class.
  2989     self class copyInvalidatedMethodsFrom:self for:newClass.
  2989     self class copyInvalidatedMethodsFrom:self for:newClass.
  2990     newClass class recompileInvalidatedMethods.
  2990     newClass class recompileInvalidatedMethods.
  3012     "/ first, create the public class ...
  3012     "/ first, create the public class ...
  3013     sel := self definitionSelector.
  3013     sel := self definitionSelector.
  3014 
  3014 
  3015     Class nameSpaceQuerySignal answer:Smalltalk
  3015     Class nameSpaceQuerySignal answer:Smalltalk
  3016     do:[
  3016     do:[
  3017         newClass := self superclass
  3017 	newClass := self superclass
  3018             perform:sel
  3018 	    perform:sel
  3019             withArguments:(Array 
  3019 	    withArguments:(Array 
  3020                             with:(self nameWithoutPrefix asSymbol)
  3020 			    with:(self nameWithoutPrefix asSymbol)
  3021                             with:(self instanceVariableString)
  3021 			    with:(self instanceVariableString)
  3022                             with:(self classVariableString)
  3022 			    with:(self classVariableString)
  3023                             with:''
  3023 			    with:''
  3024                             with:(owner category)).
  3024 			    with:(owner category)).
  3025 
  3025 
  3026         "/ copy over methods ...
  3026 	"/ copy over methods ...
  3027         self class copyInvalidatedMethodsFrom:self class for:newClass class.
  3027 	self class copyInvalidatedMethodsFrom:self class for:newClass class.
  3028         self class copyInvalidatedMethodsFrom:self for:newClass.
  3028 	self class copyInvalidatedMethodsFrom:self for:newClass.
  3029         newClass class recompileInvalidatedMethods.
  3029 	newClass class recompileInvalidatedMethods.
  3030         newClass recompileInvalidatedMethods.
  3030 	newClass recompileInvalidatedMethods.
  3031     ].
  3031     ].
  3032 
  3032 
  3033     owner changed:#newClass with:newClass.
  3033     owner changed:#newClass with:newClass.
  3034     Smalltalk changed:#newClass with:newClass.
  3034     Smalltalk changed:#newClass with:newClass.
  3035 
  3035 
  3170 
  3170 
  3171     |owner info c|
  3171     |owner info c|
  3172 
  3172 
  3173     (owner := self owningClass) notNil ifTrue:[^ owner binaryRevision].
  3173     (owner := self owningClass) notNil ifTrue:[^ owner binaryRevision].
  3174     revision notNil ifTrue:[
  3174     revision notNil ifTrue:[
  3175         c := revision first.
  3175 	c := revision first.
  3176         c == $$ ifTrue:[
  3176 	c == $$ ifTrue:[
  3177             info := Class revisionInfoFromString:revision.
  3177 	    info := Class revisionInfoFromString:revision.
  3178             info isNil ifTrue:[^ '0'].
  3178 	    info isNil ifTrue:[^ '0'].
  3179             ^ info at:#revision ifAbsent:'0'.
  3179 	    ^ info at:#revision ifAbsent:'0'.
  3180         ].
  3180 	].
  3181         c isDigit ifFalse:[
  3181 	c isDigit ifFalse:[
  3182             ^ '0'
  3182 	    ^ '0'
  3183         ].
  3183 	].
  3184     ].
  3184     ].
  3185 
  3185 
  3186     ^ revision
  3186     ^ revision
  3187 
  3187 
  3188     "
  3188     "
  3194      to find all classes which are not up-to-date:
  3194      to find all classes which are not up-to-date:
  3195 
  3195 
  3196      |classes|
  3196      |classes|
  3197 
  3197 
  3198      classes := Smalltalk allClasses 
  3198      classes := Smalltalk allClasses 
  3199                     select:[:cls | cls binaryRevision notNil and:[cls binaryRevision ~= cls revision]].
  3199 		    select:[:cls | cls binaryRevision notNil and:[cls binaryRevision ~= cls revision]].
  3200      SystemBrowser browseClasses:classes title:'classes which are not up-to-date'
  3200      SystemBrowser browseClasses:classes title:'classes which are not up-to-date'
  3201     "
  3201     "
  3202 
  3202 
  3203     "Created: 7.12.1995 / 10:58:47 / cg"
  3203     "Created: 7.12.1995 / 10:58:47 / cg"
  3204     "Modified: 1.4.1997 / 23:33:01 / stefan"
  3204     "Modified: 1.4.1997 / 23:33:01 / stefan"
  3206 !
  3206 !
  3207 
  3207 
  3208 localSourceStreamFor:sourceFile
  3208 localSourceStreamFor:sourceFile
  3209     "return an open stream on a local sourcefile, nil if that is not available"
  3209     "return an open stream on a local sourcefile, nil if that is not available"
  3210 
  3210 
  3211     |fileName info module dir fn|
  3211     |fileName info module dir fn package|
  3212 
  3212 
  3213     "/
  3213     "/
  3214     "/ old: look in 'source/<filename>'
  3214     "/ old: look in 'source/<filename>'
  3215     "/ this is still kept in order to find user-private
  3215     "/ this is still kept in order to find user-private
  3216     "/ classes in her currentDirectory.
  3216     "/ classes in her currentDirectory.
  3217     "/
  3217     "/
  3218     fileName := Smalltalk getSourceFileName:sourceFile.
  3218     fileName := Smalltalk getSourceFileName:sourceFile.
  3219     fileName notNil ifTrue:[
  3219     fileName notNil ifTrue:[
  3220         ^ fileName asFilename readStream.
  3220 	^ fileName asFilename readStream.
       
  3221     ].
       
  3222 
       
  3223     (package := self package) notNil ifTrue:[
       
  3224 	(package includes:$:) ifTrue:[
       
  3225 	    package := package asString copy replaceAll:$: with:$/
       
  3226 	] ifFalse:[
       
  3227 	    package := 'stx/' , package
       
  3228 	].
       
  3229 	fileName := Smalltalk getSourceFileName:(package , '/' , sourceFile).
       
  3230 	fileName notNil ifTrue:[
       
  3231 	    ^ fileName asFilename readStream.
       
  3232 	].
  3221     ].
  3233     ].
  3222 
  3234 
  3223     "/
  3235     "/
  3224     "/ new: look in 'source/<module>/<package>/<filename>
  3236     "/ new: look in 'source/<module>/<package>/<filename>
  3225     "/ this makes the symbolic links to (or copy of) the source files
  3237     "/ this makes the symbolic links to (or copy of) the source files
  3229 	module := info at:#module ifAbsent:nil.
  3241 	module := info at:#module ifAbsent:nil.
  3230 	module notNil ifTrue:[
  3242 	module notNil ifTrue:[
  3231 	    dir := info at:#directory ifAbsent:nil.
  3243 	    dir := info at:#directory ifAbsent:nil.
  3232 	    dir notNil ifTrue:[
  3244 	    dir notNil ifTrue:[
  3233 		fn := (module asFilename construct:dir) construct:sourceFile.
  3245 		fn := (module asFilename construct:dir) construct:sourceFile.
  3234     	        fileName := Smalltalk getSourceFileName:(fn name).
  3246 		fileName := Smalltalk getSourceFileName:(fn name).
  3235                 fileName notNil ifTrue:[
  3247 		fileName notNil ifTrue:[
  3236                     ^ fileName asFilename readStream.
  3248 		    ^ fileName asFilename readStream.
  3237                 ].
  3249 		].
  3238 	    ]
  3250 	    ]
  3239 	]
  3251 	]
  3240     ].
  3252     ].
  3241     ^ nil
  3253     ^ nil
       
  3254 
       
  3255     "Modified: / 9.1.1998 / 15:02:46 / cg"
  3242 !
  3256 !
  3243 
  3257 
  3244 packageSourceCodeInfo
  3258 packageSourceCodeInfo
  3245     "{ Pragma: +optSpace }"
  3259     "{ Pragma: +optSpace }"
  3246 
  3260 
  3266      the directory info defaults to library name.
  3280      the directory info defaults to library name.
  3267      The library name may not be left blank.
  3281      The library name may not be left blank.
  3268      (this is done for backward compatibility,)
  3282      (this is done for backward compatibility,)
  3269 
  3283 
  3270      For example: 
  3284      For example: 
  3271         '....(libbasic)'                         -> module: stx directory: libbasic library: libbasic
  3285 	'....(libbasic)'                         -> module: stx directory: libbasic library: libbasic
  3272         '....(stx:libbasic)'                     -> module: stx directory: libbasic library: libbasic
  3286 	'....(stx:libbasic)'                     -> module: stx directory: libbasic library: libbasic
  3273         '....(aeg:libIECInterface)'              -> module: aeg directory: libIECInterface library:libIECInterface
  3287 	'....(aeg:libIECInterface)'              -> module: aeg directory: libIECInterface library:libIECInterface
  3274         '....(stx:goodies/persistency:libdbase)' -> module: stx directory: goodies/persistency library:libdbase 
  3288 	'....(stx:goodies/persistency:libdbase)' -> module: stx directory: goodies/persistency library:libdbase 
  3275 
  3289 
  3276      The way how the sourceCodeManager uses this to find the source location
  3290      The way how the sourceCodeManager uses this to find the source location
  3277      depends on the scheme used. For CVS, the module is taken as the -d arg,
  3291      depends on the scheme used. For CVS, the module is taken as the -d arg,
  3278      while the directory is prepended to the file name.
  3292      while the directory is prepended to the file name.
  3279      Other schemes may do things differently - these are not yet specified.
  3293      Other schemes may do things differently - these are not yet specified.
  3280 
  3294 
  3281      Caveat:
  3295      Caveat:
  3282         Encoding this info in the package string seems somewhat kludgy.
  3296 	Encoding this info in the package string seems somewhat kludgy.
  3283     "
  3297     "
  3284 
  3298 
  3285     |owner sourceInfo packageString idx1 idx2 
  3299     |owner sourceInfo packageString idx1 idx2 
  3286      moduleString directoryString libraryString components dirComponents mgr|
  3300      moduleString directoryString libraryString components dirComponents mgr|
  3287 
  3301 
  3290     package isNil ifTrue:[^ nil].
  3304     package isNil ifTrue:[^ nil].
  3291 
  3305 
  3292     packageString := package asString.
  3306     packageString := package asString.
  3293     idx1 := packageString lastIndexOf:$(.
  3307     idx1 := packageString lastIndexOf:$(.
  3294     idx1 ~~ 0 ifTrue:[
  3308     idx1 ~~ 0 ifTrue:[
  3295         idx2 := packageString indexOf:$) startingAt:idx1+1.
  3309 	idx2 := packageString indexOf:$) startingAt:idx1+1.
  3296         idx2 ~~ 0 ifTrue:[
  3310 	idx2 ~~ 0 ifTrue:[
  3297             sourceInfo := packageString copyFrom:idx1 + 1 to:idx2 - 1
  3311 	    sourceInfo := packageString copyFrom:idx1 + 1 to:idx2 - 1
  3298         ]
  3312 	]
  3299     ] ifFalse:[
  3313     ] ifFalse:[
  3300         sourceInfo := packageString
  3314 	sourceInfo := packageString
  3301     ].
  3315     ].
  3302 
  3316 
  3303     sourceInfo isNil ifTrue:[^ nil].
  3317     sourceInfo isNil ifTrue:[^ nil].
  3304     components := sourceInfo asCollectionOfSubstringsSeparatedBy:$:.
  3318     components := sourceInfo asCollectionOfSubstringsSeparatedBy:$:.
  3305     components size == 0 ifTrue:[
  3319     components size == 0 ifTrue:[
  3306 "/        moduleString := 'stx'.
  3320 "/        moduleString := 'stx'.
  3307 "/        directoryString := libraryString := ''.
  3321 "/        directoryString := libraryString := ''.
  3308         ^ nil
  3322 	^ nil
  3309     ].
  3323     ].
  3310     components size == 1 ifTrue:[
  3324     components size == 1 ifTrue:[
  3311         "/ a single name given - the module becomes 'stx' or
  3325 	"/ a single name given - the module becomes 'stx' or
  3312         "/ the very first directory component (if such a module exists).
  3326 	"/ the very first directory component (if such a module exists).
  3313         "/ If the component includes slashes, its the directory
  3327 	"/ If the component includes slashes, its the directory
  3314         "/ otherwise the library
  3328 	"/ otherwise the library
  3315         "/ 
  3329 	"/ 
  3316         dirComponents := Filename concreteClass components:(components at:1).     
  3330 	dirComponents := Filename concreteClass components:(components at:1).     
  3317 
  3331 
  3318         (dirComponents size > 1
  3332 	(dirComponents size > 1
  3319         and:[(mgr := self sourceCodeManager) notNil
  3333 	and:[(mgr := self sourceCodeManager) notNil
  3320         and:[mgr checkForExistingModule:dirComponents first]]) ifTrue:[
  3334 	and:[mgr checkForExistingModule:dirComponents first]]) ifTrue:[
  3321             moduleString := dirComponents first.
  3335 	    moduleString := dirComponents first.
  3322             directoryString := libraryString := (Filename fromComponents:(dirComponents copyFrom:2)) asString.
  3336 	    directoryString := libraryString := (Filename fromComponents:(dirComponents copyFrom:2)) asString.
  3323         ] ifFalse:[
  3337 	] ifFalse:[
  3324             moduleString := 'stx'.
  3338 	    moduleString := 'stx'.
  3325             directoryString := libraryString := components at:1.
  3339 	    directoryString := libraryString := components at:1.
  3326         ].
  3340 	].
  3327 
  3341 
  3328         (libraryString includes:$/) ifTrue:[
  3342 	(libraryString includes:$/) ifTrue:[
  3329             libraryString := libraryString asFilename baseName
  3343 	    libraryString := libraryString asFilename baseName
  3330         ]
  3344 	]
  3331     ] ifFalse:[
  3345     ] ifFalse:[
  3332         components size == 2 ifTrue:[
  3346 	components size == 2 ifTrue:[
  3333             "/ two components - assume its the module and the directory; 
  3347 	    "/ two components - assume its the module and the directory; 
  3334             "/ the library is assumed to be named after the directory
  3348 	    "/ the library is assumed to be named after the directory
  3335             "/ except, if slashes are in the name; then the libraryname
  3349 	    "/ except, if slashes are in the name; then the libraryname
  3336             "/ is the last component.
  3350 	    "/ is the last component.
  3337             "/
  3351 	    "/
  3338             moduleString := components at:1.
  3352 	    moduleString := components at:1.
  3339             directoryString := libraryString := components at:2.
  3353 	    directoryString := libraryString := components at:2.
  3340             (libraryString includes:$/) ifTrue:[
  3354 	    (libraryString includes:$/) ifTrue:[
  3341                 libraryString := libraryString asFilename baseName
  3355 		libraryString := libraryString asFilename baseName
  3342             ]
  3356 	    ]
  3343         ] ifFalse:[
  3357 	] ifFalse:[
  3344             "/ all components given
  3358 	    "/ all components given
  3345             moduleString := components at:1.
  3359 	    moduleString := components at:1.
  3346             directoryString := components at:2.
  3360 	    directoryString := components at:2.
  3347             libraryString := components at:3.
  3361 	    libraryString := components at:3.
  3348         ]
  3362 	]
  3349     ].
  3363     ].
  3350 
  3364 
  3351     libraryString isEmpty ifTrue:[
  3365     libraryString isEmpty ifTrue:[
  3352         directoryString notEmpty ifTrue:[
  3366 	directoryString notEmpty ifTrue:[
  3353             libraryString := directoryString asFilename baseName
  3367 	    libraryString := directoryString asFilename baseName
  3354         ].
  3368 	].
  3355         libraryString isEmpty ifTrue:[
  3369 	libraryString isEmpty ifTrue:[
  3356             "/ lets extract the library from the liblist file ...
  3370 	    "/ lets extract the library from the liblist file ...
  3357             libraryString := Smalltalk libraryFileNameOfClass:self.
  3371 	    libraryString := Smalltalk libraryFileNameOfClass:self.
  3358             libraryString isNil ifTrue:[^ nil].
  3372 	    libraryString isNil ifTrue:[^ nil].
  3359         ]
  3373 	]
  3360     ].
  3374     ].
  3361 
  3375 
  3362     moduleString isEmpty ifTrue:[
  3376     moduleString isEmpty ifTrue:[
  3363         moduleString := 'stx'.
  3377 	moduleString := 'stx'.
  3364     ].
  3378     ].
  3365     directoryString isEmpty ifTrue:[
  3379     directoryString isEmpty ifTrue:[
  3366         directoryString := libraryString.
  3380 	directoryString := libraryString.
  3367     ].
  3381     ].
  3368 
  3382 
  3369     ^ IdentityDictionary
  3383     ^ IdentityDictionary
  3370         with:(#module->moduleString)
  3384 	with:(#module->moduleString)
  3371         with:(#directory->directoryString)
  3385 	with:(#directory->directoryString)
  3372         with:(#library->libraryString)
  3386 	with:(#library->libraryString)
  3373 
  3387 
  3374     "
  3388     "
  3375      Object packageSourceCodeInfo     
  3389      Object packageSourceCodeInfo     
  3376      View packageSourceCodeInfo    
  3390      View packageSourceCodeInfo    
  3377      Model packageSourceCodeInfo  
  3391      Model packageSourceCodeInfo  
  3395 
  3409 
  3396     |info|
  3410     |info|
  3397 
  3411 
  3398     info := self revisionInfo.
  3412     info := self revisionInfo.
  3399     info notNil ifTrue:[
  3413     info notNil ifTrue:[
  3400         ^ info at:#revision ifAbsent:nil
  3414 	^ info at:#revision ifAbsent:nil
  3401     ].
  3415     ].
  3402     ^ self binaryRevision
  3416     ^ self binaryRevision
  3403 
  3417 
  3404     "
  3418     "
  3405      Object revision 
  3419      Object revision 
  3416 
  3430 
  3417     |info|
  3431     |info|
  3418 
  3432 
  3419     info := self revisionInfo.
  3433     info := self revisionInfo.
  3420     info notNil ifTrue:[
  3434     info notNil ifTrue:[
  3421         ^ info at:#date ifAbsent:'??/??/??'
  3435 	^ info at:#date ifAbsent:'??/??/??'
  3422     ].
  3436     ].
  3423     ^ '??/??/??'
  3437     ^ '??/??/??'
  3424 
  3438 
  3425     "
  3439     "
  3426      Object revisionDateString 
  3440      Object revisionDateString 
  3431 
  3445 
  3432 revisionInfo
  3446 revisionInfo
  3433     "return a dictionary filled with revision info.
  3447     "return a dictionary filled with revision info.
  3434      This extracts the relevant info from the revisionString.
  3448      This extracts the relevant info from the revisionString.
  3435      The revisionInfo contains all or a subset of:
  3449      The revisionInfo contains all or a subset of:
  3436         #binaryRevision - the revision upon which the binary of this class is based
  3450 	#binaryRevision - the revision upon which the binary of this class is based
  3437         #revision       - the revision upon which the class is based logically
  3451 	#revision       - the revision upon which the class is based logically
  3438                           (different, if a changed class was checked in, but not yet recompiled)
  3452 			  (different, if a changed class was checked in, but not yet recompiled)
  3439         #user           - the user who checked in the logical revision
  3453 	#user           - the user who checked in the logical revision
  3440         #date           - the date when the logical revision was checked in
  3454 	#date           - the date when the logical revision was checked in
  3441         #time           - the time when the logical revision was checked in
  3455 	#time           - the time when the logical revision was checked in
  3442         #fileName       - the classes source file name
  3456 	#fileName       - the classes source file name
  3443         #repositoryPath - the classes source container
  3457 	#repositoryPath - the classes source container
  3444     "
  3458     "
  3445 
  3459 
  3446     |vsnString info mgr|
  3460     |vsnString info mgr|
  3447 
  3461 
  3448     vsnString := self revisionString.
  3462     vsnString := self revisionString.
  3449     vsnString notNil ifTrue:[
  3463     vsnString notNil ifTrue:[
  3450         mgr := self sourceCodeManager.
  3464 	mgr := self sourceCodeManager.
  3451         mgr notNil ifTrue:[
  3465 	mgr notNil ifTrue:[
  3452             info := mgr revisionInfoFromString:vsnString
  3466 	    info := mgr revisionInfoFromString:vsnString
  3453         ] ifFalse:[
  3467 	] ifFalse:[
  3454             info := Class revisionInfoFromString:vsnString.
  3468 	    info := Class revisionInfoFromString:vsnString.
  3455         ].
  3469 	].
  3456         info notNil ifTrue:[
  3470 	info notNil ifTrue:[
  3457             info at:#binaryRevision put:self binaryRevision.
  3471 	    info at:#binaryRevision put:self binaryRevision.
  3458         ]
  3472 	]
  3459     ].
  3473     ].
  3460     ^ info
  3474     ^ info
  3461 
  3475 
  3462     "
  3476     "
  3463      Object revisionString 
  3477      Object revisionString 
  3484     (owner := self owningClass) notNil ifTrue:[^ owner revisionString].
  3498     (owner := self owningClass) notNil ifTrue:[^ owner revisionString].
  3485 
  3499 
  3486     thisContext isRecursive ifTrue:[^ nil ].
  3500     thisContext isRecursive ifTrue:[^ nil ].
  3487 
  3501 
  3488     self isMeta ifTrue:[
  3502     self isMeta ifTrue:[
  3489         meta := self. cls := self soleInstance
  3503 	meta := self. cls := self soleInstance
  3490     ] ifFalse:[
  3504     ] ifFalse:[
  3491         cls := self. meta := self class
  3505 	cls := self. meta := self class
  3492     ].
  3506     ].
  3493 
  3507 
  3494     m := meta compiledMethodAt:#version.
  3508     m := meta compiledMethodAt:#version.
  3495     m isNil ifTrue:[
  3509     m isNil ifTrue:[
  3496         m := cls compiledMethodAt:#version.
  3510 	m := cls compiledMethodAt:#version.
  3497         m isNil ifTrue:[^ nil].
  3511 	m isNil ifTrue:[^ nil].
  3498     ].
  3512     ].
  3499 
  3513 
  3500     m isExecutable ifTrue:[
  3514     m isExecutable ifTrue:[
  3501         "/
  3515 	"/
  3502         "/ if its a method returning the string,
  3516 	"/ if its a method returning the string,
  3503         "/ thats the returned value
  3517 	"/ thats the returned value
  3504         "/
  3518 	"/
  3505         val := cls version.
  3519 	val := cls version.
  3506         val isString ifTrue:[^ val].
  3520 	val isString ifTrue:[^ val].
  3507     ].
  3521     ].
  3508 
  3522 
  3509     "/
  3523     "/
  3510     "/ if its a method consisting of a comment only
  3524     "/ if its a method consisting of a comment only
  3511     "/ extract it - this may lead to a recursive call
  3525     "/ extract it - this may lead to a recursive call
  3517     src isNil ifTrue:[^ nil].
  3531     src isNil ifTrue:[^ nil].
  3518     ^ Class revisionStringFromSource:src 
  3532     ^ Class revisionStringFromSource:src 
  3519 
  3533 
  3520     "
  3534     "
  3521      Smalltalk allClassesDo:[:cls |
  3535      Smalltalk allClassesDo:[:cls |
  3522         Transcript showCR:cls revisionString
  3536 	Transcript showCR:cls revisionString
  3523      ].
  3537      ].
  3524 
  3538 
  3525      Number revisionString  
  3539      Number revisionString  
  3526      FileDirectory revisionString
  3540      FileDirectory revisionString
  3527      Metaclass revisionString
  3541      Metaclass revisionString
  3555 
  3569 
  3556     self owningClass notNil ifTrue:[^ self].
  3570     self owningClass notNil ifTrue:[^ self].
  3557 
  3571 
  3558     mgr := self sourceCodeManager.
  3572     mgr := self sourceCodeManager.
  3559     mgr notNil ifTrue:[
  3573     mgr notNil ifTrue:[
  3560         info := mgr sourceInfoOfClass:self
  3574 	info := mgr sourceInfoOfClass:self
  3561     ].
  3575     ].
  3562 
  3576 
  3563     info notNil ifTrue:[
  3577     info notNil ifTrue:[
  3564         mod := info at:#module ifAbsent:nil.    "/ stx, aeg, <your-organization>
  3578 	mod := info at:#module ifAbsent:nil.    "/ stx, aeg, <your-organization>
  3565         dir := info at:#directory ifAbsent:nil. "/ libbasic, libtool ...
  3579 	dir := info at:#directory ifAbsent:nil. "/ libbasic, libtool ...
  3566         lib := info at:#library ifAbsent:dir.
  3580 	lib := info at:#library ifAbsent:dir.
  3567 
  3581 
  3568         p := ''.
  3582 	p := ''.
  3569         mod notNil ifTrue:[
  3583 	mod notNil ifTrue:[
  3570             mod ~= 'stx' ifTrue:[
  3584 	    mod ~= 'stx' ifTrue:[
  3571                 p := p , mod
  3585 		p := p , mod
  3572             ]
  3586 	    ]
  3573         ].
  3587 	].
  3574         dir notNil ifTrue:[
  3588 	dir notNil ifTrue:[
  3575             p notEmpty ifTrue:[p := p , ':'].
  3589 	    p notEmpty ifTrue:[p := p , ':'].
  3576             p := p , dir.
  3590 	    p := p , dir.
  3577         ].
  3591 	].
  3578         lib notNil ifTrue:[
  3592 	lib notNil ifTrue:[
  3579             lib ~= dir ifTrue:[
  3593 	    lib ~= dir ifTrue:[
  3580                 p notEmpty ifTrue:[p := p , ':'].
  3594 		p notEmpty ifTrue:[p := p , ':'].
  3581                 p := p , lib.
  3595 		p := p , lib.
  3582             ]
  3596 	    ]
  3583         ].
  3597 	].
  3584         (p notEmpty and:[p ~= package]) ifTrue:[
  3598 	(p notEmpty and:[p ~= package]) ifTrue:[
  3585 "/            package notNil ifTrue:[
  3599 "/            package notNil ifTrue:[
  3586 "/                (name , ': changing packageID from ''' , package , ''' to ''' , p , '''') infoPrintCR.
  3600 "/                (name , ': changing packageID from ''' , package , ''' to ''' , p , '''') infoPrintCR.
  3587 "/            ].
  3601 "/            ].
  3588             package := p.
  3602 	    package := p.
  3589 
  3603 
  3590             self methodDictionary do:[:aMethod |
  3604 	    self methodDictionary do:[:aMethod |
  3591                 aMethod package isNil ifTrue:[
  3605 		aMethod package isNil ifTrue:[
  3592                     aMethod package:p
  3606 		    aMethod package:p
  3593                 ]
  3607 		]
  3594             ]
  3608 	    ]
  3595         ].
  3609 	].
  3596     ].
  3610     ].
  3597     ^ self
  3611     ^ self
  3598 
  3612 
  3599     "
  3613     "
  3600      MemoryMonitor autoload.
  3614      MemoryMonitor autoload.
  3611     |owner source|
  3625     |owner source|
  3612 
  3626 
  3613     (owner := self owningClass) notNil ifTrue:[^ owner sourceStream].
  3627     (owner := self owningClass) notNil ifTrue:[^ owner sourceStream].
  3614 
  3628 
  3615     classFilename notNil ifTrue:[
  3629     classFilename notNil ifTrue:[
  3616         source := classFilename
  3630 	source := classFilename
  3617     ] ifFalse:[
  3631     ] ifFalse:[
  3618         source := (Smalltalk fileNameForClass:self) , '.st'
  3632 	source := (Smalltalk fileNameForClass:self) , '.st'
  3619     ].
  3633     ].
  3620     ^ self sourceStreamFor:source
  3634     ^ self sourceStreamFor:source
  3621 
  3635 
  3622     "Modified: 15.10.1996 / 18:59:40 / cg"
  3636     "Modified: 15.10.1996 / 18:59:40 / cg"
  3623     "Modified: 1.4.1997 / 14:33:12 / stefan"
  3637     "Modified: 1.4.1997 / 14:33:12 / stefan"
  3640     or:[TryLocalSourceFirst == true]) ifTrue:[
  3654     or:[TryLocalSourceFirst == true]) ifTrue:[
  3641 	aStream := self localSourceStreamFor:source.
  3655 	aStream := self localSourceStreamFor:source.
  3642     ].
  3656     ].
  3643 
  3657 
  3644     aStream isNil ifTrue:[
  3658     aStream isNil ifTrue:[
  3645         "/      
  3659 	"/      
  3646         "/ hard case - there is no source file for this class
  3660 	"/ hard case - there is no source file for this class
  3647         "/ (in the source-dir-path).
  3661 	"/ (in the source-dir-path).
  3648         "/      
  3662 	"/      
  3649 
  3663 
  3650         "/      
  3664 	"/      
  3651         "/ look if my binary is from a dynamically loaded module,
  3665 	"/ look if my binary is from a dynamically loaded module,
  3652         "/ and, if so, look in the modules directory for the
  3666 	"/ and, if so, look in the modules directory for the
  3653         "/ source file.
  3667 	"/ source file.
  3654         "/      
  3668 	"/      
  3655         ObjectFileLoader notNil ifTrue:[
  3669 	ObjectFileLoader notNil ifTrue:[
  3656             ObjectFileLoader loadedObjectHandlesDo:[:h |
  3670 	    ObjectFileLoader loadedObjectHandlesDo:[:h |
  3657                 |f classes|
  3671 		|f classes|
  3658 
  3672 
  3659                 aStream isNil ifTrue:[
  3673 		aStream isNil ifTrue:[
  3660                     (classes := h classes) notNil ifTrue:[
  3674 		    (classes := h classes) notNil ifTrue:[
  3661                         (classes includes:self) ifTrue:[
  3675 			(classes includes:self) ifTrue:[
  3662                             f := h pathName.
  3676 			    f := h pathName.
  3663                             f := f asFilename directory.
  3677 			    f := f asFilename directory.
  3664                             f := f construct:source.
  3678 			    f := f construct:source.
  3665                             f exists ifTrue:[
  3679 			    f exists ifTrue:[
  3666                                 aStream := f readStream.
  3680 				aStream := f readStream.
  3667                             ].
  3681 			    ].
  3668                         ].
  3682 			].
  3669                     ].
  3683 		    ].
  3670                 ]
  3684 		]
  3671             ].
  3685 	    ].
  3672         ].
  3686 	].
  3673     ].
  3687     ].
  3674 
  3688 
  3675     aStream isNil ifTrue:[
  3689     aStream isNil ifTrue:[
  3676 
  3690 
  3677         "/ mhmh - still no source file.
  3691 	"/ mhmh - still no source file.
  3678         "/ If there is a SourceCodeManager, ask it to aquire the
  3692 	"/ If there is a SourceCodeManager, ask it to aquire the
  3679         "/ the source for my class, and return an open stream on it. 
  3693 	"/ the source for my class, and return an open stream on it. 
  3680         "/ if that one does not know about the source, look in
  3694 	"/ if that one does not know about the source, look in
  3681         "/ standard places
  3695 	"/ standard places
  3682 
  3696 
  3683         mgr notNil ifTrue:[
  3697 	mgr notNil ifTrue:[
  3684             aStream := mgr getSourceStreamFor:self.
  3698 	    aStream := mgr getSourceStreamFor:self.
  3685             aStream notNil ifTrue:[
  3699 	    aStream notNil ifTrue:[
  3686                 (self validateSourceStream:aStream) ifFalse:[
  3700 		(self validateSourceStream:aStream) ifFalse:[
  3687                     ('Class [info]: repositories source for `' 
  3701 		    ('Class [info]: repositories source for `' 
  3688                      , (self isMeta ifTrue:[self soleInstance name]
  3702 		     , (self isMeta ifTrue:[self soleInstance name]
  3689                                     ifFalse:[name])
  3703 				    ifFalse:[name])
  3690                      , ''' is invalid.') infoPrintCR.
  3704 		     , ''' is invalid.') infoPrintCR.
  3691                     aStream close.
  3705 		    aStream close.
  3692                     aStream := nil
  3706 		    aStream := nil
  3693                 ] ifTrue:[
  3707 		] ifTrue:[
  3694                     validated := true.
  3708 		    validated := true.
  3695                 ].
  3709 		].
  3696             ].
  3710 	    ].
  3697 
  3711 
  3698             aStream isNil ifTrue:[
  3712 	    aStream isNil ifTrue:[
  3699 		aStream := self localSourceStreamFor:source.
  3713 		aStream := self localSourceStreamFor:source.
  3700             ].
  3714 	    ].
  3701         ].
  3715 	].
  3702 
  3716 
  3703         "/
  3717 	"/
  3704         "/ final chance: try current directory
  3718 	"/ final chance: try current directory
  3705         "/
  3719 	"/
  3706         aStream isNil ifTrue:[
  3720 	aStream isNil ifTrue:[
  3707             aStream := source asFilename readStream.
  3721 	    aStream := source asFilename readStream.
  3708         ].
  3722 	].
  3709     ].
  3723     ].
  3710 
  3724 
  3711     (aStream notNil and:[validated not]) ifTrue:[
  3725     (aStream notNil and:[validated not]) ifTrue:[
  3712         (self validateSourceStream:aStream) ifFalse:[
  3726 	(self validateSourceStream:aStream) ifFalse:[
  3713             ('Class [warning]: source for ''' , self name , ''' is invalid. Take care.') errorPrintCR
  3727 	    ('Class [warning]: source for ''' , self name , ''' is invalid. Take care.') errorPrintCR
  3714         ].
  3728 	].
  3715     ].
  3729     ].
  3716     ^ aStream
  3730     ^ aStream
  3717 
  3731 
  3718     "
  3732     "
  3719      Object sourceStream
  3733      Object sourceStream
  3733 
  3747 
  3734     |cls "vs m mgr"|
  3748     |cls "vs m mgr"|
  3735 
  3749 
  3736     cls := self.
  3750     cls := self.
  3737     self isMeta ifFalse:[
  3751     self isMeta ifFalse:[
  3738         cls := self class
  3752 	cls := self class
  3739     ].
  3753     ].
  3740 
  3754 
  3741 "/    m := cls compiledMethodAt:#version.
  3755 "/    m := cls compiledMethodAt:#version.
  3742 "/    m isNil ifTrue:[^ false].
  3756 "/    m isNil ifTrue:[^ false].
  3743 "/    vs := self revisionString.
  3757 "/    vs := self revisionString.
  3746 "/    (mgr := self sourceCodeManager) isNil ifTrue:[^ false].
  3760 "/    (mgr := self sourceCodeManager) isNil ifTrue:[^ false].
  3747 "/    newString := mgr updatedRevisionStringOf:cls forRevision:newRevision with:vs. 
  3761 "/    newString := mgr updatedRevisionStringOf:cls forRevision:newRevision with:vs. 
  3748 "/    newString isNil ifTrue:[^ false].
  3762 "/    newString isNil ifTrue:[^ false].
  3749 
  3763 
  3750     MethodRedefinitionSignal handle:[:ex |
  3764     MethodRedefinitionSignal handle:[:ex |
  3751         ex proceedWith:#keep 
  3765 	ex proceedWith:#keep 
  3752     ] do:[
  3766     ] do:[
  3753         Class withoutUpdatingChangesDo:[
  3767 	Class withoutUpdatingChangesDo:[
  3754             Compiler compile:'version
  3768 	    Compiler compile:'version
  3755     ^ ''' , newRevisionString , '''
  3769     ^ ''' , newRevisionString , '''
  3756 '
  3770 '
  3757                      forClass:cls 
  3771 		     forClass:cls 
  3758                      inCategory:#documentation 
  3772 		     inCategory:#documentation 
  3759                      notifying:nil 
  3773 		     notifying:nil 
  3760                      install:true 
  3774 		     install:true 
  3761                      skipIfSame:false 
  3775 		     skipIfSame:false 
  3762                      silent:true. 
  3776 		     silent:true. 
  3763         ]
  3777 	]
  3764     ].
  3778     ].
  3765 "/ ('updated to :' , newRevisionString) printNL.
  3779 "/ ('updated to :' , newRevisionString) printNL.
  3766 
  3780 
  3767     ^ true
  3781     ^ true
  3768 
  3782 
  3777 
  3791 
  3778     |cls meta cannotCheckReason versionMethod info
  3792     |cls meta cannotCheckReason versionMethod info
  3779      versionFromCode versionFromSource oldPos pos src rev|
  3793      versionFromCode versionFromSource oldPos pos src rev|
  3780 
  3794 
  3781     self isMeta ifTrue:[
  3795     self isMeta ifTrue:[
  3782         meta := self. cls := self soleInstance
  3796 	meta := self. cls := self soleInstance
  3783     ] ifFalse:[
  3797     ] ifFalse:[
  3784         cls := self. meta := self class
  3798 	cls := self. meta := self class
  3785     ].
  3799     ].
  3786 
  3800 
  3787     cannotCheckReason := nil.
  3801     cannotCheckReason := nil.
  3788 
  3802 
  3789     versionMethod := meta compiledMethodAt:#version.
  3803     versionMethod := meta compiledMethodAt:#version.
  3790     (versionMethod isNil 
  3804     (versionMethod isNil 
  3791     or:[versionMethod isExecutable not]) ifTrue:[
  3805     or:[versionMethod isExecutable not]) ifTrue:[
  3792         versionMethod := cls compiledMethodAt:#version.
  3806 	versionMethod := cls compiledMethodAt:#version.
  3793         (versionMethod isNil
  3807 	(versionMethod isNil
  3794         or:[versionMethod isExecutable not]) ifTrue:[
  3808 	or:[versionMethod isExecutable not]) ifTrue:[
  3795             cannotCheckReason := 'no valid version method'.
  3809 	    cannotCheckReason := 'no valid version method'.
  3796         ]
  3810 	]
  3797     ] ifFalse:[
  3811     ] ifFalse:[
  3798         "/
  3812 	"/
  3799         "/ if its a method returning the string,
  3813 	"/ if its a method returning the string,
  3800         "/ thats the returned value
  3814 	"/ thats the returned value
  3801         "/
  3815 	"/
  3802         versionFromCode := cls version.
  3816 	versionFromCode := cls version.
  3803         versionFromCode isString ifFalse:[
  3817 	versionFromCode isString ifFalse:[
  3804             cannotCheckReason := 'version method does not return a string'
  3818 	    cannotCheckReason := 'version method does not return a string'
  3805         ].
  3819 	].
  3806     ].
  3820     ].
  3807 
  3821 
  3808     "/
  3822     "/
  3809     "/ if its a method consisting of a comment only
  3823     "/ if its a method consisting of a comment only
  3810     "/ extract it - this may lead to a recursive call
  3824     "/ extract it - this may lead to a recursive call
  3811     "/ to myself (thats what the #isRecursive is for)
  3825     "/ to myself (thats what the #isRecursive is for)
  3812     "/ in case we need to access the source code manager
  3826     "/ in case we need to access the source code manager
  3813     "/ for the source ...
  3827     "/ for the source ...
  3814     "/
  3828     "/
  3815     versionMethod notNil ifTrue:[
  3829     versionMethod notNil ifTrue:[
  3816         pos := versionMethod sourcePosition.
  3830 	pos := versionMethod sourcePosition.
  3817         pos isInteger ifFalse:[
  3831 	pos isInteger ifFalse:[
  3818             "/ mhmh - either no version method,
  3832 	    "/ mhmh - either no version method,
  3819             "/ or updated due to a checkin.
  3833 	    "/ or updated due to a checkin.
  3820             "/ in any case, this should be a good source.
  3834 	    "/ in any case, this should be a good source.
  3821 
  3835 
  3822             ^ true.
  3836 	    ^ true.
  3823             "/ cannotCheckReason := 'no source position for version-method'
  3837 	    "/ cannotCheckReason := 'no source position for version-method'
  3824         ]
  3838 	]
  3825     ].
  3839     ].
  3826 
  3840 
  3827     cannotCheckReason notNil ifTrue:[
  3841     cannotCheckReason notNil ifTrue:[
  3828         ('Class [warning]: ' , cannotCheckReason) errorPrintCR.
  3842 	('Class [warning]: ' , cannotCheckReason) errorPrintCR.
  3829         'Class [info]: cannot validate source; trusting source' infoPrintCR.
  3843 	'Class [info]: cannot validate source; trusting source' infoPrintCR.
  3830         ^ true
  3844 	^ true
  3831     ].
  3845     ].
  3832 
  3846 
  3833     oldPos := aStream position.
  3847     oldPos := aStream position.
  3834     aStream position:pos.
  3848     aStream position:pos.
  3835     src := aStream nextChunk.
  3849     src := aStream nextChunk.
  3836     aStream position:oldPos.
  3850     aStream position:oldPos.
  3837 
  3851 
  3838     (src isNil or:[src isEmpty]) ifTrue:[
  3852     (src isNil or:[src isEmpty]) ifTrue:[
  3839 "/ 'empty source for version-method' printCR.
  3853 "/ 'empty source for version-method' printCR.
  3840         ^ false
  3854 	^ false
  3841     ].
  3855     ].
  3842 
  3856 
  3843     versionFromSource := Class revisionStringFromSource:src.
  3857     versionFromSource := Class revisionStringFromSource:src.
  3844     versionFromSource = versionFromCode ifTrue:[^ true].
  3858     versionFromSource = versionFromCode ifTrue:[^ true].
  3845 
  3859 
  3847 
  3861 
  3848     "/ mhmh - check my binary version ...
  3862     "/ mhmh - check my binary version ...
  3849 
  3863 
  3850     info := Class revisionInfoFromString:versionFromSource.
  3864     info := Class revisionInfoFromString:versionFromSource.
  3851     info notNil ifTrue:[
  3865     info notNil ifTrue:[
  3852         rev := info at:#revision.
  3866 	rev := info at:#revision.
  3853         rev = self binaryRevision ifTrue:[^ true].
  3867 	rev = self binaryRevision ifTrue:[^ true].
  3854     ].
  3868     ].
  3855     ^ false
  3869     ^ false
  3856 
  3870 
  3857     "Modified: 13.4.1997 / 02:18:09 / cg"
  3871     "Modified: 13.4.1997 / 02:18:09 / cg"
  3858 ! !
  3872 ! !
  3871 ! !
  3885 ! !
  3872 
  3886 
  3873 !Class class methodsFor:'documentation'!
  3887 !Class class methodsFor:'documentation'!
  3874 
  3888 
  3875 version
  3889 version
  3876     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.297 1997-10-28 20:06:50 cg Exp $'
  3890     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.298 1998-01-12 13:23:21 cg Exp $'
  3877 ! !
  3891 ! !