author | Claus Gittinger <cg@exept.de> |
Thu, 07 Nov 1996 17:36:30 +0100 | |
changeset 1922 | 0f0e0c992fc0 |
parent 1921 | bfaa8f683985 |
child 1936 | 7c2d0ae1a76d |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 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 |
Class subclass:#Metaclass |
|
1047 | 14 |
instanceVariableNames:'myClass' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Kernel-Classes' |
|
1 | 18 |
! |
19 |
||
1742 | 20 |
!Metaclass class methodsFor:'documentation'! |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
21 |
|
88 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 25 |
All Rights Reserved |
1 | 26 |
|
88 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
621 | 34 |
! |
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
every classes class is a subclass of Metaclass. |
|
39 |
(i.e. every class is the sole instance of its Metaclass) |
|
40 |
Metaclass provides support for creating new (sub)classes and/or |
|
41 |
changing the definition of an already existing class. |
|
1292 | 42 |
|
43 |
[author:] |
|
44 |
Claus Gittinger |
|
1669 | 45 |
|
46 |
[see also:] |
|
47 |
Behavior ClassDescription Class |
|
621 | 48 |
" |
88 | 49 |
! ! |
1 | 50 |
|
1742 | 51 |
!Metaclass class methodsFor:'creating metaclasses'! |
356 | 52 |
|
53 |
new |
|
54 |
"creating a new metaclass - have to set the new classes |
|
55 |
flags correctly to have it behave like a metaclass ... |
|
56 |
Not for normal applications - creating new metaclasses is a very |
|
57 |
tricky thing; should be left to the gurus ;-)" |
|
58 |
||
59 |
|newMetaclass| |
|
60 |
||
61 |
newMetaclass := super new. |
|
62 |
newMetaclass instSize:(Class instSize). |
|
63 |
newMetaclass setSuperclass:Class. |
|
64 |
||
65 |
^ newMetaclass |
|
66 |
||
67 |
" |
|
68 |
Metaclass new <- new metaclass |
|
69 |
Metaclass new new <- new class |
|
70 |
Metaclass new new new <- new instance |
|
71 |
" |
|
72 |
! ! |
|
73 |
||
1742 | 74 |
!Metaclass class methodsFor:'queries'! |
1179
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
75 |
|
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
76 |
isBuiltInClass |
1266 | 77 |
"return true if this class is known by the run-time-system. |
78 |
Here, true is returned for myself, false for subclasses." |
|
79 |
||
1179
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
80 |
^ self == Metaclass class or:[self == Metaclass] |
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
81 |
|
1266 | 82 |
"Modified: 23.4.1996 / 15:59:44 / cg" |
1179
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
83 |
! ! |
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
84 |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
85 |
!Metaclass methodsFor:'accessing'! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
86 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
87 |
name |
1480
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
88 |
"return my name - that is the name of my sole class, with ' class' |
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
89 |
appended." |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
90 |
|
682
a10f434805a7
be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
91 |
|nm| |
a10f434805a7
be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
92 |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
93 |
myClass isNil ifTrue:[ |
1087 | 94 |
^ 'someMetaclass' |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
95 |
]. |
682
a10f434805a7
be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
96 |
|
a10f434805a7
be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
97 |
(nm := myClass name) isNil ifTrue:[ |
1087 | 98 |
'METACLASS: oops - no name in my class' errorPrintNL. |
99 |
name notNil ifTrue:[ |
|
100 |
^ name |
|
101 |
]. |
|
682
a10f434805a7
be somewhat more robust against bad classnames ...
Claus Gittinger <cg@exept.de>
parents:
657
diff
changeset
|
102 |
]. |
1480
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
103 |
^ nm , ' class' |
1087 | 104 |
|
105 |
"Modified: 7.3.1996 / 19:18:53 / cg" |
|
1480
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
106 |
"Modified: 19.6.1996 / 14:30:58 / stefan" |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
107 |
! ! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
108 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
109 |
!Metaclass methodsFor:'class instance variables'! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
110 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
111 |
instanceVariableNames:aString |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
112 |
"changing / adding class-inst vars - |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
113 |
this actually creates a new metaclass and class, leaving the original |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
114 |
classes around as obsolete classes. This may also be true for all subclasses, |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
115 |
if class instance variables are added/removed. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
116 |
Existing instances continue to be defined by their original classes. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
117 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
118 |
Time will show, if this is an acceptable behavior or if we should migrate |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
119 |
instances to become insts. of the new classes." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
120 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
121 |
|newClass newMetaclass nClassInstVars oldClass |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
122 |
allSubclasses oldVars |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
123 |
oldNames newNames addedNames |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
124 |
oldOffsets newOffsets offset changeSet delta |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
125 |
oldToNew newSubMeta newSub oldSubMeta oldSuper |
986 | 126 |
commonClassInstVars t| |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
127 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
128 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
129 |
cleanup needed here: extract common things with name:inEnvironment:... |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
130 |
and restructure things ... currently way too complex. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
131 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
132 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
133 |
oldVars := self instanceVariableString. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
134 |
aString = oldVars ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
135 |
" |
1416 | 136 |
Transcript showCR:'no change (', oldVars , ') -> (', aString , ')'. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
137 |
" |
1416 | 138 |
^ self |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
139 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
140 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
141 |
oldNames := oldVars asCollectionOfWords. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
142 |
newNames := aString asCollectionOfWords. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
143 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
144 |
oldNames = newNames ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
145 |
" |
1416 | 146 |
Transcript showCR:'no real change'. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
147 |
" |
1416 | 148 |
"no real change (just formatting)" |
149 |
self setInstanceVariableString:aString. |
|
150 |
^ self |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
151 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
152 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
153 |
"/ " |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
154 |
"/ let user confirm, if any name is no good (and was good before) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
155 |
"/ " |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
156 |
"/ (oldNames inject:true |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
157 |
"/ into:[:okSoFar :word | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
158 |
"/ okSoFar and:[word first isUppercase] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
159 |
"/ ]) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
160 |
"/ ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
161 |
"/ "was ok before" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
162 |
"/ (newNames inject:true |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
163 |
"/ into:[:okSoFar :word | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
164 |
"/ okSoFar and:[word first isUppercase] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
165 |
"/ ]) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
166 |
"/ ifFalse:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
167 |
"/ (self confirm:'class instance variable names should start with an uppercase letter |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
168 |
"/(by convention only) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
169 |
"/ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
170 |
"/install anyway ?' withCRs) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
171 |
"/ ifFalse:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
172 |
"/ ^ nil |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
173 |
"/ ] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
174 |
"/ ] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
175 |
"/ ]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
176 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
177 |
nClassInstVars := newNames size. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
178 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
179 |
" |
1416 | 180 |
Transcript showCR:'create new class/metaclass'. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
181 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
182 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
183 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
184 |
create the new metaclass |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
185 |
" |
1733
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
186 |
self isPrivate ifTrue:[ |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
187 |
newMetaclass := PrivateMetaclass new. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
188 |
newMetaclass setOwningClass:(self owningClass). |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
189 |
] ifFalse:[ |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
190 |
newMetaclass := Metaclass new. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
191 |
]. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
192 |
newMetaclass setSuperclass:superclass. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
193 |
newMetaclass instSize:(superclass instSize + nClassInstVars). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
194 |
(nClassInstVars ~~ 0) ifTrue:[ |
1416 | 195 |
newMetaclass setInstanceVariableString:aString |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
196 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
197 |
"/ newMetaclass flags:(Behavior flagBehavior "flagNotIndexed"). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
198 |
newMetaclass setName:name. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
199 |
newMetaclass classVariableString:classvars. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
200 |
newMetaclass category:category. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
201 |
newMetaclass setComment:(self comment). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
202 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
203 |
"find the class which is my sole instance" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
204 |
|
1671 | 205 |
oldClass := myClass. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
206 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
207 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
208 |
create the new class |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
209 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
210 |
newClass := newMetaclass new. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
211 |
newClass setSuperclass:(oldClass superclass). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
212 |
newClass instSize:(oldClass instSize). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
213 |
newClass flags:(oldClass flags). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
214 |
newClass setName:(oldClass name). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
215 |
newClass setInstanceVariableString:(oldClass instanceVariableString). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
216 |
newClass classVariableString:(oldClass classVariableString). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
217 |
newClass setComment:(oldClass comment). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
218 |
newClass category:(oldClass category). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
219 |
(t := oldClass primitiveSpec) notNil ifTrue:[ |
1416 | 220 |
newClass primitiveSpec:t. |
221 |
newClass setClassFilename:(oldClass classFilename). |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
222 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
223 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
224 |
"/ set the new classes package |
566
3d2527a9e96d
preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
225 |
"/ from the old package |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
226 |
|
566
3d2527a9e96d
preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
227 |
t := oldClass package. |
3d2527a9e96d
preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
228 |
newMetaclass package:t. |
3d2527a9e96d
preserve package when class definition changes - its required for the SourceCodeManager
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
229 |
newClass package:t. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
230 |
|
723
ebc969b4678d
preserve binaryRevision when adding instVars
Claus Gittinger <cg@exept.de>
parents:
682
diff
changeset
|
231 |
"/ and keep the binary revision |
ebc969b4678d
preserve binaryRevision when adding instVars
Claus Gittinger <cg@exept.de>
parents:
682
diff
changeset
|
232 |
newClass setBinaryRevision:(oldClass revision). |
ebc969b4678d
preserve binaryRevision when adding instVars
Claus Gittinger <cg@exept.de>
parents:
682
diff
changeset
|
233 |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
234 |
changeSet := Set new. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
235 |
((oldNames size == 0) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
236 |
or:[newNames startsWith:oldNames]) ifTrue:[ |
1416 | 237 |
"new variable(s) has/have been added - old methods still work" |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
238 |
|
1733
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
239 |
"/ Transcript showCR:'copying methods ...'. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
240 |
"/ Transcript endEntry. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
241 |
|
1416 | 242 |
self copyMethodsFrom:self for:newMetaclass. |
243 |
self copyMethodsFrom:oldClass for:newClass. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
244 |
|
1416 | 245 |
" |
246 |
but have to recompile methods accessing stuff now defined |
|
247 |
(it might have been a global before ...) |
|
248 |
" |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
249 |
|
1416 | 250 |
addedNames := newNames select:[:nm | (oldNames includes:nm) not]. |
1733
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
251 |
|
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
252 |
"/ Transcript showCR:'recompiling methods accessing ' , addedNames printString , '...'. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
253 |
"/ Transcript endEntry. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
254 |
|
1416 | 255 |
"recompile class-methods" |
256 |
newMetaclass recompileMethodsAccessingAny:addedNames. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
257 |
] ifFalse:[ |
1416 | 258 |
" |
259 |
create the changeSet; thats the set of class instvar names |
|
260 |
which have changed their position or are new |
|
261 |
" |
|
262 |
offset := 0. oldOffsets := Dictionary new. |
|
263 |
oldNames do:[:nm | offset := offset + 1. oldOffsets at:nm put:offset]. |
|
264 |
offset := 0. newOffsets := Dictionary new. |
|
265 |
newNames do:[:nm | offset := offset + 1. newOffsets at:nm put:offset]. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
266 |
|
1416 | 267 |
oldOffsets associationsDo:[:a | |
268 |
|k| |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
269 |
|
1416 | 270 |
k := a key. |
271 |
(newOffsets includesKey:k) ifFalse:[ |
|
272 |
changeSet add:k |
|
273 |
] ifTrue:[ |
|
274 |
(a value ~~ (newOffsets at:k)) ifTrue:[ |
|
275 |
changeSet add:k |
|
276 |
] |
|
277 |
] |
|
278 |
]. |
|
279 |
newOffsets associationsDo:[:a | |
|
280 |
|k| |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
281 |
|
1416 | 282 |
k := a key. |
283 |
(oldOffsets includesKey:k) ifFalse:[ |
|
284 |
changeSet add:k |
|
285 |
] ifTrue:[ |
|
286 |
(a value ~~ (oldOffsets at:k)) ifTrue:[ |
|
287 |
changeSet add:k |
|
288 |
] |
|
289 |
] |
|
290 |
]. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
291 |
|
1733
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
292 |
"/ Transcript showCR:'recompiling methods accessing ' , changeSet printString , ' ...'. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
293 |
"/ Transcript endEntry. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
294 |
|
1416 | 295 |
" |
296 |
recompile class-methods |
|
297 |
" |
|
298 |
self copyInvalidatedMethodsFrom:self for:newMetaclass accessingAny:changeSet. |
|
1875 | 299 |
newMetaclass recompileInvalidatedMethods. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
300 |
|
1416 | 301 |
self copyMethodsFrom:oldClass for:newClass. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
302 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
303 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
304 |
delta := newNames size - oldNames size. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
305 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
306 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
307 |
get list of all subclasses - do before superclass is changed |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
308 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
309 |
allSubclasses := oldClass allSubclasses. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
310 |
allSubclasses := allSubclasses asSortedCollection:[:a :b | |
1416 | 311 |
b isSubclassOf:a |
312 |
]. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
313 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
314 |
oldToNew := IdentityDictionary new. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
315 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
316 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
317 |
create a new class tree, based on new version |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
318 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
319 |
allSubclasses do:[:aSubclass | |
1416 | 320 |
oldSuper := aSubclass superclass. |
321 |
oldSubMeta := aSubclass class. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
322 |
|
1416 | 323 |
newSubMeta := Metaclass new. |
324 |
oldSuper == oldClass ifTrue:[ |
|
325 |
newSubMeta setSuperclass:newMetaclass. |
|
326 |
] ifFalse:[ |
|
327 |
newSubMeta setSuperclass:(oldToNew at:oldSuper) class. |
|
328 |
]. |
|
329 |
newSubMeta instSize:(oldSubMeta instSize + delta). |
|
330 |
newSubMeta flags:(oldSubMeta flags). |
|
331 |
newSubMeta setName:(oldSubMeta name). |
|
332 |
newSubMeta setInstanceVariableString:(oldSubMeta instanceVariableString). |
|
333 |
newSubMeta classVariableString:(oldSubMeta classVariableString). |
|
334 |
newSubMeta setComment:(oldSubMeta comment). |
|
335 |
newSubMeta category:(oldSubMeta category). |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
336 |
|
1416 | 337 |
newSub := newSubMeta new. |
338 |
oldSuper == oldClass ifTrue:[ |
|
339 |
newSub setSuperclass:newClass. |
|
340 |
] ifFalse:[ |
|
341 |
newSub setSuperclass:(oldToNew at:oldSuper). |
|
342 |
]. |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
343 |
newSub setMethodDictionary:(aSubclass methodDictionary copy). |
1416 | 344 |
newSub setName:(aSubclass name). |
345 |
newSub classVariableString:(aSubclass classVariableString). |
|
346 |
newSub setComment:(aSubclass comment). |
|
347 |
newSub category:(aSubclass category). |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
348 |
|
1416 | 349 |
oldToNew at:aSubclass put:newSub. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
350 |
|
1655 | 351 |
aSubclass category:#'* obsolete *'. |
352 |
aSubclass class category:#'* obsolete *'. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
353 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
354 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
355 |
"recompile what needs to be" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
356 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
357 |
delta == 0 ifTrue:[ |
1416 | 358 |
"only have to recompile class methods accessing |
359 |
class instvars from changeset |
|
360 |
" |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
361 |
|
1416 | 362 |
allSubclasses do:[:oldSubclass | |
363 |
|newSubclass| |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
364 |
|
1416 | 365 |
newSubclass := oldToNew at:oldSubclass. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
366 |
|
1733
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
367 |
Transcript showCR:'recompiling class methods of ' , newSubclass class name , |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
368 |
' accessing any of ' , changeSet printString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
369 |
|
1416 | 370 |
newSubclass class recompileMethodsAccessingAny:changeSet. |
371 |
] |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
372 |
] ifFalse:[ |
1416 | 373 |
" |
374 |
have to recompile all class methods accessing class instvars |
|
375 |
" |
|
376 |
commonClassInstVars := oldClass class allInstVarNames. |
|
377 |
changeSet do:[:v | |
|
378 |
commonClassInstVars remove:v ifAbsent:[] |
|
379 |
]. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
380 |
|
1416 | 381 |
allSubclasses do:[:oldSubclass | |
382 |
|newSubclass classInstVars| |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
383 |
|
1416 | 384 |
newSubclass := oldToNew at:oldSubclass. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
385 |
|
1416 | 386 |
classInstVars := newSubclass class allInstVarNames asSet. |
387 |
classInstVars removeAll:commonClassInstVars. |
|
388 |
classInstVars addAll:changeSet. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
389 |
|
1733
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
390 |
Transcript showCR:'recompiling class methods of ' , newSubclass class name , |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
391 |
' accessing any of ' , classInstVars printString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
392 |
|
1416 | 393 |
newSubclass class recompileMethodsAccessingAny:classInstVars. |
394 |
] |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
395 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
396 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
397 |
self addChangeRecordForClassInstvars:newClass. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
398 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
399 |
"install all new classes" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
400 |
|
1671 | 401 |
(Smalltalk at:(oldClass name asSymbol) ifAbsent:nil) == oldClass ifTrue:[ |
402 |
Smalltalk at:(oldClass name asSymbol) put:newClass. |
|
1798
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
403 |
self checkForAliasesOf:oldClass with:newClass. |
1821
0ef23966c67b
move privateClasses when changing classInstVars
Claus Gittinger <cg@exept.de>
parents:
1819
diff
changeset
|
404 |
" |
0ef23966c67b
move privateClasses when changing classInstVars
Claus Gittinger <cg@exept.de>
parents:
1819
diff
changeset
|
405 |
change any private subclasses' owners |
0ef23966c67b
move privateClasses when changing classInstVars
Claus Gittinger <cg@exept.de>
parents:
1819
diff
changeset
|
406 |
" |
0ef23966c67b
move privateClasses when changing classInstVars
Claus Gittinger <cg@exept.de>
parents:
1819
diff
changeset
|
407 |
oldClass privateClassesDo:[:aClass | |
0ef23966c67b
move privateClasses when changing classInstVars
Claus Gittinger <cg@exept.de>
parents:
1819
diff
changeset
|
408 |
aClass class setOwningClass:newClass |
0ef23966c67b
move privateClasses when changing classInstVars
Claus Gittinger <cg@exept.de>
parents:
1819
diff
changeset
|
409 |
]. |
0ef23966c67b
move privateClasses when changing classInstVars
Claus Gittinger <cg@exept.de>
parents:
1819
diff
changeset
|
410 |
|
1671 | 411 |
]. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
412 |
ObjectMemory flushCachesFor:oldClass. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
413 |
|
1671 | 414 |
allSubclasses do:[:oldSubClass | |
415 |
|newSubClass| |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
416 |
|
1671 | 417 |
newSubClass := oldToNew at:oldSubClass. |
1733
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
418 |
|
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
419 |
"/ Transcript showCR:'install ' , newSubClass name , '(' , newSubClass category , ')' , |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
420 |
"/ ' as ' , newSubClass name. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
421 |
|
1671 | 422 |
(Smalltalk at:(oldSubClass name asSymbol) ifAbsent:nil) == oldSubClass ifTrue:[ |
423 |
Smalltalk at:oldSubClass name asSymbol put:newSubClass. |
|
1798
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
424 |
self checkForAliasesOf:oldSubClass with:newSubClass. |
1671 | 425 |
]. |
426 |
ObjectMemory flushCachesFor:oldSubClass. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
427 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
428 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
429 |
"tell dependents ..." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
430 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
431 |
oldClass changed:#definition. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
432 |
self changed:#definition. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
433 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
434 |
^ newMetaclass |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
435 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
436 |
"Created: 29.10.1995 / 19:57:08 / cg" |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
437 |
"Modified: 7.6.1996 / 08:43:19 / stefan" |
1875 | 438 |
"Modified: 4.11.1996 / 22:12:20 / cg" |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
439 |
! ! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
440 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
441 |
!Metaclass methodsFor:'copying'! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
442 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
443 |
postCopy |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
444 |
"redefined - a copy may have a new instance" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
445 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
446 |
myClass := nil |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
447 |
! ! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
448 |
|
1 | 449 |
!Metaclass methodsFor:'creating classes'! |
450 |
||
1724 | 451 |
name:newName in:aSystemDictionaryOrClass |
1439 | 452 |
subclassOf:aClass |
453 |
instanceVariableNames:stringOfInstVarNames |
|
454 |
variable:variableBoolean |
|
455 |
words:wordsBoolean |
|
456 |
pointers:pointersBoolean |
|
457 |
classVariableNames:stringOfClassVarNames |
|
458 |
poolDictionaries:stringOfPoolNames |
|
459 |
category:categoryString |
|
460 |
comment:commentString |
|
461 |
changed:changed |
|
462 |
classInstanceVariableNames:stringOfClassInstVarNames |
|
463 |
||
464 |
"this is the main workhorse for installing new classes - special care |
|
465 |
has to be taken, when changing an existing classes definition. In this |
|
466 |
case, some or all of the methods and subclasses methods have to be |
|
467 |
recompiled. |
|
468 |
Also, the old class(es) are still kept (but not accessable as a global), |
|
469 |
to allow existing instances some life. |
|
470 |
This might change in the future. |
|
471 |
" |
|
472 |
||
1910 | 473 |
|newClass newMetaclass nInstVars nameString classSymbol nameKey oldClass |
1439 | 474 |
classVarChange instVarChange superClassChange newComment |
475 |
changeSet1 changeSet2 addedNames |
|
476 |
anyChange oldInstVars newInstVars oldClassVars newClassVars superFlags newFlags |
|
1897 | 477 |
pkg idx spec nClassInstVars superInstVars |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
478 |
realNewName thisIsPrivate oldCIVNames newCIVNames msg nsName namespace| |
1439 | 479 |
|
480 |
"NOTICE: |
|
481 |
this method is too complex and should be splitted into managable pieces ... |
|
482 |
I dont like it anymore :-) |
|
483 |
(well, at least, its a good test for the compilers ability |
|
484 |
to handle big, complex methods ;-) |
|
485 |
take it as an example of bad coding style ... |
|
486 |
||
487 |
ST-80 uses a ClassBuilder object to collect the work and perform all updates; |
|
488 |
this method may be changed to do something similar in the future ... |
|
489 |
" |
|
490 |
||
491 |
Behavior flushSubclassInfo. |
|
492 |
||
493 |
newName = aClass name ifTrue:[ |
|
494 |
self error:'trying to create circular class definition'. |
|
495 |
^ nil |
|
496 |
]. |
|
497 |
||
1733
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
498 |
(newName isSymbol not |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
499 |
or:[newName size == 0]) ifTrue:[ |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
500 |
self error:'invalid class name (must be a nonEmpty symbol)'. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
501 |
^ nil |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
502 |
]. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
503 |
newName first isLetter ifFalse:[ |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
504 |
self error:'invalid class name (must start with a letter)'. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
505 |
^ nil |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
506 |
]. |
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
507 |
|
1439 | 508 |
"check for invalid subclassing of UndefinedObject and SmallInteger" |
509 |
aClass canBeSubclassed ifFalse:[ |
|
510 |
self error:('it is not possible to subclass ' , aClass name). |
|
511 |
^ nil |
|
512 |
]. |
|
513 |
||
514 |
nInstVars := stringOfInstVarNames countWords. |
|
515 |
nameString := newName asString. |
|
516 |
classSymbol := newName asSymbol. |
|
517 |
newComment := commentString. |
|
518 |
||
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
519 |
namespace := aSystemDictionaryOrClass. |
1910 | 520 |
nameKey := classSymbol. |
1749 | 521 |
|
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
522 |
(namespace notNil |
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
523 |
and:[namespace isNamespace not]) ifTrue:[ |
1749 | 524 |
thisIsPrivate := true. |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
525 |
realNewName := (namespace name , '::' , classSymbol) asSymbol. |
1742 | 526 |
] ifFalse:[ |
1749 | 527 |
thisIsPrivate := false. |
1742 | 528 |
realNewName := classSymbol. |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
529 |
|
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
530 |
"/ does the name imply a nameSpace ? |
1835
e90fe211cdf1
oops - corrupted the package on autolaod
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
531 |
((idx := realNewName indexOf:$:)) ~~ 0 ifTrue:[ |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
532 |
"/ check for this namespace to exist |
1835
e90fe211cdf1
oops - corrupted the package on autolaod
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
533 |
nsName := realNewName copyTo:(idx - 1). |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
534 |
nsName := nsName asSymbol. |
1835
e90fe211cdf1
oops - corrupted the package on autolaod
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
535 |
(realNewName indexOf:$: startingAt:(idx+2)) ~~ 0 ifTrue:[ |
1830 | 536 |
self warn:('nested namespaces are not (yet) implemented.') withCRs. |
537 |
^ nil |
|
538 |
]. |
|
539 |
||
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
540 |
namespace := Smalltalk at:nsName ifAbsent:nil. |
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
541 |
namespace isNamespace ifFalse:[ |
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
542 |
namespace isNil ifTrue:[ |
1916
3597f8ae2c50
ask createNameSpaceQuerySignal
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
543 |
(Class createNameSpaceQuerySignal raise |
3597f8ae2c50
ask createNameSpaceQuerySignal
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
544 |
or:[(self |
3597f8ae2c50
ask createNameSpaceQuerySignal
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
545 |
confirm:('nonexistent namespace: `' , nsName , '''.\\Create ?') withCRs)]) |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
546 |
ifFalse:[^ nil]. |
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
547 |
namespace := Namespace name:nsName. |
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
548 |
] ifFalse:[ |
1830 | 549 |
self warn:('a global named ' , nsName , ' exists, but is no namespace.') withCRs. |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
550 |
^ nil |
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
551 |
] |
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
552 |
]. |
1910 | 553 |
namespace isNamespace ifTrue:[ |
554 |
nameKey := (classSymbol copyFrom:(nsName size + 3)) asSymbol. |
|
555 |
] |
|
1921 | 556 |
] ifFalse:[ |
557 |
namespace ~~ Smalltalk ifTrue:[ |
|
558 |
realNewName := (namespace name , '::' , classSymbol) asSymbol. |
|
559 |
] |
|
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
560 |
] |
1742 | 561 |
]. |
562 |
||
1439 | 563 |
"look, if it already exists as a class" |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
564 |
namespace notNil ifTrue:[ |
1749 | 565 |
thisIsPrivate ifFalse:[ |
1910 | 566 |
oldClass := namespace at:nameKey ifAbsent:[nil]. |
1749 | 567 |
] ifTrue:[ |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
568 |
oldClass := namespace privateClassesAt:classSymbol. |
1724 | 569 |
] |
1439 | 570 |
]. |
1742 | 571 |
|
1439 | 572 |
(oldClass isBehavior and:[oldClass isLoaded]) ifFalse:[ |
573 |
oldClass := nil. |
|
1749 | 574 |
|
575 |
thisIsPrivate ifTrue:[ |
|
576 |
Compiler warnSTXSpecials ifTrue:[ |
|
577 |
(self confirm:('support for private classes is an ST/X extension.\\continue ?') withCRs) |
|
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
578 |
ifFalse:[^ nil]. |
1749 | 579 |
] |
580 |
]. |
|
1439 | 581 |
] ifTrue:[ |
1742 | 582 |
oldClass name ~= realNewName ifTrue:[ |
1439 | 583 |
(self confirm:(classSymbol , ' is an alias for ' , oldClass name , '\\continue ?') withCRs) |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
584 |
ifFalse:[^ nil]. |
1439 | 585 |
oldClass := nil |
586 |
] ifFalse:[ |
|
587 |
"/ |
|
588 |
"/ some consisteny checks |
|
589 |
"/ |
|
590 |
oldClass superclass notNil ifTrue:[ |
|
591 |
oldClass allSuperclasses do:[:cls | |
|
1776
794f35149de7
oops - use full name when checking for circular definition
Claus Gittinger <cg@exept.de>
parents:
1757
diff
changeset
|
592 |
cls name = realNewName ifTrue:[ |
1439 | 593 |
self error:'trying to create circular class definition'. |
594 |
^ nil |
|
595 |
] |
|
596 |
] |
|
597 |
]. |
|
598 |
||
599 |
aClass superclass notNil ifTrue:[ |
|
600 |
aClass allSuperclasses do:[:cls | |
|
1776
794f35149de7
oops - use full name when checking for circular definition
Claus Gittinger <cg@exept.de>
parents:
1757
diff
changeset
|
601 |
cls name = realNewName ifTrue:[ |
1439 | 602 |
self error:'trying to create circular class definition'. |
603 |
^ nil |
|
604 |
] |
|
605 |
]. |
|
606 |
]. |
|
607 |
||
608 |
newComment isNil ifTrue:[ |
|
609 |
newComment := oldClass comment |
|
610 |
]. |
|
611 |
||
612 |
" |
|
613 |
warn, if it exists with different category and different instvars, |
|
614 |
and the existing is not an autoload class. |
|
615 |
Usually, this indicates that someone wants to create a new class with |
|
616 |
a name, which already exists (it happened a few times to myself, while |
|
617 |
I wanted to create a new class called ReturnNode ...). |
|
618 |
This will be much less of a problem, once multiple name spaces are |
|
619 |
implemented and classes can be put into separate packages. |
|
620 |
" |
|
621 |
oldClass isLoaded ifTrue:[ |
|
622 |
oldClass category ~= categoryString ifTrue:[ |
|
623 |
oldClass instanceVariableString asCollectionOfWords |
|
624 |
~= stringOfInstVarNames asCollectionOfWords ifTrue:[ |
|
625 |
(self confirm:'a class named ' , oldClass name , |
|
626 |
' already exists -\\create (i.e. change) anyway ?' withCRs) |
|
627 |
ifFalse:[ |
|
628 |
^ nil |
|
629 |
] |
|
630 |
] |
|
631 |
] |
|
632 |
]. |
|
633 |
||
634 |
"/ |
|
635 |
"/ hints - warn, if creating a variableSubclass of a Set |
|
636 |
"/ (common error - containers in ST/X do not use variable-slots) |
|
637 |
"/ |
|
638 |
((variableBoolean == true) and:[pointersBoolean]) ifTrue:[ |
|
639 |
(oldClass isKindOf:Set class) ifTrue:[ |
|
640 |
(self confirm:'ST/X Set & Dictionary are not variable-classes\create anyway ?' withCRs) |
|
641 |
ifFalse:[ |
|
642 |
^ nil |
|
643 |
] |
|
644 |
] |
|
645 |
] |
|
646 |
] |
|
647 |
]. |
|
648 |
||
649 |
" |
|
650 |
Check for some 'considered bad-style' things, like lower case names. |
|
651 |
But only do these checks for new classes - |
|
652 |
- thus, once confirmed, the warnings will not come again and again. |
|
653 |
||
654 |
NOTICE: |
|
655 |
I dont like the confirmers there - we need a notifying: argument, to give |
|
656 |
the outer codeview a chance to highlight the error. |
|
657 |
(but thats how its defined in the book - maybe I will change anyway). |
|
658 |
" |
|
659 |
oldClass isNil ifTrue:[ |
|
1752 | 660 |
(self |
661 |
checkConventionsFor:newName |
|
662 |
subClassOf:aClass |
|
663 |
instVarNames:stringOfInstVarNames |
|
664 |
classVarNames:stringOfClassVarNames) |
|
665 |
ifFalse:[ |
|
1439 | 666 |
^ nil |
667 |
] |
|
668 |
]. |
|
669 |
||
1698 | 670 |
aClass notNil ifTrue:[ |
1809
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
671 |
" |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
672 |
check for instVar redef of superClass instVars |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
673 |
" |
1698 | 674 |
superInstVars := aClass allInstVarNames. |
675 |
stringOfInstVarNames asCollectionOfWords do:[:nm | |
|
676 |
(superInstVars includes:nm) ifTrue:[ |
|
1809
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
677 |
(oldClass notNil |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
678 |
and:[stringOfInstVarNames = oldClass instanceVariableString]) |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
679 |
ifTrue:[ |
1877 | 680 |
msg := 'instVar conflict in `' , newName , ''' for `' , nm , ''' due to superclass change.\You now have two different instVar slots with the same name.\\Dont forget to fix this later.'. |
1809
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
681 |
self warn:msg withCRs. |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
682 |
] ifFalse:[ |
1877 | 683 |
msg := 'instVar `' , nm , ''' is already defined in a superclass.\Change the definition of `' , newName , ''' anyway ?\\Notice: you must fix the superclass later.'. |
1809
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
684 |
(self confirm:msg withCRs) ifFalse:[ |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
685 |
^ nil. |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
686 |
] |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
687 |
]. |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
688 |
] |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
689 |
]. |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
690 |
]. |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
691 |
|
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
692 |
oldClass notNil ifTrue:[ |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
693 |
" |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
694 |
check for instVar redefs in subclass instVars |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
695 |
" |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
696 |
oldClass allSubclassesDo:[:sub | |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
697 |
|vars| |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
698 |
|
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
699 |
vars := sub instVarNames. |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
700 |
stringOfInstVarNames asCollectionOfWords do:[:nm | |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
701 |
(vars includes:nm) ifTrue:[ |
1877 | 702 |
(self confirm:('subclass ' , sub name , ' already defines an instVar named `' , nm , '''.\\Change the definition of `' , newName , ''' anyway ?\Notice: you must fix the subclass later.') withCRs) |
1809
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
703 |
ifFalse:[ |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
704 |
^ nil. |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
705 |
] |
d5f8d427904b
more care for instVar redefinitions (check subclasses);
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
706 |
] |
1698 | 707 |
] |
708 |
] |
|
709 |
]. |
|
710 |
||
1439 | 711 |
nClassInstVars := stringOfClassInstVarNames countWords. |
712 |
||
713 |
"create the metaclass first" |
|
1749 | 714 |
thisIsPrivate ifTrue:[ |
1733
2cc88c50db99
check for valid className (symbol & startsWith a letter).
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
715 |
newMetaclass := PrivateMetaclass new |
1725 | 716 |
] ifFalse:[ |
717 |
newMetaclass := Metaclass new. |
|
718 |
]. |
|
1439 | 719 |
newMetaclass setSuperclass:(aClass class). |
720 |
newMetaclass instSize:(aClass class instSize + nClassInstVars). |
|
1724 | 721 |
newMetaclass classVariableString:''. |
1439 | 722 |
newMetaclass setInstanceVariableString:stringOfClassInstVarNames. |
723 |
||
724 |
"then let the new meta create the class" |
|
725 |
newClass := newMetaclass new. |
|
726 |
newClass setSuperclass:aClass. |
|
727 |
newClass instSize:(aClass instSize + nInstVars). |
|
1724 | 728 |
|
1749 | 729 |
thisIsPrivate ifTrue:[ |
1724 | 730 |
"/ some private class |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
731 |
newMetaclass setOwningClass:namespace. |
1921 | 732 |
]. |
733 |
||
734 |
(namespace notNil |
|
735 |
and:[namespace ~~ Smalltalk]) ifTrue:[ |
|
1910 | 736 |
newClass setName:(namespace name , '::' , nameKey) asSymbol. |
1724 | 737 |
] ifFalse:[ |
738 |
newClass setName:classSymbol. |
|
739 |
]. |
|
1439 | 740 |
newClass setComment:newComment category:categoryString. |
741 |
||
1778
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
742 |
oldClass notNil ifTrue:[ |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
743 |
"/ copy over classInstanceVariables |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
744 |
"/ but not those inherited from class |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
745 |
|
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
746 |
oldCIVNames := oldClass class allInstVarNames asSet. |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
747 |
newCIVNames := newClass class allInstVarNames asSet. |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
748 |
Class class allInstVarNames do:[:n | |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
749 |
oldCIVNames remove:n ifAbsent:nil. |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
750 |
newCIVNames remove:n ifAbsent:nil. |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
751 |
]. |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
752 |
|
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
753 |
newCIVNames size > 0 ifTrue:[ |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
754 |
Transcript show:'preserving classInstVar values: '; showCR:newCIVNames. |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
755 |
newCIVNames do:[:n | |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
756 |
(oldCIVNames includes:n) ifTrue:[ |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
757 |
newClass instVarNamed:n put:(oldClass instVarNamed:n) |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
758 |
] |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
759 |
] |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
760 |
]. |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
761 |
]. |
fd558245c662
preserve values of classInstVars when creating a new class
Claus Gittinger <cg@exept.de>
parents:
1776
diff
changeset
|
762 |
|
1439 | 763 |
"/ set the new classes package |
764 |
"/ but prefer the old package |
|
765 |
||
766 |
oldClass notNil ifTrue:[ |
|
1835
e90fe211cdf1
oops - corrupted the package on autolaod
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
767 |
pkg := oldClass package. |
1439 | 768 |
newClass setBinaryRevision:(oldClass binaryRevision). |
769 |
] ifFalse:[ |
|
1897 | 770 |
pkg := Class packageQuerySignal raise |
1439 | 771 |
]. |
1835
e90fe211cdf1
oops - corrupted the package on autolaod
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
772 |
pkg notNil ifTrue:[ |
e90fe211cdf1
oops - corrupted the package on autolaod
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
773 |
newMetaclass package:pkg. |
e90fe211cdf1
oops - corrupted the package on autolaod
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
774 |
newClass package:pkg. |
1439 | 775 |
]. |
776 |
||
777 |
" |
|
778 |
Allowing non-booleans as variableBoolean |
|
779 |
is a hack for backward (ST-80) compatibility: |
|
780 |
||
781 |
ST-80 code will pass true or false as variableBoolean, |
|
782 |
while ST/X also calls it with symbols such as #float, #double etc. |
|
783 |
" |
|
784 |
(variableBoolean == true) ifTrue:[ |
|
785 |
pointersBoolean ifTrue:[ |
|
786 |
newFlags := Behavior flagPointers |
|
787 |
] ifFalse:[ |
|
788 |
wordsBoolean ifTrue:[ |
|
789 |
newFlags := Behavior flagWords |
|
790 |
] ifFalse:[ |
|
791 |
newFlags := Behavior flagBytes |
|
792 |
] |
|
793 |
] |
|
794 |
] ifFalse:[ |
|
1655 | 795 |
"/ false or symbol. |
796 |
newFlags := Behavior flagForSymbolic:variableBoolean. |
|
1439 | 797 |
]. |
798 |
superFlags := aClass flags bitAnd:(Behavior maskIndexType bitInvert). "preserve other bits" |
|
799 |
oldClass notNil ifTrue:[ |
|
800 |
oldClass isBuiltInClass ifTrue:[ |
|
801 |
" |
|
802 |
special care when redefining Method, Block and other built-in classes, |
|
803 |
which might have other flag bits ... |
|
804 |
" |
|
805 |
||
806 |
newFlags := newFlags bitOr:(oldClass flags bitAnd:(Behavior maskIndexType bitInvert)) |
|
807 |
] |
|
808 |
]. |
|
809 |
newClass flags:(newFlags bitOr:superFlags). "preserve inherited special bits" |
|
810 |
||
811 |
(nInstVars ~~ 0) ifTrue:[ |
|
812 |
newClass setInstanceVariableString:stringOfInstVarNames |
|
813 |
]. |
|
814 |
oldClass notNil ifTrue:[ |
|
815 |
" |
|
816 |
setting first will make new class clear obsolete classvars |
|
817 |
" |
|
818 |
newClass setClassVariableString:(oldClass classVariableString). |
|
1835
e90fe211cdf1
oops - corrupted the package on autolaod
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
819 |
(spec := oldClass primitiveSpec) notNil ifTrue:[ |
e90fe211cdf1
oops - corrupted the package on autolaod
Claus Gittinger <cg@exept.de>
parents:
1830
diff
changeset
|
820 |
newClass primitiveSpec:spec. |
1439 | 821 |
newClass setClassFilename:(oldClass classFilename). |
822 |
] |
|
823 |
]. |
|
824 |
newClass classVariableString:stringOfClassVarNames. |
|
825 |
||
826 |
" |
|
827 |
for new classes, we are almost done here |
|
828 |
(also for autoloaded classes) |
|
829 |
" |
|
830 |
(oldClass isNil or:[oldClass isLoaded not]) ifTrue:[ |
|
831 |
(oldClass isNil and:[changed]) ifTrue:[ |
|
832 |
self addChangeRecordForClass:newClass. |
|
833 |
]. |
|
834 |
||
835 |
commentString notNil ifTrue:[ |
|
836 |
newClass comment:commentString |
|
837 |
]. |
|
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
838 |
namespace notNil ifTrue:[ |
1749 | 839 |
thisIsPrivate ifTrue:[ |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
840 |
namespace privateClassesAt:classSymbol put:newClass. |
1749 | 841 |
] ifFalse:[ |
1910 | 842 |
namespace at:nameKey put:newClass. |
1724 | 843 |
] |
1439 | 844 |
]. |
845 |
||
846 |
oldClass isNil ifTrue:[ |
|
1897 | 847 |
newClass package:(Class packageQuerySignal raise) |
1439 | 848 |
]. |
849 |
||
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
850 |
namespace notNil ifTrue:[ |
1749 | 851 |
thisIsPrivate ifTrue:[ |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
852 |
namespace changed. |
1749 | 853 |
] ifFalse:[ |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
854 |
namespace changed:#newClass with:newClass. |
1922
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
855 |
namespace ~~ Smalltalk ifTrue:[ |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
856 |
Smalltalk changed:#newClass with:newClass. |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
857 |
] |
1724 | 858 |
] |
1439 | 859 |
]. |
860 |
^ newClass |
|
861 |
]. |
|
862 |
||
863 |
" |
|
864 |
here comes the hard part - we are actually changing the |
|
865 |
definition of an existing class .... |
|
866 |
Try hard to get away WITHOUT recompiling, since it makes all |
|
867 |
compiled code into interpreted ... |
|
868 |
" |
|
869 |
||
870 |
oldInstVars := oldClass instanceVariableString asCollectionOfWords. |
|
871 |
newInstVars := newClass instanceVariableString asCollectionOfWords. |
|
872 |
oldClassVars := oldClass classVariableString asCollectionOfWords. |
|
873 |
newClassVars := newClass classVariableString asCollectionOfWords. |
|
874 |
||
875 |
" |
|
876 |
we are on the bright side of life, if the instance layout and |
|
877 |
inheritance do not change. |
|
878 |
In this case, we can go ahead and patch the class object. |
|
879 |
" |
|
880 |
(oldClass superclass == newClass superclass) ifTrue:[ |
|
881 |
(oldClass instSize == newClass instSize) ifTrue:[ |
|
882 |
(oldClass flags == newClass flags) ifTrue:[ |
|
883 |
(oldClass name = newClass name) ifTrue:[ |
|
884 |
(oldInstVars = newInstVars) ifTrue:[ |
|
885 |
||
886 |
(newComment ~= oldClass comment) ifTrue:[ |
|
887 |
oldClass setComment:newComment. "writes a change-chunk" |
|
888 |
oldClass changed:#comment with:oldClass comment. |
|
889 |
changed ifTrue:[ |
|
890 |
self addChangeRecordForClassComment:oldClass. |
|
891 |
] |
|
892 |
]. |
|
893 |
||
894 |
(oldClassVars = newClassVars) ifTrue:[ |
|
895 |
" |
|
896 |
really no change (just comment and/or category) |
|
897 |
" |
|
898 |
anyChange := false. |
|
899 |
||
900 |
oldClass setInstanceVariableString:(newClass instanceVariableString). |
|
901 |
oldClass setClassVariableString:(newClass classVariableString). |
|
902 |
||
903 |
oldClass category ~= categoryString ifTrue:[ |
|
904 |
oldClass category:categoryString. |
|
905 |
changed ifTrue:[ |
|
906 |
self addChangeRecordForClass:newClass. |
|
907 |
]. |
|
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
908 |
namespace notNil ifTrue:[ |
1749 | 909 |
thisIsPrivate ifFalse:[ |
1724 | 910 |
"notify change of category" |
1922
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
911 |
namespace changed:#organization. |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
912 |
namespace ~~ Smalltalk ifTrue:[ |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
913 |
Smalltalk changed:#organization. |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
914 |
] |
1724 | 915 |
] |
1439 | 916 |
] |
917 |
]. |
|
918 |
"notify change of class" |
|
919 |
"/ oldClass changed. |
|
920 |
^ oldClass |
|
921 |
]. |
|
922 |
||
923 |
" |
|
924 |
when we arrive here, class variables have changed |
|
925 |
" |
|
926 |
oldClass category ~= categoryString ifTrue:[ |
|
927 |
"notify change of organization" |
|
928 |
oldClass category:categoryString. |
|
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
929 |
namespace notNil ifTrue:[ |
1749 | 930 |
thisIsPrivate ifFalse:[ |
1922
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
931 |
"notify change of organization" |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
932 |
namespace changed:#organization. |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
933 |
namespace ~~ Smalltalk ifTrue:[ |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
934 |
Smalltalk changed:#organization. |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
935 |
] |
1724 | 936 |
] |
1439 | 937 |
]. |
938 |
]. |
|
939 |
||
940 |
" |
|
941 |
set class variable string; |
|
942 |
this also updates the set of class variables |
|
943 |
by creating new / deleting obsolete ones. |
|
944 |
" |
|
945 |
oldClass classVariableString:stringOfClassVarNames. |
|
946 |
||
947 |
" |
|
948 |
get the set of changed class variables |
|
949 |
" |
|
950 |
changeSet1 := Set new. |
|
951 |
oldClassVars do:[:nm | |
|
952 |
(newClassVars includes:nm) ifFalse:[ |
|
953 |
changeSet1 add:nm |
|
954 |
] |
|
955 |
]. |
|
956 |
newClassVars do:[:nm | |
|
957 |
(oldClassVars includes:nm) ifFalse:[ |
|
958 |
changeSet1 add:nm |
|
959 |
] |
|
960 |
]. |
|
961 |
||
962 |
" |
|
963 |
recompile all methods accessing set of changed classvars |
|
964 |
here and also in all subclasses ... |
|
965 |
" |
|
966 |
||
967 |
" |
|
968 |
dont update change file for the recompilation |
|
969 |
" |
|
970 |
Class withoutUpdatingChangesDo:[ |
|
971 |
" " |
|
972 |
Transcript showCR:'recompiling class & inst methods accessing ' , changeSet1 printString. |
|
973 |
Transcript endEntry. |
|
974 |
" " |
|
975 |
oldClass withAllSubclasses do:[:aClass | |
|
976 |
aClass class recompileMethodsAccessingAny:changeSet1. |
|
977 |
aClass recompileMethodsAccessingAny:changeSet1. |
|
978 |
]. |
|
979 |
]. |
|
980 |
||
981 |
"notify change of class" |
|
982 |
changed ifTrue:[ |
|
983 |
self addChangeRecordForClass:oldClass. |
|
984 |
]. |
|
985 |
oldClass changed:#definition. |
|
986 |
||
987 |
^ oldClass |
|
988 |
] |
|
989 |
] |
|
990 |
] |
|
991 |
] |
|
992 |
]. |
|
993 |
||
994 |
" |
|
995 |
here we enter the darkness of mordor ... |
|
996 |
since instance variable layout and/or inheritance has changed. |
|
997 |
" |
|
998 |
(newComment ~= oldClass comment) ifTrue:[ |
|
999 |
newClass comment:newComment |
|
1000 |
]. |
|
1001 |
||
1002 |
superClassChange := oldClass superclass ~~ newClass superclass. |
|
1003 |
||
1004 |
" |
|
1005 |
dont allow built-in classes to be modified this way |
|
1006 |
" |
|
1007 |
(oldClass notNil and:[oldClass isBuiltInClass and:[superClassChange]]) ifTrue:[ |
|
1008 |
self error:'the inheritance of this class is fixed - you cannot change it'. |
|
1009 |
^ oldClass |
|
1010 |
]. |
|
1011 |
||
1012 |
" |
|
1013 |
catch special case, where superclass changed its layout and thus |
|
1014 |
forced redefinition of this class; |
|
1015 |
only log if this is not the case. |
|
1016 |
" |
|
1017 |
changed ifTrue:[ |
|
1018 |
(superClassChange |
|
1019 |
and:[(oldClass superclass isNil or:[oldClass superclass name = newClass superclass name]) |
|
1020 |
and:[(oldClassVars = newClassVars) |
|
1021 |
and:[(oldInstVars = newInstVars) |
|
1022 |
and:[newComment = oldClass comment]]]]) ifFalse:[ |
|
1023 |
self addChangeRecordForClass:newClass. |
|
1024 |
] |
|
1025 |
]. |
|
1026 |
||
1027 |
" |
|
1028 |
care for class methods ... |
|
1029 |
" |
|
1030 |
changeSet1 := Set new. |
|
1031 |
||
1032 |
classVarChange := false. |
|
1033 |
||
1034 |
superClassChange ifTrue:[ |
|
1035 |
" |
|
1036 |
superclass changed: |
|
1037 |
must recompile all class methods accessing ANY classvar |
|
1038 |
( |
|
1039 |
actually, we could be less strict and handle the case where |
|
1040 |
both the old and the new superclass have a common ancestor, |
|
1041 |
and both have no new classvariables in between. |
|
1042 |
This would speedup the case when a class is inserted into |
|
1043 |
the inheritance chain. |
|
1044 |
) |
|
1045 |
" |
|
1046 |
||
1047 |
oldClass allClassVarNames do:[:nm | changeSet1 add:nm]. |
|
1048 |
newClass allClassVarNames do:[:nm | changeSet1 add:nm]. |
|
1049 |
||
1050 |
" " |
|
1051 |
Transcript showCR:'recompiling class methods accessing any classvar'. |
|
1052 |
Transcript endEntry. |
|
1053 |
" " |
|
1054 |
self copyInvalidatedMethodsFrom:(oldClass class) |
|
1055 |
for:newMetaclass |
|
1056 |
accessingAny:changeSet1 |
|
1057 |
orSuper:true. |
|
1875 | 1058 |
newMetaclass recompileInvalidatedMethods. |
1439 | 1059 |
] ifFalse:[ |
1060 |
" |
|
1061 |
same superclass, find out which classvars have changed |
|
1062 |
" |
|
1063 |
classVarChange := oldClassVars ~= newClassVars. |
|
1064 |
classVarChange ifTrue:[ |
|
1065 |
oldClassVars do:[:nm | |
|
1066 |
(newClassVars includes:nm) ifFalse:[ |
|
1067 |
changeSet1 add:nm |
|
1068 |
] |
|
1069 |
]. |
|
1070 |
newClassVars do:[:nm | |
|
1071 |
(oldClassVars includes:nm) ifFalse:[ |
|
1072 |
changeSet1 add:nm |
|
1073 |
] |
|
1074 |
]. |
|
1075 |
]. |
|
1076 |
||
1077 |
classVarChange ifTrue:[ |
|
1078 |
" |
|
1079 |
must recompile some class-methods |
|
1080 |
" |
|
1081 |
" " |
|
1082 |
Transcript showCR:'recompiling class methods accessing ' , changeSet1 printString. |
|
1083 |
Transcript endEntry. |
|
1084 |
" " |
|
1085 |
self copyInvalidatedMethodsFrom:(oldClass class) for:newMetaclass accessingAny:changeSet1. |
|
1875 | 1086 |
newMetaclass recompileInvalidatedMethods. |
1439 | 1087 |
] ifFalse:[ |
1088 |
" |
|
1089 |
class methods still work |
|
1090 |
" |
|
1091 |
self copyMethodsFrom:(oldClass class) for:newMetaclass |
|
1092 |
]. |
|
1093 |
]. |
|
1094 |
||
1095 |
" |
|
1096 |
care for instance methods ... |
|
1097 |
" |
|
1098 |
||
1099 |
superClassChange ifTrue:[ |
|
1100 |
"superclass changed, |
|
1101 |
must recompile all methods accessing any class or instvar. |
|
1102 |
If number of instvars (i.e. the instances instSize) is the same, |
|
1103 |
we can limit the set of recompiled instance methods to those methods, |
|
1104 |
which refer to an instvar with a different inst-index |
|
1105 |
" |
|
1106 |
||
1107 |
" |
|
1108 |
the changeset consists of instance variables, |
|
1109 |
with a different position |
|
1110 |
" |
|
1111 |
changeSet2 := self differentInstanceVariableOffsetsIn:oldClass and:newClass. |
|
1112 |
||
1113 |
" |
|
1114 |
merge in the changed class variables |
|
1115 |
" |
|
1116 |
changeSet1 do:[:nm | changeSet2 add:nm]. |
|
1117 |
||
1118 |
" " |
|
1119 |
Transcript showCR:'recompiling instance methods accessing ' , changeSet2 printString , ' ...'. |
|
1120 |
Transcript endEntry. |
|
1121 |
" " |
|
1122 |
self copyInvalidatedMethodsFrom:oldClass |
|
1123 |
for:newClass |
|
1124 |
accessingAny:changeSet2 |
|
1125 |
orSuper:true. |
|
1875 | 1126 |
newClass recompileInvalidatedMethods. |
1439 | 1127 |
|
1128 |
] ifFalse:[ |
|
1129 |
" |
|
1130 |
same inheritance ... |
|
1131 |
" |
|
1132 |
instVarChange := oldInstVars ~= newInstVars. |
|
1133 |
instVarChange ifFalse:[ |
|
1134 |
" |
|
1135 |
same instance variables ... |
|
1136 |
" |
|
1137 |
classVarChange ifTrue:[ |
|
1138 |
"recompile all inst methods accessing changed classvars" |
|
1139 |
||
1140 |
" " |
|
1141 |
Transcript showCR:'recompiling instance methods accessing ' , changeSet1 printString , ' ...'. |
|
1142 |
Transcript endEntry. |
|
1143 |
" " |
|
1144 |
self copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:changeSet1. |
|
1875 | 1145 |
newClass recompileInvalidatedMethods. |
1439 | 1146 |
] |
1147 |
] ifTrue:[ |
|
1148 |
" |
|
1149 |
dont allow built-in classes to be modified |
|
1150 |
" |
|
1151 |
(oldClass notNil and:[oldClass isBuiltInClass and:[instVarChange]]) ifTrue:[ |
|
1152 |
self error:'the layout of this class is fixed - you cannot change it'. |
|
1153 |
^ oldClass |
|
1154 |
]. |
|
1155 |
||
1156 |
((oldInstVars size == 0) |
|
1157 |
or:[newInstVars startsWith:oldInstVars]) ifTrue:[ |
|
1158 |
" |
|
1159 |
only new inst variable(s) has/have been added - |
|
1160 |
old methods still work (the existing inst-indices are still valid) |
|
1161 |
" |
|
1162 |
" " |
|
1163 |
Transcript showCR:'copying methods ...'. |
|
1164 |
Transcript endEntry. |
|
1165 |
" " |
|
1166 |
self copyMethodsFrom:oldClass for:newClass. |
|
1167 |
||
1168 |
" |
|
1169 |
but: we have to recompile all methods accessing new instars |
|
1170 |
(it might have been a classVar/global before ...) |
|
1171 |
" |
|
1172 |
addedNames := newInstVars select:[:nm | (oldInstVars includes:nm) not]. |
|
1173 |
"merge in class variables" |
|
1174 |
changeSet1 do:[:nm | addedNames add:nm]. |
|
1175 |
||
1176 |
" " |
|
1177 |
Transcript showCR:'recompiling instance methods accessing ' , addedNames printString , '...'. |
|
1178 |
Transcript endEntry. |
|
1179 |
" " |
|
1180 |
newClass recompileMethodsAccessingAny:addedNames. |
|
1181 |
] ifFalse:[ |
|
1182 |
||
1183 |
" |
|
1184 |
the changeset consists of instance variables, |
|
1185 |
with a different position |
|
1186 |
" |
|
1187 |
changeSet2 := self differentInstanceVariableOffsetsIn:oldClass and:newClass. |
|
1188 |
||
1189 |
"merge in the class variables" |
|
1190 |
changeSet1 do:[:nm | changeSet2 add:nm]. |
|
1191 |
" " |
|
1192 |
Transcript showCR:'recompiling instance methods accessing ' , changeSet2 printString , ' ...'. |
|
1193 |
Transcript endEntry. |
|
1194 |
" " |
|
1195 |
self copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:changeSet2. |
|
1875 | 1196 |
newClass recompileInvalidatedMethods. |
1439 | 1197 |
]. |
1198 |
]. |
|
1199 |
]. |
|
1200 |
||
1201 |
" |
|
1202 |
WOW, everything done for this class |
|
1203 |
what about subclasses ? |
|
1204 |
" |
|
1205 |
||
1206 |
" |
|
1207 |
update superclass of immediate subclasses - |
|
1208 |
this forces recompilation (recursively) if needed |
|
1209 |
(dont update change file for the subclass changes) |
|
1210 |
" |
|
1211 |
Class withoutUpdatingChangesDo:[ |
|
1212 |
oldClass subclassesDo:[:aClass | |
|
1213 |
" " |
|
1214 |
Transcript showCR:'changing superclass of:' , aClass name. |
|
1215 |
Transcript endEntry. |
|
1216 |
" " |
|
1217 |
aClass superclass:newClass |
|
1218 |
] |
|
1219 |
]. |
|
1220 |
||
1221 |
" |
|
1819
e53f745ed80b
when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
1222 |
change any private subclasses' owners |
e53f745ed80b
when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
1223 |
" |
e53f745ed80b
when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
1224 |
oldClass privateClassesDo:[:aClass | |
e53f745ed80b
when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
1225 |
aClass class setOwningClass:newClass |
e53f745ed80b
when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
1226 |
]. |
e53f745ed80b
when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
1227 |
|
e53f745ed80b
when changing a class, do not forget to move the privateClasses
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
1228 |
" |
1439 | 1229 |
change category in oldClass - so we see immediately what it is ... |
1230 |
" |
|
1655 | 1231 |
oldClass category:#'* obsolete *'. |
1232 |
oldClass class category:#'* obsolete *'. |
|
1439 | 1233 |
|
1234 |
" |
|
1235 |
and make the new class globally known |
|
1236 |
" |
|
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
1237 |
namespace notNil ifTrue:[ |
1749 | 1238 |
thisIsPrivate ifTrue:[ |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
1239 |
namespace privateClassesAt:classSymbol put:newClass. |
1749 | 1240 |
] ifFalse:[ |
1910 | 1241 |
namespace at:nameKey put:newClass. |
1829
9e2a9fea35d0
ask to create nameSpace if it does not exist.
Claus Gittinger <cg@exept.de>
parents:
1821
diff
changeset
|
1242 |
namespace == Smalltalk ifTrue:[ |
1798
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1243 |
self checkForAliasesOf:oldClass with:newClass. |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1244 |
]. |
1439 | 1245 |
|
1724 | 1246 |
oldClass category ~= categoryString ifTrue:[ |
1247 |
"notify change of organization" |
|
1922
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
1248 |
namespace changed:#organization. |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
1249 |
namespace ~~ Smalltalk ifTrue:[ |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
1250 |
Smalltalk changed:#organization. |
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
1251 |
] |
1724 | 1252 |
] |
1439 | 1253 |
]. |
1254 |
]. |
|
1255 |
||
1256 |
" |
|
1257 |
Not becoming the old class creates some update problems; |
|
1258 |
the browsers must check carefully - a simple identity compare is |
|
1259 |
not enough ... |
|
1260 |
QUESTION: is this a good idea ? |
|
1261 |
" |
|
1262 |
||
1263 |
newClass dependents:(oldClass dependents). |
|
1264 |
newClass changed:#definition. |
|
1265 |
||
1266 |
"just to make certain ... - tell dependents of oldClass, that something changed |
|
1267 |
(systemBrowsers will react on this, and update their views)" |
|
1268 |
oldClass changed:#definition with:newClass. |
|
1269 |
||
1270 |
ObjectMemory flushCaches. |
|
1271 |
||
1272 |
^ newClass |
|
1273 |
||
1274 |
"Created: 26.5.1996 / 11:55:26 / cg" |
|
1480
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
1275 |
"Modified: 18.6.1996 / 14:19:39 / stefan" |
1922
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
1276 |
"Modified: 7.11.1996 / 17:35:53 / cg" |
1439 | 1277 |
! |
1278 |
||
1 | 1279 |
name:newName inEnvironment:aSystemDictionary |
1439 | 1280 |
subclassOf:aClass |
1281 |
instanceVariableNames:stringOfInstVarNames |
|
1282 |
variable:variableBoolean |
|
1283 |
words:wordsBoolean |
|
1284 |
pointers:pointersBoolean |
|
1285 |
classVariableNames:stringOfClassVarNames |
|
1286 |
poolDictionaries:stringOfPoolNames |
|
1287 |
category:categoryString |
|
1288 |
comment:commentString |
|
1289 |
changed:changed |
|
1 | 1290 |
|
885
ca805f0f4984
changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1291 |
^ self |
1439 | 1292 |
name:newName |
1293 |
in:aSystemDictionary |
|
1294 |
subclassOf:aClass |
|
1295 |
instanceVariableNames:stringOfInstVarNames |
|
1296 |
variable:variableBoolean |
|
1297 |
words:wordsBoolean |
|
1298 |
pointers:pointersBoolean |
|
1299 |
classVariableNames:stringOfClassVarNames |
|
1300 |
poolDictionaries:stringOfPoolNames |
|
1301 |
category:categoryString |
|
1302 |
comment:commentString |
|
1303 |
changed:changed |
|
1304 |
classInstanceVariableNames:'' |
|
885
ca805f0f4984
changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1305 |
|
1439 | 1306 |
"Modified: 26.5.1996 / 11:54:57 / cg" |
885
ca805f0f4984
changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1307 |
! |
ca805f0f4984
changed class creation to allow create including classInstVars (may be used to avoid recompilation)
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1308 |
|
621 | 1309 |
new |
1310 |
"create & return a new metaclass (a classes class). |
|
1311 |
Since metaclasses only have one instance (the class), |
|
1312 |
complain if there is already one. |
|
1313 |
You get a new class by sending #new to the returned metaclass |
|
1314 |
(confusing - isn't it ?)" |
|
1315 |
||
1316 |
|newClass| |
|
1317 |
||
1318 |
myClass notNil ifTrue:[ |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1319 |
^ self error:'Each metaclass may only have one instance'. |
621 | 1320 |
]. |
1321 |
newClass := self basicNew. |
|
1322 |
newClass setSuperclass:Object |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1323 |
methodDictionary:MethodDictionary new |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1324 |
instSize:0 |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1325 |
flags:(Behavior flagBehavior). |
621 | 1326 |
newClass setName:'someClass'. |
1327 |
myClass := newClass. |
|
1328 |
^ newClass |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1329 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1330 |
"Modified: 7.6.1996 / 15:39:11 / stefan" |
1 | 1331 |
! ! |
1332 |
||
1875 | 1333 |
!Metaclass methodsFor:'private'! |
68 | 1334 |
|
1752 | 1335 |
checkConventionsFor:className subClassOf:aClass instVarNames:instVarNameString classVarNames:classVarNameString |
621 | 1336 |
"Check for some 'considered bad-style' things, like lower case names. |
1337 |
NOTICE: |
|
1338 |
I dont like the confirmers below - we need a notifying: argument, to give |
|
1339 |
the outer codeview a chance to highlight the error. |
|
1340 |
(but thats how its defined in the book - maybe I will change it anyway). |
|
308 | 1341 |
" |
621 | 1342 |
|
1752 | 1343 |
|superClassInstVarNames| |
1344 |
||
1345 |
"/ superClassInstVarNames := aClass allInstVarNames asSet. |
|
1346 |
"/ |
|
1347 |
"/ "check for instVar redefs - this is not good" |
|
1348 |
"/ instVarNameString asCollectionOfWords do:[:anInstVarName | |
|
1349 |
"/ (superClassInstVarNames includes:anInstVarName) ifTrue:[ |
|
1350 |
"/ self warn:'an instance variable named ''' , anInstVarName , '''\is already defined in a superclass' withCRs. |
|
1351 |
"/ ^ false |
|
1352 |
"/ ] |
|
1353 |
"/ ]. |
|
1354 |
||
621 | 1355 |
"let user confirm, if the classname is no good" |
1356 |
className first isUppercase ifFalse:[ |
|
1752 | 1357 |
(self confirm:'classename ''' , className , ''' should start with an uppercase letter |
621 | 1358 |
(by convention only) |
308 | 1359 |
|
621 | 1360 |
install anyway ?' withCRs) |
1752 | 1361 |
ifFalse:[ |
1362 |
^ false |
|
1363 |
] |
|
621 | 1364 |
]. |
1365 |
||
1366 |
"let user confirm, if any instvarname is no good" |
|
1367 |
(instVarNameString asCollectionOfWords |
|
1368 |
findFirst:[:word | word first isUppercase]) ~~ 0 ifTrue:[ |
|
1752 | 1369 |
(self confirm:'instance variable names should start with a lowercase letter |
621 | 1370 |
(by convention only) |
1371 |
||
1372 |
install anyway ?' withCRs) |
|
1752 | 1373 |
ifFalse:[ |
1374 |
^ false |
|
1375 |
] |
|
308 | 1376 |
]. |
621 | 1377 |
|
1378 |
"let user confirm, if any classvarname is no good" |
|
1379 |
(classVarNameString asCollectionOfWords |
|
1380 |
findFirst:[:word | word first isLowercase]) ~~ 0 ifTrue:[ |
|
1752 | 1381 |
(self confirm:'class variable names should start with an uppercase letter |
621 | 1382 |
(by convention only) |
308 | 1383 |
|
621 | 1384 |
install anyway ?' withCRs) |
1752 | 1385 |
ifFalse:[ |
1386 |
^ false |
|
1387 |
]. |
|
621 | 1388 |
]. |
308 | 1389 |
|
621 | 1390 |
^ true |
1752 | 1391 |
|
1392 |
"Created: 15.10.1996 / 11:56:38 / cg" |
|
1393 |
"Modified: 15.10.1996 / 12:00:30 / cg" |
|
1 | 1394 |
! |
1395 |
||
1798
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1396 |
checkForAliasesOf:oldClass with:newClass |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1397 |
"oldClass changed its identity (now use newClass). |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1398 |
check if there are any global aliases, which should also be changed" |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1399 |
|
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1400 |
Smalltalk keysAndValuesDo:[:nm :o | |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1401 |
o == oldClass ifTrue:[ |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1402 |
nm ~~ oldClass name ifTrue:[ |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1403 |
(self confirm:('The global `' , nm , ''' is an alias for ' , oldClass name , '.\\Change it to the new class ?') withCRs) |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1404 |
ifTrue:[ |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1405 |
Smalltalk at:nm put:newClass |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1406 |
] |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1407 |
] |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1408 |
] |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1409 |
]. |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1410 |
|
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1411 |
"Created: 22.10.1996 / 15:20:59 / cg" |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1412 |
"Modified: 22.10.1996 / 15:25:50 / cg" |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1413 |
! |
543f1601bbeb
look for aliases, when migrating classes
Claus Gittinger <cg@exept.de>
parents:
1778
diff
changeset
|
1414 |
|
1 | 1415 |
copyInvalidatedMethodsFrom:oldClass for:newClass |
159 | 1416 |
"copy all methods from oldClass to newClass and change their code |
1417 |
to a trap method reporting an error. |
|
912
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1418 |
This is done when a class has changed its layout or inheritance, |
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1419 |
before recompilation is attempted. |
159 | 1420 |
This allows us to keep the source while trapping uncompilable (due to |
912
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1421 |
now undefined instvars) methods. Later compilation of these methods will show |
159 | 1422 |
an error on the transcript and lead to the debugger once called." |
1 | 1423 |
|
986 | 1424 |
|trap trapCode trapByteCode oldMethod newMethod |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1425 |
oldDict newDict| |
1 | 1426 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1427 |
oldDict := oldClass methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1428 |
newDict := MethodDictionary new:oldDict size. |
1875 | 1429 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1430 |
oldDict keysAndValuesDo:[ :sel :mthd | |
1875 | 1431 |
trap := mthd trapMethodForNumArgs:(mthd numArgs). |
1432 |
trapCode := trap code. |
|
1433 |
trapByteCode := trap byteCode. |
|
1434 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1435 |
mthd isWrapped ifTrue:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1436 |
oldMethod := mthd originalMethod |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1437 |
] ifFalse:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1438 |
oldMethod := mthd. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1439 |
]. |
1875 | 1440 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1441 |
newMethod := oldMethod copy. |
1875 | 1442 |
newMethod makeInvalid. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1443 |
newDict at:sel put:newMethod |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1444 |
]. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1445 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1446 |
newClass methodDictionary:newDict. |
912
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1447 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1448 |
"Modified: 12.6.1996 / 10:44:27 / stefan" |
1875 | 1449 |
"Modified: 4.11.1996 / 22:55:57 / cg" |
2 | 1450 |
! |
1451 |
||
1452 |
copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:setOfNames |
|
1453 |
"copy all methods from oldClass to newClass. Those methods accessing |
|
1454 |
a variable in setOfNames will be copied as invalid method, leading to |
|
159 | 1455 |
a trap when its executed. This is used when a class has changed its |
1456 |
layout for all methods which are affected by the change." |
|
1457 |
||
1458 |
self copyInvalidatedMethodsFrom:oldClass |
|
1459 |
for:newClass |
|
1460 |
accessingAny:setOfNames |
|
1461 |
orSuper:false |
|
1462 |
! |
|
1463 |
||
1464 |
copyInvalidatedMethodsFrom:oldClass for:newClass accessingAny:setOfNames orSuper:superBoolean |
|
1465 |
"copy all methods from oldClass to newClass. |
|
1466 |
Those methods accessing a variable in setOfNames will be copied as invalid method, |
|
1467 |
leading to a trap when its executed. If superBoolean is true, this is also done |
|
1468 |
for methods accessing super. This is used when a class has changed its |
|
1469 |
layout for all methods which are affected by the change." |
|
2 | 1470 |
|
1875 | 1471 |
|p source mustInvalidate |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1472 |
oldMethod newMethod methodDict newMethodDict nNames usedVars| |
2 | 1473 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1474 |
methodDict := oldClass methodDictionary. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1475 |
newMethodDict := methodDict copy. |
912
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1476 |
nNames := setOfNames size. |
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1477 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1478 |
methodDict keysAndValuesDo:[:selector :method | |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1479 |
method isWrapped ifTrue:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1480 |
oldMethod := method originalMethod |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1481 |
] ifFalse:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1482 |
oldMethod := method |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1483 |
]. |
202 | 1484 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1485 |
"before parsing (which may take some time), |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1486 |
do a string search if its only one variable, |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1487 |
we are looking for. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1488 |
Could look for more than one variable by string compare, but then |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1489 |
parsing it right away may be faster ..." |
202 | 1490 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1491 |
source := oldMethod source. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1492 |
((nNames == 1) and:[superBoolean not]) ifTrue:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1493 |
mustInvalidate := (source findString:(setOfNames first)) ~~ 0. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1494 |
] ifFalse:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1495 |
((nNames == 0) and:[superBoolean]) ifTrue:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1496 |
mustInvalidate := (source findString:'super') ~~ 0. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1497 |
] ifFalse:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1498 |
mustInvalidate := true |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1499 |
]. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1500 |
]. |
202 | 1501 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1502 |
mustInvalidate ifTrue:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1503 |
"we have to parse it ..." |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1504 |
p := Parser parseMethod:source in:newClass. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1505 |
(p isNil |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1506 |
or:[((usedVars := p usedVars) notNil and:[usedVars includesAny:setOfNames]) |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1507 |
or:[superBoolean and:[p usesSuper]]]) ifFalse:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1508 |
mustInvalidate := false |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1509 |
] |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1510 |
]. |
202 | 1511 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1512 |
mustInvalidate ifTrue:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1513 |
newMethod := oldMethod copy. |
1875 | 1514 |
newMethod makeInvalid. |
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1515 |
] ifFalse:[ |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1516 |
newMethod := oldMethod. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1517 |
]. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1518 |
newMethodDict at:selector put:newMethod |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1519 |
]. |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1520 |
newClass methodDictionary:newMethodDict. |
912
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1521 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1522 |
"Modified: 7.6.1996 / 08:33:52 / stefan" |
1875 | 1523 |
"Modified: 4.11.1996 / 22:56:10 / cg" |
1 | 1524 |
! |
1525 |
||
621 | 1526 |
copyMethodsFrom:oldClass for:newClass |
1527 |
"copy all methods from oldClass to newClass. |
|
912
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1528 |
This is used for class-methods when a class has changed, but its metaclass is |
621 | 1529 |
unaffected (i.e. classVars/inheritance have not changed) so there is no need |
1530 |
to recompile the class methods." |
|
195 | 1531 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1532 |
newClass methodDictionary:(oldClass methodDictionary copy). |
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1533 |
|
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1442
diff
changeset
|
1534 |
"Modified: 7.6.1996 / 08:34:43 / stefan" |
621 | 1535 |
! |
1536 |
||
1537 |
differentInstanceVariableOffsetsIn:class1 and:class2 |
|
1538 |
"return a set of instance variable names which have different |
|
1539 |
positions in class1 and class2. |
|
1540 |
Also, variables which are only present in one class are returned. |
|
1541 |
This is used to find methods which need recompilation after a |
|
912
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1542 |
change in the instance variable layout." |
621 | 1543 |
|
1544 |
|offsets1 offsets2 changeSet| |
|
195 | 1545 |
|
621 | 1546 |
changeSet := Set new. |
1547 |
||
1548 |
" |
|
1549 |
collect the instvar-indices in the old and new class |
|
1550 |
" |
|
1551 |
offsets1 := class1 instanceVariableOffsets. |
|
1552 |
offsets2 := class2 instanceVariableOffsets. |
|
195 | 1553 |
|
621 | 1554 |
" |
912
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1555 |
compute the changeset as a set of instance variables, |
a009f25a6800
be careful with self-chaning selector/methodArrays (done in VM's lookup)
Claus Gittinger <cg@exept.de>
parents:
904
diff
changeset
|
1556 |
which have a different position |
621 | 1557 |
" |
1558 |
offsets1 keysAndValuesDo:[:varName :varIndex | |
|
1559 |
(offsets2 includesKey:varName) ifFalse:[ |
|
1560 |
changeSet add:varName |
|
1561 |
] ifTrue:[ |
|
1562 |
(varIndex ~~ (offsets2 at:varName)) ifTrue:[ |
|
1563 |
changeSet add:varName |
|
1564 |
] |
|
195 | 1565 |
] |
1566 |
]. |
|
621 | 1567 |
offsets2 keysAndValuesDo:[:varName :varIndex | |
1568 |
(offsets1 includesKey:varName) ifFalse:[ |
|
1569 |
changeSet add:varName |
|
1570 |
] ifTrue:[ |
|
1571 |
(varIndex ~~ (offsets1 at:varName)) ifTrue:[ |
|
1572 |
changeSet add:varName |
|
1573 |
] |
|
1574 |
] |
|
1575 |
]. |
|
1576 |
^ changeSet |
|
195 | 1577 |
|
621 | 1578 |
" |
1579 |
View class |
|
1580 |
differentInstanceVariableOffsetsIn:View |
|
1581 |
and:StandardSystemView |
|
1582 |
View class |
|
1583 |
differentInstanceVariableOffsetsIn:Object |
|
1584 |
and:Point |
|
1585 |
" |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1586 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1587 |
|
1047 | 1588 |
setSoleInstance:aClass |
1589 |
myClass := aClass |
|
1590 |
||
1591 |
"Created: 12.12.1995 / 13:46:22 / cg" |
|
1 | 1592 |
! ! |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1593 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1594 |
!Metaclass methodsFor:'queries'! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1595 |
|
1179
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
1596 |
isBuiltInClass |
1266 | 1597 |
"return true if this class is known by the run-time-system. |
1598 |
Here, true is returned for myself, false for subclasses." |
|
1599 |
||
1179
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
1600 |
^ self == Metaclass class or:[self == Metaclass] |
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
1601 |
|
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
1602 |
"Created: 15.4.1996 / 17:17:34 / cg" |
1266 | 1603 |
"Modified: 23.4.1996 / 15:59:37 / cg" |
1179
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
1604 |
! |
3e0f32177af4
allow subclasses of Class to be changed
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
1605 |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1606 |
isMeta |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1607 |
"return true, if the receiver is some kind of metaclass; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1608 |
true is returned here. Redefines isMeta in Object" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1609 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1610 |
^ true |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1611 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1612 |
|
1920 | 1613 |
nameSpace |
1614 |
"return the nameSpace I am contained in. |
|
1615 |
Due to the implementation of nameSpaces (as classVariables), |
|
1616 |
a class can only be contained in one nameSpace (which is the desired)" |
|
1617 |
||
1618 |
"/ this information is in the class |
|
1619 |
||
1620 |
^ myClass nameSpace |
|
1621 |
||
1622 |
"Created: 7.11.1996 / 13:18:52 / cg" |
|
1623 |
! |
|
1624 |
||
1724 | 1625 |
owningClass |
1626 |
"return nil here - regular metaclasses are never private" |
|
1627 |
||
1628 |
^ nil |
|
1629 |
||
1630 |
"Created: 12.10.1996 / 20:12:16 / cg" |
|
1631 |
! |
|
1632 |
||
1757 | 1633 |
package |
1634 |
"return my package-id" |
|
1635 |
||
1636 |
^ myClass package |
|
1637 |
||
1638 |
"Created: 15.10.1996 / 19:44:51 / cg" |
|
1639 |
! |
|
1640 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1641 |
soleInstance |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1642 |
"return my sole class." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1643 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1644 |
^ myClass |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
1645 |
! ! |
621 | 1646 |
|
1742 | 1647 |
!Metaclass class methodsFor:'documentation'! |
639 | 1648 |
|
1649 |
version |
|
1922
0f0e0c992fc0
also send a change notifiaction for Smalltalk,
Claus Gittinger <cg@exept.de>
parents:
1921
diff
changeset
|
1650 |
^ '$Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.90 1996-11-07 16:36:30 cg Exp $' |
639 | 1651 |
! ! |