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