author | Claus Gittinger <cg@exept.de> |
Fri, 19 Mar 2004 13:14:48 +0100 | |
changeset 5759 | b6cea74440db |
parent 5758 | 8f88193a4a93 |
child 5763 | 8cce359fd150 |
permissions | -rw-r--r-- |
5141 | 1 |
" |
2 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
||
3712 | 13 |
"{ Package: 'stx:libtool' }" |
14 |
||
15 |
Object subclass:#CodeGeneratorTool |
|
5758 | 16 |
instanceVariableNames:'compositeChangeCollector compositeChangeNesting' |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
17 |
classVariableNames:'GenerateCommentsForGetters GenerateCommentsForSetters' |
3712 | 18 |
poolDictionaries:'' |
19 |
category:'Interface-Browsers' |
|
20 |
! |
|
21 |
||
3719 | 22 |
!CodeGeneratorTool class methodsFor:'documentation'! |
23 |
||
5141 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
3719 | 38 |
documentation |
39 |
" |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
40 |
This utility class contains various code generation facilites; |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
41 |
these were extracted from the old and newBrowser. |
3719 | 42 |
There is probably more to gome... |
43 |
||
44 |
[author:] |
|
45 |
Claus Gittiner |
|
46 |
" |
|
47 |
! ! |
|
3712 | 48 |
|
49 |
!CodeGeneratorTool class methodsFor:'code generation'! |
|
50 |
||
51 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
52 |
"create accessors in aClass" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
53 |
|
5758 | 54 |
^ self new |
55 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly |
|
4444
6b077945517c
generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents:
4351
diff
changeset
|
56 |
! |
6b077945517c
generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents:
4351
diff
changeset
|
57 |
|
3712 | 58 |
createApplicationCodeFor:aClass |
59 |
"create an empty application framework" |
|
60 |
||
5758 | 61 |
^ self new createApplicationCodeFor:aClass |
3712 | 62 |
! |
63 |
||
3804 | 64 |
createClassResponsibleProtocolFor:aClass |
65 |
"create stubs for the required protocol" |
|
66 |
||
5758 | 67 |
^ self new createClassResponsibleProtocolFor:aClass |
3804 | 68 |
! |
69 |
||
5124 | 70 |
createClassTypeTestMethodsIn:aClass forClasses:subClasses |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
71 |
"create a #isXXX test methods (I'm tired of typing)" |
4351 | 72 |
|
5758 | 73 |
^ self new createClassTypeTestMethodsIn:aClass forClasses:subClasses |
4351 | 74 |
! |
75 |
||
3712 | 76 |
createDocumentationMethodsFor:aClass |
77 |
"create empty documentation methods" |
|
78 |
||
5758 | 79 |
^ self new createDocumentationMethodsFor:aClass |
3712 | 80 |
! |
81 |
||
82 |
createStandardInitializationMethodsIn:aClass |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
83 |
"create a #new and #initialize methods (I'm tired of typing)" |
3712 | 84 |
|
5758 | 85 |
^ self new createStandardInitializationMethodsIn:aClass |
3712 | 86 |
! |
87 |
||
88 |
createTestCaseSampleCodeFor:aClass |
|
4590 | 89 |
"create an (almost) empty testCase class" |
3712 | 90 |
|
5758 | 91 |
^ self new createTestCaseSampleCodeFor:aClass |
3712 | 92 |
! |
93 |
||
94 |
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
95 |
"create acceptVisitor: in visitedClass and acceptXXX in visitorClass. (I'm tired of typing)" |
3712 | 96 |
|
5758 | 97 |
^ self new createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass |
3712 | 98 |
! |
99 |
||
100 |
initialMenuSpecMethodSourceForApplications |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
101 |
"return a menuSpec with typical stuff in it" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
102 |
|
3712 | 103 |
^ |
104 |
'mainMenu |
|
105 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
106 |
||
107 |
"Do not manually edit this!! If it is corrupted, |
|
108 |
the MenuEditor may not be able to read the specification." |
|
109 |
||
110 |
" |
|
111 |
MenuEditor new openOnClass:%1 andSelector:#mainMenu |
|
112 |
" |
|
113 |
||
114 |
<resource: #menu> |
|
115 |
||
116 |
^ #(#Menu |
|
117 |
#( |
|
118 |
#(#MenuItem |
|
119 |
#label: ''File'' |
|
120 |
#translateLabel: true |
|
121 |
#submenu: |
|
122 |
#(#Menu |
|
123 |
#( |
|
124 |
#(#MenuItem |
|
125 |
#label: ''New'' |
|
126 |
#translateLabel: true |
|
127 |
#value: #menuNew |
|
128 |
) |
|
129 |
#(#MenuItem |
|
130 |
#label: ''-'' |
|
131 |
) |
|
132 |
#(#MenuItem |
|
133 |
#label: ''Open...'' |
|
134 |
#translateLabel: true |
|
135 |
#value: #menuOpen |
|
136 |
) |
|
137 |
#(#MenuItem |
|
138 |
#label: ''-'' |
|
139 |
) |
|
140 |
#(#MenuItem |
|
141 |
#label: ''Save'' |
|
142 |
#translateLabel: true |
|
143 |
#value: #menuSave |
|
144 |
) |
|
145 |
#(#MenuItem |
|
146 |
#label: ''Save As...'' |
|
147 |
#translateLabel: true |
|
148 |
#value: #menuSaveAs |
|
149 |
) |
|
150 |
#(#MenuItem |
|
151 |
#label: ''-'' |
|
152 |
) |
|
153 |
#(#MenuItem |
|
154 |
#label: ''Exit'' |
|
155 |
#translateLabel: true |
|
156 |
#value: #closeRequest |
|
157 |
) |
|
158 |
) nil |
|
159 |
nil |
|
160 |
) |
|
161 |
) |
|
162 |
#(#MenuItem |
|
163 |
#label: ''Help'' |
|
164 |
#translateLabel: true |
|
165 |
#startGroup: #right |
|
166 |
#submenu: |
|
167 |
#(#Menu |
|
168 |
#( |
|
169 |
#(#MenuItem |
|
170 |
#label: ''Documentation'' |
|
171 |
#translateLabel: true |
|
172 |
#value: #openDocumentation |
|
173 |
) |
|
174 |
#(#MenuItem |
|
175 |
#label: ''-'' |
|
176 |
) |
|
177 |
#(#MenuItem |
|
178 |
#label: ''About this Application'' |
|
179 |
#translateLabel: true |
|
180 |
#value: #openAboutThisApplication |
|
181 |
) |
|
182 |
) nil |
|
183 |
nil |
|
184 |
) |
|
185 |
) |
|
186 |
) nil |
|
187 |
nil |
|
188 |
) |
|
189 |
'. |
|
190 |
! |
|
191 |
||
192 |
initialWindowSpecMethodSourceForApplications |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
193 |
"return an empty windowSpec with an initial menubar in it" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
194 |
|
3712 | 195 |
^ |
196 |
'windowSpec |
|
197 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
198 |
||
199 |
"Do not manually edit this!! If it is corrupted, |
|
200 |
the UIPainter may not be able to read the specification." |
|
201 |
||
202 |
" |
|
203 |
UIPainter new openOnClass:%1 andSelector:#windowSpec |
|
204 |
" |
|
205 |
||
206 |
<resource: #canvas> |
|
207 |
||
208 |
^ #(#FullSpec |
|
209 |
#window: |
|
210 |
#(#WindowSpec |
|
211 |
#name: ''%1'' |
|
212 |
#layout: #(#LayoutFrame 204 0 162 0 503 0 461 0) |
|
213 |
#label: ''%1'' |
|
214 |
#min: #(#Point 10 10) |
|
215 |
#max: #(#Point 1024 768) |
|
216 |
#bounds: #(#Rectangle 204 162 504 462) |
|
217 |
#menu: #mainMenu |
|
218 |
#usePreferredExtent: false |
|
219 |
) |
|
220 |
#component: |
|
221 |
#(#SpecCollection |
|
222 |
#collection: #() |
|
223 |
) |
|
224 |
) |
|
225 |
'. |
|
226 |
! |
|
227 |
||
228 |
initialWindowSpecMethodSourceForDialogs |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
229 |
"return an empty windowSpec for dialogs" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
230 |
|
3712 | 231 |
^ |
232 |
'windowSpec |
|
233 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
234 |
||
235 |
"Do not manually edit this!! If it is corrupted, |
|
236 |
the UIPainter may not be able to read the specification." |
|
237 |
||
238 |
" |
|
239 |
UIPainter new openOnClass:%1 andSelector:#windowSpec |
|
240 |
" |
|
241 |
||
242 |
<resource: #canvas> |
|
243 |
||
244 |
^ |
|
245 |
||
246 |
#(#FullSpec |
|
247 |
#window: |
|
248 |
#(#WindowSpec |
|
249 |
#name: ''%1'' |
|
250 |
#layout: #(#LayoutFrame 221 0 118 0 520 0 417 0) |
|
251 |
#level: 0 |
|
252 |
#label: ''%1'' |
|
253 |
#min: #(#Point 10 10) |
|
254 |
#max: #(#Point 1024 768) |
|
255 |
#bounds: #(#Rectangle 221 118 521 418) |
|
256 |
#usePreferredExtent: false |
|
257 |
) |
|
258 |
#component: |
|
259 |
#(#SpecCollection |
|
260 |
#collection: |
|
261 |
#( |
|
262 |
#(#HorizontalPanelViewSpec |
|
263 |
#name: ''buttonPanel'' |
|
264 |
#layout: #(#LayoutFrame 0 0.0 -45 1 0 1.0 0 1.0) |
|
265 |
#component: |
|
266 |
#(#SpecCollection |
|
267 |
#collection: |
|
268 |
#( |
|
269 |
#(#ActionButtonSpec |
|
270 |
#name: ''cancelButton'' |
|
271 |
#label: ''Cancel'' |
|
272 |
#tabable: true |
|
273 |
#translateLabel: true |
|
274 |
#model: #cancel |
|
275 |
#extent: #(#Point 125 22) |
|
276 |
) |
|
277 |
#(#ActionButtonSpec |
|
278 |
#name: ''okButton'' |
|
279 |
#label: ''OK'' |
|
280 |
#tabable: true |
|
281 |
#translateLabel: true |
|
282 |
#isDefault: true |
|
283 |
#model: #accept |
|
284 |
#extent: #(#Point 125 22) |
|
285 |
) |
|
286 |
) |
|
287 |
) |
|
288 |
#reverseOrderIfOKAtLeft: true |
|
289 |
#horizontalLayout: #spreadSpaceMax |
|
290 |
#verticalLayout: #center |
|
291 |
#horizontalSpace: 3 |
|
292 |
#verticalSpace: 3 |
|
293 |
) |
|
294 |
) |
|
295 |
) |
|
296 |
) |
|
297 |
'. |
|
298 |
! ! |
|
299 |
||
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
300 |
!CodeGeneratorTool class methodsFor:'code generation-basic'! |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
301 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
302 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
303 |
"workhorse for creating access methods for instvars." |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
304 |
|
5758 | 305 |
^ self new |
306 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization |
|
307 |
! ! |
|
308 |
||
309 |
!CodeGeneratorTool class methodsFor:'code generation-individual methods'! |
|
310 |
||
311 |
createAcceptVisitorMethod:selector in:aClass |
|
312 |
"create an acceptVisitor: method |
|
313 |
(I'm tired of typing)" |
|
314 |
||
315 |
^ self new createAcceptVisitorMethod:selector in:aClass |
|
316 |
! |
|
317 |
||
318 |
createAcceptVisitorMethodIn:aClass |
|
319 |
"create an acceptVisitor: method |
|
320 |
(I'm tired of typing)" |
|
321 |
||
322 |
^ self new createAcceptVisitorMethodIn:aClass |
|
323 |
! |
|
324 |
||
325 |
createCopyrightMethodFor:aClass |
|
326 |
"add copyright method containing your/your companies |
|
327 |
copyright template but only if not already present. |
|
328 |
this is only added, if specified in the |
|
329 |
COPYRIGHT_TEMPLATE_FILE resources." |
|
330 |
||
331 |
^ self new createCopyrightMethodFor:aClass |
|
332 |
! |
|
333 |
||
334 |
createDocumentationMethodFor:aClass |
|
335 |
"add documentation method containing doc template |
|
336 |
but only if not already present." |
|
337 |
||
338 |
^ self new createDocumentationMethodFor:aClass |
|
339 |
! |
|
340 |
||
341 |
createExamplesMethodFor:aClass |
|
342 |
"add examples method containing examples template |
|
343 |
but only if not already present." |
|
344 |
||
345 |
^ self new createExamplesMethodFor:aClass |
|
346 |
! |
|
347 |
||
348 |
createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel |
|
349 |
^ self new createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel |
|
350 |
! |
|
351 |
||
352 |
createInitialHistoryMethodFor:aClass |
|
353 |
"add history method containing created-entry |
|
354 |
but only if not already present." |
|
355 |
||
356 |
^ self new createInitialHistoryMethodFor:aClass |
|
357 |
! |
|
358 |
||
359 |
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass |
|
360 |
"add an inst-creation method" |
|
361 |
||
362 |
^ self new createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass |
|
363 |
! |
|
364 |
||
365 |
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass |
|
366 |
"create a multi-setter method for instvars." |
|
367 |
||
368 |
^ self new createMultiSetterMethodFor:aCollectionOfVarNames in:aClass |
|
369 |
! |
|
370 |
||
371 |
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass |
|
372 |
"add a subclassResponsibility method; |
|
373 |
but only if not already present." |
|
374 |
||
375 |
^ self new createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass |
|
376 |
! |
|
377 |
||
378 |
createUpdateMethodIn:aClass |
|
379 |
"create an update:with:from:-method |
|
380 |
(I'm tired of typing)" |
|
381 |
||
382 |
^ self new createUpdateMethodIn:aClass |
|
383 |
! |
|
384 |
||
385 |
createVersionMethodFor:aClass |
|
386 |
"add version method containing RCS template |
|
387 |
but only if not already present and its not a private class." |
|
388 |
||
389 |
^ self new createVersionMethodFor:aClass |
|
390 |
! ! |
|
391 |
||
392 |
!CodeGeneratorTool class methodsFor:'compilation'! |
|
393 |
||
394 |
compile:theCode forClass:aClass inCategory:cat |
|
395 |
"install some code for a class. |
|
396 |
If refactory browser stuff is avaliable the refactory tools are used to support undo" |
|
397 |
||
398 |
^ self new compile:theCode forClass:aClass inCategory:cat |
|
399 |
! ! |
|
400 |
||
401 |
!CodeGeneratorTool class methodsFor:'private'! |
|
402 |
||
403 |
canUseRefactoringSupport |
|
404 |
"check if refactory browser stuff is avaliable" |
|
405 |
||
406 |
^ RefactoryChangeManager notNil |
|
407 |
and:[RefactoryChangeManager isLoaded |
|
408 |
and:[UserPreferences current useRefactoringSupport]] |
|
409 |
! ! |
|
410 |
||
5759 | 411 |
!CodeGeneratorTool methodsFor:'buld changes'! |
412 |
||
413 |
executeCollectedChangesNamed:name |
|
414 |
compositeChangeCollector notNil ifTrue:[ |
|
415 |
compositeChangeNesting := compositeChangeNesting - 1. |
|
416 |
compositeChangeNesting == 0 ifTrue:[ |
|
417 |
compositeChangeCollector name:name. |
|
418 |
compositeChangeCollector changesSize == 0 ifTrue:[ |
|
419 |
self information:'Nothing generated.'. |
|
420 |
] ifFalse:[ |
|
421 |
RefactoryChangeManager instance performChange:compositeChangeCollector. |
|
422 |
]. |
|
423 |
compositeChangeCollector := nil. |
|
424 |
] |
|
425 |
] |
|
426 |
! |
|
427 |
||
428 |
startCollectChanges |
|
429 |
(self canUseRefactoringSupport) ifTrue:[ |
|
430 |
compositeChangeCollector isNil ifTrue:[ |
|
431 |
compositeChangeCollector := CompositeRefactoryChange new. |
|
432 |
compositeChangeNesting := 0. |
|
433 |
]. |
|
434 |
compositeChangeNesting := compositeChangeNesting + 1. |
|
435 |
] |
|
436 |
! ! |
|
437 |
||
5758 | 438 |
!CodeGeneratorTool methodsFor:'code generation'! |
439 |
||
440 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly |
|
441 |
"create accessors in aClass" |
|
442 |
||
443 |
self |
|
444 |
createAccessMethodsFor:aCollectionOfVarNames |
|
445 |
in:aClass |
|
446 |
withChange:withChange |
|
447 |
asValueHolder:asValueHolder |
|
448 |
readersOnly:readersOnly |
|
449 |
writersOnly:writersOnly |
|
450 |
lazyInitialization:false |
|
451 |
! |
|
452 |
||
453 |
createApplicationCodeFor:aClass |
|
454 |
"create an empty application framework" |
|
455 |
||
456 |
|nonMetaClass metaClass className txt isDialog categoryForMenuActionsMethods| |
|
457 |
||
458 |
self startCollectChanges. |
|
459 |
||
460 |
categoryForMenuActionsMethods := UserPreferences current categoryForMenuActionsMethods. |
|
461 |
||
462 |
nonMetaClass := aClass theNonMetaclass. |
|
463 |
metaClass := aClass theMetaclass. |
|
464 |
className := nonMetaClass name. |
|
465 |
||
466 |
isDialog := (nonMetaClass isSubclassOf:SimpleDialog). |
|
467 |
||
468 |
"/ add a windowSpec method for an empty applicationWindow, |
|
469 |
"/ with a menuPanel. |
|
470 |
||
471 |
(metaClass includesSelector:#windowSpec) ifFalse:[ |
|
472 |
isDialog ifTrue:[ |
|
473 |
txt := self class initialWindowSpecMethodSourceForDialogs. |
|
474 |
] ifFalse:[ |
|
475 |
txt := self class initialWindowSpecMethodSourceForApplications. |
|
476 |
]. |
|
477 |
self |
|
478 |
compile:(txt bindWith:className) |
|
479 |
forClass:metaClass |
|
480 |
inCategory:'interface specs'. |
|
481 |
]. |
|
482 |
||
483 |
isDialog ifFalse:[ |
|
484 |
"/ add a topMenu method |
|
485 |
||
486 |
(metaClass includesSelector:#mainMenu) ifFalse:[ |
|
487 |
txt := self class initialMenuSpecMethodSourceForApplications. |
|
488 |
self |
|
489 |
compile:(txt bindWith:className) |
|
490 |
forClass:metaClass |
|
491 |
inCategory:'menu specs'. |
|
492 |
]. |
|
493 |
]. |
|
494 |
||
495 |
(metaClass includesSelector:#postBuildWith:) ifFalse:[ |
|
496 |
txt := |
|
497 |
'postBuildWith:aBuilder |
|
498 |
"This is a hook method generated by the Browser. |
|
499 |
It will be invoked during the initialization of your app/dialog, |
|
500 |
after all of the visual components have been built, |
|
501 |
but BEFORE the top window is made visible. |
|
502 |
Add any app-specific actions here (reading files, setting up values etc.) |
|
503 |
See also #postOpenWith:, which is invoked after opening." |
|
504 |
||
505 |
"/ add any code here ... |
|
506 |
||
507 |
^ super postBuildWith:aBuilder |
|
508 |
'. |
|
509 |
self |
|
510 |
compile:txt |
|
511 |
forClass:nonMetaClass |
|
512 |
inCategory:'initialization & release'. |
|
513 |
]. |
|
514 |
||
515 |
(metaClass includesSelector:#postOpenWith:) ifFalse:[ |
|
516 |
txt := |
|
517 |
'postOpenWith:aBuilder |
|
518 |
"This is a hook method generated by the Browser. |
|
519 |
It will be invoked right after the applications window has been opened. |
|
520 |
Add any app-specific actions here (starting background processes etc.). |
|
521 |
See also #postBuildWith:, which is invoked before opening." |
|
522 |
||
523 |
"/ add any code here ... |
|
524 |
||
525 |
^ super postOpenWith:aBuilder |
|
526 |
'. |
|
527 |
self |
|
528 |
compile:txt |
|
529 |
forClass:nonMetaClass |
|
530 |
inCategory:'initialization & release'. |
|
531 |
]. |
|
532 |
||
533 |
isDialog ifFalse:[ |
|
534 |
(metaClass includesSelector:#closeRequest) ifFalse:[ |
|
535 |
txt := |
|
536 |
'closeRequest |
|
537 |
"This is a hook method generated by the Browser. |
|
538 |
It will be invoked when your app/dialog-window is about to be |
|
539 |
closed (this method has a chance to suppress the close). |
|
540 |
See also #closeDownViews, which is invoked when the close is really done." |
|
541 |
||
542 |
"/ change the code below as required ... |
|
543 |
"/ Closing can be suppressed, by simply returning. |
|
544 |
"/ The ''super closeRequest'' at the end will initiate the real closeDown |
|
545 |
||
546 |
("self hasUnsavedChanges" true) ifTrue:[ |
|
547 |
(self confirm:(resources string:''Close without saving ?'')) ifFalse:[ |
|
548 |
^ self |
|
549 |
] |
|
550 |
]. |
|
551 |
||
552 |
^ super closeRequest |
|
553 |
'. |
|
554 |
self |
|
555 |
compile:txt |
|
556 |
forClass:nonMetaClass |
|
557 |
inCategory:'initialization & release'. |
|
558 |
]. |
|
559 |
]. |
|
560 |
||
561 |
isDialog ifFalse:[ |
|
562 |
(metaClass includesSelector:#closeDownViews) ifFalse:[ |
|
563 |
txt := |
|
564 |
'closeDownViews |
|
565 |
"This is a hook method generated by the Browser. |
|
566 |
It will be invoked when your app/dialog-window is really closed. |
|
567 |
See also #closeDownViews, which is invoked before and may suppress the close |
|
568 |
or ask the user for confirmation." |
|
569 |
||
570 |
"/ change the code below as required ... |
|
571 |
"/ This should cleanup any leftover resources |
|
572 |
"/ (for example, temporary files) |
|
573 |
"/ super closeRequest will initiate the closeDown |
|
574 |
||
575 |
"/ add your code here |
|
576 |
||
577 |
"/ do not remove the one below ... |
|
578 |
^ super closeDownViews |
|
579 |
'. |
|
580 |
self |
|
581 |
compile:txt |
|
582 |
forClass:nonMetaClass |
|
583 |
inCategory:'initialization & release'. |
|
584 |
]. |
|
585 |
]. |
|
586 |
||
587 |
isDialog ifTrue:[ |
|
588 |
(metaClass includesSelector:#accept) ifFalse:[ |
|
589 |
txt := |
|
590 |
'closeAccept |
|
591 |
"This is a hook method generated by the Browser. |
|
592 |
It will be invoked when your dialog-window is closed with OK." |
|
593 |
||
594 |
"/ add any actions as required here ... |
|
595 |
Transcript showCR:''dialog accepted''. |
|
596 |
||
597 |
"/ do not remove the one below ... |
|
598 |
^ super closeAccept |
|
599 |
'. |
|
600 |
self |
|
601 |
compile:txt |
|
602 |
forClass:nonMetaClass |
|
603 |
inCategory:'user actions'. |
|
604 |
]. |
|
605 |
]. |
|
606 |
||
607 |
isDialog ifFalse:[ |
|
608 |
(metaClass includesSelector:#menuNew) ifFalse:[ |
|
609 |
txt := |
|
610 |
'menuNew |
|
611 |
"This method was generated by the Browser. |
|
612 |
It will be invoked when the menu-item ''new'' is selected." |
|
613 |
||
614 |
"/ change below and add any actions as required here ... |
|
615 |
self warn:''no action for ''''new'''' available.''. |
|
616 |
'. |
|
617 |
self |
|
618 |
compile:txt |
|
619 |
forClass:nonMetaClass |
|
620 |
inCategory:categoryForMenuActionsMethods. |
|
621 |
]. |
|
622 |
]. |
|
623 |
isDialog ifFalse:[ |
|
624 |
(metaClass includesSelector:#menuOpen) ifFalse:[ |
|
625 |
txt := |
|
626 |
'menuOpen |
|
627 |
"This method was generated by the Browser. |
|
628 |
It will be invoked when the menu-item ''open'' is selected." |
|
629 |
||
630 |
"/ change below and add any actions as required here ... |
|
631 |
self warn:''no action for ''''open'''' available.''. |
|
632 |
'. |
|
633 |
self |
|
634 |
compile:txt |
|
635 |
forClass:nonMetaClass |
|
636 |
inCategory:categoryForMenuActionsMethods. |
|
637 |
]. |
|
638 |
]. |
|
639 |
isDialog ifFalse:[ |
|
640 |
(metaClass includesSelector:#menuSave) ifFalse:[ |
|
641 |
txt := |
|
642 |
'menuSave |
|
643 |
"This method was generated by the Browser. |
|
644 |
It will be invoked when the menu-item ''save'' is selected." |
|
645 |
||
646 |
"/ change below and add any actions as required here ... |
|
647 |
self warn:''no action for ''''save'''' available.''. |
|
648 |
'. |
|
649 |
self |
|
650 |
compile:txt |
|
651 |
forClass:nonMetaClass |
|
652 |
inCategory:categoryForMenuActionsMethods. |
|
653 |
]. |
|
654 |
]. |
|
655 |
isDialog ifFalse:[ |
|
656 |
(metaClass includesSelector:#menuSaveAs) ifFalse:[ |
|
657 |
txt := |
|
658 |
'menuSaveAs |
|
659 |
"This method was generated by the Browser. |
|
660 |
It will be invoked when the menu-item ''saveAs'' is selected." |
|
661 |
||
662 |
"/ change below and add any actions as required here ... |
|
663 |
self warn:''no action for ''''saveAs'''' available.''. |
|
664 |
'. |
|
665 |
self |
|
666 |
compile:txt |
|
667 |
forClass:nonMetaClass |
|
668 |
inCategory:categoryForMenuActionsMethods. |
|
669 |
]. |
|
670 |
]. |
|
671 |
||
672 |
isDialog ifFalse:[ |
|
673 |
(metaClass includesSelector:#openDocumentation) ifFalse:[ |
|
674 |
txt := |
|
675 |
'openDocumentation |
|
676 |
"This method was generated by the Browser. |
|
677 |
It will be invoked when the menu-item ''help-documentation'' is selected." |
|
678 |
||
679 |
"/ change below as required ... |
|
680 |
||
681 |
"/ to open an HTML viewer on some document (under ''doc/online/<language>/'' ): |
|
682 |
HTMLDocumentView openFullOnDocumentationFile:''TOP.html''. |
|
683 |
||
684 |
"/ add application-specific help files under the ''doc/online/<language>/help/appName'' |
|
685 |
"/ directory, and open a viewer with: |
|
686 |
"/ HTMLDocumentView openFullOnDocumentationFile:''help/<MyApplication>/TOP.html''. |
|
687 |
'. |
|
688 |
self |
|
689 |
compile:txt |
|
690 |
forClass:nonMetaClass |
|
691 |
inCategory:categoryForMenuActionsMethods. |
|
692 |
]. |
|
693 |
]. |
|
694 |
||
695 |
isDialog ifFalse:[ |
|
696 |
(metaClass includesSelector:#openAboutThisApplication) ifFalse:[ |
|
697 |
txt := |
|
698 |
'openAboutThisApplication |
|
699 |
"This method was generated by the Browser. |
|
700 |
It will be invoked when the menu-item ''help-about'' is selected." |
|
701 |
||
702 |
"/ could open a customized aboutBox here ... |
|
703 |
super openAboutThisApplication |
|
704 |
'. |
|
705 |
self |
|
706 |
compile:txt |
|
707 |
forClass:nonMetaClass |
|
708 |
inCategory:categoryForMenuActionsMethods. |
|
709 |
]. |
|
710 |
]. |
|
711 |
||
712 |
self executeCollectedChangesNamed:('Add Application Code' , aClass nonMetaclass name). |
|
713 |
||
714 |
"Modified: / 1.2.1998 / 16:10:03 / cg" |
|
715 |
! |
|
716 |
||
717 |
createClassResponsibleProtocolFor:aClass |
|
718 |
"create stubs for the required protocol" |
|
719 |
||
720 |
self startCollectChanges. |
|
721 |
||
722 |
self privCreateClassResponsibleProtocolFor:aClass theNonMetaclass. |
|
723 |
self privCreateClassResponsibleProtocolFor:aClass theMetaclass. |
|
724 |
||
725 |
self executeCollectedChangesNamed:('Add Required Protocol to ' , aClass theNonMetaclass name). |
|
726 |
! |
|
727 |
||
728 |
createClassTypeTestMethodsIn:aClass forClasses:subClasses |
|
729 |
"create a #isXXX test methods (I'm tired of typing)" |
|
730 |
||
731 |
| code| |
|
732 |
||
733 |
self startCollectChanges. |
|
734 |
||
735 |
subClasses do:[:eachSubClass | |
|
736 |
|nm selector| |
|
737 |
||
738 |
nm := eachSubClass nameWithoutPrefix. |
|
739 |
selector := 'is' , nm. |
|
740 |
(aClass includesSelector:selector) ifFalse:[ |
|
741 |
code := (selector , '\ ^ false') withCRs. |
|
742 |
self |
|
743 |
compile:code |
|
744 |
forClass:aClass |
|
745 |
inCategory:'testing'. |
|
746 |
]. |
|
747 |
(eachSubClass includesSelector:selector) ifFalse:[ |
|
748 |
code := (selector , '\ ^ true') withCRs. |
|
749 |
self |
|
750 |
compile:code |
|
751 |
forClass:eachSubClass |
|
752 |
inCategory:'testing'. |
|
753 |
]. |
|
754 |
]. |
|
755 |
||
5759 | 756 |
self executeCollectedChangesNamed:'Add ClassType Tests' |
5758 | 757 |
! |
758 |
||
759 |
createDocumentationMethodsFor:aClass |
|
760 |
"create empty documentation methods" |
|
761 |
||
762 |
|cls| |
|
763 |
||
764 |
cls := aClass theMetaclass. |
|
765 |
||
766 |
self startCollectChanges. |
|
767 |
||
768 |
self createVersionMethodFor:cls. |
|
769 |
self createCopyrightMethodFor:aClass. |
|
770 |
self createDocumentationMethodFor:aClass. |
|
771 |
self createInitialHistoryMethodFor:aClass. |
|
772 |
||
773 |
self executeCollectedChangesNamed:('Add Documentation to ' , aClass theNonMetaclass name). |
|
774 |
! |
|
775 |
||
776 |
createStandardInitializationMethodsIn:aClass |
|
777 |
"create a #new and #initialize methods (I'm tired of typing)" |
|
778 |
||
779 |
|code initializer m| |
|
780 |
||
781 |
self startCollectChanges. |
|
782 |
||
783 |
(aClass includesSelector:#'initialize') ifFalse:[ |
|
784 |
code := |
|
785 |
'initialize |
|
786 |
"Invoked when a new instance is created." |
|
787 |
||
788 |
super initialize. |
|
789 |
||
790 |
"/ please change as required (and remove this comment) |
|
791 |
'. |
|
792 |
||
793 |
m := aClass responseTo:#initialize. |
|
794 |
m notNil ifTrue:[ |
|
795 |
m messagesSent size == 0 ifTrue:[ |
|
796 |
"/ inherits an empty initialize. |
|
797 |
||
798 |
code := |
|
799 |
'initialize |
|
800 |
"Invoked when a new instance is created." |
|
801 |
||
802 |
"/ please change as required (and remove this comment) |
|
803 |
||
804 |
"/ super initialize. -- commented since inherited method does nothing |
|
805 |
'. |
|
806 |
||
807 |
]. |
|
808 |
]. |
|
809 |
||
810 |
aClass instVarNames do:[:eachInstVar | |
|
811 |
initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ... |
|
812 |
code := code , (' ' , eachInstVar , ' := ' , initializer , Character cr). |
|
813 |
]. |
|
814 |
||
815 |
self |
|
816 |
compile:code |
|
817 |
forClass:aClass |
|
818 |
inCategory:'initialization'. |
|
819 |
]. |
|
820 |
||
821 |
(aClass class includesSelector:#'new') ifFalse:[ |
|
822 |
m := aClass class responseTo:#new. |
|
823 |
m notNil ifTrue:[ |
|
824 |
(m sends:#initialize) ifTrue:[ |
|
825 |
(self confirm:'The inherited #new method already seems to invoke #initialize. Redefine ?') |
|
826 |
ifFalse:[ |
|
827 |
^ self |
|
828 |
] |
|
829 |
]. |
|
830 |
]. |
|
831 |
code := |
|
832 |
'new |
|
833 |
^ self basicNew initialize. |
|
834 |
'. |
|
835 |
self |
|
836 |
compile:code |
|
837 |
forClass:aClass class |
|
838 |
inCategory:'instance creation'. |
|
839 |
]. |
|
840 |
||
841 |
self executeCollectedChangesNamed:('Add Initialization to ' , aClass theNonMetaclass name). |
|
842 |
||
843 |
"Created: / 11.10.2001 / 22:18:55 / cg" |
|
844 |
! |
|
845 |
||
846 |
createTestCaseSampleCodeFor:aClass |
|
847 |
"create an (almost) empty testCase class" |
|
848 |
||
849 |
|nonMetaClass metaClass| |
|
850 |
||
851 |
nonMetaClass := aClass theNonMetaclass. |
|
852 |
metaClass := aClass theMetaclass. |
|
853 |
"/ className := nonMetaClass name. |
|
854 |
||
855 |
( nonMetaClass includesSelector:#test1 ) ifFalse:[ |
|
856 |
self |
|
857 |
compile: |
|
858 |
'test1 |
|
859 |
"This is a demonstration testCase - it is meant to be removed eventually. |
|
860 |
This testCase will PASS. |
|
861 |
Double click on the TestCase class or open a TestRunner to see me checking... |
|
862 |
- please add more methods like this..." |
|
863 |
||
864 |
|o| |
|
865 |
||
866 |
o := Array new:2. |
|
867 |
self assert: ( o size == 2 ). |
|
868 |
self should: [ o at:0 ] raise:Error. |
|
869 |
self shouldnt: [ o at:1 ] raise:Error. |
|
870 |
||
871 |
" |
|
872 |
self run:#test1 |
|
873 |
self new test1 |
|
874 |
" |
|
875 |
' |
|
876 |
forClass:nonMetaClass |
|
877 |
inCategory:'tests'. |
|
878 |
]. |
|
879 |
||
880 |
( nonMetaClass includesSelector:#test2 ) ifFalse:[ |
|
881 |
self |
|
882 |
compile: |
|
883 |
'test2 |
|
884 |
"This is a demonstration testCase - it is meant to be removed eventually.. |
|
885 |
This testCase WILL FAIL. |
|
886 |
Double click on the TestCase class or open a TestRunner to see me checking... |
|
887 |
- please add more methods like this..." |
|
888 |
||
889 |
|o| |
|
890 |
||
891 |
o := Array new:2. |
|
892 |
self assert: ( o size == 3 ). |
|
893 |
||
894 |
" |
|
895 |
self run:#test2 |
|
896 |
self new test2 |
|
897 |
" |
|
898 |
' |
|
899 |
forClass:nonMetaClass |
|
900 |
inCategory:'tests'. |
|
901 |
]. |
|
902 |
||
903 |
( nonMetaClass includesSelector:#test3 ) ifFalse:[ |
|
904 |
self |
|
905 |
compile: |
|
906 |
'test3 |
|
907 |
"This is a demonstration testCase - it is meant to be removed eventually.. |
|
908 |
This testCase WILL generate an ERROR. |
|
909 |
Double click on the TestCase class or open a TestRunner to see me checking... |
|
910 |
- please add more methods like this..." |
|
911 |
||
912 |
|o| |
|
913 |
||
914 |
o := Array new:2. |
|
915 |
self assert: ( o foo ). |
|
916 |
||
917 |
" |
|
918 |
self run:#test3 |
|
919 |
self new test3 |
|
920 |
" |
|
921 |
' |
|
922 |
forClass:nonMetaClass |
|
923 |
inCategory:'tests'. |
|
924 |
]. |
|
925 |
||
926 |
( nonMetaClass includesSelector:#setUp ) ifFalse:[ |
|
927 |
self |
|
928 |
compile: |
|
929 |
'setUp |
|
930 |
"common setup - invoked before testing." |
|
931 |
||
932 |
super setUp |
|
933 |
' |
|
934 |
forClass:nonMetaClass |
|
935 |
inCategory:'initialize / release'. |
|
936 |
]. |
|
937 |
||
938 |
( nonMetaClass includesSelector:#tearDown ) ifFalse:[ |
|
939 |
self |
|
940 |
compile: |
|
941 |
'tearDown |
|
942 |
"common cleanup - invoked after testing." |
|
943 |
||
944 |
super tearDown |
|
945 |
' |
|
946 |
forClass:nonMetaClass |
|
947 |
inCategory:'initialize / release'. |
|
948 |
] |
|
949 |
! |
|
950 |
||
951 |
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass |
|
952 |
"create acceptVisitor: in visitedClass and acceptXXX in visitorClass. (I'm tired of typing)" |
|
953 |
||
954 |
|sel| |
|
955 |
||
956 |
visitedClass isMeta ifTrue:[self halt]. |
|
957 |
visitorClass isMeta ifTrue:[self halt]. |
|
958 |
||
959 |
self startCollectChanges. |
|
960 |
||
961 |
sel := ('visit' , visitedClass nameWithoutPrefix , ':'). |
|
962 |
self createAcceptVisitorMethod:sel in:visitedClass. |
|
963 |
||
964 |
(visitorClass includesSelector:sel) ifFalse:[ |
|
965 |
self |
|
966 |
compile: |
|
967 |
(('%1anObject |
|
968 |
"dispatched back from the visited %2-object (visitor pattern)" |
|
969 |
||
970 |
"fall back to general object-case - please change as required" |
|
971 |
||
972 |
^ self visitObject:anObject |
|
973 |
') bindWith:sel with:visitedClass nameWithoutPrefix asLowercaseFirst) |
|
974 |
forClass:visitorClass |
|
975 |
inCategory:'visiting'. |
|
976 |
]. |
|
977 |
||
978 |
(visitorClass includesSelector:#'visitObject:') ifFalse:[ |
|
979 |
self |
|
980 |
compile: |
|
981 |
('visitObject:anObject |
|
982 |
"dispatched back from the visited objects (visitor pattern)" |
|
983 |
||
984 |
"general fallBack - please change as required" |
|
985 |
||
986 |
self halt:''not yet implemented'' |
|
987 |
') |
|
988 |
forClass:visitorClass |
|
989 |
inCategory:'visiting'. |
|
990 |
]. |
|
991 |
||
992 |
(visitorClass includesSelector:#'visit:') ifFalse:[ |
|
993 |
self |
|
994 |
compile: |
|
995 |
('visit:anObject |
|
996 |
"visit anObject (visitor pattern). |
|
997 |
The object should call back one of my visitXXXX methods." |
|
998 |
||
999 |
^ anObject acceptVisitor:self |
|
1000 |
') |
|
1001 |
forClass:visitorClass |
|
1002 |
inCategory:'visiting'. |
|
1003 |
]. |
|
1004 |
||
1005 |
self executeCollectedChangesNamed:('Add Visitor Pattern'). |
|
1006 |
! ! |
|
1007 |
||
1008 |
!CodeGeneratorTool methodsFor:'code generation-basic'! |
|
1009 |
||
1010 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization |
|
1011 |
"workhorse for creating access methods for instvars." |
|
1012 |
||
1013 |
|classesClassVars generateComments generateCommentsForSetters generateCommentsForGetters| |
|
1014 |
||
1015 |
self startCollectChanges. |
|
1016 |
||
1017 |
generateComments := UserPreferences current generateComments. |
|
1018 |
generateCommentsForSetters := UserPreferences current generateCommentsForSetters. |
|
1019 |
generateCommentsForGetters := UserPreferences current generateCommentsForGetters. |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1020 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1021 |
classesClassVars := aClass theNonMetaclass allClassVarNames. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1022 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1023 |
aCollectionOfVarNames do:[:name | |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1024 |
|source varType methodName defaultMethodName| |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1025 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1026 |
varType := (classesClassVars includes:name) |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1027 |
ifTrue:['static'] |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1028 |
ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1029 |
(aClass isMeta ifTrue:['classInstVar'] ifFalse:['instance'])]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1030 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1031 |
methodName := name. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1032 |
name first isUppercase ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1033 |
methodName := methodName asLowercaseFirst. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1034 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1035 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1036 |
"/ the GETTER |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1037 |
writersOnly ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1038 |
lazyInitialization ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1039 |
defaultMethodName := 'default' , name asUppercaseFirst. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1040 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1041 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1042 |
"check, if method is not already present" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1043 |
(aClass includesSelector:(methodName asSymbol)) ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1044 |
asValueHolder ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1045 |
source := methodName , '\'. |
5758 | 1046 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1047 |
source := source , ' "return/create the ''%2'' value holder (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1048 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1049 |
source := source , ' %2 isNil ifTrue:[\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1050 |
lazyInitialization ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1051 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1052 |
, ' %2 := self class %3 asValue.\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1053 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1054 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1055 |
, ' %2 := ValueHolder new.\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1056 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1057 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1058 |
withChange ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1059 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1060 |
, ' %2 addDependent:self.\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1061 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1062 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1063 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1064 |
, ' ^ %2'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1065 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1066 |
source := methodName , '\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1067 |
lazyInitialization ifTrue:[ |
5758 | 1068 |
generateCommentsForGetters ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1069 |
source := source , ' "return the %1 instance variable ''%2'' with lazy instance creation (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1070 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1071 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1072 |
, ' %2 isNil ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1073 |
, ' %2 := self class %3.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1074 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1075 |
, ' ^ %2'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1076 |
] ifFalse:[ |
5758 | 1077 |
generateCommentsForGetters ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1078 |
source := source , ' "return the %1 instance variable ''%2'' (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1079 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1080 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1081 |
, ' ^ %2'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1082 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1083 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1084 |
source := (source bindWith:varType with:name with:defaultMethodName) withCRs. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1085 |
self compile:source forClass:aClass inCategory:(asValueHolder ifTrue:['aspects'] ifFalse:['accessing']). |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1086 |
] ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1087 |
Transcript showCR:'method ''', methodName , ''' already present' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1088 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1089 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1090 |
"/ default for lazy on class side |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1091 |
lazyInitialization ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1092 |
(aClass class includesSelector:(defaultMethodName asSymbol)) ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1093 |
source := defaultMethodName , '\'. |
5758 | 1094 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1095 |
source := source , ' "default value for the ''%2'' instance variable (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1096 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1097 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1098 |
, ' self halt:''unfinished code''.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1099 |
, ' ^ nil.'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1100 |
source := (source bindWith:varType with:name) withCRs. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1101 |
self compile:source forClass:aClass class inCategory:'defaults'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1102 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1103 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1104 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1105 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1106 |
"/ the SETTER |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1107 |
readersOnly ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1108 |
(aClass includesSelector:((methodName , ':') asSymbol)) ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1109 |
asValueHolder ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1110 |
source := methodName , ':something\'. |
5758 | 1111 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1112 |
source := source , ' "set the ''%2'' value holder' , ' (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1113 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1114 |
withChange ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1115 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1116 |
, ' |oldValue newValue|\\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1117 |
, ' %2 notNil ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1118 |
, ' oldValue := %2 value.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1119 |
, ' %2 removeDependent:self.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1120 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1121 |
, ' %2 := something.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1122 |
, ' %2 notNil ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1123 |
, ' %2 addDependent:self.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1124 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1125 |
, ' newValue := %2 value.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1126 |
, ' oldValue ~~ newValue ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1127 |
, ' self update:#value with:newValue from:%2.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1128 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1129 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1130 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1131 |
, ' %2 := something.'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1132 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1133 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1134 |
source := methodName , ':something\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1135 |
withChange ifTrue:[ |
5758 | 1136 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1137 |
source := source , ' "set the value of the %1 variable ''%2'''. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1138 |
source := source , ' and send a change notification (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1139 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1140 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1141 |
, ' (%2 ~~ something) ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1142 |
, ' %2 := something.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1143 |
, ' self changed:#%2.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1144 |
, ' ].\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1145 |
] ifFalse:[ |
5758 | 1146 |
generateCommentsForSetters ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1147 |
source := source , ' "set the value of the %1 variable ''%2'''. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1148 |
source := source , ' (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1149 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1150 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1151 |
, ' %2 := something.'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1152 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1153 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1154 |
source := (source bindWith:varType with:name) withCRs. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1155 |
self |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1156 |
compile:source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1157 |
forClass:aClass |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1158 |
inCategory:(asValueHolder ifTrue:['aspects'] ifFalse:['accessing']). |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1159 |
] ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1160 |
Transcript showCR:'method ''', methodName , ':'' already present' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1161 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1162 |
]. |
5758 | 1163 |
]. |
1164 |
||
1165 |
self executeCollectedChangesNamed:('Add Accessors'). |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1166 |
! ! |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1167 |
|
5758 | 1168 |
!CodeGeneratorTool methodsFor:'code generation-individual methods'! |
3712 | 1169 |
|
1170 |
createAcceptVisitorMethod:selector in:aClass |
|
1171 |
"create an acceptVisitor: method |
|
1172 |
(I'm tired of typing)" |
|
1173 |
||
1174 |
aClass isMeta ifTrue:[self halt]. |
|
1175 |
||
1176 |
(aClass includesSelector:#'acceptVisitor:') ifFalse:[ |
|
1177 |
self |
|
1178 |
compile: |
|
1179 |
(('acceptVisitor:aVisitor |
|
1180 |
"Double dispatch back to the visitor, passing my type encoded in |
|
1181 |
the selector (visitor pattern)" |
|
1182 |
||
1183 |
"stub code automatically generated - please change if required" |
|
1184 |
||
1185 |
^ aVisitor %1self |
|
1186 |
') bindWith:selector) |
|
1187 |
forClass:aClass |
|
1188 |
inCategory:'visiting'. |
|
1189 |
] |
|
1190 |
! |
|
1191 |
||
1192 |
createAcceptVisitorMethodIn:aClass |
|
1193 |
"create an acceptVisitor: method |
|
1194 |
(I'm tired of typing)" |
|
1195 |
||
1196 |
self |
|
1197 |
createAcceptVisitorMethod:('visit' , aClass nameWithoutPrefix , ':') asSymbol |
|
1198 |
in:aClass |
|
1199 |
! |
|
1200 |
||
1201 |
createCopyrightMethodFor:aClass |
|
1202 |
"add copyright method containing your/your companies |
|
1203 |
copyright template but only if not already present. |
|
1204 |
this is only added, if specified in the |
|
1205 |
COPYRIGHT_TEMPLATE_FILE resources." |
|
1206 |
||
1207 |
|fn txt| |
|
1208 |
||
1209 |
(aClass includesSelector:#copyright) ifFalse:[ |
|
1210 |
fn := SystemBrowser classResources at:#'COPYRIGHT_TEMPLATE_FILE' default:nil. |
|
1211 |
fn notNil ifTrue:[ |
|
1212 |
fn := fn asFilename. |
|
1213 |
fn exists ifTrue:[ |
|
1214 |
txt := fn contents asString |
|
1215 |
] |
|
1216 |
]. |
|
1217 |
||
1218 |
txt notNil ifTrue:[ |
|
1219 |
txt := txt bindWith:(Date today year). |
|
1220 |
self compile: |
|
1221 |
'copyright |
|
1222 |
" |
|
1223 |
' , txt , ' |
|
1224 |
" |
|
1225 |
' forClass:aClass |
|
1226 |
inCategory:'documentation'. |
|
1227 |
] |
|
1228 |
]. |
|
1229 |
! |
|
1230 |
||
1231 |
createDocumentationMethodFor:aClass |
|
1232 |
"add documentation method containing doc template |
|
1233 |
but only if not already present." |
|
1234 |
||
5756 | 1235 |
|userName loginName hostName emailAddress code| |
3712 | 1236 |
|
1237 |
(aClass includesSelector:#documentation) ifFalse:[ |
|
1238 |
userName := OperatingSystem getFullUserName. |
|
1239 |
loginName := OperatingSystem getLoginName. |
|
1240 |
hostName := OperatingSystem getHostName. |
|
1241 |
emailAddress := loginName , '@' , hostName. |
|
1242 |
||
5756 | 1243 |
"/ ugly; should ask the class for that |
1244 |
aClass isJavaScriptClass ifTrue:[ |
|
1245 |
code := |
|
1246 |
'function documentation() { |
|
1247 |
/* |
|
1248 |
' , (aClass theNonMetaclass comment ? ' documentation to be added.') , ' |
|
1249 |
||
1250 |
[author:] |
|
1251 |
' , userName |
|
1252 |
, ' (' , emailAddress , ')' , ' |
|
1253 |
||
1254 |
[instance variables:] |
|
1255 |
||
1256 |
[class variables:] |
|
1257 |
||
1258 |
[see also:] |
|
1259 |
||
1260 |
*/ |
|
1261 |
} |
|
1262 |
' |
|
1263 |
] ifFalse:[ |
|
1264 |
code:= |
|
3712 | 1265 |
'documentation |
1266 |
" |
|
5401 | 1267 |
' , (aClass theNonMetaclass comment ? ' documentation to be added.') , ' |
3712 | 1268 |
|
1269 |
[author:] |
|
1270 |
' , userName |
|
1271 |
, ' (' , emailAddress , ')' , ' |
|
1272 |
||
1273 |
[instance variables:] |
|
1274 |
||
1275 |
[class variables:] |
|
1276 |
||
1277 |
[see also:] |
|
1278 |
||
1279 |
" |
|
5756 | 1280 |
' |
1281 |
]. |
|
1282 |
||
1283 |
self |
|
1284 |
compile:code |
|
1285 |
forClass:aClass |
|
1286 |
inCategory:'documentation'. |
|
3712 | 1287 |
]. |
1288 |
! |
|
1289 |
||
1290 |
createExamplesMethodFor:aClass |
|
1291 |
"add examples method containing examples template |
|
1292 |
but only if not already present." |
|
1293 |
||
1294 |
|fragment| |
|
1295 |
||
1296 |
(aClass includesSelector:#examples) ifFalse:[ |
|
1297 |
(aClass theNonMetaclass isSubclassOf:ApplicationModel) ifTrue:[ |
|
1298 |
fragment := ' Starting the application: |
|
1299 |
[exBegin] |
|
1300 |
' , aClass theNonMetaclass name , ' open |
|
1301 |
||
1302 |
[exEnd] |
|
1303 |
' |
|
1304 |
] ifFalse:[ |
|
1305 |
fragment := '' |
|
1306 |
]. |
|
1307 |
||
1308 |
self |
|
1309 |
compile: |
|
1310 |
'examples |
|
1311 |
" |
|
1312 |
' , fragment , ' |
|
1313 |
more examples to be added: |
|
1314 |
[exBegin] |
|
1315 |
... add code fragment for |
|
1316 |
... executable example here ... |
|
1317 |
[exEnd] |
|
1318 |
" |
|
1319 |
' |
|
1320 |
forClass:aClass |
|
1321 |
inCategory:'documentation'. |
|
1322 |
]. |
|
1323 |
! |
|
1324 |
||
3822
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1325 |
createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1326 |
|imageStoreStream mthd imageKey category| |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1327 |
|
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1328 |
anImage storeOn: (imageStoreStream := WriteStream on: ''). |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1329 |
|
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1330 |
"/ if that method already exists, do not overwrite the category |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1331 |
category := 'image specs'. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1332 |
(mthd := aClass compiledMethodAt:sel) notNil ifTrue:[ |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1333 |
category := mthd category. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1334 |
]. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1335 |
|
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1336 |
imageKey := (aClass name, ' ', sel) asSymbol. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1337 |
Icon constantNamed: imageKey put:nil. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1338 |
aClass |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1339 |
compile: ((sel, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1340 |
'\', comment, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1341 |
'\\' , |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1342 |
' "\', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1343 |
' self ' , sel , ' inspect\', |
3823 | 1344 |
' ImageEditor openOnClass:self andSelector:#', sel, '\', |
3822
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1345 |
' Icon flushCachedIcons', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1346 |
'\ "', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1347 |
'\\', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1348 |
' <resource: #image>', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1349 |
'\\', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1350 |
' ^Icon\') withCRs, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1351 |
' constantNamed:#''', imageKey, '''\' withCRs, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1352 |
' ifAbsentPut:[', imageStoreStream contents, ']') |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1353 |
classified: category. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1354 |
! |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1355 |
|
3712 | 1356 |
createInitialHistoryMethodFor:aClass |
1357 |
"add history method containing created-entry |
|
1358 |
but only if not already present." |
|
1359 |
||
5758 | 1360 |
|code| |
1361 |
||
3712 | 1362 |
(aClass includesSelector:#history) ifFalse:[ |
1363 |
HistoryManager notNil ifTrue:[ |
|
5758 | 1364 |
code := HistoryManager codeForInitialHistoryMethodIn:aClass. |
1365 |
self |
|
1366 |
compile:code |
|
1367 |
forClass:aClass |
|
1368 |
inCategory:'documentation'. |
|
3712 | 1369 |
]. |
1370 |
]. |
|
1371 |
! |
|
1372 |
||
4512 | 1373 |
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass |
1374 |
"add an inst-creation method" |
|
1375 |
||
1376 |
|template| |
|
1377 |
||
1378 |
(aMetaClass includesSelector:selector) ifFalse:[ |
|
1379 |
template := Parser methodSpecificationForSelector:selector. |
|
1380 |
self |
|
1381 |
compile: |
|
1382 |
template , ' |
|
1383 |
^ self new ' , template , ' |
|
1384 |
' |
|
1385 |
forClass:aMetaClass |
|
1386 |
inCategory:category. |
|
1387 |
]. |
|
1388 |
! |
|
1389 |
||
3712 | 1390 |
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass |
1391 |
"create a multi-setter method for instvars." |
|
1392 |
||
1393 |
|source| |
|
1394 |
||
1395 |
source := ''. |
|
1396 |
aCollectionOfVarNames do:[:eachVar | |
|
1397 |
source := source , (eachVar , ':' , eachVar , 'Arg '). |
|
1398 |
]. |
|
1399 |
source := source , Character cr. |
|
1400 |
source := source , (' "set instance variables (automatically generated)"' , Character cr , Character cr). |
|
1401 |
aCollectionOfVarNames do:[:eachVar | |
|
1402 |
source := source , (' ' , eachVar , ' := ' , eachVar , 'Arg.' , Character cr). |
|
1403 |
]. |
|
1404 |
self compile:source forClass:aClass inCategory:'accessing'. |
|
1405 |
! |
|
1406 |
||
3800
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1407 |
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1408 |
"add a subclassResponsibility method; |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1409 |
but only if not already present." |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1410 |
|
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1411 |
(aClass includesSelector:aSelector) ifFalse:[ |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1412 |
|
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1413 |
self compile: |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1414 |
(Method methodDefinitionTemplateForSelector:aSelector) , |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1415 |
' |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1416 |
"raise an error: must be redefined in concrete subclass(es)" |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1417 |
|
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1418 |
^ self subclassResponsibility |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1419 |
' |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1420 |
forClass:aClass |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1421 |
inCategory:cat. |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1422 |
]. |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1423 |
! |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1424 |
|
3712 | 1425 |
createUpdateMethodIn:aClass |
1426 |
"create an update:with:from:-method |
|
1427 |
(I'm tired of typing)" |
|
1428 |
||
1429 |
(aClass includesSelector:#'update:with:from:') ifFalse:[ |
|
1430 |
self |
|
1431 |
compile: |
|
1432 |
'update:something with:aParameter from:changedObject |
|
1433 |
"Invoked when an object that I depend upon sends a change notification." |
|
1434 |
||
1435 |
"stub code automatically generated - please change as required" |
|
1436 |
||
1437 |
"/ changedObject == someOfMyValueHolders ifTrue:[ |
|
4926 | 1438 |
"/ self doSomethingApropriate. |
1439 |
"/ ^ self. |
|
3712 | 1440 |
"/ ]. |
1441 |
super update:something with:aParameter from:changedObject |
|
1442 |
' |
|
1443 |
forClass:aClass |
|
1444 |
inCategory:'change & update'. |
|
1445 |
] |
|
1446 |
! |
|
1447 |
||
1448 |
createVersionMethodFor:aClass |
|
1449 |
"add version method containing RCS template |
|
1450 |
but only if not already present and its not a private class." |
|
1451 |
||
5756 | 1452 |
|code| |
1453 |
||
3712 | 1454 |
aClass isPrivate ifFalse:[ |
1455 |
(aClass includesSelector:#version) ifFalse:[ |
|
5756 | 1456 |
"/ ugly; should ask the class for that |
1457 |
aClass isJavaScriptClass ifTrue:[ |
|
1458 |
code:= ('function version() {\ return ("$' , 'Header$");\}') withCRs |
|
1459 |
] ifFalse:[ |
|
1460 |
code:= ('version\ ^ ''$' , 'Header$''') withCRs |
|
1461 |
]. |
|
1462 |
self |
|
1463 |
compile:code |
|
1464 |
forClass:aClass |
|
1465 |
inCategory:'documentation'. |
|
3712 | 1466 |
] |
1467 |
]. |
|
1468 |
! ! |
|
1469 |
||
5758 | 1470 |
!CodeGeneratorTool methodsFor:'compilation'! |
3712 | 1471 |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1472 |
compile:theCode forClass:aClass inCategory:cat |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1473 |
"install some code for a class. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1474 |
If refactory browser stuff is avaliable the refactory tools are used to support undo" |
3712 | 1475 |
|
1476 |
|change| |
|
1477 |
||
1478 |
self canUseRefactoringSupport ifFalse:[ |
|
5758 | 1479 |
"/ compile immediately |
3716 | 1480 |
aClass compile:theCode classified:cat. |
3712 | 1481 |
^ self. |
1482 |
]. |
|
1483 |
||
3716 | 1484 |
change := InteractiveAddMethodChange compile:(theCode asString) in:aClass classified:cat. |
5758 | 1485 |
|
1486 |
"/ if collecting, add to changes (to be executed as one change at the end, |
|
1487 |
"/ in order to have only one change in the undo-list (instead of many) |
|
1488 |
compositeChangeCollector notNil ifTrue:[ |
|
1489 |
compositeChangeCollector addChange:change |
|
1490 |
] ifFalse:[ |
|
1491 |
RefactoryChangeManager instance performChange:change. |
|
1492 |
] |
|
3712 | 1493 |
! ! |
1494 |
||
5758 | 1495 |
!CodeGeneratorTool methodsFor:'private'! |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1496 |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1497 |
canUseRefactoringSupport |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1498 |
"check if refactory browser stuff is avaliable" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1499 |
|
5758 | 1500 |
^ self class canUseRefactoringSupport |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1501 |
! |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1502 |
|
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1503 |
privCreateClassResponsibleProtocolFor:aClass |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1504 |
"create stubs for the required protocol aClass may be a a MetaClass |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1505 |
or a NonMetaClass" |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1506 |
|
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1507 |
|selectors| |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1508 |
|
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1509 |
selectors := IdentitySet new. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1510 |
aClass allSuperclassesDo:[:cls | |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1511 |
cls methodDictionary keysAndValuesDo:[:sel :mthd | |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1512 |
(mthd sends:#subclassResponsibility) ifTrue:[ |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1513 |
selectors add:sel. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1514 |
] |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1515 |
] |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1516 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1517 |
|
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1518 |
selectors do:[:eachSelector | |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1519 |
|cat comment mthd implClass| |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1520 |
|
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1521 |
implClass := aClass whichClassImplements:eachSelector. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1522 |
implClass ~~ aClass ifTrue:[ |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1523 |
mthd := implClass compiledMethodAt:eachSelector. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1524 |
(mthd sends:#subclassResponsibility) ifTrue:[ |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1525 |
cat := mthd category. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1526 |
comment := mthd methodComment. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1527 |
comment size == 0 ifTrue:[ |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1528 |
comment := 'Superclass says that I am responsible to implement this method' |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1529 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1530 |
|
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1531 |
self |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1532 |
compile: |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1533 |
(Method methodDefinitionTemplateForSelector:eachSelector), Character cr, ' "', comment, |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1534 |
'" |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1535 |
|
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1536 |
self shouldImplement |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1537 |
' |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1538 |
forClass:aClass |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1539 |
inCategory:cat. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1540 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1541 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1542 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1543 |
! ! |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1544 |
|
3712 | 1545 |
!CodeGeneratorTool class methodsFor:'documentation'! |
1546 |
||
1547 |
version |
|
5759 | 1548 |
^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.25 2004-03-19 12:14:48 cg Exp $' |
3712 | 1549 |
! ! |