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