author | Claus Gittinger <cg@exept.de> |
Tue, 14 Nov 1995 20:02:34 +0100 | |
changeset 544 | d78012b20769 |
parent 527 | 7eedfdb0db62 |
child 555 | d63400e20718 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
153 | 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 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
13 |
'From Smalltalk/X, Version:2.10.8 on 29-oct-1995 at 19:51:30' ! |
453 | 14 |
|
1 | 15 |
ClassDescription subclass:#Class |
453 | 16 |
instanceVariableNames:'classvars comment subclasses classFilename package revision |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
17 |
history' |
488
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
18 |
classVariableNames:'UpdatingChanges LockChangesFile FileOutErrorSignal CatchMethodRedefinitions |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
19 |
MethodRedefinitionSignal UpdateChangeFileQuerySignal' |
453 | 20 |
poolDictionaries:'' |
21 |
category:'Kernel-Classes' |
|
1 | 22 |
! |
23 |
||
68 | 24 |
!Class class methodsFor:'documentation'! |
25 |
||
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
26 |
copyright |
88 | 27 |
" |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
28 |
COPYRIGHT (c) 1989 by Claus Gittinger |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
29 |
All Rights Reserved |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
30 |
|
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
31 |
This software is furnished under a license and may be used |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
32 |
only in accordance with the terms of that license and with the |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
33 |
inclusion of the above copyright notice. This software may not |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
34 |
be provided or otherwise made available to, or used by, any |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
35 |
other person. No title to or ownership of the software is |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
36 |
hereby transferred. |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
37 |
" |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
38 |
! |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
39 |
|
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
40 |
version |
544 | 41 |
^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.70 1995-11-14 19:01:36 cg Exp $' |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
42 |
! |
88 | 43 |
|
68 | 44 |
documentation |
45 |
" |
|
46 |
Class adds more functionality to classes; minimum stuff has already |
|
47 |
been defined in Behavior and ClassDescription; this adds naming, categories etc. |
|
48 |
||
49 |
Also change management and recompilation is defined here (since the superclasses |
|
50 |
do not have enough symbolic information to support compilation). |
|
51 |
||
168 | 52 |
For production code, the stc compiler is planned to (optionally) generate classes |
53 |
as subclasses of Behavior - to excludes all name, source info etc., |
|
68 | 54 |
however, normally all classes are subclasses of Class. |
55 |
||
56 |
Instance variables: |
|
57 |
||
153 | 58 |
classvars <String> the names of the class variables |
168 | 59 |
|
60 |
comment <String> the classes comment; either a string, |
|
61 |
a number specifying the offset in classFilename, or nil |
|
62 |
||
153 | 63 |
subclasses <Collection> cached collection of subclasses |
64 |
(currently unused - but will be soon) |
|
168 | 65 |
|
66 |
classFilename <String> the file (or nil) where the classes |
|
67 |
sources are found |
|
68 |
||
153 | 69 |
package <Symbol> the package, in which the class was defined |
385 | 70 |
(inserted by compilers) |
71 |
||
391 | 72 |
revision <String> revision string - inserted by stc |
168 | 73 |
|
74 |
history <any> a place for a history string (not currently used) |
|
68 | 75 |
|
76 |
Class variables: |
|
77 |
||
153 | 78 |
UpdatingChanges <Boolean> true if the changes-file shall be updated |
79 |
(except during startup and when filing in, this flag |
|
80 |
is usually true) |
|
68 | 81 |
|
488
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
82 |
LockChangesFile <Boolean> if true, the change file is locked for updates. |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
83 |
Required when multiple users operate on a common |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
84 |
change file. |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
85 |
This is an experimental new feature, being evaluated. |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
86 |
|
421 | 87 |
UpdateChangeFileQuerySignal used as an upQuery from the change management. |
88 |
Whenever a changeRecord is to be written, |
|
89 |
this signal is raised and a handler (if present) |
|
90 |
is supposed to return true or false. |
|
91 |
If unhandled, the value of the global |
|
92 |
UpdatingChanges is returned for backward |
|
93 |
compatibility (which means that the old |
|
94 |
mechanism is used if no query-handler |
|
95 |
is present). |
|
96 |
||
168 | 97 |
FileOutErrorSignal raised when an error occurs during fileOut |
98 |
||
362 | 99 |
CatchMethodRedefinitions if true, classes protect themself |
100 |
MethodRedefinitionSignal (by raising MethodRedefinitionSignal) |
|
101 |
from redefining any existing methods, |
|
102 |
which are defined in another package. |
|
103 |
(i.e. a signal will be raised, if you |
|
104 |
fileIn something which redefines an |
|
105 |
existing method and the packages do not |
|
106 |
match). |
|
107 |
The default is (currently) true. |
|
108 |
||
68 | 109 |
WARNING: layout known by compiler and runtime system |
110 |
" |
|
111 |
! ! |
|
112 |
||
1 | 113 |
!Class class methodsFor:'initialization'! |
114 |
||
115 |
initialize |
|
28 | 116 |
"the classvariable 'UpdatingChanges' controls if changes are put |
1 | 117 |
into the changes-file; normally this variable is set to true, but |
68 | 118 |
(for example) during fileIn or when changes are applied, it is set to false |
119 |
to avoid putting too much junk into the changes-file." |
|
1 | 120 |
|
153 | 121 |
UpdatingChanges := true. |
488
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
122 |
LockChangesFile := false. |
362 | 123 |
CatchMethodRedefinitions := true. |
124 |
||
153 | 125 |
FileOutErrorSignal isNil ifTrue:[ |
421 | 126 |
FileOutErrorSignal := ErrorSignal newSignalMayProceed:false. |
153 | 127 |
FileOutErrorSignal nameClass:self message:#fileOutErrorSignal. |
128 |
FileOutErrorSignal notifierString:'error during fileOut'. |
|
362 | 129 |
|
421 | 130 |
MethodRedefinitionSignal := ErrorSignal newSignalMayProceed:true. |
362 | 131 |
MethodRedefinitionSignal nameClass:self message:#methodRedefinitionSignal. |
132 |
MethodRedefinitionSignal notifierString:'attempt to redefine method from different package'. |
|
421 | 133 |
|
134 |
UpdateChangeFileQuerySignal := QuerySignal new mayProceed:true. |
|
135 |
UpdateChangeFileQuerySignal nameClass:self message:#updateChangeFileQuerySignal. |
|
136 |
UpdateChangeFileQuerySignal notifierString:'asking if changeFile update is wanted'. |
|
137 |
UpdateChangeFileQuerySignal handlerBlock:[:ex | ex proceedWith:UpdatingChanges]. |
|
153 | 138 |
] |
139 |
! ! |
|
140 |
||
345 | 141 |
!Class class methodsFor:'Signal constants'! |
153 | 142 |
|
453 | 143 |
updateChangeFileQuerySignal |
144 |
"return the signal used as an upQuery if the changeFile should be updated. |
|
145 |
If unhandled, the value of UpdatingChanges is returned by the signals |
|
146 |
static handler." |
|
147 |
||
148 |
^ UpdateChangeFileQuerySignal |
|
149 |
||
150 |
! |
|
151 |
||
153 | 152 |
fileOutErrorSignal |
168 | 153 |
"return the signal raised when an error occurs while fileing out. |
154 |
This is signalled to allow browsers some user feed back in case |
|
155 |
a fileout fails (for example due to disk-full errors)" |
|
156 |
||
153 | 157 |
^ FileOutErrorSignal |
362 | 158 |
! |
159 |
||
160 |
methodRedefinitionSignal |
|
161 |
"return the signal raised when a method is about to be installed |
|
162 |
which redefines an existing method and the methods packages are not |
|
163 |
equal. This helps when filing in alien code, to prevent existing |
|
164 |
methods to be overwritten or redefined by incompatible methods" |
|
165 |
||
166 |
^ MethodRedefinitionSignal |
|
167 |
! ! |
|
168 |
||
169 |
!Class class methodsFor:'accessing - flags'! |
|
170 |
||
171 |
updateChanges:aBoolean |
|
172 |
"turn on/off changes management. Return the prior value of the flag." |
|
173 |
||
174 |
|prev| |
|
175 |
||
176 |
prev := UpdatingChanges. |
|
177 |
UpdatingChanges := aBoolean. |
|
178 |
^ prev |
|
179 |
! |
|
180 |
||
488
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
181 |
lockChangesFile:aBoolean |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
182 |
"turn on/off change-file-locking. Return the previous value of the flag." |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
183 |
|
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
184 |
|prev| |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
185 |
|
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
186 |
prev := LockChangesFile. |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
187 |
LockChangesFile := aBoolean. |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
188 |
^ prev |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
189 |
! |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
190 |
|
362 | 191 |
catchMethodRedefinitions:aBoolean |
192 |
"turn on/off redefinition catching. Return the prior value of the flag." |
|
193 |
||
194 |
|prev| |
|
195 |
||
196 |
prev := CatchMethodRedefinitions. |
|
197 |
CatchMethodRedefinitions := aBoolean. |
|
198 |
^ prev |
|
453 | 199 |
! |
200 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
201 |
updatingChanges |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
202 |
"return true if changes are recorded" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
203 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
204 |
^ UpdatingChanges |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
205 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
206 |
|
488
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
207 |
lockChangesFile |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
208 |
"return true, if the change file is locked during update" |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
209 |
|
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
210 |
^ LockChangesFile |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
211 |
! |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
212 |
|
453 | 213 |
catchMethodRedefinitions |
214 |
"return the redefinition catching flag." |
|
215 |
||
216 |
^ CatchMethodRedefinitions |
|
1 | 217 |
! ! |
218 |
||
193 | 219 |
!Class class methodsFor:'enumeration '! |
220 |
||
221 |
allClassesInCategory:aCategory do:aBlock |
|
222 |
"evaluate aBlock for all classes in aCategory; |
|
223 |
no specific order is defined." |
|
224 |
||
199 | 225 |
Smalltalk allBehaviorsDo:[:aClass | |
193 | 226 |
aClass isMeta ifFalse:[ |
227 |
(aClass category = aCategory) ifTrue:[ |
|
228 |
aBlock value:aClass |
|
229 |
] |
|
230 |
]. |
|
231 |
] |
|
232 |
||
233 |
" |
|
234 |
Class allClassesInCategory:'Kernel-Classes' |
|
235 |
do:[:class |Transcript showCr:class name] |
|
236 |
" |
|
237 |
! |
|
238 |
||
239 |
allClassesInCategory:aCategory inOrderDo:aBlock |
|
240 |
"evaluate aBlock for all classes in aCategory; |
|
241 |
superclasses come first - then subclasses." |
|
242 |
||
243 |
|classes| |
|
244 |
||
245 |
classes := OrderedCollection new. |
|
199 | 246 |
Smalltalk allBehaviorsDo:[:aClass | |
193 | 247 |
aClass isMeta ifFalse:[ |
248 |
(aClass category = aCategory) ifTrue:[ |
|
249 |
classes add:aClass |
|
250 |
] |
|
251 |
] |
|
252 |
]. |
|
253 |
classes topologicalSort:[:a :b | b isSubclassOf:a]. |
|
254 |
classes do:aBlock |
|
255 |
! ! |
|
256 |
||
1 | 257 |
!Class methodsFor:'ST/V subclass creation'! |
258 |
||
37 | 259 |
subclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s |
260 |
"this method allows fileIn of ST/V classes |
|
1 | 261 |
(which seem to have no category)" |
262 |
||
263 |
^ self subclass:t |
|
153 | 264 |
instanceVariableNames:f |
265 |
classVariableNames:d |
|
266 |
poolDictionaries:s |
|
267 |
category:'ST/V classes' |
|
1 | 268 |
! |
269 |
||
37 | 270 |
variableByteSubclass:t classVariableNames:d poolDictionaries:s |
271 |
"this method allows fileIn of ST/V variable byte classes |
|
1 | 272 |
(which seem to have no category and no instvars)" |
273 |
||
274 |
^ self variableByteSubclass:t |
|
153 | 275 |
instanceVariableNames:'' |
276 |
classVariableNames:d |
|
277 |
poolDictionaries:s |
|
278 |
category:'ST/V classes' |
|
1 | 279 |
! |
280 |
||
37 | 281 |
variableSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s |
282 |
"this method allows fileIn of ST/V variable pointer classes |
|
1 | 283 |
(which seem to have no category)" |
284 |
||
285 |
^ self variableSubclass:t |
|
153 | 286 |
instanceVariableNames:f |
287 |
classVariableNames:d |
|
288 |
poolDictionaries:s |
|
289 |
category:'ST/V classes' |
|
1 | 290 |
! ! |
291 |
||
292 |
!Class methodsFor:'accessing'! |
|
293 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
294 |
allClassVarNames |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
295 |
"return a collection of all the class variable name-strings |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
296 |
this includes all superclass-class variables" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
297 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
298 |
^ self addAllClassVarNamesTo:(OrderedCollection new) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
299 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
300 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
301 |
Float allClassVarNames |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
302 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
303 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
304 |
|
1 | 305 |
classVarNames |
68 | 306 |
"return a collection of the class variable name-strings. |
307 |
Only names of class variables defined in this class are included |
|
308 |
in the returned collection - use allClassVarNames, to get all known names." |
|
1 | 309 |
|
10 | 310 |
classvars isNil ifTrue:[ |
153 | 311 |
^ OrderedCollection new |
10 | 312 |
]. |
313 |
^ classvars asCollectionOfWords |
|
68 | 314 |
|
153 | 315 |
" |
316 |
Object classVarNames |
|
317 |
Float classVarNames |
|
318 |
" |
|
319 |
! |
|
320 |
||
453 | 321 |
classVariableString:aString |
322 |
"set the classes classvarnames string; |
|
323 |
Initialize new class variables with nil, clear and remove old ones. |
|
324 |
No change record is written and no classes are recompiled." |
|
325 |
||
326 |
|prevVarNames varNames any| |
|
327 |
||
328 |
"ignore for metaclasses except the one" |
|
329 |
(self isMeta) ifTrue:[ |
|
330 |
(self == Metaclass) ifFalse:[ |
|
331 |
^ self |
|
332 |
] |
|
333 |
]. |
|
334 |
(classvars = aString) ifFalse:[ |
|
335 |
prevVarNames := self classVarNames. |
|
336 |
classvars := aString. |
|
337 |
varNames := self classVarNames. |
|
338 |
||
339 |
"new ones get initialized to nil; |
|
340 |
- old ones are nilled and removed from Smalltalk" |
|
341 |
any := false. |
|
342 |
||
343 |
varNames do:[:aName | |
|
344 |
(prevVarNames includes:aName) ifFalse:[ |
|
345 |
"a new one" |
|
346 |
self classVarAt:aName put:nil. |
|
347 |
any := true. |
|
348 |
] ifTrue:[ |
|
349 |
prevVarNames remove:aName |
|
350 |
] |
|
351 |
]. |
|
352 |
"left overs are gone" |
|
353 |
prevVarNames do:[:aName | |
|
354 |
self classVarAt:aName put:nil. |
|
355 |
Smalltalk removeKey:(self name , ':' , aName) asSymbol. |
|
356 |
]. |
|
357 |
any ifTrue:[ |
|
358 |
Smalltalk changed:#classVariables with:self |
|
359 |
]. |
|
360 |
] |
|
361 |
! |
|
362 |
||
363 |
setComment:com category:categoryStringOrSymbol |
|
364 |
"set the comment and category of the class; |
|
365 |
do NOT create a change record" |
|
366 |
||
367 |
|cat| |
|
368 |
||
369 |
comment := com. |
|
370 |
categoryStringOrSymbol isNil ifTrue:[ |
|
371 |
cat := '' |
|
372 |
] ifFalse:[ |
|
373 |
cat := categoryStringOrSymbol |
|
374 |
]. |
|
375 |
category := cat asSymbol |
|
376 |
! |
|
377 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
378 |
revision |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
379 |
"return the revision-ID of the class which corresponds to the |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
380 |
rcs-id of the source from which this class was compiled. |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
381 |
This is always valid for stc-compiled classes which include a version method, |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
382 |
since stc extracts this info and places it into an instance variable. |
544 | 383 |
Alternatively, the code below tries to extract it from the revisionString directly, |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
384 |
this is used with filed-In classes (non stc-compiled). |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
385 |
To check if a source corresponds to a compiled binary, compare this |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
386 |
ID with the one found in the version-methods comment." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
387 |
|
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
388 |
|vsnString words| |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
389 |
|
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
390 |
revision notNil ifTrue:[ ^ revision]. |
544 | 391 |
vsnString := self revisionString. |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
392 |
vsnString notNil ifTrue:[ |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
393 |
words := vsnString asCollectionOfWords. |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
394 |
"/ |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
395 |
"/ supported formats: |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
396 |
"/ |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
397 |
"/ $-Header: pathName rev date time user state $ |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
398 |
"/ $-Revision: rev $ |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
399 |
"/ $-Id: fileName rev date time user state $ |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
400 |
"/ |
544 | 401 |
((words at:1) = '$Header:') ifTrue:[ |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
402 |
^ words at:3 |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
403 |
]. |
544 | 404 |
((words at:1) = '$Revision:') ifTrue:[ |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
405 |
^ words at:2 |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
406 |
]. |
544 | 407 |
((words at:1) = '$Id:') ifTrue:[ |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
408 |
^ words at:3 |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
409 |
]. |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
410 |
]. |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
411 |
^ nil |
453 | 412 |
|
413 |
" |
|
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
414 |
Object revision |
453 | 415 |
" |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
416 |
|
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
417 |
"Created: 11.11.1995 / 14:27:20 / cg" |
453 | 418 |
! |
419 |
||
420 |
classVariableString |
|
421 |
"return a string of the class variables names. |
|
422 |
Only names of class variables defined in this class are in the |
|
423 |
returned string." |
|
424 |
||
425 |
classvars isNil ifTrue:[^ '']. |
|
426 |
^ classvars |
|
427 |
||
428 |
" |
|
429 |
Object classVariableString |
|
430 |
Float classVariableString |
|
431 |
" |
|
432 |
! |
|
433 |
||
1 | 434 |
comment |
435 |
"return the comment (aString) of the class" |
|
436 |
||
168 | 437 |
|stream string| |
438 |
||
439 |
"the comment is either a string, or an integer specifying the |
|
440 |
position within the classes sourcefile ... |
|
441 |
" |
|
442 |
comment isNumber ifTrue:[ |
|
443 |
classFilename notNil ifTrue:[ |
|
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
444 |
stream := self sourceStream. "/ Smalltalk sourceFileStreamFor:classFilename. |
168 | 445 |
stream notNil ifTrue:[ |
446 |
stream position:comment. |
|
216 | 447 |
string := String readFrom:stream onError:''. |
168 | 448 |
stream close. |
449 |
^ string |
|
450 |
] |
|
451 |
] |
|
452 |
]. |
|
1 | 453 |
^ comment |
153 | 454 |
|
455 |
" |
|
456 |
Object comment |
|
457 |
" |
|
453 | 458 |
! |
459 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
460 |
classVarAt:aSymbol |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
461 |
"return the value of a class variable. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
462 |
Currently, this returns nil if there is no such classvar - |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
463 |
this may change." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
464 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
465 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
466 |
this hides the (current) implementation of classVariables |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
467 |
from the outside world. Currently, classvars are stored in |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
468 |
the Smalltalk dictionary with a funny name, since there are |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
469 |
no classPools yet. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
470 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
471 |
^ Smalltalk at:(self name , ':' , aSymbol) asSymbol |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
472 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
473 |
|
453 | 474 |
classVarAt:aSymbol put:something |
475 |
"store something in a classvariable. |
|
476 |
Currently this creates a global with a funny name if no such |
|
477 |
classVar exists - this may change." |
|
478 |
||
479 |
" |
|
480 |
this hides the (current) implementation of classVariables |
|
481 |
from the outside world. Currently, classvars are stored in |
|
482 |
the Smalltalk dictionary with a funny name, since there are |
|
483 |
no classPools yet. |
|
484 |
" |
|
485 |
Smalltalk at:(self name , ':' , aSymbol) asSymbol put:something. |
|
486 |
! |
|
1 | 487 |
|
488 |
setComment:aString |
|
489 |
"set the comment of the class to be the argument, aString; |
|
490 |
do NOT create a change record" |
|
491 |
||
492 |
comment := aString |
|
493 |
! |
|
494 |
||
495 |
comment:aString |
|
496 |
"set the comment of the class to be the argument, aString; |
|
153 | 497 |
create a change record and notify dependents." |
498 |
||
499 |
|oldComment| |
|
1 | 500 |
|
10 | 501 |
comment ~= aString ifTrue:[ |
168 | 502 |
oldComment := self comment. |
153 | 503 |
comment := aString. |
504 |
self changed:#comment with:oldComment. |
|
544 | 505 |
self updateRevisionString. |
153 | 506 |
self addChangeRecordForClassComment:self. |
10 | 507 |
] |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
508 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
509 |
"Created: 29.10.1995 / 19:41:24 / cg" |
10 | 510 |
! |
511 |
||
216 | 512 |
package |
513 |
"return the package of the class" |
|
514 |
||
515 |
^ package |
|
516 |
||
517 |
" |
|
518 |
Object package |
|
519 |
" |
|
520 |
! |
|
521 |
||
484
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
522 |
package:aStringOrSymbol |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
523 |
"set the package of the class." |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
524 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
525 |
package := aStringOrSymbol |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
526 |
! |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
527 |
|
216 | 528 |
setPackage:aStringOrSymbol |
529 |
"set the package of the class." |
|
530 |
||
531 |
package := aStringOrSymbol |
|
532 |
! |
|
533 |
||
385 | 534 |
revision:aString |
535 |
"set the revision-ID. |
|
536 |
This should normally not be done in the running system, as the source-manager |
|
537 |
will need this to validate sourcefiles being correct for a given binary |
|
538 |
(and optionally: extracting the required sourcefile from the rcs source)" |
|
539 |
||
540 |
revision := aString |
|
541 |
! |
|
542 |
||
484
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
543 |
sourceCodeInfo |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
544 |
"return the sourceCodeInfo, which defines the module and the subdirectory |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
545 |
in which the receiver class was built. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
546 |
The info returned consists of a dictionary |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
547 |
filled with (at least) values at: #module, #directory and #library. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
548 |
If no such info is present in the class, nil is returned. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
549 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
550 |
By convention, this info is encoded in the classes package |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
551 |
string (which is given as argument to stc) as the last word in parenthesis. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
552 |
The info consists of 1 to 3 subcomponents, separated by colons. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
553 |
The first defines the classes module (i.e. some application identifier), |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
554 |
the second defines the subdirectory within that module, the third |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
555 |
defines the name of the class library. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
556 |
If left blank, the module info defaults to 'stx', |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
557 |
the directory info defaults to library name. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
558 |
The library name may not be left blank. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
559 |
(this is done for backward compatibility,) |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
560 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
561 |
For example: |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
562 |
'....(libbasic)' -> module: stx directory: libbasic library: libbasic |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
563 |
'....(stx:libbasic)' -> module: stx directory: libbasic library: libbasic |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
564 |
'....(aeg:libIECInterface)' -> module: aeg directory: libIECInterface library:libIECInterface |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
565 |
'....(stx:goodies/persistency:libdbase)' -> module: stx directory: goodies/persistency library:libdbase |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
566 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
567 |
The way how the sourceCodeManager uses this to find the source location |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
568 |
depends on the scheme used. For CVS, the module is taken as the -d arg, |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
569 |
while the directory is prepended to the file name. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
570 |
Other schemes may do things differently - these are not yet specified. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
571 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
572 |
Caveat: |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
573 |
Encoding this info in the package string seems somewhat kludgy. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
574 |
" |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
575 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
576 |
|sourceInfo packageString idx1 idx2 |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
577 |
moduleString directoryString libraryString components| |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
578 |
|
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
579 |
package isNil ifTrue:[^ nil]. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
580 |
|
484
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
581 |
packageString := package asString. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
582 |
idx1 := packageString lastIndexOf:$(. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
583 |
idx1 ~~ 0 ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
584 |
idx2 := packageString indexOf:$) startingAt:idx1+1. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
585 |
idx2 ~~ 0 ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
586 |
sourceInfo := packageString copyFrom:idx1 + 1 to:idx2 - 1 |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
587 |
] |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
588 |
]. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
589 |
sourceInfo isNil ifTrue:[^ nil]. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
590 |
components := sourceInfo asCollectionOfSubstringsSeparatedBy:$:. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
591 |
components size == 0 ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
592 |
moduleString := 'stx'. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
593 |
directoryString := libraryString := ''. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
594 |
^ nil |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
595 |
] ifFalse:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
596 |
components size == 1 ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
597 |
"/ a single name given - the module becomes 'stx', |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
598 |
"/ if the component includes slashes, its the directory |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
599 |
"/ otherwise the library |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
600 |
"/ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
601 |
moduleString := 'stx'. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
602 |
directoryString := libraryString := components at:1. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
603 |
(libraryString includes:$/) ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
604 |
libraryString := libraryString asFilename baseName |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
605 |
] |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
606 |
] ifFalse:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
607 |
components size == 2 ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
608 |
"/ two components - assume its the directory and the library |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
609 |
moduleString := 'stx'. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
610 |
directoryString := components at:1. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
611 |
libraryString := components at:2. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
612 |
] ifFalse:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
613 |
"/ all components given |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
614 |
moduleString := components at:1. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
615 |
directoryString := components at:2. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
616 |
libraryString := components at:3. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
617 |
] |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
618 |
] |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
619 |
]. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
620 |
libraryString isEmpty ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
621 |
directoryString notEmpty ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
622 |
libraryString := directoryString asFilename baseName |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
623 |
]. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
624 |
libraryString isEmpty ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
625 |
"/ lets extract the library from the liblist file ... |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
626 |
libraryString := Smalltalk libraryFileNameOfClass:self. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
627 |
libraryString isNil ifTrue:[^ nil]. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
628 |
] |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
629 |
]. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
630 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
631 |
moduleString isEmpty ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
632 |
moduleString := 'stx'. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
633 |
]. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
634 |
directoryString isEmpty ifTrue:[ |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
635 |
directoryString := libraryString. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
636 |
]. |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
637 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
638 |
^ IdentityDictionary |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
639 |
with:(#module->moduleString) |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
640 |
with:(#directory->directoryString) |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
641 |
with:(#library->libraryString) |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
642 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
643 |
" |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
644 |
Object sourceCodeInfo |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
645 |
View sourceCodeInfo |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
646 |
Model sourceCodeInfo |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
647 |
BinaryObjectStorage sourceCodeInfo |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
648 |
MemoryMonitor sourceCodeInfo |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
649 |
ClockView sourceCodeInfo |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
650 |
" |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
651 |
|
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
652 |
"Created: 4.11.1995 / 20:36:53 / cg" |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
653 |
! |
12f066c0ac29
method to extract sourceInfo from package string added
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
654 |
|
216 | 655 |
history |
656 |
"return the history of the class" |
|
657 |
||
658 |
^ history |
|
659 |
||
660 |
" |
|
661 |
Object history |
|
662 |
" |
|
663 |
! |
|
664 |
||
665 |
setHistory:aString |
|
666 |
"set the history of the class." |
|
667 |
||
668 |
history := aString |
|
669 |
! |
|
670 |
||
671 |
primitiveDefinitionsString |
|
672 |
"return the primitiveDefinition string or nil" |
|
673 |
||
357 | 674 |
^ self getPrimitiveSpecsAt:1 |
216 | 675 |
|
676 |
" |
|
677 |
Object primitiveDefinitionsString |
|
678 |
String primitiveDefinitionsString |
|
679 |
" |
|
680 |
! |
|
681 |
||
682 |
primitiveVariablesString |
|
683 |
"return the primitiveVariables string or nil" |
|
684 |
||
357 | 685 |
^ self getPrimitiveSpecsAt:2 |
216 | 686 |
! |
687 |
||
688 |
primitiveFunctionsString |
|
689 |
"return the primitiveFunctions string or nil" |
|
690 |
||
357 | 691 |
^ self getPrimitiveSpecsAt:3 |
216 | 692 |
! |
693 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
694 |
history:aString |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
695 |
"set the history of the class." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
696 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
697 |
history := aString |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
698 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
699 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
700 |
primitiveSpec |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
701 |
"return the primitiveSpec or nil" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
702 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
703 |
^ primitiveSpec |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
704 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
705 |
|
453 | 706 |
primitiveSpec:anArrayOf3ElementsOrNil |
707 |
"set the primitiveSpec or nil" |
|
708 |
||
709 |
primitiveSpec := anArrayOf3ElementsOrNil |
|
710 |
! |
|
711 |
||
216 | 712 |
primitiveDefinitions:aString |
713 |
"set the primitiveDefinition string" |
|
714 |
||
360 | 715 |
self setPrimitiveSpecsAt:1 to:aString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
716 |
self addChangeRecordForPrimitiveDefinitions:self. |
544 | 717 |
self updateRevisionString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
718 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
719 |
"Created: 29.10.1995 / 19:41:39 / cg" |
216 | 720 |
! |
721 |
||
722 |
primitiveVariables:aString |
|
723 |
"set the primitiveVariable string" |
|
724 |
||
360 | 725 |
self setPrimitiveSpecsAt:2 to:aString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
726 |
self addChangeRecordForPrimitiveVariables:self. |
544 | 727 |
self updateRevisionString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
728 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
729 |
"Created: 29.10.1995 / 19:41:58 / cg" |
216 | 730 |
! |
731 |
||
732 |
primitiveFunctions:aString |
|
733 |
"set the primitiveFunction string" |
|
734 |
||
360 | 735 |
self setPrimitiveSpecsAt:3 to:aString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
736 |
self addChangeRecordForPrimitiveFunctions:self. |
544 | 737 |
self updateRevisionString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
738 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
739 |
"Created: 29.10.1995 / 19:41:48 / cg" |
216 | 740 |
! |
741 |
||
168 | 742 |
classFilename |
153 | 743 |
"return the name of the file from which the class was compiled. |
744 |
This is currently NOT used." |
|
10 | 745 |
|
168 | 746 |
^ classFilename |
1 | 747 |
! |
748 |
||
423 | 749 |
setClassFilename:aFilename |
750 |
"set the classes filename. |
|
751 |
This is a dangerous (low level) operation, since the |
|
752 |
comment and primitiveSpecs may no longer be accessable, if a wrong filename |
|
753 |
is set here." |
|
754 |
||
755 |
classFilename := aFilename |
|
756 |
||
757 |
"Modified: 8.9.1995 / 14:16:48 / claus" |
|
758 |
! |
|
759 |
||
1 | 760 |
definition |
761 |
"return an expression-string to define myself" |
|
762 |
||
763 |
|s| |
|
764 |
||
765 |
s := WriteStream on:(String new). |
|
766 |
self fileOutDefinitionOn:s. |
|
767 |
^ s contents |
|
768 |
||
153 | 769 |
" |
770 |
Object definition |
|
771 |
Point definition |
|
772 |
" |
|
1 | 773 |
! |
774 |
||
199 | 775 |
source |
776 |
"return the classes full source code" |
|
777 |
||
778 |
|code aStream| |
|
779 |
||
780 |
" this is too slow for big classes ... |
|
781 |
code := String new:1000. |
|
782 |
aStream := WriteStream on:code. |
|
783 |
self fileOutOn:aStream |
|
784 |
" |
|
785 |
aStream := FileStream newFileNamed:'__temp'. |
|
786 |
aStream isNil ifTrue:[ |
|
787 |
self notify:'cannot create temporary file.'. |
|
788 |
^ nil |
|
789 |
]. |
|
399 | 790 |
FileOutErrorSignal handle:[:ex | |
791 |
aStream nextPutAll:'"no source available"'. |
|
792 |
] do:[ |
|
403 | 793 |
self fileOutOn:aStream. |
399 | 794 |
]. |
199 | 795 |
aStream close. |
796 |
aStream := FileStream oldFileNamed:'__temp'. |
|
797 |
aStream isNil ifTrue:[ |
|
798 |
self notify:'oops - cannot reopen temp file'. |
|
799 |
^ nil |
|
800 |
]. |
|
801 |
code := aStream contents. |
|
802 |
aStream close. |
|
803 |
OperatingSystem removeFile:'__temp'. |
|
804 |
^ code |
|
805 |
! |
|
806 |
||
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
807 |
sourceStream |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
808 |
"return an open stream on my sourcefile, nil if that is not available" |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
809 |
|
524 | 810 |
|source fileName aStream cls| |
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
811 |
|
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
812 |
classFilename notNil ifTrue:[ |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
813 |
source := classFilename |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
814 |
] ifFalse:[ |
524 | 815 |
self isMeta ifTrue:[ |
816 |
cls := self soleInstance |
|
817 |
] ifFalse:[ |
|
818 |
cls := self |
|
819 |
]. |
|
820 |
source := (Smalltalk fileNameForClass:cls) , '.st' |
|
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
821 |
]. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
822 |
|
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
823 |
fileName := Smalltalk getSourceFileName:source. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
824 |
fileName isNil ifTrue:[ |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
825 |
fileName := source |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
826 |
]. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
827 |
aStream := fileName asFilename readStream. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
828 |
aStream isNil ifTrue:[ |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
829 |
"/ |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
830 |
"/ hard case - there is no source file for this class |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
831 |
"/ (neither in the source-dir-path, nor in the current directory). |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
832 |
"/ |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
833 |
|
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
834 |
"/ |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
835 |
"/ look if my binary is from a dynamically loaded module, |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
836 |
"/ and, if so, look in the modules directory for the |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
837 |
"/ source file. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
838 |
"/ |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
839 |
ObjectFileLoader notNil ifTrue:[ |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
840 |
ObjectFileLoader loadedObjectHandlesDo:[:h | |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
841 |
|f| |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
842 |
|
524 | 843 |
aStream isNil ifTrue:[ |
844 |
(h classes includes:self) ifTrue:[ |
|
845 |
f := h pathName. |
|
846 |
f := f asFilename directory. |
|
847 |
f := f construct:source. |
|
848 |
f exists ifTrue:[ |
|
849 |
aStream := f readStream. |
|
850 |
]. |
|
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
851 |
]. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
852 |
] |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
853 |
]. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
854 |
]. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
855 |
]. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
856 |
|
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
857 |
aStream isNil ifTrue:[ |
524 | 858 |
|
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
859 |
"/ mhmh - still no source file. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
860 |
"/ If there is a SourceCodeManager, ask it to aquire the |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
861 |
"/ the source for my class, and return an open stream on it. |
524 | 862 |
|
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
863 |
SourceCodeManager notNil ifTrue:[ |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
864 |
aStream := SourceCodeManager sourceStreamFor:self. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
865 |
] |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
866 |
]. |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
867 |
|
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
868 |
^ aStream |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
869 |
|
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
870 |
" |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
871 |
Object sourceStream |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
872 |
Clock sourceStream |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
873 |
" |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
874 |
|
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
875 |
"Created: 10.11.1995 / 21:05:13 / cg" |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
876 |
! |
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
877 |
|
1 | 878 |
addClassVarName:aString |
153 | 879 |
"add a class variable if not already there and initialize it with nil. |
391 | 880 |
Also writes a change record and notifies dependents. |
153 | 881 |
BUG: Currently, no recompilation is done - this will change." |
1 | 882 |
|
883 |
(self classVarNames includes:aString) ifFalse:[ |
|
153 | 884 |
self classVariableString:(self classVariableString , ' ' , aString). |
885 |
self addChangeRecordForClass:self. |
|
544 | 886 |
self updateRevisionString. |
153 | 887 |
self changed:#definition. |
888 |
] |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
889 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
890 |
"Created: 29.10.1995 / 19:40:51 / cg" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
891 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
892 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
893 |
sharedPools |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
894 |
"ST/X does not (currently) support pools" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
895 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
896 |
^ #() |
153 | 897 |
! |
898 |
||
453 | 899 |
setClassVariableString:aString |
900 |
"set the classes classvarnames string. |
|
901 |
This is a dangerous (low level) operation, since the |
|
902 |
classvariables are not really created or updated. Also, |
|
903 |
NO change record is written." |
|
904 |
||
905 |
classvars := aString |
|
906 |
! |
|
907 |
||
153 | 908 |
removeClassVarName:aString |
909 |
"remove a class variable if not already there. |
|
391 | 910 |
Also writes a change record and notifies dependents. |
153 | 911 |
BUG: Currently, no recompilation is done - this will change." |
912 |
||
913 |
|names newNames| |
|
914 |
||
915 |
names := self classVarNames. |
|
916 |
(names includes:aString) ifTrue:[ |
|
917 |
newNames := ''. |
|
918 |
names do:[:nm | nm ~= aString ifTrue:[newNames := newNames , nm , ' ']]. |
|
919 |
self classVariableString:newNames withoutSpaces. |
|
920 |
self addChangeRecordForClass:self. |
|
544 | 921 |
self updateRevisionString. |
153 | 922 |
self changed:#definition. |
1 | 923 |
] |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
924 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
925 |
"Created: 29.10.1995 / 19:42:08 / cg" |
85 | 926 |
! |
927 |
||
928 |
renameCategory:oldCategory to:newCategory |
|
153 | 929 |
"rename a category (changes category of those methods). |
391 | 930 |
Appends a change record and notifies dependents." |
85 | 931 |
|
932 |
|any| |
|
933 |
||
934 |
any := false. |
|
92 | 935 |
methodArray do:[:aMethod | |
153 | 936 |
aMethod category = oldCategory ifTrue:[ |
937 |
aMethod category:newCategory. |
|
938 |
any := true. |
|
939 |
] |
|
85 | 940 |
]. |
941 |
any ifTrue:[ |
|
153 | 942 |
self addChangeRecordForRenameCategory:oldCategory to:newCategory. |
544 | 943 |
self updateRevisionString. |
153 | 944 |
self changed:#methodCategory. |
85 | 945 |
] |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
946 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
947 |
"Created: 29.10.1995 / 19:42:15 / cg" |
1 | 948 |
! ! |
949 |
||
950 |
!Class methodsFor:'adding/removing'! |
|
951 |
||
68 | 952 |
addSelector:newSelector withMethod:newMethod |
953 |
"add the method given by 2nd argument under the selector given by |
|
92 | 954 |
1st argument to the methodDictionary. |
153 | 955 |
Append a change record to the changes file and tell dependents." |
1 | 956 |
|
362 | 957 |
|oldMethod| |
958 |
||
959 |
CatchMethodRedefinitions ifTrue:[ |
|
960 |
"check for attempts to redefine a method |
|
961 |
in a different package. Signal a resumable error if so. |
|
962 |
This allows tracing redefinitions of existing system methods |
|
963 |
when filing in alien code .... |
|
964 |
(which we may want to forbit sometimes) |
|
965 |
" |
|
966 |
oldMethod := self compiledMethodAt:newSelector. |
|
967 |
oldMethod notNil ifTrue:[ |
|
968 |
oldMethod package ~= newMethod package ifTrue:[ |
|
969 |
" |
|
970 |
attempt to redefine an existing method, which was |
|
971 |
defined in another package. |
|
972 |
If you continue in the debugger, the new method gets installed. |
|
973 |
Otherwise, the existing (old) method remains valid. |
|
974 |
||
975 |
You can turn of the catching of redefinitions by setting |
|
976 |
CatchMethodRedefinitions to false |
|
977 |
(also found in the NewLaunchers 'settings-misc' menu) |
|
978 |
" |
|
406 | 979 |
MethodRedefinitionSignal |
980 |
raiseErrorString:(' ' , name , '>>' , newSelector) |
|
362 | 981 |
] |
982 |
] |
|
983 |
]. |
|
92 | 984 |
(super addSelector:newSelector withMethod:newMethod) ifTrue:[ |
544 | 985 |
self updateRevisionString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
986 |
self addChangeRecordForMethod:newMethod. |
92 | 987 |
] |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
988 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
989 |
"Created: 29.10.1995 / 19:42:42 / cg" |
1 | 990 |
! |
991 |
||
992 |
removeSelector:aSelector |
|
993 |
"remove the selector, aSelector and its associated method |
|
92 | 994 |
from the methodDictionary. |
153 | 995 |
Append a change record to the changes file and tell dependents." |
1 | 996 |
|
92 | 997 |
(super removeSelector:aSelector) ifTrue:[ |
153 | 998 |
self addChangeRecordForRemoveSelector:aSelector. |
544 | 999 |
self updateRevisionString. |
153 | 1000 |
self changed:#methodDictionary with:aSelector. |
1 | 1001 |
] |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1002 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1003 |
"Created: 29.10.1995 / 19:42:47 / cg" |
216 | 1004 |
! |
1005 |
||
1006 |
unload |
|
293 | 1007 |
"if the receiver was autoloaded, unload and reinstall it as |
1008 |
autoloaded. Can be used to get rid of no longer needed autoloaded |
|
328 | 1009 |
classes. |
1010 |
(maybe, autoloaded classes should unload themselfes when no |
|
1011 |
longer needed - for example, after some delay when the last instance |
|
1012 |
is gone ...)" |
|
293 | 1013 |
|
1014 |
|nm| |
|
1015 |
||
216 | 1016 |
self wasAutoloaded ifFalse:[ |
1017 |
||
1018 |
" |
|
1019 |
can it be done ? |
|
1020 |
" |
|
1021 |
self methodArray do:[:aMethod | |
|
1022 |
aMethod source isNil ifTrue:[^false]. |
|
1023 |
aMethod hasPrimitiveCode ifTrue:[^ false]. |
|
1024 |
]. |
|
1025 |
]. |
|
1026 |
||
283 | 1027 |
self allSubclassesDo:[:aClass | |
1028 |
aClass unload |
|
1029 |
]. |
|
1030 |
Transcript showCr:'unloading ' , name. |
|
1031 |
||
359 | 1032 |
Autoload removeClass:self. |
293 | 1033 |
nm := name. |
1034 |
Smalltalk at:nm put:nil. |
|
1035 |
name := nm , ' (leftover)'. |
|
288 | 1036 |
ObjectMemory flushInlineCaches. |
1037 |
ObjectMemory flushMethodCache. |
|
293 | 1038 |
Autoload addClass:nm inCategory:category. |
216 | 1039 |
^ true |
1040 |
||
1041 |
" |
|
1042 |
Clock open. |
|
1043 |
Clock unload. |
|
1044 |
ClockView unload. |
|
1045 |
Clock open |
|
1046 |
" |
|
1 | 1047 |
! ! |
1048 |
||
453 | 1049 |
!Class methodsFor:'binary storage'! |
1050 |
||
1051 |
addGlobalsTo: globalDictionary manager: manager |
|
1052 |
" |
|
1053 |
classPool == nil ifFalse: [ |
|
1054 |
classPool associationsDo: [:assoc| |
|
1055 |
globalDictionary at: assoc put: self |
|
1056 |
] |
|
1057 |
] |
|
1058 |
" |
|
1059 |
! |
|
1060 |
||
1061 |
storeBinaryDefinitionOn: stream manager: manager |
|
1062 |
"classes will store the name, signature and instvar names. |
|
1063 |
They restore by looking for that name in the Smalltalk dictionary. |
|
1064 |
However, using the signature, a check for being valid is made at |
|
1065 |
restore time." |
|
1066 |
||
1067 |
|varnames n sz| |
|
1068 |
||
1069 |
" |
|
1070 |
output the signature |
|
1071 |
" |
|
1072 |
stream nextNumber:4 put:self signature. |
|
1073 |
||
1074 |
" |
|
1075 |
output the instance variable name string |
|
1076 |
" |
|
1077 |
varnames := self allInstVarNames. |
|
1078 |
n := varnames size. |
|
1079 |
n == 0 ifTrue:[ |
|
1080 |
sz := 0 |
|
1081 |
] ifFalse:[ |
|
1082 |
sz := varnames inject:0 into:[:sum :nm | sum + nm size]. |
|
1083 |
sz := sz + n - 1. |
|
1084 |
]. |
|
1085 |
stream nextNumber:2 put:sz. |
|
1086 |
varnames keysAndValuesDo:[:i :nm | |
|
1087 |
nm do:[:c | |
|
1088 |
stream nextPut:c asciiValue |
|
1089 |
]. |
|
1090 |
i ~~ n ifTrue:[stream nextPut:(Character space asciiValue)] |
|
1091 |
]. |
|
1092 |
||
1093 |
" |
|
1094 |
output my name |
|
1095 |
" |
|
1096 |
stream nextNumber:2 put:name size. |
|
1097 |
name do:[:c| |
|
1098 |
stream nextPut:c asciiValue |
|
1099 |
] |
|
1100 |
||
1101 |
" |
|
1102 |
|s| |
|
1103 |
s := WriteStream on:ByteArray new. |
|
1104 |
Rectangle storeBinaryOn:s. |
|
1105 |
Object readBinaryFrom:(ReadStream on:s contents) |
|
1106 |
" |
|
1107 |
! |
|
1108 |
||
1109 |
storeBinaryDefinitionOf: anAssociation on: stream manager: manager |
|
1110 |
"not usable at the moment - there are no classpools currently" |
|
1111 |
||
1112 |
| string | |
|
1113 |
||
1114 |
string := self name, ' classPool at: ', anAssociation key storeString. |
|
1115 |
stream nextNumber: 2 put: string size. |
|
1116 |
string do: [:char| stream nextPut: char asciiValue] |
|
1117 |
! ! |
|
1118 |
||
1119 |
!Class methodsFor:'c function interfacing'! |
|
1120 |
||
1121 |
cInterfaceFunction:selector calling:cFunctionNameString args:argTypeArray returning:returnType |
|
1122 |
"create an interface to an existing (i.e. already linked in) c function. |
|
1123 |
The function can be called by sending selector to the receiver class. |
|
1124 |
The c-function has the name cFunctionNameString, and expects parameters as specified in |
|
1125 |
argTypeArray. The functions return value has a type as specified by returnType. |
|
1126 |
WARNING: |
|
1127 |
this interface is EXPERIMENTAL - it may change or even be removed." |
|
1128 |
||
1129 |
StubGenerator isNil ifTrue:[ |
|
1130 |
^ self error:'this system does not support dynamic C Interface functions'. |
|
1131 |
]. |
|
1132 |
||
1133 |
StubGenerator |
|
1134 |
createStubFor:selector |
|
1135 |
calling:cFunctionNameString |
|
1136 |
args:argTypeArray |
|
1137 |
returning:returnType |
|
1138 |
in:self |
|
1139 |
||
1140 |
" |
|
1141 |
Object subclass:#CInterface |
|
1142 |
instanceVariableNames:'' |
|
1143 |
classVariableNames:'' |
|
1144 |
poolDictionaries:'' |
|
1145 |
category:'Examples'. |
|
1146 |
||
1147 |
CInterface cInterfaceFunction:#printfOn:format:withFloat: |
|
1148 |
calling:'fprintf' |
|
1149 |
args:#(ExternalStream String Float) |
|
1150 |
returning:#SmallInteger. |
|
1151 |
||
1152 |
CInterface printfOn:Stdout format:'this is a float: %g' withFloat:(Float pi). Stdout cr |
|
1153 |
" |
|
1154 |
! ! |
|
1155 |
||
1 | 1156 |
!Class methodsFor:'changes management'! |
1157 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1158 |
addChangeRecordForMethod:aMethod to:aStream |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1159 |
"append a method-change-record to aStream" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1160 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1161 |
self fileOutMethod:aMethod on:aStream. |
199 | 1162 |
! |
1163 |
||
1 | 1164 |
changesStream |
453 | 1165 |
"return a Stream for the writing changes file - or nil if no update is wanted" |
1 | 1166 |
|
488
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
1167 |
|streamType aStream fileName| |
1 | 1168 |
|
453 | 1169 |
(UpdateChangeFileQuerySignal raise) ifTrue:[ |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1170 |
fileName := ObjectMemory nameForChanges. |
488
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
1171 |
|
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
1172 |
LockChangesFile ifTrue:[ |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
1173 |
streamType := LockedFileStream. |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
1174 |
] ifFalse:[ |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
1175 |
streamType := FileStream. |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
1176 |
]. |
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
1177 |
aStream := streamType oldFileNamed:fileName. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1178 |
aStream isNil ifTrue:[ |
488
1677ee52d630
hooks for change-file-locking. Experimental
Claus Gittinger <cg@exept.de>
parents:
484
diff
changeset
|
1179 |
aStream := streamType newFileNamed:fileName. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1180 |
aStream isNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1181 |
self warn:'cannot create/update the changes file'. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1182 |
^ nil |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1183 |
] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1184 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1185 |
aStream setToEnd |
92 | 1186 |
]. |
1187 |
^ aStream |
|
453 | 1188 |
|
1189 |
"Created: 28.10.1995 / 16:53:43 / cg" |
|
1190 |
"Modified: 28.10.1995 / 16:55:03 / cg" |
|
92 | 1191 |
! |
1192 |
||
155 | 1193 |
writingChangeDo:aBlock |
1194 |
"common helper to write a change record. |
|
1195 |
Opens the changefile and executes aBlock passing the stream |
|
168 | 1196 |
as argument. WriteErrors are cought and will lead to a warning. |
1197 |
The changefile is not kept open, to force the change to go to disk |
|
1198 |
as soon as possible - thus, in case of a crash, no changes should |
|
1199 |
be lost due to buffering." |
|
1 | 1200 |
|
139 | 1201 |
|aStream| |
1 | 1202 |
|
1203 |
aStream := self changesStream. |
|
1204 |
aStream notNil ifTrue:[ |
|
155 | 1205 |
FileStream writeErrorSignal handle:[:ex | |
355 | 1206 |
self warn:('could not update the changes-file\\' , ex errorString) withCRs. |
155 | 1207 |
ex return |
1208 |
] do:[ |
|
199 | 1209 |
aBlock value:aStream. |
1210 |
aStream cr. |
|
155 | 1211 |
]. |
1212 |
aStream close |
|
1213 |
] |
|
1214 |
! |
|
1215 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1216 |
writingChangePerform:aSelector with:anArgument |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1217 |
self writingChangeDo:[:stream | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1218 |
self perform:aSelector with:anArgument with:stream. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1219 |
] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1220 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1221 |
"Created: 28.10.1995 / 16:50:48 / cg" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1222 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1223 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1224 |
withoutUpdatingChangesDo:aBlock |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1225 |
"turn off change file update while evaluating aBlock. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1226 |
This method makes sure, that the update-flag is correctly restored |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1227 |
in case of an abort or other error." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1228 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1229 |
UpdateChangeFileQuerySignal handle:[:ex | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1230 |
ex proceedWith:false |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1231 |
] do:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1232 |
aBlock value |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1233 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1234 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1235 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1236 |
addChangeRecordForMethod:aMethod |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1237 |
"add a method-change-record to the changes file" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1238 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1239 |
(UpdateChangeFileQuerySignal raise) "UpdatingChanges" ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1240 |
self writingChangePerform:#addChangeRecordForMethod:to: with:aMethod. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1241 |
"this test allows a smalltalk without Projects/ChangeSets" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1242 |
Project notNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1243 |
Project addMethodChange:aMethod in:self |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1244 |
] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1245 |
] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1246 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1247 |
|
453 | 1248 |
sourcesStream |
1249 |
"return a stream for writing the sources file. |
|
1250 |
Notice, in ST/X, it is noncommon to use a single |
|
1251 |
source file; typically each classes source is kept |
|
1252 |
in a separate file." |
|
1253 |
||
1254 |
|aStream fileName| |
|
1255 |
||
1256 |
fileName := ObjectMemory nameForSources. |
|
1257 |
aStream := FileStream oldFileNamed:fileName. |
|
1258 |
aStream isNil ifTrue:[ |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1259 |
aStream := FileStream newFileNamed:fileName. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1260 |
aStream isNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1261 |
Transcript showCr:'cannot update sources file'. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1262 |
^ nil |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1263 |
] |
453 | 1264 |
]. |
1265 |
aStream setToEnd. |
|
1266 |
^ aStream |
|
1267 |
||
1268 |
"Created: 28.10.1995 / 16:53:17 / cg" |
|
155 | 1269 |
! |
1270 |
||
1271 |
addChangeRecordForRemoveSelector:aSelector to:aStream |
|
1272 |
"append a method-remove-record to aStream" |
|
1273 |
||
1274 |
self printClassNameOn:aStream. |
|
1275 |
aStream nextPutAll:(' removeSelector:#' , aSelector). |
|
432 | 1276 |
aStream nextPutChunkSeparator. |
199 | 1277 |
! |
1278 |
||
1279 |
addChangeRecordForMethodCategory:aMethod category:newCategory to:aStream |
|
1280 |
"append a methodCategory-change-record to aStream" |
|
1281 |
||
1282 |
|selector| |
|
1283 |
||
1284 |
selector := aMethod selector. |
|
326 | 1285 |
selector notNil ifTrue:[ |
1286 |
aStream nextPutAll:'('. |
|
1287 |
self printClassNameOn:aStream. |
|
1288 |
aStream nextPutAll:(' compiledMethodAt:' , selector storeString). |
|
1289 |
aStream nextPutAll:(') category:' , newCategory storeString). |
|
432 | 1290 |
aStream nextPutChunkSeparator. |
326 | 1291 |
] |
155 | 1292 |
! |
1293 |
||
414 | 1294 |
addChangeRecordForMethodPrivacy:aMethod to:aStream |
1295 |
"append a method-privacy-change-record to aStream" |
|
1296 |
||
1297 |
|selector| |
|
1298 |
||
1299 |
selector := aMethod selector. |
|
1300 |
selector notNil ifTrue:[ |
|
1301 |
aStream nextPutAll:'('. |
|
1302 |
self printClassNameOn:aStream. |
|
1303 |
aStream nextPutAll:(' compiledMethodAt:' , selector storeString). |
|
1304 |
aStream nextPutAll:(') privacy:' , aMethod privacy storeString). |
|
432 | 1305 |
aStream nextPutChunkSeparator. |
414 | 1306 |
] |
1307 |
||
1308 |
"Modified: 27.8.1995 / 22:59:56 / claus" |
|
1309 |
! |
|
1310 |
||
155 | 1311 |
addChangeRecordForClass:aClass to:aStream |
1312 |
"append a class-definition-record to aStream" |
|
1313 |
||
403 | 1314 |
aClass isLoaded ifTrue:[ |
1315 |
aClass fileOutDefinitionOn:aStream. |
|
432 | 1316 |
aStream nextPutChunkSeparator. |
403 | 1317 |
] |
155 | 1318 |
! |
1319 |
||
1320 |
addChangeRecordForClassInstvars:aClass to:aStream |
|
1321 |
"append a class-instvars-record to aStream" |
|
1322 |
||
1323 |
aClass fileOutClassInstVarDefinitionOn:aStream. |
|
432 | 1324 |
aStream nextPutChunkSeparator. |
155 | 1325 |
! |
1326 |
||
1327 |
addChangeRecordForClassComment:aClass to:aStream |
|
1328 |
"append a class-comment-record to aStream" |
|
1329 |
||
1330 |
aClass fileOutCommentOn:aStream. |
|
432 | 1331 |
aStream nextPutChunkSeparator. |
155 | 1332 |
! |
1333 |
||
360 | 1334 |
addChangeRecordForPrimitiveVariables:aClass to:aStream |
1335 |
"append a primitiveVariables-record to aStream" |
|
1336 |
||
1337 |
aStream nextPutAll:aClass name |
|
435 | 1338 |
, ' primitiveVariables:' |
360 | 1339 |
, aClass primitiveVariablesString storeString. |
432 | 1340 |
aStream nextPutChunkSeparator. |
360 | 1341 |
! |
1342 |
||
1343 |
addChangeRecordForPrimitiveDefinitions:aClass to:aStream |
|
1344 |
"append a primitiveDefinitions-record to aStream" |
|
1345 |
||
1346 |
aStream nextPutAll:aClass name |
|
435 | 1347 |
, ' primitiveDefinitions:' |
360 | 1348 |
, aClass primitiveDefinitionsString storeString. |
432 | 1349 |
aStream nextPutChunkSeparator. |
360 | 1350 |
! |
1351 |
||
1352 |
addChangeRecordForPrimitiveFunctions:aClass to:aStream |
|
1353 |
"append a primitiveFunctions-record to aStream" |
|
1354 |
||
1355 |
aStream nextPutAll:aClass name |
|
435 | 1356 |
, ' primitiveFunctions:' |
360 | 1357 |
, aClass primitiveFunctionsString storeString. |
432 | 1358 |
aStream nextPutChunkSeparator. |
360 | 1359 |
! |
1360 |
||
155 | 1361 |
addChangeRecordForClassRename:oldName to:newName to:aStream |
1362 |
"append a class-rename-record to aStream" |
|
1363 |
||
1364 |
aStream nextPutAll:('Smalltalk renameClass:' , oldName , ' to:''' , newName , ''''). |
|
432 | 1365 |
aStream nextPutChunkSeparator. |
155 | 1366 |
! |
1367 |
||
1368 |
addChangeRecordForClassRemove:oldName to:aStream |
|
1369 |
"append a class-remove-record to aStream" |
|
1370 |
||
1371 |
aStream nextPutAll:('Smalltalk removeClass:' , oldName). |
|
432 | 1372 |
aStream nextPutChunkSeparator. |
155 | 1373 |
! |
1374 |
||
1375 |
addChangeRecordForRenameCategory:oldCategory to:newCategory to:aStream |
|
1376 |
"append a category-rename record to aStream" |
|
1377 |
||
1378 |
self printClassNameOn:aStream. |
|
1379 |
aStream nextPutAll:(' renameCategory:' , oldCategory storeString). |
|
1380 |
aStream nextPutAll:(' to:' , newCategory storeString). |
|
432 | 1381 |
aStream nextPutChunkSeparator. |
155 | 1382 |
! |
1383 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1384 |
addInfoRecord:aMessage to:aStream |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1385 |
"append an info-record (snapshot, class fileOut etc.) to aStream" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1386 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1387 |
aStream nextPutAll:('''---- ' , aMessage , ' ', |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1388 |
Date today printString , ' ' , |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1389 |
Time now printString , |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1390 |
' ----'''). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1391 |
aStream nextPutChunkSeparator. |
453 | 1392 |
! |
1393 |
||
302 | 1394 |
addChangeRecordForChangeCategory:category to:aStream |
155 | 1395 |
"append a category change record to aStream" |
1396 |
||
1397 |
self printClassNameOn:aStream. |
|
1398 |
aStream nextPutAll:(' category:' , category storeString). |
|
432 | 1399 |
aStream nextPutChunkSeparator. |
199 | 1400 |
! |
1401 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1402 |
addChangeRecordForClass:aClass |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1403 |
"add a class-definition-record to the changes file" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1404 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1405 |
self writingChangePerform:#addChangeRecordForClass:to: with:aClass. |
155 | 1406 |
! |
1407 |
||
1408 |
addChangeRecordForSnapshot:aFileName to:aStream |
|
199 | 1409 |
"add a snapshot-record to aStream" |
155 | 1410 |
|
199 | 1411 |
self addInfoRecord:('snapshot ' , aFileName) to:aStream |
155 | 1412 |
! |
1413 |
||
1 | 1414 |
addChangeRecordForRemoveSelector:aSelector |
1415 |
"add a method-remove-record to the changes file" |
|
1416 |
||
302 | 1417 |
self writingChangePerform:#addChangeRecordForRemoveSelector:to: with:aSelector. |
1 | 1418 |
! |
1419 |
||
199 | 1420 |
addChangeRecordForMethodCategory:aMethod category:aString |
1421 |
"add a methodCategory-change-record to the changes file" |
|
1422 |
||
421 | 1423 |
(UpdateChangeFileQuerySignal raise) "UpdatingChanges" ifTrue:[ |
302 | 1424 |
self writingChangeDo:[:aStream | |
1425 |
self addChangeRecordForMethodCategory:aMethod category:aString to:aStream. |
|
1426 |
]. |
|
199 | 1427 |
|
1428 |
"this test allows a smalltalk without Projects/ChangeSets" |
|
1429 |
Project notNil ifTrue:[ |
|
1430 |
Project addMethodCategoryChange:aMethod category:aString in:self |
|
1431 |
] |
|
1432 |
] |
|
1433 |
! |
|
1434 |
||
414 | 1435 |
addChangeRecordForMethodPrivacy:aMethod |
1436 |
"add a method-privacy-change-record to the changes file" |
|
1437 |
||
421 | 1438 |
(UpdateChangeFileQuerySignal raise) "UpdatingChanges" ifTrue:[ |
414 | 1439 |
self writingChangePerform:#addChangeRecordForMethodPrivacy:to: with:aMethod. |
1440 |
"this test allows a smalltalk without Projects/ChangeSets" |
|
1441 |
Project notNil ifTrue:[ |
|
1442 |
Project addMethodPrivacyChange:aMethod in:self |
|
1443 |
] |
|
1444 |
] |
|
1445 |
||
1446 |
"Modified: 27.8.1995 / 22:47:32 / claus" |
|
1447 |
! |
|
1448 |
||
2 | 1449 |
addChangeRecordForClassInstvars:aClass |
1450 |
"add a class-instvars-record to the changes file" |
|
1451 |
||
302 | 1452 |
self writingChangePerform:#addChangeRecordForClassInstvars:to: with:aClass. |
2 | 1453 |
! |
1454 |
||
1 | 1455 |
addChangeRecordForClassComment:aClass |
1456 |
"add a class-comment-record to the changes file" |
|
1457 |
||
302 | 1458 |
self writingChangePerform:#addChangeRecordForClassComment:to: with:aClass. |
1 | 1459 |
! |
1460 |
||
360 | 1461 |
addChangeRecordForPrimitiveVariables:aClass |
1462 |
"add a primitiveVariables-record to the changes file" |
|
1463 |
||
1464 |
self writingChangePerform:#addChangeRecordForPrimitiveVariables:to: with:aClass. |
|
1465 |
! |
|
1466 |
||
1467 |
addChangeRecordForPrimitiveDefinitions:aClass |
|
1468 |
"add a primitiveDefinitions-record to the changes file" |
|
1469 |
||
1470 |
self writingChangePerform:#addChangeRecordForPrimitiveDefinitions:to: with:aClass. |
|
1471 |
! |
|
1472 |
||
1473 |
addChangeRecordForPrimitiveFunctions:aClass |
|
1474 |
"add a primitiveFunctions-record to the changes file" |
|
1475 |
||
1476 |
self writingChangePerform:#addChangeRecordForPrimitiveFunctions:to: with:aClass. |
|
1477 |
! |
|
1478 |
||
10 | 1479 |
addChangeRecordForClassRename:oldName to:newName |
1480 |
"add a class-rename-record to the changes file" |
|
1481 |
||
421 | 1482 |
self writingChangeDo:[:aStream | |
1483 |
self addChangeRecordForClassRename:oldName to:newName to:aStream |
|
10 | 1484 |
] |
1485 |
! |
|
1486 |
||
1487 |
addChangeRecordForClassRemove:oldName |
|
1488 |
"add a class-remove-record to the changes file" |
|
1489 |
||
302 | 1490 |
self writingChangePerform:#addChangeRecordForClassRemove:to: with:oldName. |
10 | 1491 |
! |
1492 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1493 |
addInfoRecord:aMessage |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1494 |
"add an info-record (snapshot, class fileOut etc.) to the changes file" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1495 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1496 |
self writingChangePerform:#addInfoRecord:to: with:aMessage. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1497 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1498 |
|
85 | 1499 |
addChangeRecordForRenameCategory:oldCategory to:newCategory |
1500 |
"add a category-rename record to the changes file" |
|
1501 |
||
421 | 1502 |
self writingChangeDo:[:aStream | |
1503 |
self addChangeRecordForRenameCategory:oldCategory to:newCategory to:aStream. |
|
85 | 1504 |
] |
1505 |
! |
|
1506 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1507 |
addChangeRecordForClassFileOut:aClass |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1508 |
"append a class-was-filedOut-record to the changes file" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1509 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1510 |
self addInfoRecord:('fileOut ' , aClass name) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1511 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1512 |
|
85 | 1513 |
addChangeRecordForChangeCategory |
1514 |
"add a category change record to the changes file" |
|
1515 |
||
302 | 1516 |
self writingChangePerform:#addChangeRecordForChangeCategory:to: with:category. |
85 | 1517 |
! |
1518 |
||
22 | 1519 |
addChangeRecordForSnapshot:aFileName |
1 | 1520 |
"add a snapshot-record to the changes file" |
1521 |
||
199 | 1522 |
self addInfoRecord:('snapshot ' , aFileName) |
1 | 1523 |
! ! |
1524 |
||
1525 |
!Class methodsFor:'compiling'! |
|
1526 |
||
1527 |
compile:code |
|
328 | 1528 |
"compile code, aString for this class; |
1529 |
if sucessful update the method dictionary." |
|
1530 |
||
1531 |
self compilerClass |
|
1532 |
compile:code |
|
1533 |
forClass:self |
|
1534 |
! |
|
1535 |
||
1536 |
compile:code classified:category |
|
1537 |
"compile code, aString for this class; |
|
1538 |
if sucessful update the method dictionary. |
|
1539 |
The method is classified under category." |
|
1540 |
||
1541 |
self compilerClass |
|
1542 |
compile:code |
|
1543 |
forClass:self |
|
1544 |
inCategory:category |
|
1 | 1545 |
! |
1546 |
||
1547 |
compile:code notifying:requestor |
|
1548 |
"compile code, aString for this class; on any error, notify |
|
328 | 1549 |
requestor, anObject with the error reason." |
1550 |
||
1551 |
self compilerClass |
|
1552 |
compile:code |
|
1553 |
forClass:self |
|
1554 |
notifying:requestor |
|
1 | 1555 |
! |
1556 |
||
2 | 1557 |
recompileMethodsAccessingAny:setOfNames |
1558 |
"recompile all methods accessing a variable from setOfNames" |
|
1559 |
||
153 | 1560 |
self recompileMethodsAccessingAny:setOfNames orSuper:false |
1561 |
! |
|
1562 |
||
1563 |
recompileMethodsAccessingAny:setOfNames orSuper:superBoolean |
|
1564 |
"recompile all methods accessing a variable from setOfNames, |
|
1565 |
or super (if superBoolean is true)" |
|
1566 |
||
2 | 1567 |
|p| |
1568 |
||
92 | 1569 |
selectorArray do:[:aSelector | |
153 | 1570 |
|m| |
2 | 1571 |
|
153 | 1572 |
m := self compiledMethodAt:aSelector. |
1573 |
p := Parser parseMethod:(m source) in:self. |
|
1574 |
(p isNil |
|
1575 |
or:[(p usedVars notNil and:[p usedVars includesAny:setOfNames]) |
|
1576 |
or:[superBoolean and:[p usesSuper]]]) ifTrue:[ |
|
1577 |
self recompile:aSelector |
|
1578 |
] |
|
2 | 1579 |
] |
1580 |
! |
|
1581 |
||
1 | 1582 |
recompile:aSelector |
1583 |
"recompile the method associated with the argument, aSelector; |
|
1584 |
used when a superclass changes instances and we have to recompile |
|
1585 |
subclasses" |
|
1586 |
||
199 | 1587 |
|cat code| |
1 | 1588 |
|
199 | 1589 |
Class withoutUpdatingChangesDo:[ |
362 | 1590 |
Class methodRedefinitionSignal handle:[:ex | |
1591 |
ex proceed |
|
1592 |
] do:[ |
|
1593 |
cat := (self compiledMethodAt:aSelector) category. |
|
1594 |
code := self sourceCodeAt:aSelector. |
|
1595 |
self compilerClass compile:code forClass:self inCategory:cat |
|
1596 |
] |
|
2 | 1597 |
] |
1 | 1598 |
! |
1599 |
||
1600 |
recompile |
|
1601 |
"recompile all methods |
|
1602 |
used when a class changes instances and therefore all methods |
|
1603 |
have to be recompiled" |
|
1604 |
||
92 | 1605 |
selectorArray do:[:aSelector | |
153 | 1606 |
self recompile:aSelector |
1 | 1607 |
] |
1608 |
! |
|
1609 |
||
1610 |
recompileAll |
|
1611 |
"recompile this class and all subclasses" |
|
1612 |
||
2 | 1613 |
|classes| |
1614 |
||
1615 |
classes := self subclasses. |
|
1616 |
self recompile. |
|
1617 |
classes do:[:aClass | |
|
153 | 1618 |
aClass recompileAll |
2 | 1619 |
] |
1620 |
! |
|
1621 |
||
92 | 1622 |
recompileInvalidatedMethods:trap |
2 | 1623 |
"recompile all invalidated methods" |
1 | 1624 |
|
92 | 1625 |
|trapCode trapByteCode| |
2 | 1626 |
|
1627 |
trapCode := trap code. |
|
1628 |
trapByteCode := trap byteCode. |
|
1629 |
||
92 | 1630 |
selectorArray do:[:aSelector | |
153 | 1631 |
|m| |
2 | 1632 |
|
153 | 1633 |
m := self compiledMethodAt:aSelector. |
362 | 1634 |
((m code = trapCode) and:[m byteCode == trapByteCode]) ifTrue:[ |
153 | 1635 |
self recompile:aSelector |
1636 |
] |
|
1 | 1637 |
] |
1638 |
! ! |
|
1639 |
||
1640 |
!Class methodsFor:'fileIn interface'! |
|
1641 |
||
1642 |
methodsFor:aCategory |
|
10 | 1643 |
"return a ClassCategoryReader to read in and compile methods for me. |
1644 |
This one actually creates the ClassReader when code is filed-in." |
|
1 | 1645 |
|
1646 |
^ ClassCategoryReader class:self category:aCategory |
|
1647 |
! |
|
1648 |
||
1649 |
publicMethodsFor:aCategory |
|
68 | 1650 |
"this method allows fileIn of ENVY methods |
1651 |
(although ST/X currently does NOT support method visibility). |
|
1652 |
Returns a ClassCategoryReader to read in and compile methods for me." |
|
1 | 1653 |
|
1654 |
^ self methodsFor:aCategory |
|
1655 |
! |
|
1656 |
||
1657 |
privateMethodsFor:aCategory |
|
68 | 1658 |
"this method allows fileIn of ENVY methods |
92 | 1659 |
(although ST/X currently does NOT really enforce method visibility yet). |
68 | 1660 |
Returns a ClassCategoryReader to read in and compile methods for me." |
1 | 1661 |
|
68 | 1662 |
^ (self methodsFor:aCategory) privateProtocol |
1 | 1663 |
! |
1664 |
||
168 | 1665 |
protectedMethodsFor:aCategory |
1666 |
"this method allows fileIn of ENVY methods |
|
1667 |
(although ST/X currently does NOT really enforce method visibility yet). |
|
1668 |
Returns a ClassCategoryReader to read in and compile methods for me." |
|
1669 |
||
1670 |
^ (self methodsFor:aCategory) protectedProtocol |
|
1671 |
! |
|
1672 |
||
295 | 1673 |
methodsForUndefined:categoryString |
1674 |
"ST-80 compatibility. |
|
1675 |
I dont yet know what this does - it was encountered by some tester. |
|
1676 |
For now, simply forward it." |
|
1677 |
||
1678 |
^ self methodsFor:categoryString |
|
1679 |
! |
|
1680 |
||
137 | 1681 |
ignoredMethodsFor:aCategory |
1682 |
"this is a speciality of ST/X - it allows quick commenting of methods |
|
1683 |
from a source-file by replacing the 'methodsFor:' by 'ignoredMethodsFor'. |
|
1684 |
Returns a ClassCategoryReader to read in and skip methods." |
|
1 | 1685 |
|
168 | 1686 |
^ ClassCategoryReader skippingChunks |
1 | 1687 |
! |
1688 |
||
1689 |
methods |
|
1690 |
"this method allows fileIn of ST/V methods - |
|
1691 |
return a ClassCategoryReader to read in and compile methods for me." |
|
1692 |
||
1693 |
^ ClassCategoryReader class:self category:'ST/V methods' |
|
168 | 1694 |
! |
1695 |
||
1696 |
primitiveDefinitions |
|
1697 |
"this method allows fileIn of classes with primitive code |
|
1698 |
outside of methods - it returns a CCReader which skips the next chunks" |
|
1699 |
||
216 | 1700 |
^ ClassCategoryReader class:self primitiveSpec:#primitiveDefinitions: |
168 | 1701 |
! |
1702 |
||
1703 |
primitiveVariables |
|
1704 |
"this method allows fileIn of classes with primitive code |
|
1705 |
outside of methods - it returns a CCReader which skips the next chunks" |
|
1706 |
||
216 | 1707 |
^ ClassCategoryReader class:self primitiveSpec:#primitiveVariables: |
168 | 1708 |
! |
1709 |
||
1710 |
primitiveFunctions |
|
1711 |
"this method allows fileIn of classes with primitive code |
|
1712 |
outside of methods - it returns a CCReader which skips the next chunks" |
|
1713 |
||
216 | 1714 |
^ ClassCategoryReader class:self primitiveSpec:#primitiveFunctions: |
1 | 1715 |
! ! |
1716 |
||
1717 |
!Class methodsFor:'fileOut'! |
|
1718 |
||
1719 |
fileOutDefinitionOn:aStream |
|
68 | 1720 |
"append an expression on aStream, which defines myself." |
1 | 1721 |
|
238 | 1722 |
^ self basicFileOutDefinitionOn:aStream |
1723 |
! |
|
1724 |
||
1725 |
basicFileOutDefinitionOn:aStream |
|
1726 |
"append an expression on aStream, which defines myself." |
|
1727 |
||
293 | 1728 |
|isVar line s| |
1 | 1729 |
|
68 | 1730 |
"take care of nil-superclass" |
1 | 1731 |
superclass isNil ifTrue:[ |
92 | 1732 |
"/ previous versions of stc were not able to compile nil-subclasses; |
1733 |
"/ after 2.10, it can ... |
|
1734 |
"/ line := 'Object "nil"'. |
|
153 | 1735 |
line := 'nil' |
1 | 1736 |
] ifFalse:[ |
153 | 1737 |
line := (superclass name) |
1 | 1738 |
]. |
1739 |
superclass isNil ifTrue:[ |
|
153 | 1740 |
isVar := self isVariable |
1 | 1741 |
] ifFalse:[ |
153 | 1742 |
"I cant remember what this is for ?" |
1743 |
isVar := (self isVariable and:[superclass isVariable not]) |
|
1 | 1744 |
]. |
293 | 1745 |
|
1 | 1746 |
isVar ifTrue:[ |
153 | 1747 |
self isBytes ifTrue:[ |
293 | 1748 |
s := ' variableByteSubclass:#' |
153 | 1749 |
] ifFalse:[ |
1750 |
self isWords ifTrue:[ |
|
293 | 1751 |
s := ' variableWordSubclass:#' |
153 | 1752 |
] ifFalse:[ |
1753 |
self isLongs ifTrue:[ |
|
293 | 1754 |
s := ' variableLongSubclass:#' |
153 | 1755 |
] ifFalse:[ |
1756 |
self isFloats ifTrue:[ |
|
293 | 1757 |
s := ' variableFloatSubclass:#' |
153 | 1758 |
] ifFalse:[ |
1759 |
self isDoubles ifTrue:[ |
|
293 | 1760 |
s := ' variableDoubleSubclass:#' |
153 | 1761 |
] ifFalse:[ |
293 | 1762 |
s := ' variableSubclass:#' |
153 | 1763 |
] |
1764 |
] |
|
1765 |
] |
|
1766 |
] |
|
1767 |
] |
|
1 | 1768 |
] ifFalse:[ |
293 | 1769 |
s := ' subclass:#' |
1 | 1770 |
]. |
293 | 1771 |
line := line , s , name. |
1 | 1772 |
aStream nextPutAll:line. |
1773 |
||
345 | 1774 |
aStream crtab. |
1 | 1775 |
aStream nextPutAll:' instanceVariableNames:'''. |
1776 |
self printInstVarNamesOn:aStream indent:16. |
|
1777 |
aStream nextPutAll:''''. |
|
1778 |
||
345 | 1779 |
aStream crtab. |
1 | 1780 |
aStream nextPutAll:' classVariableNames:'''. |
1781 |
self printClassVarNamesOn:aStream indent:16. |
|
1782 |
aStream nextPutAll:''''. |
|
1783 |
||
345 | 1784 |
aStream crtab. |
1 | 1785 |
aStream nextPutAll:' poolDictionaries:'''''. |
1786 |
||
345 | 1787 |
aStream crtab. |
1 | 1788 |
aStream nextPutAll:' category:'. |
1789 |
category isNil ifTrue:[ |
|
333 | 1790 |
s := '''''' |
1 | 1791 |
] ifFalse:[ |
333 | 1792 |
s := category asString storeString |
1 | 1793 |
]. |
333 | 1794 |
aStream nextPutAll:s. |
1 | 1795 |
aStream cr |
1796 |
! |
|
1797 |
||
453 | 1798 |
fileOutMethod:aMethod on:aStream |
1799 |
"file out the method, aMethod onto aStream" |
|
1800 |
||
1801 |
|cat source privacy| |
|
1802 |
||
1803 |
methodArray notNil ifTrue:[ |
|
1804 |
aStream nextPutChunkSeparator. |
|
1805 |
self printClassNameOn:aStream. |
|
1806 |
||
1807 |
(privacy := aMethod privacy) ~~ #public ifTrue:[ |
|
1808 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'''. |
|
1809 |
] ifFalse:[ |
|
1810 |
aStream nextPutAll:' methodsFor:'''. |
|
1811 |
]. |
|
1812 |
cat := aMethod category. |
|
1813 |
cat notNil ifTrue:[ |
|
1814 |
aStream nextPutAll:cat |
|
1815 |
]. |
|
1816 |
aStream nextPut:$'; nextPutChunkSeparator; cr; cr. |
|
1817 |
source := aMethod source. |
|
1818 |
source isNil ifTrue:[ |
|
1819 |
FileOutErrorSignal |
|
1820 |
raiseRequestWith:self |
|
1821 |
errorString:('no source for method: ' , |
|
1822 |
self name , '>>' , |
|
1823 |
(self selectorAtMethod:aMethod)) |
|
1824 |
] ifFalse:[ |
|
1825 |
aStream nextChunkPut:source. |
|
1826 |
]. |
|
1827 |
aStream space. |
|
1828 |
aStream nextPutChunkSeparator. |
|
1829 |
aStream cr |
|
1830 |
] |
|
1831 |
||
1832 |
"Modified: 27.8.1995 / 01:23:19 / claus" |
|
1 | 1833 |
! |
1834 |
||
1835 |
fileOutCategory:aCategory on:aStream |
|
1836 |
"file out all methods belonging to aCategory, aString onto aStream" |
|
1837 |
||
432 | 1838 |
|nMethods count source sortedSelectors sortedMethods first |
415 | 1839 |
privacy| |
1 | 1840 |
|
92 | 1841 |
methodArray notNil ifTrue:[ |
153 | 1842 |
nMethods := 0. |
1843 |
methodArray do:[:aMethod | |
|
1844 |
(aCategory = aMethod category) ifTrue:[ |
|
1845 |
nMethods := nMethods + 1 |
|
1846 |
] |
|
1847 |
]. |
|
1848 |
(nMethods ~~ 0) ifTrue:[ |
|
1849 |
count := 1. |
|
412 | 1850 |
first := true. |
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
1851 |
privacy := nil. |
362 | 1852 |
|
1853 |
"/ |
|
1854 |
"/ sort by selector |
|
1855 |
"/ |
|
1856 |
sortedSelectors := selectorArray copy. |
|
1857 |
sortedMethods := methodArray copy. |
|
1858 |
sortedSelectors sortWith:sortedMethods. |
|
1859 |
||
153 | 1860 |
methodArray do:[:aMethod | |
1861 |
(aCategory = aMethod category) ifTrue:[ |
|
412 | 1862 |
|
1863 |
first ifFalse:[ |
|
415 | 1864 |
privacy ~~ aMethod privacy ifTrue:[ |
412 | 1865 |
first := true. |
1866 |
aStream space. |
|
432 | 1867 |
aStream nextPutChunkSeparator. |
412 | 1868 |
]. |
1869 |
aStream cr; cr |
|
1870 |
]. |
|
1871 |
||
415 | 1872 |
privacy := aMethod privacy. |
412 | 1873 |
|
1874 |
first ifTrue:[ |
|
432 | 1875 |
aStream nextPutChunkSeparator. |
412 | 1876 |
self printClassNameOn:aStream. |
415 | 1877 |
privacy ~~ #public ifTrue:[ |
1878 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'''. |
|
412 | 1879 |
] ifFalse:[ |
415 | 1880 |
aStream nextPutAll:' methodsFor:'''. |
412 | 1881 |
]. |
1882 |
aCategory notNil ifTrue:[ |
|
1883 |
aStream nextPutAll:aCategory |
|
1884 |
]. |
|
432 | 1885 |
aStream nextPut:$'; nextPutChunkSeparator; cr; cr. |
412 | 1886 |
first := false. |
1887 |
]. |
|
153 | 1888 |
source := aMethod source. |
1889 |
source isNil ifTrue:[ |
|
1890 |
FileOutErrorSignal raiseRequestWith:'no source for method' |
|
1891 |
] ifFalse:[ |
|
362 | 1892 |
aStream nextChunkPut:source. |
153 | 1893 |
]. |
1894 |
count := count + 1 |
|
1895 |
] |
|
1896 |
]. |
|
1897 |
aStream space. |
|
432 | 1898 |
aStream nextPutChunkSeparator. |
153 | 1899 |
aStream cr |
1900 |
] |
|
1 | 1901 |
] |
412 | 1902 |
|
415 | 1903 |
"Modified: 28.8.1995 / 14:30:41 / claus" |
1 | 1904 |
! |
1905 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1906 |
fileOutPrimitiveDefinitionsOn:aStream |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1907 |
"append primitive defs (if any) to aStream." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1908 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1909 |
|s| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1910 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1911 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1912 |
primitive definitions - if any |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1913 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1914 |
(s := self primitiveDefinitionsString) notNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1915 |
aStream nextPutChunkSeparator; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1916 |
nextPutAll:name; nextPutAll:' primitiveDefinitions'; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1917 |
nextPutChunkSeparator; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1918 |
cr. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1919 |
aStream nextPutAll:s. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1920 |
aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1921 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1922 |
(s := self primitiveVariablesString) notNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1923 |
aStream nextPutChunkSeparator; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1924 |
nextPutAll:name; nextPutAll:' primitiveVariables'; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1925 |
nextPutChunkSeparator; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1926 |
cr. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1927 |
aStream nextPutAll:s. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1928 |
aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr |
453 | 1929 |
]. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1930 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1931 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1932 |
fileOutCommentOn:aStream |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1933 |
"append an expression on aStream, which defines my comment" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1934 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1935 |
|comment s| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1936 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1937 |
aStream nextPutAll:name; nextPutAll:' comment:'. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1938 |
(comment := self comment) isNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1939 |
s := '''''' |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1940 |
] ifFalse:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1941 |
s := comment storeString |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1942 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1943 |
aStream nextPutAll:s. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1944 |
aStream cr |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1945 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1946 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1947 |
fileOutPrimitiveSpecsOn:aStream |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1948 |
"append primitive defs (if any) to aStream." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1949 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1950 |
|s| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1951 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1952 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1953 |
primitive definitions - if any |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1954 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1955 |
self fileOutPrimitiveDefinitionsOn:aStream. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1956 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1957 |
primitive functions - if any |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1958 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1959 |
(s := self primitiveFunctionsString) notNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1960 |
aStream nextPutChunkSeparator; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1961 |
nextPutAll:name; nextPutAll:' primitiveFunctions'; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1962 |
nextPutChunkSeparator; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1963 |
cr. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1964 |
aStream nextPutAll:s. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1965 |
aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1966 |
]. |
1 | 1967 |
! |
1968 |
||
1969 |
fileOutOn:aStream |
|
92 | 1970 |
"file out my definition and all methods onto aStream" |
1971 |
||
432 | 1972 |
|collectionOfCategories copyrightText comment cls| |
92 | 1973 |
|
403 | 1974 |
self isLoaded ifFalse:[ |
1975 |
^ FileOutErrorSignal |
|
1976 |
raiseRequestWith:self |
|
1977 |
errorString:'will not fileOut unloaded classes' |
|
1978 |
]. |
|
1979 |
||
92 | 1980 |
" |
216 | 1981 |
if there is a copyright method, add a copyright comment |
1982 |
at the beginning, taking the string from the copyright method. |
|
199 | 1983 |
We cannot do this unconditionally - that would lead to my copyrights |
1984 |
being put on your code ;-). |
|
1985 |
On the other hand: I want every file created by myself to have the |
|
1986 |
copyright string at the beginning be preserved .... even if the |
|
1987 |
code was edited in the browser and filedOut. |
|
92 | 1988 |
" |
356 | 1989 |
((cls := self class) selectorArray includes:#copyright) ifTrue:[ |
153 | 1990 |
" |
1991 |
get the copyright methods source, |
|
1992 |
and insert at beginning. |
|
1993 |
" |
|
356 | 1994 |
copyrightText := (cls compiledMethodAt:#copyright) source. |
153 | 1995 |
copyrightText isNil ifTrue:[ |
1996 |
" |
|
1997 |
no source available - trigger an error |
|
1998 |
" |
|
399 | 1999 |
FileOutErrorSignal |
2000 |
raiseRequestWith:'no source for class ' , name , ' available. Cannot fileOut'. |
|
153 | 2001 |
^ self |
2002 |
]. |
|
2003 |
copyrightText := copyrightText asCollectionOfLines. |
|
2004 |
copyrightText := copyrightText copyFrom:2 to:(copyrightText size). |
|
2005 |
copyrightText do:[:line | aStream nextPutAll:line. aStream cr.]. |
|
92 | 2006 |
]. |
1 | 2007 |
|
92 | 2008 |
" |
2009 |
first, a timestamp |
|
2010 |
" |
|
1 | 2011 |
aStream nextPutAll:(Smalltalk timeStamp). |
432 | 2012 |
aStream nextPutChunkSeparator. |
333 | 2013 |
aStream cr; cr. |
92 | 2014 |
|
2015 |
" |
|
2016 |
then the definition |
|
2017 |
" |
|
1 | 2018 |
self fileOutDefinitionOn:aStream. |
432 | 2019 |
aStream nextPutChunkSeparator. |
333 | 2020 |
aStream cr; cr. |
92 | 2021 |
" |
2022 |
optional classInstanceVariables |
|
2023 |
" |
|
1 | 2024 |
self class instanceVariableString isBlank ifFalse:[ |
153 | 2025 |
self fileOutClassInstVarDefinitionOn:aStream. |
432 | 2026 |
aStream nextPutChunkSeparator. |
333 | 2027 |
aStream cr; cr |
1 | 2028 |
]. |
2029 |
||
92 | 2030 |
" |
2031 |
a comment - if any |
|
2032 |
" |
|
193 | 2033 |
(comment := self comment) notNil ifTrue:[ |
333 | 2034 |
aStream nextPutAll:name; nextPutAll:' comment:'. |
153 | 2035 |
aStream nextPutAll:(comment storeString). |
432 | 2036 |
aStream nextPutChunkSeparator. |
333 | 2037 |
aStream cr; cr |
1 | 2038 |
]. |
92 | 2039 |
|
2040 |
" |
|
216 | 2041 |
primitive definitions - if any |
2042 |
" |
|
2043 |
self fileOutPrimitiveSpecsOn:aStream. |
|
2044 |
||
2045 |
" |
|
92 | 2046 |
methods from all categories in metaclass |
2047 |
" |
|
362 | 2048 |
collectionOfCategories := self class categories asSortedCollection. |
1 | 2049 |
collectionOfCategories notNil ifTrue:[ |
168 | 2050 |
" |
199 | 2051 |
documentation first (if any) |
168 | 2052 |
" |
2053 |
(collectionOfCategories includes:'documentation') ifTrue:[ |
|
2054 |
self class fileOutCategory:'documentation' on:aStream. |
|
199 | 2055 |
aStream cr. |
2056 |
]. |
|
2057 |
" |
|
2058 |
initialization next (if any) |
|
2059 |
" |
|
2060 |
(collectionOfCategories includes:'initialization') ifTrue:[ |
|
2061 |
self class fileOutCategory:'initialization' on:aStream. |
|
2062 |
aStream cr. |
|
2063 |
]. |
|
2064 |
" |
|
2065 |
instance creation next (if any) |
|
2066 |
" |
|
2067 |
(collectionOfCategories includes:'instance creation') ifTrue:[ |
|
213 | 2068 |
self class fileOutCategory:'instance creation' on:aStream. |
199 | 2069 |
aStream cr. |
168 | 2070 |
]. |
153 | 2071 |
collectionOfCategories do:[:aCategory | |
199 | 2072 |
((aCategory ~= 'documentation') |
2073 |
and:[(aCategory ~= 'initialization') |
|
2074 |
and:[aCategory ~= 'instance creation']]) ifTrue:[ |
|
168 | 2075 |
self class fileOutCategory:aCategory on:aStream. |
2076 |
aStream cr |
|
2077 |
] |
|
153 | 2078 |
] |
1 | 2079 |
]. |
92 | 2080 |
" |
2081 |
methods from all categories in myself |
|
2082 |
" |
|
362 | 2083 |
collectionOfCategories := self categories asSortedCollection. |
1 | 2084 |
collectionOfCategories notNil ifTrue:[ |
153 | 2085 |
collectionOfCategories do:[:aCategory | |
2086 |
self fileOutCategory:aCategory on:aStream. |
|
2087 |
aStream cr |
|
2088 |
] |
|
1 | 2089 |
]. |
92 | 2090 |
" |
2091 |
optionally an initialize message |
|
2092 |
" |
|
1 | 2093 |
(self class implements:#initialize) ifTrue:[ |
153 | 2094 |
aStream nextPutAll:(name , ' initialize'). |
432 | 2095 |
aStream nextPutChunkSeparator. |
153 | 2096 |
aStream cr |
1 | 2097 |
] |
2098 |
! |
|
2099 |
||
2100 |
fileOut |
|
54 | 2101 |
"create a file 'class.st' consisting of all methods in myself. |
2102 |
If the current project is not nil, create the file in the projects |
|
153 | 2103 |
directory. Care is taken, to not clobber any existing file in |
356 | 2104 |
case of errors (for example: disk full). |
2105 |
Also, since the classes methods need a valid sourcefile, the current |
|
2106 |
sourceFile may not be rewritten." |
|
2107 |
||
2108 |
|aStream baseName dirName fileName newFileName needRename |
|
2109 |
mySourceFileName sameFile| |
|
1 | 2110 |
|
153 | 2111 |
baseName := (Smalltalk fileNameForClass:self name). |
2112 |
fileName := baseName , '.st'. |
|
356 | 2113 |
|
139 | 2114 |
" |
2115 |
this test allows a smalltalk to be built without Projects/ChangeSets |
|
2116 |
" |
|
68 | 2117 |
Project notNil ifTrue:[ |
153 | 2118 |
dirName := Project currentProjectDirectory |
2119 |
] ifFalse:[ |
|
2120 |
dirName := '' |
|
54 | 2121 |
]. |
153 | 2122 |
fileName := dirName , fileName. |
356 | 2123 |
|
153 | 2124 |
" |
2125 |
if file exists, copy the existing to a .sav-file, |
|
199 | 2126 |
create the new file as XXX.new-file, |
153 | 2127 |
and, if that worked rename afterwards ... |
2128 |
" |
|
357 | 2129 |
(fileName asFilename exists |
2130 |
and:[classFilename notNil]) ifTrue:[ |
|
356 | 2131 |
" |
2132 |
check for overwriting my current source file |
|
2133 |
this is not allowed, since it would clobber my methods source |
|
2134 |
file ... you have to save it to some other place. |
|
2135 |
This happens if you ask for a fileOut into the source-directory |
|
2136 |
(from which my methods get their source) |
|
2137 |
" |
|
2138 |
mySourceFileName := Smalltalk getSourceFileName:classFilename. |
|
2139 |
sameFile := (fileName = mySourceFileName). |
|
2140 |
sameFile ifFalse:[ |
|
2141 |
sameFile := (fileName asFilename info at:#id) == (mySourceFileName asFilename info at:#id) |
|
2142 |
]. |
|
2143 |
sameFile ifTrue:[ |
|
2144 |
^ FileOutErrorSignal |
|
2145 |
raiseRequestWith:fileName |
|
2146 |
errorString:('may not overwrite sourcefile:', fileName) |
|
2147 |
]. |
|
2148 |
||
153 | 2149 |
fileName asFilename copyTo:('/tmp/' , baseName , '.sav'). |
2150 |
newFileName := dirName , baseName , '.new'. |
|
2151 |
needRename := true |
|
2152 |
] ifFalse:[ |
|
2153 |
newFileName := fileName. |
|
2154 |
needRename := false |
|
2155 |
]. |
|
2156 |
||
2157 |
aStream := FileStream newFileNamed:newFileName. |
|
1 | 2158 |
aStream isNil ifTrue:[ |
356 | 2159 |
^ FileOutErrorSignal |
2160 |
raiseRequestWith:newFileName |
|
2161 |
errorString:('cannot create file:', newFileName) |
|
1 | 2162 |
]. |
2163 |
self fileOutOn:aStream. |
|
153 | 2164 |
aStream close. |
2165 |
||
2166 |
" |
|
2167 |
finally, replace the old-file |
|
2168 |
be careful, if the old one is a symbolic link; in this case, |
|
2169 |
we have to do a copy ... |
|
2170 |
" |
|
2171 |
needRename ifTrue:[ |
|
2172 |
newFileName asFilename copyTo:fileName. |
|
2173 |
newFileName asFilename delete |
|
2174 |
]. |
|
199 | 2175 |
|
2176 |
" |
|
2177 |
add a change record; that way, administration is much easier, |
|
2178 |
since we can see in that changeBrowser, which changes have |
|
2179 |
already found their way into a sourceFile and which must be |
|
2180 |
applied again |
|
2181 |
" |
|
2182 |
self addChangeRecordForClassFileOut:self |
|
1 | 2183 |
! |
2184 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2185 |
fileOutClassInstVarDefinitionOn:aStream |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2186 |
"append an expression to define my classInstanceVariables on aStream" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2187 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2188 |
aStream nextPutAll:(name , ' class instanceVariableNames:'''). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2189 |
self class printInstVarNamesOn:aStream indent:8. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2190 |
aStream nextPutAll:''''. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2191 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2192 |
"mhmh - good idea; saw this in SmallDraw sourcecode ..." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2193 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2194 |
aStream cr; cr; nextPut:(Character doubleQuote); cr. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2195 |
aStream space; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2196 |
nextPutAll:'The following class instance variables are inherited by this class:'; |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2197 |
cr; cr. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2198 |
self allSuperclassesDo:[:aSuperClass | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2199 |
aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2200 |
aStream nextPutAll:(aSuperClass class instanceVariableString); cr. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2201 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2202 |
aStream nextPut:(Character doubleQuote); cr. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2203 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2204 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2205 |
fileOutCategory:aCategory |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2206 |
"create a file 'class-category.st' consisting of all methods in aCategory. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2207 |
If the current project is not nil, create the file in the projects |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2208 |
directory." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2209 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2210 |
|aStream fileName| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2211 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2212 |
fileName := name , '-' , aCategory , '.st'. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2213 |
fileName replaceAll:(Character space) by:$_. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2214 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2215 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2216 |
this test allows a smalltalk to be built without Projects/ChangeSets |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2217 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2218 |
Project notNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2219 |
fileName := Project currentProjectDirectory , fileName. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2220 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2221 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2222 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2223 |
if file exists, save original in a .sav file |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2224 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2225 |
fileName asFilename exists ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2226 |
fileName asFilename copyTo:(fileName , '.sav') |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2227 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2228 |
aStream := FileStream newFileNamed:fileName. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2229 |
aStream isNil ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2230 |
^ FileOutErrorSignal |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2231 |
raiseRequestWith:fileName |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2232 |
errorString:('cannot create file:', fileName) |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2233 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2234 |
self fileOutCategory:aCategory on:aStream. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2235 |
aStream close |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2236 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2237 |
|
453 | 2238 |
fileOutMethod:aMethod |
2239 |
"create a file 'class-method.st' consisting of the method, aMethod. |
|
2240 |
If the current project is not nil, create the file in the projects |
|
2241 |
directory." |
|
2242 |
||
2243 |
|aStream fileName selector| |
|
2244 |
||
2245 |
selector := self selectorAtMethod:aMethod. |
|
2246 |
selector notNil ifTrue:[ |
|
2247 |
fileName := name , '-' , selector, '.st'. |
|
2248 |
fileName replaceAll:$: by:$_. |
|
2249 |
" |
|
2250 |
this test allows a smalltalk to be built without Projects/ChangeSets |
|
2251 |
" |
|
2252 |
Project notNil ifTrue:[ |
|
2253 |
fileName := Project currentProjectDirectory , fileName. |
|
2254 |
]. |
|
2255 |
||
2256 |
" |
|
2257 |
if file exists, save original in a .sav file |
|
2258 |
" |
|
2259 |
fileName asFilename exists ifTrue:[ |
|
2260 |
fileName asFilename copyTo:(fileName , '.sav') |
|
2261 |
]. |
|
2262 |
aStream := FileStream newFileNamed:fileName. |
|
2263 |
aStream isNil ifTrue:[ |
|
2264 |
^ FileOutErrorSignal |
|
2265 |
raiseRequestWith:fileName |
|
2266 |
errorString:('cannot create file:', fileName) |
|
2267 |
]. |
|
2268 |
self fileOutMethod:aMethod on:aStream. |
|
2269 |
aStream close |
|
2270 |
] |
|
2271 |
! |
|
2272 |
||
1 | 2273 |
fileOutIn:aFileDirectory |
2274 |
"create a file 'class.st' consisting of all methods in self in |
|
139 | 2275 |
directory aFileDirectory (ignoring any directory setting in |
199 | 2276 |
the current porject). |
2277 |
This is not logged in that change file (should it be ?)." |
|
1 | 2278 |
|
2279 |
|aStream fileName| |
|
2280 |
||
54 | 2281 |
fileName := (Smalltalk fileNameForClass:self name) , '.st'. |
139 | 2282 |
aStream := FileStream newFileNamed:fileName in:aFileDirectory. |
1 | 2283 |
aStream isNil ifTrue:[ |
356 | 2284 |
^ FileOutErrorSignal |
2285 |
raiseRequestWith:fileName |
|
2286 |
errorString:('cannot create file:', fileName) |
|
1 | 2287 |
]. |
2288 |
self fileOutOn:aStream. |
|
2289 |
aStream close |
|
54 | 2290 |
! ! |
2291 |
||
1 | 2292 |
!Class methodsFor:'printOut'! |
2293 |
||
54 | 2294 |
printClassNameOn:aStream |
2295 |
"helper for fileOut - print my name if I am not a Metaclass; |
|
2296 |
otherwise my name without -class followed by space-class" |
|
2297 |
||
2298 |
self isMeta ifTrue:[ |
|
333 | 2299 |
aStream nextPutAll:(name copyTo:(name size - 5)); nextPutAll:' class' |
54 | 2300 |
] ifFalse:[ |
153 | 2301 |
name printOn:aStream |
54 | 2302 |
] |
2303 |
! |
|
2304 |
||
2305 |
printNameArray:anArray on:aStream indent:indent |
|
2306 |
"print an array of strings separated by spaces; when the stream |
|
2307 |
defines a lineLength, break when this limit is reached; indent |
|
293 | 2308 |
every line; used to printOut instance variable names" |
54 | 2309 |
|
2310 |
|thisName nextName arraySize lenMax pos mustBreak line spaces| |
|
2311 |
||
2312 |
arraySize := anArray size. |
|
2313 |
arraySize ~~ 0 ifTrue:[ |
|
153 | 2314 |
pos := indent. |
2315 |
lenMax := aStream lineLength. |
|
2316 |
thisName := anArray at:1. |
|
2317 |
line := ''. |
|
2318 |
1 to:arraySize do:[:index | |
|
2319 |
line := line , thisName. |
|
2320 |
pos := pos + thisName size. |
|
2321 |
(index == arraySize) ifFalse:[ |
|
2322 |
nextName := anArray at:(index + 1). |
|
2323 |
mustBreak := false. |
|
2324 |
(lenMax > 0) ifTrue:[ |
|
2325 |
((pos + nextName size) > lenMax) ifTrue:[ |
|
2326 |
mustBreak := true |
|
2327 |
] |
|
2328 |
]. |
|
2329 |
mustBreak ifTrue:[ |
|
2330 |
aStream nextPutAll:line. |
|
2331 |
aStream cr. |
|
2332 |
spaces isNil ifTrue:[ |
|
2333 |
spaces := String new:indent |
|
2334 |
]. |
|
2335 |
line := spaces. |
|
2336 |
pos := indent |
|
2337 |
] ifFalse:[ |
|
2338 |
line := line , ' '. |
|
2339 |
pos := pos + 1 |
|
2340 |
]. |
|
2341 |
thisName := nextName |
|
2342 |
] |
|
2343 |
]. |
|
2344 |
aStream nextPutAll:line |
|
54 | 2345 |
] |
2346 |
! |
|
2347 |
||
2348 |
printClassVarNamesOn:aStream indent:indent |
|
2349 |
"print the class variable names indented and breaking at line end" |
|
2350 |
||
2351 |
self printNameArray:(self classVarNames) on:aStream indent:indent |
|
2352 |
! |
|
2353 |
||
2354 |
printInstVarNamesOn:aStream indent:indent |
|
2355 |
"print the instance variable names indented and breaking at line end" |
|
2356 |
||
2357 |
self printNameArray:(self instVarNames) on:aStream indent:indent |
|
2358 |
! |
|
2359 |
||
2360 |
printHierarchyOn:aStream |
|
2361 |
"print my class hierarchy on aStream" |
|
2362 |
||
2363 |
self printHierarchyAnswerIndentOn:aStream |
|
2364 |
! |
|
2365 |
||
2366 |
printHierarchyAnswerIndentOn:aStream |
|
2367 |
"print my class hierarchy on aStream - return indent |
|
2368 |
recursively calls itself to print superclass and use returned indent |
|
2369 |
for my description - used in the browser" |
|
2370 |
||
2371 |
|indent| |
|
2372 |
||
2373 |
indent := 0. |
|
2374 |
(superclass notNil) ifTrue:[ |
|
153 | 2375 |
indent := (superclass printHierarchyAnswerIndentOn:aStream) + 2 |
54 | 2376 |
]. |
2377 |
aStream spaces:indent. |
|
333 | 2378 |
aStream nextPutAll:name; nextPutAll:' ('. |
54 | 2379 |
self printInstVarNamesOn:aStream indent:(indent + name size + 2). |
2380 |
aStream nextPutAll:')'. |
|
2381 |
aStream cr. |
|
2382 |
^ indent |
|
2383 |
! |
|
2384 |
||
2385 |
printFullHierarchyOn:aStream indent:indent |
|
2386 |
"print myself and all subclasses on aStream. |
|
2387 |
recursively calls itself to print subclasses. |
|
2388 |
Can be used to print hierarchy on the printer." |
|
2389 |
||
333 | 2390 |
aStream spaces:indent; bold; nextPutAll:name; normal; nextPutAll:' ('. |
54 | 2391 |
self printInstVarNamesOn:aStream indent:(indent + name size + 2). |
2392 |
aStream nextPutAll:')'. |
|
2393 |
aStream cr. |
|
2394 |
||
2395 |
(self subclasses sort:[:a :b | a name < b name]) do:[:aSubclass | |
|
153 | 2396 |
aSubclass printFullHierarchyOn:aStream indent:(indent + 2) |
54 | 2397 |
] |
2398 |
||
2399 |
"|printStream| |
|
2400 |
printStream := Printer new. |
|
2401 |
Object printFullHierarchyOn:printStream indent:0. |
|
2402 |
printStream close" |
|
2403 |
! |
|
2404 |
||
1 | 2405 |
printOutDefinitionOn:aPrintStream |
2406 |
"print out my definition" |
|
2407 |
||
333 | 2408 |
|comment s| |
2409 |
||
2410 |
aPrintStream nextPutAll:'class '; bold; nextPutAll:name; normal; cr. |
|
1 | 2411 |
aPrintStream nextPutAll:'superclass '. |
2412 |
superclass isNil ifTrue:[ |
|
333 | 2413 |
s := 'Object' |
1 | 2414 |
] ifFalse:[ |
333 | 2415 |
s := superclass name |
1 | 2416 |
]. |
333 | 2417 |
aPrintStream nextPutAll:s. |
1 | 2418 |
aPrintStream cr. |
2419 |
||
2420 |
aPrintStream nextPutAll:'instance Variables '. |
|
2421 |
self printInstVarNamesOn:aPrintStream indent:21. |
|
2422 |
aPrintStream cr. |
|
2423 |
||
2424 |
aPrintStream nextPutAll:'class Variables '. |
|
2425 |
self printClassVarNamesOn:aPrintStream indent:21. |
|
2426 |
aPrintStream cr. |
|
2427 |
||
2428 |
category notNil ifTrue:[ |
|
333 | 2429 |
aPrintStream nextPutAll:'category '; nextPutAll:(category printString). |
153 | 2430 |
aPrintStream cr |
1 | 2431 |
]. |
2432 |
||
193 | 2433 |
(comment := self comment) notNil ifTrue:[ |
333 | 2434 |
aPrintStream cr; nextPutAll:'comment:'; cr; italic; nextPutAll:comment; normal; cr |
1 | 2435 |
] |
2436 |
! |
|
2437 |
||
155 | 2438 |
printOutSourceProtocol:aMethod on:aPrintStream |
1 | 2439 |
"given the source in aString, print the methods message specification |
2440 |
and any method comments - without source; used to generate documentation |
|
2441 |
pages" |
|
2442 |
||
155 | 2443 |
|text| |
1 | 2444 |
|
247 | 2445 |
text := aMethod source asStringCollection. |
1 | 2446 |
(text size < 1) ifTrue:[^self]. |
2447 |
aPrintStream bold. |
|
2448 |
aPrintStream nextPutAll:(text at:1). |
|
2449 |
aPrintStream cr. |
|
2450 |
(text size >= 2) ifTrue:[ |
|
153 | 2451 |
aPrintStream italic. |
155 | 2452 |
aPrintStream spaces:((text at:2) indexOfNonSeparatorStartingAt:1). |
2453 |
aPrintStream nextPutAll:aMethod comment. |
|
2454 |
aPrintStream cr. |
|
1 | 2455 |
]. |
2456 |
aPrintStream normal |
|
155 | 2457 |
|
2458 |
" |
|
2459 |
Float printOutProtocolOn:Stdout |
|
2460 |
" |
|
1 | 2461 |
! |
2462 |
||
2463 |
printOutSource:aString on:aPrintStream |
|
2464 |
"print out a source-string; the message-specification is printed bold, |
|
2465 |
comments are printed italic" |
|
2466 |
||
2467 |
|text textIndex textSize line lineIndex lineSize inComment aCharacter| |
|
247 | 2468 |
text := aString asStringCollection. |
1 | 2469 |
aPrintStream bold. |
2470 |
aPrintStream nextPutAll:(text at:1). |
|
2471 |
aPrintStream normal. |
|
2472 |
aPrintStream cr. |
|
2473 |
inComment := false. |
|
2474 |
textSize := text size. |
|
2475 |
textIndex := 2. |
|
2476 |
[textIndex <= textSize] whileTrue:[ |
|
153 | 2477 |
line := text at:textIndex. |
2478 |
((line occurrencesOf:Character doubleQuote) == 0) ifTrue:[ |
|
2479 |
aPrintStream nextPutAll:line |
|
2480 |
] ifFalse:[ |
|
2481 |
lineSize := line size. |
|
2482 |
lineIndex := 1. |
|
2483 |
[lineIndex <= lineSize] whileTrue:[ |
|
2484 |
aCharacter := line at:lineIndex. |
|
2485 |
(aCharacter == Character doubleQuote) ifTrue:[ |
|
2486 |
inComment ifTrue:[ |
|
2487 |
aPrintStream normal. |
|
2488 |
aPrintStream nextPut:aCharacter. |
|
2489 |
inComment := false |
|
2490 |
] ifFalse:[ |
|
2491 |
aPrintStream nextPut:aCharacter. |
|
2492 |
aPrintStream italic. |
|
2493 |
inComment := true |
|
2494 |
] |
|
2495 |
] ifFalse:[ |
|
2496 |
aPrintStream nextPut:aCharacter |
|
2497 |
]. |
|
2498 |
lineIndex := lineIndex + 1 |
|
2499 |
] |
|
2500 |
]. |
|
2501 |
aPrintStream cr. |
|
2502 |
textIndex := textIndex + 1 |
|
1 | 2503 |
] |
2504 |
! |
|
453 | 2505 |
|
1 | 2506 |
printOutCategory:aCategory on:aPrintStream |
2507 |
"print out all methods in aCategory on aPrintStream should be a PrintStream" |
|
2508 |
||
2509 |
|any| |
|
92 | 2510 |
methodArray notNil ifTrue:[ |
153 | 2511 |
any := false. |
2512 |
methodArray do:[:aMethod | |
|
2513 |
(aCategory = aMethod category) ifTrue:[ |
|
2514 |
any := true |
|
2515 |
] |
|
2516 |
]. |
|
2517 |
any ifTrue:[ |
|
2518 |
aPrintStream italic. |
|
2519 |
aPrintStream nextPutAll:aCategory. |
|
2520 |
aPrintStream normal. |
|
333 | 2521 |
aPrintStream cr; cr. |
153 | 2522 |
methodArray do:[:aMethod | |
2523 |
(aCategory = aMethod category) ifTrue:[ |
|
2524 |
self printOutSource:(aMethod source) on:aPrintStream. |
|
333 | 2525 |
aPrintStream cr; cr |
153 | 2526 |
] |
2527 |
]. |
|
2528 |
aPrintStream cr |
|
2529 |
] |
|
1 | 2530 |
] |
2531 |
! |
|
2532 |
||
2533 |
printOutOn:aPrintStream |
|
2534 |
"print out all methods on aPrintStream which should be a printStream" |
|
2535 |
||
2536 |
|collectionOfCategories| |
|
333 | 2537 |
|
1 | 2538 |
self printOutDefinitionOn:aPrintStream. |
2539 |
aPrintStream cr. |
|
2540 |
collectionOfCategories := self class categories. |
|
2541 |
collectionOfCategories notNil ifTrue:[ |
|
153 | 2542 |
aPrintStream nextPutAll:'class protocol'. |
333 | 2543 |
aPrintStream cr; cr. |
153 | 2544 |
collectionOfCategories do:[:aCategory | |
2545 |
self class printOutCategory:aCategory on:aPrintStream |
|
2546 |
] |
|
1 | 2547 |
]. |
2548 |
collectionOfCategories := self categories. |
|
2549 |
collectionOfCategories notNil ifTrue:[ |
|
153 | 2550 |
aPrintStream nextPutAll:'instance protocol'. |
333 | 2551 |
aPrintStream cr; cr. |
153 | 2552 |
collectionOfCategories do:[:aCategory | |
2553 |
self printOutCategory:aCategory on:aPrintStream |
|
2554 |
] |
|
1 | 2555 |
] |
2556 |
! |
|
2557 |
||
2558 |
printOutCategoryProtocol:aCategory on:aPrintStream |
|
2559 |
|any| |
|
54 | 2560 |
|
92 | 2561 |
methodArray notNil ifTrue:[ |
153 | 2562 |
any := false. |
2563 |
methodArray do:[:aMethod | |
|
2564 |
(aCategory = aMethod category) ifTrue:[ |
|
2565 |
any := true |
|
2566 |
] |
|
2567 |
]. |
|
2568 |
any ifTrue:[ |
|
2569 |
aPrintStream italic. |
|
2570 |
aPrintStream nextPutAll:aCategory. |
|
2571 |
aPrintStream normal. |
|
333 | 2572 |
aPrintStream cr; cr. |
153 | 2573 |
methodArray do:[:aMethod | |
2574 |
(aCategory = aMethod category) ifTrue:[ |
|
155 | 2575 |
self printOutSourceProtocol:aMethod |
153 | 2576 |
on:aPrintStream. |
333 | 2577 |
aPrintStream cr; cr |
153 | 2578 |
] |
2579 |
]. |
|
2580 |
aPrintStream cr |
|
2581 |
] |
|
1 | 2582 |
] |
2583 |
! |
|
2584 |
||
2585 |
printOutProtocolOn:aPrintStream |
|
2586 |
|collectionOfCategories| |
|
2587 |
self printOutDefinitionOn:aPrintStream. |
|
2588 |
aPrintStream cr. |
|
2589 |
collectionOfCategories := self class categories. |
|
2590 |
collectionOfCategories notNil ifTrue:[ |
|
153 | 2591 |
aPrintStream nextPutAll:'class protocol'. |
333 | 2592 |
aPrintStream cr; cr. |
153 | 2593 |
collectionOfCategories do:[:aCategory | |
2594 |
self class printOutCategoryProtocol:aCategory on:aPrintStream |
|
2595 |
] |
|
1 | 2596 |
]. |
2597 |
collectionOfCategories := self categories. |
|
2598 |
collectionOfCategories notNil ifTrue:[ |
|
153 | 2599 |
aPrintStream nextPutAll:'instance protocol'. |
333 | 2600 |
aPrintStream cr; cr. |
153 | 2601 |
collectionOfCategories do:[:aCategory | |
2602 |
self printOutCategoryProtocol:aCategory on:aPrintStream |
|
2603 |
] |
|
1 | 2604 |
] |
2605 |
! ! |
|
2 | 2606 |
|
453 | 2607 |
!Class methodsFor:'private'! |
2608 |
||
544 | 2609 |
updateRevisionString |
2610 |
"update my revision string, to reflect a change w.r.t. |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2611 |
the original source. |
544 | 2612 |
The original revision string is kept as a reference i.e. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2613 |
Header: /files/CVS/stx/libbasic/Class.st,v 1.63 1995/10/28 16:44:51 cg Exp $ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2614 |
is changed into: |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2615 |
Header: /files/CVS/stx/libbasic/Class.st,v 1.63mod 1995/10/28 16:44:51 cg Exp $ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2616 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2617 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2618 |
|cls vs m idx leftPart rightPart vsnString| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2619 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2620 |
cls := self. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2621 |
self isMeta ifFalse:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2622 |
cls := self class |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2623 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2624 |
m := cls compiledMethodAt:#version. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2625 |
m isNil ifTrue:[^ self]. |
544 | 2626 |
vs := self revisionString. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2627 |
vs isNil ifTrue:[^ self]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2628 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2629 |
"/ search for ,v |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2630 |
idx := vs indexOfSubCollection:'.st,v'. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2631 |
idx == 0 ifTrue:[^ self]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2632 |
leftPart := vs copyTo:(idx - 1 + 5). |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2633 |
rightPart := (vs copyFrom:(idx + 5)) withoutSpaces. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2634 |
idx := rightPart indexOfSeparator. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2635 |
idx == 0 ifTrue:[^ self]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2636 |
vsnString := rightPart copyTo:idx - 1. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2637 |
rightPart := rightPart copyFrom:idx + 1. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2638 |
vsnString ~= self revision ifTrue:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2639 |
"/ alread a modified class |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2640 |
"/ ('already modified: ' , vsnString) printNL. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2641 |
^ self |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2642 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2643 |
m source:'version |
544 | 2644 |
^ ''' , leftPart , ' ' , vsnString , 'mod' , ' ' , rightPart , ''''. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2645 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2646 |
"/ ('updated to :' , vsnString , 'mod') printNL. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2647 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2648 |
" |
544 | 2649 |
Class updateRevisionString |
2650 |
Number updateRevisionString |
|
2651 |
ProcessMonitor updateRevisionString |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2652 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2653 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2654 |
"Created: 29.10.1995 / 19:25:15 / cg" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2655 |
"Modified: 29.10.1995 / 19:39:38 / cg" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2656 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2657 |
|
544 | 2658 |
revisionString |
2659 |
"return my revision string; that one is extracted from the |
|
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2660 |
classes #version method. Either this is a method returning that string, |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2661 |
or its a comment-only method and the comment defines the version. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2662 |
If the source is not accessable or no such method exists, |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2663 |
nil is returned." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2664 |
|
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2665 |
|cls meta m src lines idx val| |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2666 |
|
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2667 |
self isMeta ifTrue:[ |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2668 |
meta := self. cls := meta soleInstance |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2669 |
] ifFalse:[ |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2670 |
cls := self. meta := self class |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2671 |
]. |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2672 |
|
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2673 |
m := meta compiledMethodAt:#version. |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2674 |
m isNil ifTrue:[^ nil]. |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2675 |
|
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2676 |
"/ if its a method returning the string, |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2677 |
val := cls version. |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2678 |
val isString ifTrue:[^ val]. |
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2679 |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2680 |
src := m source. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2681 |
src isNil ifTrue:[^ nil]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2682 |
lines := src asCollectionOfLines. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2683 |
idx := lines findFirst:[:l | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2684 |
l withoutSpaces startsWith:'$Header' |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2685 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2686 |
idx == 0 ifTrue:[^ nil]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2687 |
^ lines at:idx. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2688 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2689 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2690 |
Smalltalk allClassesDo:[:cls | |
544 | 2691 |
Transcript showCr:cls revisionString |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2692 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2693 |
|
544 | 2694 |
Number revisionString |
2695 |
FileDirectory revisionString |
|
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2696 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2697 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2698 |
"Created: 29.10.1995 / 19:28:03 / cg" |
527
7eedfdb0db62
try revisionString for revision-number as well
Claus Gittinger <cg@exept.de>
parents:
524
diff
changeset
|
2699 |
"Modified: 11.11.1995 / 14:11:41 / cg" |
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2700 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2701 |
|
544 | 2702 |
revisionInfo |
2703 |
"return a dictionary filled with revision info. |
|
2704 |
This extracts the reevant info from the revisionString." |
|
2705 |
||
2706 |
|vsnString words info nm| |
|
2707 |
||
2708 |
info := IdentityDictionary new. |
|
2709 |
vsnString := self revisionString. |
|
2710 |
vsnString notNil ifTrue:[ |
|
2711 |
words := vsnString asCollectionOfWords. |
|
2712 |
||
2713 |
"/ |
|
2714 |
"/ supported formats: |
|
2715 |
"/ |
|
2716 |
"/ $-Header: pathName rev date time user state $ |
|
2717 |
"/ $-Revision: rev $ |
|
2718 |
"/ $-Id: fileName rev date time user state $ |
|
2719 |
"/ |
|
2720 |
((words at:1) = '$Header:') ifTrue:[ |
|
2721 |
nm := words at:2. |
|
2722 |
info at:#repositoryPathName put:nm. |
|
2723 |
(nm endsWith:',v') ifTrue:[ |
|
2724 |
nm := nm copyWithoutLast:2 |
|
2725 |
]. |
|
2726 |
info at:#fileName put:nm asFilename baseName. |
|
2727 |
info at:#revision put:(words at:3). |
|
2728 |
info at:#date put:(words at:4). |
|
2729 |
info at:#time put:(words at:5). |
|
2730 |
info at:#user put:(words at:6). |
|
2731 |
info at:#state put:(words at:7). |
|
2732 |
^ info |
|
2733 |
]. |
|
2734 |
((words at:1) = '$Revision:') ifTrue:[ |
|
2735 |
info at:#revision put:(words at:2). |
|
2736 |
^ info |
|
2737 |
]. |
|
2738 |
((words at:1) = '$Id:') ifTrue:[ |
|
2739 |
info at:#fileName put:(words at:2). |
|
2740 |
info at:#revision put:(words at:3). |
|
2741 |
info at:#date put:(words at:4). |
|
2742 |
info at:#time put:(words at:5). |
|
2743 |
info at:#user put:(words at:6). |
|
2744 |
info at:#state put:(words at:7). |
|
2745 |
^ info |
|
2746 |
]. |
|
2747 |
]. |
|
2748 |
^ nil |
|
2749 |
||
2750 |
" |
|
2751 |
Object revisionString |
|
2752 |
Object revisionInfo |
|
2753 |
" |
|
2754 |
||
2755 |
"Created: 11.11.1995 / 14:27:20 / cg" |
|
2756 |
"Modified: 14.11.1995 / 16:00:51 / cg" |
|
2757 |
! |
|
2758 |
||
453 | 2759 |
addAllClassVarNamesTo:aCollection |
2760 |
"helper - add the name-strings of the class variables and of the class-vars |
|
2761 |
of all superclasses to the argument, aCollection. Return aCollection" |
|
2762 |
||
2763 |
(superclass notNil) ifTrue:[ |
|
2764 |
superclass addAllClassVarNamesTo:aCollection |
|
2765 |
]. |
|
2766 |
classvars notNil ifTrue:[ |
|
2767 |
aCollection addAll:(classvars asCollectionOfWords). |
|
2768 |
]. |
|
2769 |
^ aCollection |
|
2770 |
! |
|
2771 |
||
2772 |
getPrimitiveSpecsAt:index |
|
2773 |
"return a primitiveSpecification component as string or nil" |
|
2774 |
||
2775 |
|pos stream string| |
|
2776 |
||
2777 |
primitiveSpec isNil ifTrue:[^ nil]. |
|
2778 |
pos := primitiveSpec at:index. |
|
2779 |
pos isNil ifTrue:[^ nil]. |
|
2780 |
||
2781 |
"the primitiveSpec is either a string, or an integer specifying the |
|
2782 |
position within the classes sourcefile ... |
|
2783 |
" |
|
2784 |
pos isNumber ifTrue:[ |
|
2785 |
classFilename notNil ifTrue:[ |
|
523
27e13690f124
sourceStream added (handles dynamic loaded code);
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
2786 |
stream := self sourceStream. "/ Smalltalk sourceFileStreamFor:classFilename. |
453 | 2787 |
stream notNil ifTrue:[ |
2788 |
stream position:pos+1. |
|
2789 |
string := stream nextChunk. |
|
2790 |
stream close. |
|
2791 |
^ string |
|
2792 |
] |
|
2793 |
]. |
|
2794 |
^ nil |
|
2795 |
]. |
|
2796 |
^ pos |
|
2 | 2797 |
! |
2798 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2799 |
addCategoriesTo:aCollection |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2800 |
"helper - add categories to the argument, aCollection" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2801 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2802 |
methodArray do:[:aMethod | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2803 |
|cat| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2804 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2805 |
cat := aMethod category. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2806 |
(aCollection includes:cat) ifFalse:[ |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2807 |
aCollection add:cat |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2808 |
] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2809 |
] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2810 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2811 |
|
453 | 2812 |
addAllCategoriesTo:aCollection |
2813 |
"helper - add categories and all superclasses categories |
|
2814 |
to the argument, aCollection" |
|
2815 |
||
2816 |
(superclass notNil) ifTrue:[ |
|
2817 |
superclass addAllCategoriesTo:aCollection |
|
2818 |
]. |
|
2819 |
self addCategoriesTo:aCollection |
|
2820 |
! |
|
2821 |
||
2822 |
setPrimitiveSpecsAt:index to:aString |
|
2823 |
"set a primitiveSpecification component to aString" |
|
2824 |
||
2825 |
primitiveSpec isNil ifTrue:[ |
|
2826 |
primitiveSpec := Array new:3 |
|
2827 |
]. |
|
2828 |
primitiveSpec at:index put:aString |
|
2829 |
! ! |
|
2830 |
||
2831 |
!Class methodsFor:'queries'! |
|
2832 |
||
2833 |
isClass |
|
2834 |
"return true, if the receiver is some kind of class |
|
2835 |
(a real class, not just behavior); |
|
2836 |
true is returned here - the method is redefined from Object. |
|
2837 |
See also Behavior>>isBehavior." |
|
2838 |
||
2839 |
^ true |
|
2840 |
||
2841 |
" |
|
2842 |
Point isClass |
|
2843 |
1 isClass |
|
2844 |
Behavior new isBehavior |
|
2845 |
Behavior new isClass |
|
2846 |
Class new isBehavior |
|
2847 |
Class new isClass |
|
2848 |
" |
|
2849 |
! |
|
2850 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2851 |
categories |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2852 |
"Return a Collection of all method-category strings known in class. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2853 |
The returned collection is not sorted by any order." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2854 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2855 |
|newList cat| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2856 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2857 |
newList := OrderedCollection new. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2858 |
methodArray do:[:aMethod | |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2859 |
cat := aMethod category. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2860 |
newList indexOf:cat ifAbsent:[newList add:cat] |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2861 |
]. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2862 |
^ newList |
453 | 2863 |
|
2864 |
" |
|
2865 |
Point categories |
|
293 | 2866 |
" |
453 | 2867 |
! |
2868 |
||
2869 |
whichClassDefinesClassVar:aVariableName |
|
2870 |
"return the class which defines the class variable |
|
2871 |
named aVariableName. This method should not be used for |
|
2872 |
repeated searches (i.e. in the compiler/parser), since it creates |
|
2873 |
many throw away intermediate objects." |
|
2874 |
||
2875 |
|cls| |
|
2876 |
||
2877 |
cls := self. |
|
2878 |
[cls notNil] whileTrue:[ |
|
2879 |
(cls classVarNames includes:aVariableName) ifTrue:[ ^ cls]. |
|
2880 |
cls := cls superclass |
|
2881 |
]. |
|
2882 |
^ nil |
|
2883 |
||
2884 |
" |
|
2885 |
StandardSystemView whichClassDefinesClassVar:'ErrorSignal' |
|
2886 |
StandardSystemView whichClassDefinesClassVar:'Foo' |
|
2887 |
" |
|
2888 |
! |
|
2889 |
||
2890 |
wasAutoloaded |
|
2891 |
"return true, if this class came into the system via an |
|
2892 |
autoload; false otherwise. |
|
2893 |
This is not an attribute of the class, but instead remembered in |
|
2894 |
Autoload. The interface here is for covenience." |
|
2895 |
||
2896 |
^ Autoload wasAutoloaded:self |
|
2897 |
! |
|
2898 |
||
457
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2899 |
allCategories |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2900 |
"Return a Collection of all method-category strings known in class |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2901 |
and all superclasses. The returned collection is not sorted by any order." |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2902 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2903 |
|coll| |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2904 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2905 |
coll := OrderedCollection new. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2906 |
self addAllCategoriesTo:coll. |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2907 |
^ coll |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2908 |
|
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2909 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2910 |
Point categories |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2911 |
Point allCategories |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2912 |
" |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2913 |
! |
41c73cbee305
change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2914 |
|
453 | 2915 |
whichClassDefinesInstVar:aVariableName |
2916 |
"return the class which defines the instance variable |
|
2917 |
named aVariableName. This method should not be used for |
|
2918 |
repeated searches (i.e. in the compiler/parser), since it creates |
|
2919 |
many throw away intermediate objects." |
|
2920 |
||
2921 |
|cls| |
|
2922 |
||
2923 |
cls := self. |
|
2924 |
[cls notNil] whileTrue:[ |
|
2925 |
(cls instVarNames includes:aVariableName) ifTrue:[ ^ cls]. |
|
2926 |
cls := cls superclass |
|
2927 |
]. |
|
2928 |
^ nil |
|
293 | 2929 |
|
2930 |
" |
|
453 | 2931 |
StandardSystemView whichClassDefinesInstVar:'label' |
2932 |
StandardSystemView whichClassDefinesInstVar:'paint' |
|
2933 |
StandardSystemView whichClassDefinesInstVar:'foo' |
|
293 | 2934 |
" |
453 | 2935 |
! ! |
2936 |
||
2937 |
!Class methodsFor:'subclass creation'! |
|
2938 |
||
2939 |
subclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat |
|
2940 |
"create a new class as a subclass of an existing class (the receiver). |
|
2941 |
The subclass will have indexed variables if the receiving-class has." |
|
2942 |
||
2943 |
self isVariable ifFalse:[ |
|
2944 |
^ self class |
|
2945 |
name:t |
|
2946 |
inEnvironment:Smalltalk |
|
2947 |
subclassOf:self |
|
2948 |
instanceVariableNames:f |
|
2949 |
variable:false |
|
2950 |
words:true |
|
2951 |
pointers:true |
|
2952 |
classVariableNames:d |
|
2953 |
poolDictionaries:s |
|
2954 |
category:cat |
|
2955 |
comment:nil |
|
2956 |
changed:false |
|
2957 |
]. |
|
2958 |
self isBytes ifTrue:[ |
|
2959 |
^ self |
|
2960 |
variableByteSubclass:t |
|
2961 |
instanceVariableNames:f |
|
2962 |
classVariableNames:d |
|
2963 |
poolDictionaries:s |
|
2964 |
category:cat |
|
2965 |
]. |
|
2966 |
self isLongs ifTrue:[ |
|
2967 |
^ self |
|
2968 |
variableLongSubclass:t |
|
2969 |
instanceVariableNames:f |
|
2970 |
classVariableNames:d |
|
2971 |
poolDictionaries:s |
|
2972 |
category:cat |
|
2973 |
]. |
|
2974 |
self isFloats ifTrue:[ |
|
2975 |
^ self |
|
2976 |
variableFloatSubclass:t |
|
2977 |
instanceVariableNames:f |
|
2978 |
classVariableNames:d |
|
2979 |
poolDictionaries:s |
|
2980 |
category:cat |
|
2981 |
]. |
|
2982 |
self isDoubles ifTrue:[ |
|
2983 |
^ self |
|
2984 |
variableDoubleSubclass:t |
|
2985 |
instanceVariableNames:f |
|
2986 |
classVariableNames:d |
|
2987 |
poolDictionaries:s |
|
2988 |
category:cat |
|
2989 |
]. |
|
2990 |
self isWords ifTrue:[ |
|
2991 |
^ self |
|
2992 |
variableWordSubclass:t |
|
2993 |
instanceVariableNames:f |
|
2994 |
classVariableNames:d |
|
2995 |
poolDictionaries:s |
|
2996 |
category:cat |
|
2997 |
]. |
|
2998 |
^ self |
|
2999 |
variableSubclass:t |
|
3000 |
instanceVariableNames:f |
|
3001 |
classVariableNames:d |
|
3002 |
poolDictionaries:s |
|
3003 |
category:cat |
|
3004 |
! |
|
3005 |
||
3006 |
variableSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat |
|
3007 |
"create a new class as a subclass of an existing class (the receiver) |
|
3008 |
in which the subclass has indexable pointer variables" |
|
3009 |
||
3010 |
self isVariable ifTrue:[ |
|
3011 |
self isPointers ifFalse:[ |
|
3012 |
^ self error: |
|
3013 |
'cannot make a variable pointer subclass of a variable non-pointer class' |
|
3014 |
] |
|
3015 |
]. |
|
3016 |
||
3017 |
^ self class |
|
3018 |
name:t |
|
3019 |
inEnvironment:Smalltalk |
|
3020 |
subclassOf:self |
|
3021 |
instanceVariableNames:f |
|
3022 |
variable:true |
|
3023 |
words:false |
|
3024 |
pointers:true |
|
3025 |
classVariableNames:d |
|
3026 |
poolDictionaries:s |
|
3027 |
category:cat |
|
3028 |
comment:nil |
|
3029 |
changed:false |
|
293 | 3030 |
! |
3031 |
||
453 | 3032 |
variableByteSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat |
3033 |
"create a new class as a subclass of an existing class (the receiver) |
|
3034 |
in which the subclass has indexable byte-sized nonpointer variables" |
|
3035 |
||
3036 |
self isVariable ifTrue:[ |
|
3037 |
self isBytes ifFalse:[ |
|
3038 |
^ self error: |
|
3039 |
'cannot make a variable byte subclass of a variable non-byte class' |
|
3040 |
]. |
|
3041 |
]. |
|
3042 |
||
3043 |
^ self class |
|
3044 |
name:t |
|
3045 |
inEnvironment:Smalltalk |
|
3046 |
subclassOf:self |
|
3047 |
instanceVariableNames:f |
|
3048 |
variable:true |
|
3049 |
words:false |
|
3050 |
pointers:false |
|
3051 |
classVariableNames:d |
|
3052 |
poolDictionaries:s |
|
3053 |
category:cat |
|
3054 |
comment:nil |
|
3055 |
changed:false |
|
3056 |
! |
|
3057 |
||
3058 |
variableWordSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat |
|
3059 |
"create a new class as a subclass of an existing class (the receiver) |
|
3060 |
in which the subclass has indexable word-sized nonpointer variables" |
|
3061 |
||
3062 |
self isVariable ifTrue:[ |
|
3063 |
self isWords ifFalse:[ |
|
3064 |
^ self error: |
|
3065 |
'cannot make a variable word subclass of a variable non-word class' |
|
3066 |
]. |
|
3067 |
]. |
|
3068 |
||
3069 |
^ self class |
|
3070 |
name:t |
|
3071 |
inEnvironment:Smalltalk |
|
3072 |
subclassOf:self |
|
3073 |
instanceVariableNames:f |
|
3074 |
variable:true |
|
3075 |
words:true |
|
3076 |
pointers:false |
|
3077 |
classVariableNames:d |
|
3078 |
poolDictionaries:s |
|
3079 |
category:cat |
|
3080 |
comment:nil |
|
3081 |
changed:false |
|
3082 |
! |
|
3083 |
||
3084 |
variableLongSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat |
|
3085 |
"create a new class as a subclass of an existing class (the receiver) |
|
3086 |
in which the subclass has indexable long-sized nonpointer variables" |
|
3087 |
||
3088 |
self isVariable ifTrue:[ |
|
3089 |
self isLongs ifFalse:[ |
|
3090 |
^ self error: |
|
3091 |
'cannot make a variable long subclass of a variable non-long class' |
|
3092 |
]. |
|
3093 |
]. |
|
3094 |
||
3095 |
^ self class |
|
3096 |
name:t |
|
3097 |
inEnvironment:Smalltalk |
|
3098 |
subclassOf:self |
|
3099 |
instanceVariableNames:f |
|
3100 |
variable:#long |
|
3101 |
words:false |
|
3102 |
pointers:false |
|
3103 |
classVariableNames:d |
|
3104 |
poolDictionaries:s |
|
3105 |
category:cat |
|
3106 |
comment:nil |
|
3107 |
changed:false |
|
3108 |
! |
|
3109 |
||
3110 |
variableFloatSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat |
|
3111 |
||
3112 |
"create a new class as a subclass of an existing class (the receiver) |
|
3113 |
in which the subclass has indexable float-sized nonpointer variables" |
|
3114 |
||
3115 |
self isVariable ifTrue:[ |
|
3116 |
self isFloats ifFalse:[ |
|
3117 |
^ self error: |
|
3118 |
'cannot make a variable float subclass of a variable non-float class' |
|
3119 |
]. |
|
3120 |
]. |
|
3121 |
||
3122 |
^ self class |
|
3123 |
name:t |
|
3124 |
inEnvironment:Smalltalk |
|
3125 |
subclassOf:self |
|
3126 |
instanceVariableNames:f |
|
3127 |
variable:#float |
|
3128 |
words:false |
|
3129 |
pointers:false |
|
3130 |
classVariableNames:d |
|
3131 |
poolDictionaries:s |
|
3132 |
category:cat |
|
3133 |
comment:nil |
|
3134 |
changed:false |
|
3135 |
! |
|
3136 |
||
3137 |
variableDoubleSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat |
|
3138 |
||
3139 |
"create a new class as a subclass of an existing class (the receiver) |
|
3140 |
in which the subclass has indexable double-sized nonpointer variables" |
|
3141 |
||
3142 |
self isVariable ifTrue:[ |
|
3143 |
self isDoubles ifFalse:[ |
|
3144 |
^ self error: |
|
3145 |
'cannot make a variable double subclass of a variable non-double class' |
|
3146 |
]. |
|
3147 |
]. |
|
3148 |
||
3149 |
^ self class |
|
3150 |
name:t |
|
3151 |
inEnvironment:Smalltalk |
|
3152 |
subclassOf:self |
|
3153 |
instanceVariableNames:f |
|
3154 |
variable:#double |
|
3155 |
words:false |
|
3156 |
pointers:false |
|
3157 |
classVariableNames:d |
|
3158 |
poolDictionaries:s |
|
3159 |
category:cat |
|
3160 |
comment:nil |
|
3161 |
changed:false |
|
2 | 3162 |
! ! |
453 | 3163 |
|
3164 |
Class initialize! |