--- a/Class.st Tue Feb 15 15:33:34 1994 +0100
+++ b/Class.st Fri Feb 25 13:58:55 1994 +0100
@@ -45,7 +45,7 @@
WARNING: layout known by compiler and runtime system
-$Header: /cvs/stx/stx/libbasic/Class.st,v 1.9 1994-02-05 12:18:46 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Class.st,v 1.10 1994-02-25 12:55:33 claus Exp $
written Spring 89 by claus
'!
@@ -194,7 +194,7 @@
changed:false
!
-variableWordSubclass:t instanceVariableNames:f lassVariableNames:d oolDictionaries:s ategory:cat
+variableWordSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
"create a new class as a subclass of an existing class (the receiver)
in which the subclass has indexable word-sized nonpointer variables"
@@ -496,11 +496,11 @@
to be flushed is info for myself and all of my subclasses)"
"
problem: this is slower; since looking for all subclasses is (currently)
- a bit slow :-(
+ a bit slow :-(
self withAllSubclassesDo:[:aClass |
- ObjectMemory flushInlineCachesFor:aClass withArgs:nargs.
- ObjectMemory flushMethodCacheFor:aClass
+ ObjectMemory flushInlineCachesFor:aClass withArgs:nargs.
+ ObjectMemory flushMethodCacheFor:aClass
].
"
@@ -895,126 +895,6 @@
!Class methodsFor:'fileOut'!
-printClassNameOn:aStream
- "helper for fileOut - print my name if I am not a Metaclass;
- otherwise my name without -class followed by space-class"
-
- (self isMeta "isMemberOf:Metaclass") ifTrue:[
- aStream nextPutAll:(name copyFrom:1 to:(name size - 5)).
- aStream nextPutAll:' class'
- ] ifFalse:[
- name printOn:aStream
- ]
-!
-
-printNameArray:anArray on:aStream indent:indent
- "print an array of strings separated by spaces; when the stream
- defines a lineLength, break when this limit is reached; indent
- every line; used to printOut instanve variable names"
-
- |thisName nextName arraySize lenMax pos mustBreak line spaces|
-
- arraySize := 0.
- anArray notNil ifTrue:[
- arraySize := anArray size
- ].
- arraySize ~~ 0 ifTrue:[
- pos := indent.
- lenMax := aStream lineLength.
- thisName := anArray at:1.
- line := ''.
- 1 to:arraySize do:[:index |
- line := line , thisName.
- pos := pos + thisName size.
- (index == arraySize) ifFalse:[
- nextName := anArray at:(index + 1).
- mustBreak := false.
- (lenMax > 0) ifTrue:[
- ((pos + nextName size) > lenMax) ifTrue:[
- mustBreak := true
- ]
- ].
- mustBreak ifTrue:[
- aStream nextPutAll:line.
- aStream cr.
- spaces isNil ifTrue:[
- spaces := String new:indent
- ].
- line := spaces.
- pos := indent
- ] ifFalse:[
- line := line , ' '.
- pos := pos + 1
- ].
- thisName := nextName
- ]
- ].
- aStream nextPutAll:line
- ]
-!
-
-printClassVarNamesOn:aStream indent:indent
- "print the class variable names indented and breaking at line end"
-
- self printNameArray:(self classVarNames) on:aStream indent:indent
-!
-
-printInstVarNamesOn:aStream indent:indent
- "print the instance variable names indented and breaking at line end"
-
- self printNameArray:(self instVarNames) on:aStream indent:indent
-!
-
-printHierarchyOn:aStream
- "print my class hierarchy on aStream"
-
- self printHierarchyAnswerIndentOn:aStream
-!
-
-printHierarchyAnswerIndentOn:aStream
- "print my class hierarchy on aStream - return indent
- recursively calls itself to print superclass and use returned indent
- for my description - used in the browser"
-
- |indent|
-
- indent := 0.
- (superclass notNil) ifTrue:[
- indent := (superclass printHierarchyAnswerIndentOn:aStream) + 2
- ].
- aStream nextPutAll:(String new:indent).
- aStream nextPutAll:name.
- aStream nextPutAll:' ('.
- self printInstVarNamesOn:aStream indent:(indent + name size + 2).
- aStream nextPutAll:')'.
- aStream cr.
- ^ indent
-!
-
-printFullHierarchyOn:aStream indent:indent
- "print myself and all subclasses on aStream.
- recursively calls itself to print subclasses.
- Can be used to print hierarchy on the printer."
-
- aStream nextPutAll:(String new:indent).
- aStream bold.
- aStream nextPutAll:name.
- aStream normal.
- aStream nextPutAll:' ('.
- self printInstVarNamesOn:aStream indent:(indent + name size + 2).
- aStream nextPutAll:')'.
- aStream cr.
-
- (self subclasses sort:[:a :b | a name < b name]) do:[:aSubclass |
- aSubclass printFullHierarchyOn:aStream indent:(indent + 2)
- ]
-
- "|printStream|
- printStream := Printer new.
- Object printFullHierarchyOn:printStream indent:0.
- printStream close"
-!
-
fileOutCommentOn:aStream
"print an expression on aStream to define my comment"
@@ -1214,24 +1094,36 @@
!
fileOutCategory:aCategory
- "create a file 'class-category.st' consisting of all methods in aCategory"
+ "create a file 'class-category.st' consisting of all methods in aCategory.
+ If the current project is not nil, create the file in the projects
+ directory."
- |aStream fileName|
+ |aStream fileName project|
fileName := name , '-' , aCategory , '.st'.
+ project := Project current.
+ project notNil ifTrue:[
+ fileName := project directory , Filename separator asString , fileName.
+ ].
aStream := FileStream newFileNamed:fileName.
self fileOutCategory:aCategory on:aStream.
aStream close
!
fileOutMethod:aMethod
- "create a file 'class-method.st' consisting of the method, aMethod"
+ "create a file 'class-method.st' consisting of the method, aMethod.
+ If the current project is not nil, create the file in the projects
+ directory."
- |aStream fileName selector|
+ |aStream fileName selector project|
selector := self selectorForMethod:aMethod.
selector notNil ifTrue:[
fileName := name , '-' , selector, '.st'.
+ project := Project current.
+ project notNil ifTrue:[
+ fileName := project directory , Filename separator asString , fileName.
+ ].
aStream := FileStream newFileNamed:fileName.
self fileOutMethod:aMethod on:aStream.
aStream close
@@ -1239,11 +1131,17 @@
!
fileOut
- "create a file 'class.st' consisting of all methods in myself"
+ "create a file 'class.st' consisting of all methods in myself.
+ If the current project is not nil, create the file in the projects
+ directory."
- |aStream fileName|
+ |aStream fileName project|
fileName := (Smalltalk fileNameForClass:self name) , '.st'.
+ project := Project current.
+ project notNil ifTrue:[
+ fileName := project directory , Filename separator asString , fileName.
+ ].
aStream := FileStream newFileNamed:fileName.
aStream isNil ifTrue:[
^ self error:('cannot create source file:', fileName)
@@ -1258,7 +1156,7 @@
|aStream fileName|
- fileName := (Smalltalk fileNameForClass:self) , '.st'.
+ fileName := (Smalltalk fileNameForClass:self name) , '.st'.
aStream := FileStream newFileNamed:fileName
in:aFileDirectory.
aStream isNil ifTrue:[
@@ -1266,7 +1164,9 @@
].
self fileOutOn:aStream.
aStream close
-!
+! !
+
+!Class methodsFor:'obsolete binary fileOut'!
binaryFileOutMethodsOn:aStream
"binary file out all methods onto aStream"
@@ -1333,11 +1233,17 @@
!
binaryFileOut
- "create a file 'class.sb' consisting of all methods in myself"
+ "create a file 'class.sb' consisting of all methods in myself.
+ If the current project is not nil, create the file in the projects
+ directory."
- |aStream fileName|
+ |aStream fileName project|
fileName := (Smalltalk fileNameForClass:self name) , '.sb'.
+ project := Project current.
+ project notNil ifTrue:[
+ fileName := project directory , Filename separator asString , fileName.
+ ].
aStream := FileStream newFileNamed:fileName.
aStream isNil ifTrue:[
^ self error:('cannot create class file:', fileName)
@@ -1348,6 +1254,123 @@
!Class methodsFor:'printOut'!
+printClassNameOn:aStream
+ "helper for fileOut - print my name if I am not a Metaclass;
+ otherwise my name without -class followed by space-class"
+
+ self isMeta ifTrue:[
+ aStream nextPutAll:(name copyTo:(name size - 5)).
+ aStream nextPutAll:' class'
+ ] ifFalse:[
+ name printOn:aStream
+ ]
+!
+
+printNameArray:anArray on:aStream indent:indent
+ "print an array of strings separated by spaces; when the stream
+ defines a lineLength, break when this limit is reached; indent
+ every line; used to printOut instanve variable names"
+
+ |thisName nextName arraySize lenMax pos mustBreak line spaces|
+
+ arraySize := anArray size.
+ arraySize ~~ 0 ifTrue:[
+ pos := indent.
+ lenMax := aStream lineLength.
+ thisName := anArray at:1.
+ line := ''.
+ 1 to:arraySize do:[:index |
+ line := line , thisName.
+ pos := pos + thisName size.
+ (index == arraySize) ifFalse:[
+ nextName := anArray at:(index + 1).
+ mustBreak := false.
+ (lenMax > 0) ifTrue:[
+ ((pos + nextName size) > lenMax) ifTrue:[
+ mustBreak := true
+ ]
+ ].
+ mustBreak ifTrue:[
+ aStream nextPutAll:line.
+ aStream cr.
+ spaces isNil ifTrue:[
+ spaces := String new:indent
+ ].
+ line := spaces.
+ pos := indent
+ ] ifFalse:[
+ line := line , ' '.
+ pos := pos + 1
+ ].
+ thisName := nextName
+ ]
+ ].
+ aStream nextPutAll:line
+ ]
+!
+
+printClassVarNamesOn:aStream indent:indent
+ "print the class variable names indented and breaking at line end"
+
+ self printNameArray:(self classVarNames) on:aStream indent:indent
+!
+
+printInstVarNamesOn:aStream indent:indent
+ "print the instance variable names indented and breaking at line end"
+
+ self printNameArray:(self instVarNames) on:aStream indent:indent
+!
+
+printHierarchyOn:aStream
+ "print my class hierarchy on aStream"
+
+ self printHierarchyAnswerIndentOn:aStream
+!
+
+printHierarchyAnswerIndentOn:aStream
+ "print my class hierarchy on aStream - return indent
+ recursively calls itself to print superclass and use returned indent
+ for my description - used in the browser"
+
+ |indent|
+
+ indent := 0.
+ (superclass notNil) ifTrue:[
+ indent := (superclass printHierarchyAnswerIndentOn:aStream) + 2
+ ].
+ aStream spaces:indent.
+ aStream nextPutAll:name.
+ aStream nextPutAll:' ('.
+ self printInstVarNamesOn:aStream indent:(indent + name size + 2).
+ aStream nextPutAll:')'.
+ aStream cr.
+ ^ indent
+!
+
+printFullHierarchyOn:aStream indent:indent
+ "print myself and all subclasses on aStream.
+ recursively calls itself to print subclasses.
+ Can be used to print hierarchy on the printer."
+
+ aStream spaces:indent.
+ aStream bold.
+ aStream nextPutAll:name.
+ aStream normal.
+ aStream nextPutAll:' ('.
+ self printInstVarNamesOn:aStream indent:(indent + name size + 2).
+ aStream nextPutAll:')'.
+ aStream cr.
+
+ (self subclasses sort:[:a :b | a name < b name]) do:[:aSubclass |
+ aSubclass printFullHierarchyOn:aStream indent:(indent + 2)
+ ]
+
+ "|printStream|
+ printStream := Printer new.
+ Object printFullHierarchyOn:printStream indent:0.
+ printStream close"
+!
+
printOutDefinitionOn:aPrintStream
"print out my definition"
@@ -1529,6 +1552,7 @@
printOutCategoryProtocol:aCategory on:aPrintStream
|any|
+
methods notNil ifTrue:[
any := false.
methods do:[:aMethod |