1
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Behavior subclass:#ClassDescription
|
|
14 |
instanceVariableNames:'name category instvars'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Kernel-Classes'
|
|
18 |
!
|
|
19 |
|
|
20 |
ClassDescription comment:'
|
|
21 |
|
|
22 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
this class has been added for ST-80 compatibility only.
|
|
26 |
All class stuff used to be in Behavior and Class - but, to be
|
|
27 |
able to file in some PD code, it became nescessary to add it.
|
|
28 |
|
|
29 |
Instance variables:
|
|
30 |
|
|
31 |
name <String> the classes name
|
|
32 |
category <String> the classes category
|
|
33 |
instvars <String> the names of the instance variables
|
|
34 |
|
10
|
35 |
$Header: /cvs/stx/stx/libbasic/ClassDescription.st,v 1.4 1993-11-08 02:29:45 claus Exp $
|
1
|
36 |
'!
|
|
37 |
|
|
38 |
!ClassDescription methodsFor:'accessing'!
|
|
39 |
|
|
40 |
instanceVariableString
|
|
41 |
"return a string of the instance variable names"
|
|
42 |
|
|
43 |
instvars isNil ifTrue:[^ ''].
|
|
44 |
^ instvars
|
|
45 |
!
|
|
46 |
|
|
47 |
instanceVariableString:aString
|
|
48 |
"set the classes instvarnames string - notice, that this
|
|
49 |
should be used only during class creation; the number of
|
|
50 |
instance variables is determined by another instance
|
|
51 |
(see Behavior)."
|
|
52 |
|
|
53 |
instvars := aString.
|
|
54 |
self changed
|
|
55 |
!
|
|
56 |
|
10
|
57 |
instVarNames
|
|
58 |
"return a collection of the instance variable name-strings"
|
|
59 |
|
|
60 |
instvars isNil ifTrue:[
|
|
61 |
^ OrderedCollection new
|
|
62 |
].
|
|
63 |
^ instvars asCollectionOfWords
|
|
64 |
!
|
|
65 |
|
|
66 |
allInstVarNames
|
|
67 |
"return a collection of all the instance variable name-strings
|
|
68 |
this includes all superclass-instance variables"
|
|
69 |
|
|
70 |
^ self addAllInstVarNamesTo:(OrderedCollection new)
|
|
71 |
!
|
|
72 |
|
|
73 |
|
1
|
74 |
setName:aString
|
|
75 |
"set the classes name - be careful, it will be still
|
|
76 |
in the Smalltalk dictionary - under another key"
|
|
77 |
|
|
78 |
name := aString
|
|
79 |
!
|
|
80 |
|
|
81 |
name
|
|
82 |
"return the name (aString) of the class"
|
|
83 |
|
|
84 |
^ name
|
|
85 |
!
|
|
86 |
|
|
87 |
category
|
|
88 |
"return the category (aString) of the class"
|
|
89 |
|
|
90 |
^ category
|
|
91 |
!
|
|
92 |
|
|
93 |
category:aStringOrSymbol
|
|
94 |
"set the category of the class to be the argument, aString"
|
|
95 |
|
|
96 |
category := aStringOrSymbol asSymbol
|
|
97 |
! !
|
10
|
98 |
|
|
99 |
!ClassDescription methodsFor:'renaming'!
|
|
100 |
|
|
101 |
renameTo:newName
|
|
102 |
"change the name of the class - this writes a change record"
|
|
103 |
|
|
104 |
|oldName oldSym|
|
|
105 |
|
|
106 |
oldName := name.
|
|
107 |
oldSym := name asSymbol.
|
|
108 |
self setName:newName.
|
|
109 |
|
|
110 |
Smalltalk at:oldSym put:nil.
|
|
111 |
Smalltalk removeKey:oldSym. "26.jun 93"
|
|
112 |
Smalltalk at:(newName asSymbol) put:self.
|
|
113 |
! !
|
|
114 |
|
|
115 |
!ClassDescription methodsFor:'private'!
|
|
116 |
|
|
117 |
addAllInstVarNamesTo:aCollection
|
|
118 |
"helper - add the name-strings of the instance variables and of the inst-vars
|
|
119 |
of all superclasses to the argument, aCollection. Return aCollection"
|
|
120 |
|
|
121 |
(superclass notNil) ifTrue:[
|
|
122 |
superclass addAllInstVarNamesTo:aCollection
|
|
123 |
].
|
|
124 |
instvars notNil ifTrue:[
|
|
125 |
aCollection addAll:(instvars asCollectionOfWords).
|
|
126 |
].
|
|
127 |
^ aCollection
|
|
128 |
! !
|