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