author | Claus Gittinger <cg@exept.de> |
Fri, 25 Aug 2006 15:41:38 +0200 | |
changeset 6993 | 22233dd2489d |
parent 6992 | 93d4212a20d5 |
child 7037 | ec9705009031 |
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. |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
42 |
There is probably more to come... |
3719 | 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 |
6313 | 55 |
createAccessMethodsFor:aCollectionOfVarNames |
56 |
in:aClass |
|
57 |
withChange:withChange |
|
58 |
asValueHolder:asValueHolder |
|
59 |
readersOnly:readersOnly |
|
60 |
writersOnly:writersOnly |
|
4444
6b077945517c
generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents:
4351
diff
changeset
|
61 |
! |
6b077945517c
generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents:
4351
diff
changeset
|
62 |
|
3712 | 63 |
createApplicationCodeFor:aClass |
64 |
"create an empty application framework" |
|
65 |
||
5758 | 66 |
^ self new createApplicationCodeFor:aClass |
3712 | 67 |
! |
68 |
||
3804 | 69 |
createClassResponsibleProtocolFor:aClass |
70 |
"create stubs for the required protocol" |
|
71 |
||
5758 | 72 |
^ self new createClassResponsibleProtocolFor:aClass |
3804 | 73 |
! |
74 |
||
5124 | 75 |
createClassTypeTestMethodsIn:aClass forClasses:subClasses |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
76 |
"create a #isXXX test methods (I'm tired of typing)" |
4351 | 77 |
|
5758 | 78 |
^ self new createClassTypeTestMethodsIn:aClass forClasses:subClasses |
4351 | 79 |
! |
80 |
||
3712 | 81 |
createDocumentationMethodsFor:aClass |
82 |
"create empty documentation methods" |
|
83 |
||
5758 | 84 |
^ self new createDocumentationMethodsFor:aClass |
3712 | 85 |
! |
86 |
||
6313 | 87 |
createEnumTypeCodeFor:aClass |
88 |
^ self new createEnumTypeCodeFor:aClass |
|
89 |
! |
|
90 |
||
6718 | 91 |
createInitializedInstanceCreationMethodsIn:aClass |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
92 |
"create a #new and #initialize methods (I'm tired of typing)" |
3712 | 93 |
|
6718 | 94 |
^ self new createInitializedInstanceCreationMethodsIn:aClass |
95 |
! |
|
96 |
||
97 |
createParametrizedInstanceCreationMethodsNamed:selector in:aClass |
|
98 |
"create a #selector instance creation method (I'm tired of typing)" |
|
99 |
||
100 |
^ self new createParametrizedInstanceCreationMethodsNamed:selector in:aClass |
|
3712 | 101 |
! |
102 |
||
103 |
createTestCaseSampleCodeFor:aClass |
|
4590 | 104 |
"create an (almost) empty testCase class" |
3712 | 105 |
|
5758 | 106 |
^ self new createTestCaseSampleCodeFor:aClass |
3712 | 107 |
! |
108 |
||
109 |
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
110 |
"create acceptVisitor: in visitedClass and acceptXXX in visitorClass. (I'm tired of typing)" |
3712 | 111 |
|
5758 | 112 |
^ self new createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass |
3712 | 113 |
! |
114 |
||
6050 | 115 |
createWebApplicationCodeFor:aClass |
116 |
"create an empty webApplication framework" |
|
117 |
||
118 |
^ self new createWebApplicationCodeFor:aClass |
|
119 |
! |
|
120 |
||
3712 | 121 |
initialMenuSpecMethodSourceForApplications |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
122 |
"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
|
123 |
|
3712 | 124 |
^ |
125 |
'mainMenu |
|
126 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
127 |
||
128 |
"Do not manually edit this!! If it is corrupted, |
|
129 |
the MenuEditor may not be able to read the specification." |
|
130 |
||
131 |
" |
|
132 |
MenuEditor new openOnClass:%1 andSelector:#mainMenu |
|
133 |
" |
|
134 |
||
135 |
<resource: #menu> |
|
136 |
||
137 |
^ #(#Menu |
|
138 |
#( |
|
139 |
#(#MenuItem |
|
140 |
#label: ''File'' |
|
141 |
#translateLabel: true |
|
142 |
#submenu: |
|
143 |
#(#Menu |
|
144 |
#( |
|
145 |
#(#MenuItem |
|
146 |
#label: ''New'' |
|
147 |
#translateLabel: true |
|
148 |
#value: #menuNew |
|
149 |
) |
|
150 |
#(#MenuItem |
|
151 |
#label: ''-'' |
|
152 |
) |
|
153 |
#(#MenuItem |
|
154 |
#label: ''Open...'' |
|
155 |
#translateLabel: true |
|
156 |
#value: #menuOpen |
|
157 |
) |
|
158 |
#(#MenuItem |
|
159 |
#label: ''-'' |
|
160 |
) |
|
161 |
#(#MenuItem |
|
162 |
#label: ''Save'' |
|
163 |
#translateLabel: true |
|
164 |
#value: #menuSave |
|
165 |
) |
|
166 |
#(#MenuItem |
|
167 |
#label: ''Save As...'' |
|
168 |
#translateLabel: true |
|
169 |
#value: #menuSaveAs |
|
170 |
) |
|
171 |
#(#MenuItem |
|
172 |
#label: ''-'' |
|
173 |
) |
|
174 |
#(#MenuItem |
|
175 |
#label: ''Exit'' |
|
176 |
#translateLabel: true |
|
177 |
#value: #closeRequest |
|
178 |
) |
|
179 |
) nil |
|
180 |
nil |
|
181 |
) |
|
182 |
) |
|
183 |
#(#MenuItem |
|
184 |
#label: ''Help'' |
|
185 |
#translateLabel: true |
|
186 |
#startGroup: #right |
|
187 |
#submenu: |
|
188 |
#(#Menu |
|
189 |
#( |
|
190 |
#(#MenuItem |
|
191 |
#label: ''Documentation'' |
|
192 |
#translateLabel: true |
|
193 |
#value: #openDocumentation |
|
194 |
) |
|
195 |
#(#MenuItem |
|
196 |
#label: ''-'' |
|
197 |
) |
|
198 |
#(#MenuItem |
|
6643 | 199 |
#label: ''About this Application...'' |
3712 | 200 |
#translateLabel: true |
201 |
#value: #openAboutThisApplication |
|
202 |
) |
|
203 |
) nil |
|
204 |
nil |
|
205 |
) |
|
206 |
) |
|
207 |
) nil |
|
208 |
nil |
|
209 |
) |
|
210 |
'. |
|
211 |
! |
|
212 |
||
213 |
initialWindowSpecMethodSourceForApplications |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
214 |
"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
|
215 |
|
3712 | 216 |
^ |
217 |
'windowSpec |
|
218 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
219 |
||
220 |
"Do not manually edit this!! If it is corrupted, |
|
221 |
the UIPainter may not be able to read the specification." |
|
222 |
||
223 |
" |
|
224 |
UIPainter new openOnClass:%1 andSelector:#windowSpec |
|
225 |
" |
|
226 |
||
227 |
<resource: #canvas> |
|
228 |
||
229 |
^ #(#FullSpec |
|
230 |
#window: |
|
231 |
#(#WindowSpec |
|
232 |
#name: ''%1'' |
|
233 |
#layout: #(#LayoutFrame 204 0 162 0 503 0 461 0) |
|
234 |
#label: ''%1'' |
|
235 |
#min: #(#Point 10 10) |
|
236 |
#max: #(#Point 1024 768) |
|
237 |
#bounds: #(#Rectangle 204 162 504 462) |
|
238 |
#menu: #mainMenu |
|
239 |
#usePreferredExtent: false |
|
240 |
) |
|
241 |
#component: |
|
242 |
#(#SpecCollection |
|
243 |
#collection: #() |
|
244 |
) |
|
245 |
) |
|
246 |
'. |
|
247 |
! |
|
248 |
||
249 |
initialWindowSpecMethodSourceForDialogs |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
250 |
"return an empty windowSpec for dialogs" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
251 |
|
3712 | 252 |
^ |
253 |
'windowSpec |
|
254 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
255 |
||
256 |
"Do not manually edit this!! If it is corrupted, |
|
257 |
the UIPainter may not be able to read the specification." |
|
258 |
||
259 |
" |
|
260 |
UIPainter new openOnClass:%1 andSelector:#windowSpec |
|
261 |
" |
|
262 |
||
263 |
<resource: #canvas> |
|
264 |
||
265 |
^ |
|
266 |
||
267 |
#(#FullSpec |
|
268 |
#window: |
|
269 |
#(#WindowSpec |
|
270 |
#name: ''%1'' |
|
271 |
#layout: #(#LayoutFrame 221 0 118 0 520 0 417 0) |
|
272 |
#level: 0 |
|
273 |
#label: ''%1'' |
|
274 |
#min: #(#Point 10 10) |
|
275 |
#max: #(#Point 1024 768) |
|
276 |
#bounds: #(#Rectangle 221 118 521 418) |
|
277 |
#usePreferredExtent: false |
|
278 |
) |
|
279 |
#component: |
|
280 |
#(#SpecCollection |
|
281 |
#collection: |
|
282 |
#( |
|
283 |
#(#HorizontalPanelViewSpec |
|
284 |
#name: ''buttonPanel'' |
|
285 |
#layout: #(#LayoutFrame 0 0.0 -45 1 0 1.0 0 1.0) |
|
286 |
#component: |
|
287 |
#(#SpecCollection |
|
288 |
#collection: |
|
289 |
#( |
|
290 |
#(#ActionButtonSpec |
|
291 |
#name: ''cancelButton'' |
|
292 |
#label: ''Cancel'' |
|
293 |
#tabable: true |
|
294 |
#translateLabel: true |
|
295 |
#model: #cancel |
|
296 |
#extent: #(#Point 125 22) |
|
297 |
) |
|
298 |
#(#ActionButtonSpec |
|
299 |
#name: ''okButton'' |
|
300 |
#label: ''OK'' |
|
301 |
#tabable: true |
|
302 |
#translateLabel: true |
|
303 |
#isDefault: true |
|
304 |
#model: #accept |
|
305 |
#extent: #(#Point 125 22) |
|
306 |
) |
|
307 |
) |
|
308 |
) |
|
309 |
#reverseOrderIfOKAtLeft: true |
|
310 |
#horizontalLayout: #spreadSpaceMax |
|
311 |
#verticalLayout: #center |
|
312 |
#horizontalSpace: 3 |
|
313 |
#verticalSpace: 3 |
|
314 |
) |
|
315 |
) |
|
316 |
) |
|
317 |
) |
|
318 |
'. |
|
319 |
! ! |
|
320 |
||
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
321 |
!CodeGeneratorTool class methodsFor:'code generation-basic'! |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
322 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
323 |
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
|
324 |
"workhorse for creating access methods for instvars." |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
325 |
|
5758 | 326 |
^ self new |
327 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization |
|
328 |
! ! |
|
329 |
||
330 |
!CodeGeneratorTool class methodsFor:'code generation-individual methods'! |
|
331 |
||
332 |
createAcceptVisitorMethod:selector in:aClass |
|
333 |
"create an acceptVisitor: method |
|
334 |
(I'm tired of typing)" |
|
335 |
||
336 |
^ self new createAcceptVisitorMethod:selector in:aClass |
|
337 |
! |
|
338 |
||
339 |
createAcceptVisitorMethodIn:aClass |
|
340 |
"create an acceptVisitor: method |
|
341 |
(I'm tired of typing)" |
|
342 |
||
343 |
^ self new createAcceptVisitorMethodIn:aClass |
|
344 |
! |
|
345 |
||
346 |
createCopyrightMethodFor:aClass |
|
347 |
"add copyright method containing your/your companies |
|
348 |
copyright template but only if not already present. |
|
349 |
this is only added, if specified in the |
|
350 |
COPYRIGHT_TEMPLATE_FILE resources." |
|
351 |
||
352 |
^ self new createCopyrightMethodFor:aClass |
|
353 |
! |
|
354 |
||
355 |
createDocumentationMethodFor:aClass |
|
356 |
"add documentation method containing doc template |
|
357 |
but only if not already present." |
|
358 |
||
359 |
^ self new createDocumentationMethodFor:aClass |
|
360 |
! |
|
361 |
||
362 |
createExamplesMethodFor:aClass |
|
363 |
"add examples method containing examples template |
|
364 |
but only if not already present." |
|
365 |
||
366 |
^ self new createExamplesMethodFor:aClass |
|
367 |
! |
|
368 |
||
369 |
createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel |
|
370 |
^ self new createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel |
|
371 |
! |
|
372 |
||
373 |
createInitialHistoryMethodFor:aClass |
|
374 |
"add history method containing created-entry |
|
375 |
but only if not already present." |
|
376 |
||
377 |
^ self new createInitialHistoryMethodFor:aClass |
|
378 |
! |
|
379 |
||
380 |
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass |
|
381 |
"add an inst-creation method" |
|
382 |
||
383 |
^ self new createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass |
|
384 |
! |
|
385 |
||
386 |
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass |
|
387 |
"create a multi-setter method for instvars." |
|
388 |
||
389 |
^ self new createMultiSetterMethodFor:aCollectionOfVarNames in:aClass |
|
390 |
! |
|
391 |
||
392 |
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass |
|
393 |
"add a subclassResponsibility method; |
|
394 |
but only if not already present." |
|
395 |
||
396 |
^ self new createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass |
|
397 |
! |
|
398 |
||
399 |
createUpdateMethodIn:aClass |
|
400 |
"create an update:with:from:-method |
|
401 |
(I'm tired of typing)" |
|
402 |
||
403 |
^ self new createUpdateMethodIn:aClass |
|
404 |
! |
|
405 |
||
406 |
createVersionMethodFor:aClass |
|
407 |
"add version method containing RCS template |
|
408 |
but only if not already present and its not a private class." |
|
409 |
||
410 |
^ self new createVersionMethodFor:aClass |
|
411 |
! ! |
|
412 |
||
413 |
!CodeGeneratorTool class methodsFor:'compilation'! |
|
414 |
||
415 |
compile:theCode forClass:aClass inCategory:cat |
|
416 |
"install some code for a class. |
|
417 |
If refactory browser stuff is avaliable the refactory tools are used to support undo" |
|
418 |
||
419 |
^ self new compile:theCode forClass:aClass inCategory:cat |
|
420 |
! ! |
|
421 |
||
422 |
!CodeGeneratorTool class methodsFor:'private'! |
|
423 |
||
424 |
canUseRefactoringSupport |
|
425 |
"check if refactory browser stuff is avaliable" |
|
426 |
||
427 |
^ RefactoryChangeManager notNil |
|
428 |
and:[RefactoryChangeManager isLoaded |
|
429 |
and:[UserPreferences current useRefactoringSupport]] |
|
430 |
! ! |
|
431 |
||
5759 | 432 |
!CodeGeneratorTool methodsFor:'buld changes'! |
433 |
||
5763 | 434 |
addChange:aChange |
435 |
compositeChangeCollector addChange:aChange |
|
436 |
! |
|
437 |
||
5759 | 438 |
executeCollectedChangesNamed:name |
439 |
compositeChangeCollector notNil ifTrue:[ |
|
440 |
compositeChangeNesting := compositeChangeNesting - 1. |
|
441 |
compositeChangeNesting == 0 ifTrue:[ |
|
442 |
compositeChangeCollector name:name. |
|
443 |
compositeChangeCollector changesSize == 0 ifTrue:[ |
|
444 |
self information:'Nothing generated.'. |
|
445 |
] ifFalse:[ |
|
446 |
RefactoryChangeManager instance performChange:compositeChangeCollector. |
|
447 |
]. |
|
448 |
compositeChangeCollector := nil. |
|
449 |
] |
|
450 |
] |
|
451 |
! |
|
452 |
||
453 |
startCollectChanges |
|
454 |
(self canUseRefactoringSupport) ifTrue:[ |
|
455 |
compositeChangeCollector isNil ifTrue:[ |
|
456 |
compositeChangeCollector := CompositeRefactoryChange new. |
|
457 |
compositeChangeNesting := 0. |
|
458 |
]. |
|
459 |
compositeChangeNesting := compositeChangeNesting + 1. |
|
460 |
] |
|
461 |
! ! |
|
462 |
||
5758 | 463 |
!CodeGeneratorTool methodsFor:'code generation'! |
464 |
||
465 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly |
|
466 |
"create accessors in aClass" |
|
467 |
||
468 |
self |
|
469 |
createAccessMethodsFor:aCollectionOfVarNames |
|
470 |
in:aClass |
|
471 |
withChange:withChange |
|
472 |
asValueHolder:asValueHolder |
|
473 |
readersOnly:readersOnly |
|
474 |
writersOnly:writersOnly |
|
475 |
lazyInitialization:false |
|
476 |
! |
|
477 |
||
478 |
createApplicationCodeFor:aClass |
|
479 |
"create an empty application framework" |
|
480 |
||
481 |
|nonMetaClass metaClass className txt isDialog categoryForMenuActionsMethods| |
|
482 |
||
483 |
self startCollectChanges. |
|
484 |
||
485 |
categoryForMenuActionsMethods := UserPreferences current categoryForMenuActionsMethods. |
|
486 |
||
487 |
nonMetaClass := aClass theNonMetaclass. |
|
488 |
metaClass := aClass theMetaclass. |
|
489 |
className := nonMetaClass name. |
|
490 |
||
491 |
isDialog := (nonMetaClass isSubclassOf:SimpleDialog). |
|
492 |
||
493 |
"/ add a windowSpec method for an empty applicationWindow, |
|
494 |
"/ with a menuPanel. |
|
495 |
||
496 |
(metaClass includesSelector:#windowSpec) ifFalse:[ |
|
497 |
isDialog ifTrue:[ |
|
498 |
txt := self class initialWindowSpecMethodSourceForDialogs. |
|
499 |
] ifFalse:[ |
|
500 |
txt := self class initialWindowSpecMethodSourceForApplications. |
|
501 |
]. |
|
502 |
self |
|
503 |
compile:(txt bindWith:className) |
|
504 |
forClass:metaClass |
|
505 |
inCategory:'interface specs'. |
|
506 |
]. |
|
507 |
||
508 |
isDialog ifFalse:[ |
|
509 |
"/ add a topMenu method |
|
510 |
||
511 |
(metaClass includesSelector:#mainMenu) ifFalse:[ |
|
512 |
txt := self class initialMenuSpecMethodSourceForApplications. |
|
513 |
self |
|
514 |
compile:(txt bindWith:className) |
|
515 |
forClass:metaClass |
|
516 |
inCategory:'menu specs'. |
|
517 |
]. |
|
518 |
]. |
|
519 |
||
5817 | 520 |
(nonMetaClass includesSelector:#postBuildWith:) ifFalse:[ |
5758 | 521 |
txt := |
522 |
'postBuildWith:aBuilder |
|
523 |
"This is a hook method generated by the Browser. |
|
524 |
It will be invoked during the initialization of your app/dialog, |
|
525 |
after all of the visual components have been built, |
|
526 |
but BEFORE the top window is made visible. |
|
527 |
Add any app-specific actions here (reading files, setting up values etc.) |
|
528 |
See also #postOpenWith:, which is invoked after opening." |
|
529 |
||
530 |
"/ add any code here ... |
|
531 |
||
532 |
^ super postBuildWith:aBuilder |
|
533 |
'. |
|
534 |
self |
|
535 |
compile:txt |
|
536 |
forClass:nonMetaClass |
|
537 |
inCategory:'initialization & release'. |
|
538 |
]. |
|
539 |
||
5817 | 540 |
(nonMetaClass includesSelector:#postOpenWith:) ifFalse:[ |
5758 | 541 |
txt := |
542 |
'postOpenWith:aBuilder |
|
543 |
"This is a hook method generated by the Browser. |
|
544 |
It will be invoked right after the applications window has been opened. |
|
545 |
Add any app-specific actions here (starting background processes etc.). |
|
546 |
See also #postBuildWith:, which is invoked before opening." |
|
547 |
||
548 |
"/ add any code here ... |
|
549 |
||
550 |
^ super postOpenWith:aBuilder |
|
551 |
'. |
|
552 |
self |
|
553 |
compile:txt |
|
554 |
forClass:nonMetaClass |
|
555 |
inCategory:'initialization & release'. |
|
556 |
]. |
|
557 |
||
558 |
isDialog ifFalse:[ |
|
5817 | 559 |
(nonMetaClass includesSelector:#closeRequest) ifFalse:[ |
5758 | 560 |
txt := |
561 |
'closeRequest |
|
562 |
"This is a hook method generated by the Browser. |
|
563 |
It will be invoked when your app/dialog-window is about to be |
|
564 |
closed (this method has a chance to suppress the close). |
|
565 |
See also #closeDownViews, which is invoked when the close is really done." |
|
566 |
||
567 |
"/ change the code below as required ... |
|
568 |
"/ Closing can be suppressed, by simply returning. |
|
569 |
"/ The ''super closeRequest'' at the end will initiate the real closeDown |
|
570 |
||
571 |
("self hasUnsavedChanges" true) ifTrue:[ |
|
572 |
(self confirm:(resources string:''Close without saving ?'')) ifFalse:[ |
|
573 |
^ self |
|
574 |
] |
|
575 |
]. |
|
576 |
||
577 |
^ super closeRequest |
|
578 |
'. |
|
579 |
self |
|
580 |
compile:txt |
|
581 |
forClass:nonMetaClass |
|
582 |
inCategory:'initialization & release'. |
|
583 |
]. |
|
584 |
]. |
|
585 |
||
586 |
isDialog ifFalse:[ |
|
5817 | 587 |
(nonMetaClass includesSelector:#closeDownViews) ifFalse:[ |
5758 | 588 |
txt := |
589 |
'closeDownViews |
|
590 |
"This is a hook method generated by the Browser. |
|
591 |
It will be invoked when your app/dialog-window is really closed. |
|
592 |
See also #closeDownViews, which is invoked before and may suppress the close |
|
593 |
or ask the user for confirmation." |
|
594 |
||
595 |
"/ change the code below as required ... |
|
596 |
"/ This should cleanup any leftover resources |
|
597 |
"/ (for example, temporary files) |
|
598 |
"/ super closeRequest will initiate the closeDown |
|
599 |
||
600 |
"/ add your code here |
|
601 |
||
602 |
"/ do not remove the one below ... |
|
603 |
^ super closeDownViews |
|
604 |
'. |
|
605 |
self |
|
606 |
compile:txt |
|
607 |
forClass:nonMetaClass |
|
608 |
inCategory:'initialization & release'. |
|
609 |
]. |
|
610 |
]. |
|
611 |
||
612 |
isDialog ifTrue:[ |
|
5817 | 613 |
(nonMetaClass includesSelector:#accept) ifFalse:[ |
5758 | 614 |
txt := |
615 |
'closeAccept |
|
616 |
"This is a hook method generated by the Browser. |
|
617 |
It will be invoked when your dialog-window is closed with OK." |
|
618 |
||
619 |
"/ add any actions as required here ... |
|
620 |
Transcript showCR:''dialog accepted''. |
|
621 |
||
622 |
"/ do not remove the one below ... |
|
623 |
^ super closeAccept |
|
624 |
'. |
|
625 |
self |
|
626 |
compile:txt |
|
627 |
forClass:nonMetaClass |
|
628 |
inCategory:'user actions'. |
|
629 |
]. |
|
630 |
]. |
|
631 |
||
632 |
isDialog ifFalse:[ |
|
5817 | 633 |
(nonMetaClass includesSelector:#menuNew) ifFalse:[ |
5758 | 634 |
txt := |
635 |
'menuNew |
|
636 |
"This method was generated by the Browser. |
|
637 |
It will be invoked when the menu-item ''new'' is selected." |
|
638 |
||
639 |
"/ change below and add any actions as required here ... |
|
640 |
self warn:''no action for ''''new'''' available.''. |
|
641 |
'. |
|
642 |
self |
|
643 |
compile:txt |
|
644 |
forClass:nonMetaClass |
|
645 |
inCategory:categoryForMenuActionsMethods. |
|
646 |
]. |
|
647 |
]. |
|
648 |
isDialog ifFalse:[ |
|
5817 | 649 |
(nonMetaClass includesSelector:#menuOpen) ifFalse:[ |
5758 | 650 |
txt := |
651 |
'menuOpen |
|
652 |
"This method was generated by the Browser. |
|
653 |
It will be invoked when the menu-item ''open'' is selected." |
|
654 |
||
655 |
"/ change below and add any actions as required here ... |
|
656 |
self warn:''no action for ''''open'''' available.''. |
|
657 |
'. |
|
658 |
self |
|
659 |
compile:txt |
|
660 |
forClass:nonMetaClass |
|
661 |
inCategory:categoryForMenuActionsMethods. |
|
662 |
]. |
|
663 |
]. |
|
664 |
isDialog ifFalse:[ |
|
5817 | 665 |
(nonMetaClass includesSelector:#menuSave) ifFalse:[ |
5758 | 666 |
txt := |
667 |
'menuSave |
|
668 |
"This method was generated by the Browser. |
|
669 |
It will be invoked when the menu-item ''save'' is selected." |
|
670 |
||
671 |
"/ change below and add any actions as required here ... |
|
672 |
self warn:''no action for ''''save'''' available.''. |
|
673 |
'. |
|
674 |
self |
|
675 |
compile:txt |
|
676 |
forClass:nonMetaClass |
|
677 |
inCategory:categoryForMenuActionsMethods. |
|
678 |
]. |
|
679 |
]. |
|
680 |
isDialog ifFalse:[ |
|
5817 | 681 |
(nonMetaClass includesSelector:#menuSaveAs) ifFalse:[ |
5758 | 682 |
txt := |
683 |
'menuSaveAs |
|
684 |
"This method was generated by the Browser. |
|
685 |
It will be invoked when the menu-item ''saveAs'' is selected." |
|
686 |
||
687 |
"/ change below and add any actions as required here ... |
|
688 |
self warn:''no action for ''''saveAs'''' available.''. |
|
689 |
'. |
|
690 |
self |
|
691 |
compile:txt |
|
692 |
forClass:nonMetaClass |
|
693 |
inCategory:categoryForMenuActionsMethods. |
|
694 |
]. |
|
695 |
]. |
|
696 |
||
697 |
isDialog ifFalse:[ |
|
5817 | 698 |
(nonMetaClass includesSelector:#openDocumentation) ifFalse:[ |
5758 | 699 |
txt := |
700 |
'openDocumentation |
|
701 |
"This method was generated by the Browser. |
|
702 |
It will be invoked when the menu-item ''help-documentation'' is selected." |
|
703 |
||
704 |
"/ change below as required ... |
|
705 |
||
706 |
"/ to open an HTML viewer on some document (under ''doc/online/<language>/'' ): |
|
707 |
HTMLDocumentView openFullOnDocumentationFile:''TOP.html''. |
|
708 |
||
709 |
"/ add application-specific help files under the ''doc/online/<language>/help/appName'' |
|
710 |
"/ directory, and open a viewer with: |
|
711 |
"/ HTMLDocumentView openFullOnDocumentationFile:''help/<MyApplication>/TOP.html''. |
|
712 |
'. |
|
713 |
self |
|
714 |
compile:txt |
|
715 |
forClass:nonMetaClass |
|
716 |
inCategory:categoryForMenuActionsMethods. |
|
717 |
]. |
|
718 |
]. |
|
719 |
||
720 |
isDialog ifFalse:[ |
|
5817 | 721 |
(nonMetaClass includesSelector:#openAboutThisApplication) ifFalse:[ |
5758 | 722 |
txt := |
723 |
'openAboutThisApplication |
|
724 |
"This method was generated by the Browser. |
|
725 |
It will be invoked when the menu-item ''help-about'' is selected." |
|
726 |
||
727 |
"/ could open a customized aboutBox here ... |
|
728 |
super openAboutThisApplication |
|
729 |
'. |
|
730 |
self |
|
731 |
compile:txt |
|
732 |
forClass:nonMetaClass |
|
733 |
inCategory:categoryForMenuActionsMethods. |
|
734 |
]. |
|
735 |
]. |
|
736 |
||
6050 | 737 |
self executeCollectedChangesNamed:('Add Application Code for ' , className). |
5758 | 738 |
|
739 |
"Modified: / 1.2.1998 / 16:10:03 / cg" |
|
740 |
! |
|
741 |
||
742 |
createClassResponsibleProtocolFor:aClass |
|
743 |
"create stubs for the required protocol" |
|
744 |
||
6050 | 745 |
|nonMetaClass metaClass className| |
746 |
||
747 |
nonMetaClass := aClass theNonMetaclass. |
|
748 |
metaClass := aClass theMetaclass. |
|
749 |
className := nonMetaClass name. |
|
750 |
||
5758 | 751 |
self startCollectChanges. |
752 |
||
6050 | 753 |
self privCreateClassResponsibleProtocolFor:nonMetaClass. |
754 |
self privCreateClassResponsibleProtocolFor:metaClass. |
|
5758 | 755 |
|
6050 | 756 |
self executeCollectedChangesNamed:('Add Required Protocol to ' , className). |
5758 | 757 |
! |
758 |
||
759 |
createClassTypeTestMethodsIn:aClass forClasses:subClasses |
|
760 |
"create a #isXXX test methods (I'm tired of typing)" |
|
761 |
||
762 |
| code| |
|
763 |
||
764 |
self startCollectChanges. |
|
765 |
||
766 |
subClasses do:[:eachSubClass | |
|
767 |
|nm selector| |
|
768 |
||
769 |
nm := eachSubClass nameWithoutPrefix. |
|
770 |
selector := 'is' , nm. |
|
771 |
(aClass includesSelector:selector) ifFalse:[ |
|
772 |
code := (selector , '\ ^ false') withCRs. |
|
773 |
self |
|
774 |
compile:code |
|
775 |
forClass:aClass |
|
776 |
inCategory:'testing'. |
|
777 |
]. |
|
778 |
(eachSubClass includesSelector:selector) ifFalse:[ |
|
779 |
code := (selector , '\ ^ true') withCRs. |
|
780 |
self |
|
781 |
compile:code |
|
782 |
forClass:eachSubClass |
|
783 |
inCategory:'testing'. |
|
784 |
]. |
|
785 |
]. |
|
786 |
||
5759 | 787 |
self executeCollectedChangesNamed:'Add ClassType Tests' |
5758 | 788 |
! |
789 |
||
790 |
createDocumentationMethodsFor:aClass |
|
791 |
"create empty documentation methods" |
|
792 |
||
6050 | 793 |
|nonMetaClass metaClass className| |
5758 | 794 |
|
6050 | 795 |
nonMetaClass := aClass theNonMetaclass. |
796 |
metaClass := aClass theMetaclass. |
|
797 |
className := nonMetaClass name. |
|
5758 | 798 |
|
799 |
self startCollectChanges. |
|
800 |
||
6050 | 801 |
self createVersionMethodFor:metaClass. |
802 |
self createCopyrightMethodFor:metaClass. |
|
803 |
self createDocumentationMethodFor:metaClass. |
|
804 |
self createInitialHistoryMethodFor:metaClass. |
|
5758 | 805 |
|
6050 | 806 |
self executeCollectedChangesNamed:('Add Documentation to ' , className). |
5758 | 807 |
! |
808 |
||
6313 | 809 |
createEnumTypeCodeFor:aClass |
810 |
|nonMetaClass metaClass className enumValues code initCode runValue maxValue| |
|
811 |
||
812 |
self startCollectChanges. |
|
813 |
||
814 |
nonMetaClass := aClass theNonMetaclass. |
|
815 |
metaClass := aClass theMetaclass. |
|
816 |
className := nonMetaClass name. |
|
817 |
||
818 |
enumValues := nonMetaClass classVarNames. |
|
819 |
enumValues do:[:eachVariableName | |
|
820 |
self |
|
821 |
createAccessMethodsFor:(Array with:eachVariableName) |
|
822 |
in:metaClass |
|
823 |
withChange:false |
|
824 |
asValueHolder:false |
|
825 |
readersOnly:true |
|
826 |
writersOnly:false |
|
827 |
]. |
|
828 |
||
829 |
maxValue := enumValues inject:0 into:[:maxSoFar :eachVariableName | |oldVal val| |
|
830 |
oldVal := nonMetaClass classVarAt:eachVariableName. |
|
831 |
oldVal notNil ifTrue:[ val := oldVal numericValue ]. |
|
832 |
(val ? maxSoFar) max:maxSoFar]. |
|
833 |
||
834 |
initCode := WriteStream on: String new. |
|
835 |
initCode nextPutLine:'initialize'. |
|
836 |
runValue := maxValue + 1. |
|
837 |
enumValues keysAndValuesDo:[:idx :eachVariableName | |
|
838 |
|oldValue thisValue| |
|
839 |
||
840 |
oldValue := nonMetaClass classVarAt:eachVariableName. |
|
841 |
oldValue notNil ifTrue:[ |
|
842 |
thisValue := oldValue numericValue. |
|
843 |
] ifFalse:[ |
|
844 |
thisValue := runValue. |
|
845 |
runValue := runValue + 1. |
|
846 |
]. |
|
847 |
initCode |
|
848 |
nextPutAll:' '; |
|
849 |
nextPutAll:eachVariableName; |
|
850 |
nextPutAll:' := self basicNew'. |
|
851 |
(aClass canUnderstand:#'setNumericValue:') ifTrue:[ |
|
852 |
initCode nextPutAll:' setNumericValue: ',thisValue printString. |
|
853 |
]. |
|
854 |
(aClass canUnderstand:#'setCssClassString:') ifTrue:[ |
|
855 |
initCode nextPutAll:('; setCssClassString: ''' , nonMetaClass nameWithoutPrefix asLowercaseFirst , eachVariableName , ''''). |
|
856 |
]. |
|
857 |
(aClass canUnderstand:#'setName:') ifTrue:[ |
|
858 |
initCode nextPutAll:('; setName: ''' , eachVariableName asLowercaseFirst , ''''). |
|
859 |
]. |
|
860 |
initCode nextPutLine:'.'. |
|
861 |
]. |
|
862 |
initCode cr. |
|
863 |
initCode nextPutLine:' "'. |
|
864 |
initCode nextPutLine:' ',className, ' initialize'. |
|
865 |
initCode nextPutLine:' "'. |
|
866 |
||
867 |
self |
|
868 |
compile:(initCode contents) |
|
869 |
forClass:metaClass |
|
870 |
inCategory:'class initialization'. |
|
871 |
||
872 |
||
873 |
code := 'allStateNames\ ^ #( ' , |
|
6341 | 874 |
((enumValues collect:[:each | '#''',each asLowercaseFirst,'''']) asStringWith:' ') , ')', |
6313 | 875 |
'\\ "\' , |
876 |
' ',className, ' allStateNames\' , |
|
877 |
' "\'. |
|
878 |
self |
|
879 |
compile:code withCRs |
|
880 |
forClass:metaClass |
|
881 |
inCategory:'queries'. |
|
882 |
||
883 |
self executeCollectedChangesNamed:('Generate EnumType Code for ' , className). |
|
884 |
||
885 |
aClass initialize. |
|
886 |
||
887 |
"Modified: / 1.2.1998 / 16:10:03 / cg" |
|
888 |
! |
|
889 |
||
6718 | 890 |
createInitializedInstanceCreationMethodsIn:aClass |
5758 | 891 |
"create a #new and #initialize methods (I'm tired of typing)" |
892 |
||
6050 | 893 |
|nonMetaClass metaClass className code initializer m| |
894 |
||
895 |
nonMetaClass := aClass theNonMetaclass. |
|
896 |
metaClass := aClass theMetaclass. |
|
897 |
className := nonMetaClass name. |
|
5758 | 898 |
|
899 |
self startCollectChanges. |
|
900 |
||
6050 | 901 |
(nonMetaClass includesSelector:#'initialize') ifFalse:[ |
5758 | 902 |
code := |
903 |
'initialize |
|
904 |
"Invoked when a new instance is created." |
|
905 |
||
906 |
"/ please change as required (and remove this comment) |
|
907 |
'. |
|
908 |
||
6718 | 909 |
nonMetaClass instVarNames do:[:eachInstVar | |
910 |
initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ... |
|
911 |
code := code , (' "/ ' , eachInstVar , ' := ' , initializer , '.' , Character cr). |
|
912 |
]. |
|
5758 | 913 |
|
6718 | 914 |
m := nonMetaClass responseTo:#initialize. |
915 |
(m notNil and:[m messagesSent size == 0]) ifTrue:[ |
|
916 |
"/ inherits an empty initialize. |
|
5758 | 917 |
|
6718 | 918 |
code := code , ' |
5758 | 919 |
"/ super initialize. -- commented since inherited method does nothing |
920 |
'. |
|
6718 | 921 |
] ifFalse:[ |
922 |
code := code , ' |
|
923 |
super initialize. |
|
924 |
'. |
|
5758 | 925 |
]. |
926 |
||
927 |
self |
|
928 |
compile:code |
|
6050 | 929 |
forClass:nonMetaClass |
5758 | 930 |
inCategory:'initialization'. |
931 |
]. |
|
932 |
||
6050 | 933 |
(metaClass includesSelector:#'new') ifFalse:[ |
934 |
m := metaClass responseTo:#new. |
|
6718 | 935 |
(m isNil |
936 |
or:[ (m sends:#initialize) not |
|
937 |
or:[ |answer| |
|
938 |
(Dialog |
|
939 |
confirmWithCancel:'The inherited #new method already seems to invoke #initialize. Redefine ?' |
|
940 |
onCancel:[^ self]) ]]) ifTrue:[ |
|
941 |
code := |
|
5758 | 942 |
'new |
943 |
^ self basicNew initialize. |
|
944 |
'. |
|
6718 | 945 |
self |
946 |
compile:code |
|
947 |
forClass:metaClass |
|
948 |
inCategory:'instance creation'. |
|
949 |
]. |
|
950 |
]. |
|
951 |
||
952 |
self executeCollectedChangesNamed:('Add Initialized Instance Creation to ' , className). |
|
953 |
||
954 |
"Created: / 11.10.2001 / 22:18:55 / cg" |
|
955 |
! |
|
956 |
||
957 |
createParametrizedInstanceCreationMethodsNamed:selector in:aClass |
|
958 |
"create a #selector instance creation method (I'm tired of typing)" |
|
959 |
||
960 |
|nonMetaClass metaClass className code initializer m dfn| |
|
961 |
||
962 |
dfn := Method methodDefinitionTemplateForSelector:selector. |
|
963 |
||
964 |
nonMetaClass := aClass theNonMetaclass. |
|
965 |
metaClass := aClass theMetaclass. |
|
966 |
className := nonMetaClass name. |
|
967 |
||
968 |
self startCollectChanges. |
|
969 |
||
970 |
(nonMetaClass includesSelector:selector asSymbol) ifFalse:[ |
|
971 |
code := |
|
972 |
'initialize',dfn asUppercaseFirst,' |
|
973 |
"Invoked when a new instance is created for arg." |
|
974 |
||
975 |
"/ please change as required (and remove these comments) |
|
976 |
"/ do something with arg here (instVar-foo := arg) |
|
977 |
'. |
|
978 |
nonMetaClass instVarNames do:[:eachInstVar | |
|
979 |
initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ... |
|
980 |
code := code , (' "/ ' , eachInstVar , ' := ' , initializer , '.' , Character cr). |
|
981 |
]. |
|
982 |
||
983 |
m := nonMetaClass responseTo:#initialize. |
|
984 |
(m notNil and:[ m messagesSent size == 0 ]) ifTrue:[ |
|
985 |
"/ inherits an empty initialize. |
|
986 |
||
987 |
code := code , ' |
|
988 |
"/ super initialize. -- commented since inherited method does nothing |
|
989 |
'. |
|
990 |
] ifFalse:[ |
|
991 |
code := code , ' |
|
992 |
super initialize. |
|
993 |
'. |
|
994 |
]. |
|
995 |
||
5758 | 996 |
self |
997 |
compile:code |
|
6718 | 998 |
forClass:nonMetaClass |
999 |
inCategory:'initialization'. |
|
5758 | 1000 |
]. |
1001 |
||
6718 | 1002 |
(metaClass includesSelector:selector) ifFalse:[ |
1003 |
m := metaClass responseTo:selector. |
|
1004 |
(m isNil |
|
1005 |
or:[ (Dialog confirmWithCancel:'The ',selector,'- method is already inherited. Redefine ?' onCancel:[^ self]) ]) |
|
1006 |
ifTrue:[ |
|
1007 |
code := |
|
1008 |
dfn,' |
|
1009 |
"Create & return a new instance for arg." |
|
5758 | 1010 |
|
6718 | 1011 |
^ self basicNew initialize',dfn asUppercaseFirst,' |
1012 |
'. |
|
1013 |
self |
|
1014 |
compile:code |
|
1015 |
forClass:metaClass |
|
1016 |
inCategory:'instance creation'. |
|
1017 |
]. |
|
1018 |
]. |
|
1019 |
||
1020 |
self executeCollectedChangesNamed:('Add Parametrized Instance Creation to ' , className). |
|
5758 | 1021 |
! |
1022 |
||
5953 | 1023 |
createStandardPrintOnMethodIn:aClass |
1024 |
"create a #printOn: method (I'm tired of typing)" |
|
1025 |
||
6050 | 1026 |
|code nonMetaClass| |
1027 |
||
1028 |
nonMetaClass := aClass theNonMetaclass. |
|
5953 | 1029 |
|
1030 |
self startCollectChanges. |
|
1031 |
||
6050 | 1032 |
(nonMetaClass includesSelector:#'printOn:') ifFalse:[ |
5953 | 1033 |
code := |
1034 |
'printOn:aStream |
|
1035 |
"append a printed representation if the receiver to the argument, aStream" |
|
1036 |
||
1037 |
super printOn:aStream. |
|
1038 |
'. |
|
6050 | 1039 |
nonMetaClass instVarNames do:[:eachInstVarName | |
5953 | 1040 |
code := code , ' '. |
1041 |
code := code , 'aStream nextPutAll:'''. |
|
1042 |
code := code , eachInstVarName. |
|
1043 |
code := code , ': ''.' , Character cr. |
|
1044 |
code := code , ' '. |
|
1045 |
code := code , eachInstVarName. |
|
1046 |
code := code , ' printOn:aStream.' , Character cr. |
|
1047 |
||
1048 |
]. |
|
1049 |
||
1050 |
self |
|
1051 |
compile:code |
|
6050 | 1052 |
forClass:nonMetaClass |
5953 | 1053 |
inCategory:'printing & storing'. |
1054 |
]. |
|
1055 |
||
1056 |
||
6050 | 1057 |
self executeCollectedChangesNamed:('Add #printOn: to ' , nonMetaClass name). |
5953 | 1058 |
|
1059 |
"Created: / 11.10.2001 / 22:18:55 / cg" |
|
1060 |
! |
|
1061 |
||
5758 | 1062 |
createTestCaseSampleCodeFor:aClass |
1063 |
"create an (almost) empty testCase class" |
|
1064 |
||
1065 |
|nonMetaClass metaClass| |
|
1066 |
||
1067 |
nonMetaClass := aClass theNonMetaclass. |
|
1068 |
metaClass := aClass theMetaclass. |
|
1069 |
"/ className := nonMetaClass name. |
|
1070 |
||
1071 |
( nonMetaClass includesSelector:#test1 ) ifFalse:[ |
|
1072 |
self |
|
1073 |
compile: |
|
1074 |
'test1 |
|
1075 |
"This is a demonstration testCase - it is meant to be removed eventually. |
|
1076 |
This testCase will PASS. |
|
1077 |
Double click on the TestCase class or open a TestRunner to see me checking... |
|
1078 |
- please add more methods like this..." |
|
1079 |
||
1080 |
|o| |
|
1081 |
||
1082 |
o := Array new:2. |
|
1083 |
self assert: ( o size == 2 ). |
|
1084 |
self should: [ o at:0 ] raise:Error. |
|
1085 |
self shouldnt: [ o at:1 ] raise:Error. |
|
1086 |
||
1087 |
" |
|
1088 |
self run:#test1 |
|
1089 |
self new test1 |
|
1090 |
" |
|
1091 |
' |
|
1092 |
forClass:nonMetaClass |
|
1093 |
inCategory:'tests'. |
|
1094 |
]. |
|
1095 |
||
1096 |
( nonMetaClass includesSelector:#test2 ) ifFalse:[ |
|
1097 |
self |
|
1098 |
compile: |
|
1099 |
'test2 |
|
1100 |
"This is a demonstration testCase - it is meant to be removed eventually.. |
|
1101 |
This testCase WILL FAIL. |
|
1102 |
Double click on the TestCase class or open a TestRunner to see me checking... |
|
1103 |
- please add more methods like this..." |
|
1104 |
||
1105 |
|o| |
|
1106 |
||
1107 |
o := Array new:2. |
|
1108 |
self assert: ( o size == 3 ). |
|
1109 |
||
1110 |
" |
|
1111 |
self run:#test2 |
|
1112 |
self new test2 |
|
1113 |
" |
|
1114 |
' |
|
1115 |
forClass:nonMetaClass |
|
1116 |
inCategory:'tests'. |
|
1117 |
]. |
|
1118 |
||
1119 |
( nonMetaClass includesSelector:#test3 ) ifFalse:[ |
|
1120 |
self |
|
1121 |
compile: |
|
1122 |
'test3 |
|
1123 |
"This is a demonstration testCase - it is meant to be removed eventually.. |
|
1124 |
This testCase WILL generate an ERROR. |
|
1125 |
Double click on the TestCase class or open a TestRunner to see me checking... |
|
1126 |
- please add more methods like this..." |
|
1127 |
||
1128 |
|o| |
|
1129 |
||
1130 |
o := Array new:2. |
|
1131 |
self assert: ( o foo ). |
|
1132 |
||
1133 |
" |
|
1134 |
self run:#test3 |
|
1135 |
self new test3 |
|
1136 |
" |
|
1137 |
' |
|
1138 |
forClass:nonMetaClass |
|
1139 |
inCategory:'tests'. |
|
1140 |
]. |
|
1141 |
||
1142 |
( nonMetaClass includesSelector:#setUp ) ifFalse:[ |
|
1143 |
self |
|
1144 |
compile: |
|
1145 |
'setUp |
|
1146 |
"common setup - invoked before testing." |
|
1147 |
||
1148 |
super setUp |
|
1149 |
' |
|
1150 |
forClass:nonMetaClass |
|
1151 |
inCategory:'initialize / release'. |
|
1152 |
]. |
|
1153 |
||
1154 |
( nonMetaClass includesSelector:#tearDown ) ifFalse:[ |
|
1155 |
self |
|
1156 |
compile: |
|
1157 |
'tearDown |
|
1158 |
"common cleanup - invoked after testing." |
|
1159 |
||
1160 |
super tearDown |
|
1161 |
' |
|
1162 |
forClass:nonMetaClass |
|
1163 |
inCategory:'initialize / release'. |
|
1164 |
] |
|
1165 |
! |
|
1166 |
||
1167 |
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass |
|
1168 |
"create acceptVisitor: in visitedClass and acceptXXX in visitorClass. (I'm tired of typing)" |
|
1169 |
||
1170 |
|sel| |
|
1171 |
||
6921 | 1172 |
self assert:( visitedClass isMeta not ). |
1173 |
self assert:( visitorClass isMeta not ). |
|
5758 | 1174 |
|
1175 |
self startCollectChanges. |
|
1176 |
||
1177 |
sel := ('visit' , visitedClass nameWithoutPrefix , ':'). |
|
1178 |
self createAcceptVisitorMethod:sel in:visitedClass. |
|
1179 |
||
1180 |
(visitorClass includesSelector:sel) ifFalse:[ |
|
1181 |
self |
|
1182 |
compile: |
|
1183 |
(('%1anObject |
|
1184 |
"dispatched back from the visited %2-object (visitor pattern)" |
|
1185 |
||
1186 |
"fall back to general object-case - please change as required" |
|
1187 |
||
1188 |
^ self visitObject:anObject |
|
1189 |
') bindWith:sel with:visitedClass nameWithoutPrefix asLowercaseFirst) |
|
1190 |
forClass:visitorClass |
|
1191 |
inCategory:'visiting'. |
|
1192 |
]. |
|
1193 |
||
1194 |
(visitorClass includesSelector:#'visitObject:') ifFalse:[ |
|
1195 |
self |
|
1196 |
compile: |
|
1197 |
('visitObject:anObject |
|
1198 |
"dispatched back from the visited objects (visitor pattern)" |
|
1199 |
||
1200 |
"general fallBack - please change as required" |
|
1201 |
||
1202 |
self halt:''not yet implemented'' |
|
1203 |
') |
|
1204 |
forClass:visitorClass |
|
1205 |
inCategory:'visiting'. |
|
1206 |
]. |
|
1207 |
||
1208 |
(visitorClass includesSelector:#'visit:') ifFalse:[ |
|
1209 |
self |
|
1210 |
compile: |
|
1211 |
('visit:anObject |
|
1212 |
"visit anObject (visitor pattern). |
|
1213 |
The object should call back one of my visitXXXX methods." |
|
1214 |
||
1215 |
^ anObject acceptVisitor:self |
|
1216 |
') |
|
1217 |
forClass:visitorClass |
|
1218 |
inCategory:'visiting'. |
|
1219 |
]. |
|
1220 |
||
1221 |
self executeCollectedChangesNamed:('Add Visitor Pattern'). |
|
6050 | 1222 |
! |
1223 |
||
1224 |
createWebApplicationCodeFor:aClass |
|
1225 |
"create an empty webApplication framework" |
|
1226 |
||
1227 |
|nonMetaClass metaClass className txt| |
|
1228 |
||
1229 |
self startCollectChanges. |
|
1230 |
||
1231 |
nonMetaClass := aClass theNonMetaclass. |
|
1232 |
metaClass := aClass theMetaclass. |
|
1233 |
className := nonMetaClass name. |
|
1234 |
||
1235 |
(nonMetaClass includesSelector:#process:) ifFalse:[ |
|
1236 |
txt := |
|
1237 |
'process:aRequest |
|
1238 |
"This is the web applications main processing method. |
|
1239 |
It will be invoked for every incoming webBrowser-request. |
|
1240 |
The argument, aRequest contains the parameters (url, fields, parameters etc.)." |
|
1241 |
||
1242 |
|response| |
|
1243 |
||
1244 |
response := aRequest response. |
|
1245 |
response nextPutLine:''<HTML>''. |
|
1246 |
response nextPutLine:'' <HEAD>''. |
|
1247 |
response nextPutLine:'' <TITLE>Hello</TITLE>''. |
|
1248 |
response nextPutLine:'' </HEAD>''. |
|
1249 |
response nextPutLine:'' <BODY>''. |
|
1250 |
response nextPutLine:'' <H1>Hello World !!</H1>''. |
|
1251 |
response nextPutLine:'' </BODY>''. |
|
1252 |
response nextPutLine:''</HTML>''. |
|
1253 |
'. |
|
1254 |
self |
|
1255 |
compile:txt |
|
1256 |
forClass:nonMetaClass |
|
1257 |
inCategory:'response generation'. |
|
1258 |
]. |
|
1259 |
||
1260 |
(metaClass includesSelector:#linkName) ifFalse:[ |
|
1261 |
txt := |
|
1262 |
'linkName |
|
1263 |
"return the default linkName path (with slash)." |
|
1264 |
||
1265 |
^ ''/NewService'' |
|
1266 |
'. |
|
1267 |
self |
|
1268 |
compile:txt |
|
1269 |
forClass:metaClass |
|
1270 |
inCategory:'defaults'. |
|
1271 |
]. |
|
1272 |
||
1273 |
(metaClass includesSelector:#settingsApplicationClass) ifFalse:[ |
|
1274 |
txt := |
|
1275 |
'settingsApplicationClass |
|
1276 |
"a SettingsApplication class - or nil (used in the settings dialog if non-nil)." |
|
1277 |
||
1278 |
^ nil |
|
1279 |
'. |
|
1280 |
self |
|
1281 |
compile:txt |
|
1282 |
forClass:metaClass |
|
1283 |
inCategory:'defaults'. |
|
1284 |
]. |
|
1285 |
||
1286 |
||
1287 |
self executeCollectedChangesNamed:('Add WebApplication Code for ' , className). |
|
1288 |
||
1289 |
"Modified: / 1.2.1998 / 16:10:03 / cg" |
|
5758 | 1290 |
! ! |
1291 |
||
1292 |
!CodeGeneratorTool methodsFor:'code generation-basic'! |
|
1293 |
||
1294 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization |
|
1295 |
"workhorse for creating access methods for instvars." |
|
1296 |
||
1297 |
|classesClassVars generateComments generateCommentsForSetters generateCommentsForGetters| |
|
1298 |
||
1299 |
self startCollectChanges. |
|
1300 |
||
1301 |
generateComments := UserPreferences current generateComments. |
|
1302 |
generateCommentsForSetters := UserPreferences current generateCommentsForSetters. |
|
1303 |
generateCommentsForGetters := UserPreferences current generateCommentsForGetters. |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1304 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1305 |
classesClassVars := aClass theNonMetaclass allClassVarNames. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1306 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1307 |
aCollectionOfVarNames do:[:name | |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1308 |
|source varType methodName defaultMethodName| |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1309 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1310 |
varType := (classesClassVars includes:name) |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1311 |
ifTrue:['static'] |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1312 |
ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1313 |
(aClass isMeta ifTrue:['classInstVar'] ifFalse:['instance'])]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1314 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1315 |
methodName := name. |
6643 | 1316 |
name isUppercaseFirst ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1317 |
methodName := methodName asLowercaseFirst. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1318 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1319 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1320 |
"/ the GETTER |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1321 |
writersOnly ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1322 |
lazyInitialization ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1323 |
defaultMethodName := 'default' , name asUppercaseFirst. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1324 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1325 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1326 |
"check, if method is not already present" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1327 |
(aClass includesSelector:(methodName asSymbol)) ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1328 |
asValueHolder ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1329 |
source := methodName , '\'. |
5758 | 1330 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1331 |
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
|
1332 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1333 |
source := source , ' %2 isNil ifTrue:[\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1334 |
lazyInitialization ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1335 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1336 |
, ' %2 := self class %3 asValue.\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1337 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1338 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1339 |
, ' %2 := ValueHolder new.\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1340 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1341 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1342 |
withChange ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1343 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1344 |
, ' %2 addDependent:self.\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1345 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1346 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1347 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1348 |
, ' ^ %2'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1349 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1350 |
source := methodName , '\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1351 |
lazyInitialization ifTrue:[ |
5758 | 1352 |
generateCommentsForGetters ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1353 |
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
|
1354 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1355 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1356 |
, ' %2 isNil ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1357 |
, ' %2 := self class %3.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1358 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1359 |
, ' ^ %2'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1360 |
] ifFalse:[ |
5758 | 1361 |
generateCommentsForGetters ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1362 |
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
|
1363 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1364 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1365 |
, ' ^ %2'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1366 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1367 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1368 |
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
|
1369 |
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
|
1370 |
] ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1371 |
Transcript showCR:'method ''', methodName , ''' already present' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1372 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1373 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1374 |
"/ default for lazy on class side |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1375 |
lazyInitialization ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1376 |
(aClass class includesSelector:(defaultMethodName asSymbol)) ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1377 |
source := defaultMethodName , '\'. |
5758 | 1378 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1379 |
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
|
1380 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1381 |
source := source |
6839
c25218305e50
Send #shouldImplement instead of #halt:.
Stefan Vogel <sv@exept.de>
parents:
6791
diff
changeset
|
1382 |
, ' self shouldImplement.\' |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1383 |
, ' ^ nil.'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1384 |
source := (source bindWith:varType with:name) withCRs. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1385 |
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
|
1386 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1387 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1388 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1389 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1390 |
"/ the SETTER |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1391 |
readersOnly ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1392 |
(aClass includesSelector:((methodName , ':') asSymbol)) ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1393 |
asValueHolder ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1394 |
source := methodName , ':something\'. |
5758 | 1395 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1396 |
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
|
1397 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1398 |
withChange ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1399 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1400 |
, ' |oldValue newValue|\\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1401 |
, ' %2 notNil ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1402 |
, ' oldValue := %2 value.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1403 |
, ' %2 removeDependent:self.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1404 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1405 |
, ' %2 := something.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1406 |
, ' %2 notNil ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1407 |
, ' %2 addDependent:self.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1408 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1409 |
, ' newValue := %2 value.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1410 |
, ' oldValue ~~ newValue ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1411 |
, ' self update:#value with:newValue from:%2.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1412 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1413 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1414 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1415 |
, ' %2 := something.'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1416 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1417 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1418 |
source := methodName , ':something\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1419 |
withChange ifTrue:[ |
5758 | 1420 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1421 |
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
|
1422 |
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
|
1423 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1424 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1425 |
, ' (%2 ~~ something) ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1426 |
, ' %2 := something.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1427 |
, ' self changed:#%2.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1428 |
, ' ].\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1429 |
] ifFalse:[ |
5758 | 1430 |
generateCommentsForSetters ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1431 |
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
|
1432 |
source := source , ' (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1433 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1434 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1435 |
, ' %2 := something.'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1436 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1437 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1438 |
source := (source bindWith:varType with:name) withCRs. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1439 |
self |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1440 |
compile:source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1441 |
forClass:aClass |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1442 |
inCategory:(asValueHolder ifTrue:['aspects'] ifFalse:['accessing']). |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1443 |
] ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1444 |
Transcript showCR:'method ''', methodName , ':'' already present' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1445 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1446 |
]. |
5758 | 1447 |
]. |
1448 |
||
1449 |
self executeCollectedChangesNamed:('Add Accessors'). |
|
5763 | 1450 |
! |
1451 |
||
1452 |
createValueHoldersFor:aCollectionOfVarNames in:aClass lazyInitialization:lazyInitialization |
|
1453 |
"workhorse for creating access methods for instvars." |
|
1454 |
||
6050 | 1455 |
|nonMetaClass metaClass classesClassVars generateComments generateCommentsForSetters generateCommentsForGetters| |
1456 |
||
1457 |
nonMetaClass := aClass theNonMetaclass. |
|
1458 |
metaClass := aClass theMetaclass. |
|
5763 | 1459 |
|
1460 |
self startCollectChanges. |
|
1461 |
||
1462 |
generateComments := UserPreferences current generateComments. |
|
1463 |
generateCommentsForSetters := UserPreferences current generateCommentsForSetters. |
|
1464 |
generateCommentsForGetters := UserPreferences current generateCommentsForGetters. |
|
1465 |
||
6050 | 1466 |
classesClassVars := nonMetaClass allClassVarNames. |
5763 | 1467 |
|
1468 |
aCollectionOfVarNames do:[:name | |
|
1469 |
|source varType methodName holderMethodName defaultMethodName| |
|
1470 |
||
1471 |
holderMethodName := name. |
|
6643 | 1472 |
name isUppercaseFirst ifTrue:[ |
5763 | 1473 |
holderMethodName := holderMethodName asLowercaseFirst. |
1474 |
]. |
|
1475 |
(holderMethodName endsWith:'Holder') ifTrue:[ |
|
1476 |
methodName := holderMethodName copyWithoutLast:6. |
|
1477 |
] ifFalse:[ |
|
1478 |
methodName := holderMethodName. |
|
1479 |
holderMethodName := methodName , 'Holder'. |
|
1480 |
]. |
|
1481 |
||
1482 |
methodName notNil ifTrue:[ |
|
6050 | 1483 |
(metaClass includesSelector:(methodName asSymbol)) ifFalse:[ |
5763 | 1484 |
source := '%1\'. |
1485 |
generateComments ifTrue:[ |
|
1486 |
source := source , ' "return the value in ''%2''"\\'. |
|
1487 |
]. |
|
1488 |
source := source , ' ^ self %2 value'. |
|
1489 |
source := (source bindWith:methodName with:holderMethodName) withCRs. |
|
6050 | 1490 |
self compile:source forClass:nonMetaClass inCategory:('accessing'). |
5763 | 1491 |
] ifTrue:[ |
1492 |
Transcript showCR:'method ''', methodName , ''' already present' |
|
1493 |
]. |
|
1494 |
||
6050 | 1495 |
(metaClass includesSelector:((methodName , ':') asSymbol)) ifFalse:[ |
5763 | 1496 |
source := '%1: newValue\'. |
1497 |
generateComments ifTrue:[ |
|
1498 |
source := source , ' "set the value in ''%2''"\\'. |
|
1499 |
]. |
|
1500 |
source := source , ' self %2 value: newValue'. |
|
1501 |
source := (source bindWith:methodName with:holderMethodName) withCRs. |
|
6050 | 1502 |
self compile:source forClass:nonMetaClass inCategory:('accessing'). |
5763 | 1503 |
] ifTrue:[ |
1504 |
Transcript showCR:'method ''', methodName , ':'' already present' |
|
1505 |
]. |
|
1506 |
]. |
|
6050 | 1507 |
(metaClass includesSelector:(holderMethodName asSymbol)) ifFalse:[ |
5763 | 1508 |
source := '%1\'. |
1509 |
generateComments ifTrue:[ |
|
1510 |
source := source , ' "return/create the valueHolder ''%1''"\\'. |
|
1511 |
]. |
|
1512 |
source := source , ' %1 isNil ifTrue:[\'. |
|
1513 |
source := source , ' %1 := ValueHolder with:nil "defaultValue here".\'. |
|
1514 |
source := source , ' ].\'. |
|
1515 |
source := source , ' ^ %1\'. |
|
1516 |
source := (source bindWith:holderMethodName) withCRs. |
|
6050 | 1517 |
self compile:source forClass:nonMetaClass inCategory:('accessing'). |
5763 | 1518 |
] ifTrue:[ |
1519 |
Transcript showCR:'method ''', methodName , ''' already present' |
|
1520 |
]. |
|
1521 |
]. |
|
1522 |
||
1523 |
self executeCollectedChangesNamed:('Add ValueHolder'). |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1524 |
! ! |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1525 |
|
5758 | 1526 |
!CodeGeneratorTool methodsFor:'code generation-individual methods'! |
3712 | 1527 |
|
1528 |
createAcceptVisitorMethod:selector in:aClass |
|
1529 |
"create an acceptVisitor: method |
|
1530 |
(I'm tired of typing)" |
|
1531 |
||
6921 | 1532 |
self assert:( aClass isMeta not ). |
3712 | 1533 |
|
1534 |
(aClass includesSelector:#'acceptVisitor:') ifFalse:[ |
|
1535 |
self |
|
1536 |
compile: |
|
1537 |
(('acceptVisitor:aVisitor |
|
1538 |
"Double dispatch back to the visitor, passing my type encoded in |
|
1539 |
the selector (visitor pattern)" |
|
1540 |
||
1541 |
"stub code automatically generated - please change if required" |
|
1542 |
||
1543 |
^ aVisitor %1self |
|
1544 |
') bindWith:selector) |
|
1545 |
forClass:aClass |
|
1546 |
inCategory:'visiting'. |
|
1547 |
] |
|
1548 |
! |
|
1549 |
||
1550 |
createAcceptVisitorMethodIn:aClass |
|
1551 |
"create an acceptVisitor: method |
|
1552 |
(I'm tired of typing)" |
|
1553 |
||
1554 |
self |
|
1555 |
createAcceptVisitorMethod:('visit' , aClass nameWithoutPrefix , ':') asSymbol |
|
1556 |
in:aClass |
|
1557 |
! |
|
1558 |
||
1559 |
createCopyrightMethodFor:aClass |
|
1560 |
"add copyright method containing your/your companies |
|
1561 |
copyright template but only if not already present. |
|
1562 |
this is only added, if specified in the |
|
1563 |
COPYRIGHT_TEMPLATE_FILE resources." |
|
1564 |
||
1565 |
|fn txt| |
|
1566 |
||
1567 |
(aClass includesSelector:#copyright) ifFalse:[ |
|
1568 |
fn := SystemBrowser classResources at:#'COPYRIGHT_TEMPLATE_FILE' default:nil. |
|
1569 |
fn notNil ifTrue:[ |
|
1570 |
fn := fn asFilename. |
|
1571 |
fn exists ifTrue:[ |
|
1572 |
txt := fn contents asString |
|
1573 |
] |
|
1574 |
]. |
|
1575 |
||
1576 |
txt notNil ifTrue:[ |
|
1577 |
txt := txt bindWith:(Date today year). |
|
1578 |
self compile: |
|
1579 |
'copyright |
|
1580 |
" |
|
1581 |
' , txt , ' |
|
1582 |
" |
|
1583 |
' forClass:aClass |
|
1584 |
inCategory:'documentation'. |
|
1585 |
] |
|
1586 |
]. |
|
1587 |
! |
|
1588 |
||
1589 |
createDocumentationMethodFor:aClass |
|
1590 |
"add documentation method containing doc template |
|
1591 |
but only if not already present." |
|
1592 |
||
6050 | 1593 |
|metaClass nonMetaClass userName loginName hostName emailAddress code existingComment| |
1594 |
||
1595 |
metaClass := aClass theMetaclass. |
|
1596 |
nonMetaClass := aClass theNonMetaclass. |
|
3712 | 1597 |
|
6050 | 1598 |
(metaClass includesSelector:#documentation) ifFalse:[ |
1599 |
existingComment := nonMetaClass comment. |
|
1600 |
existingComment isEmptyOrNil ifTrue:[ |
|
1601 |
(nonMetaClass isSubclassOf:HTTPService) ifTrue:[ |
|
6159 | 1602 |
existingComment := ' [start Server with:] |
1603 |
HTTPServer startServerOnPort:9090 |
|
1604 |
||
1605 |
[start with:] |
|
6050 | 1606 |
(self new) |
1607 |
registerServiceOn:(HTTPServer runningServerOnPort:9090)'. |
|
1608 |
]. |
|
1609 |
]. |
|
1610 |
||
3712 | 1611 |
userName := OperatingSystem getFullUserName. |
1612 |
loginName := OperatingSystem getLoginName. |
|
1613 |
hostName := OperatingSystem getHostName. |
|
1614 |
emailAddress := loginName , '@' , hostName. |
|
1615 |
||
5756 | 1616 |
"/ ugly; should ask the class for that |
6350 | 1617 |
metaClass isJavaScriptMetaclass ifTrue:[ |
5756 | 1618 |
code := |
1619 |
'function documentation() { |
|
1620 |
/* |
|
6050 | 1621 |
' , (existingComment ? ' documentation to be added.') , ' |
5756 | 1622 |
|
1623 |
[author:] |
|
1624 |
' , userName |
|
1625 |
, ' (' , emailAddress , ')' , ' |
|
1626 |
||
1627 |
[instance variables:] |
|
1628 |
||
1629 |
[class variables:] |
|
1630 |
||
1631 |
[see also:] |
|
1632 |
||
1633 |
*/ |
|
1634 |
} |
|
1635 |
' |
|
1636 |
] ifFalse:[ |
|
1637 |
code:= |
|
3712 | 1638 |
'documentation |
1639 |
" |
|
6050 | 1640 |
' , (existingComment ? ' documentation to be added.') , ' |
3712 | 1641 |
|
1642 |
[author:] |
|
1643 |
' , userName |
|
1644 |
, ' (' , emailAddress , ')' , ' |
|
1645 |
||
1646 |
[instance variables:] |
|
1647 |
||
1648 |
[class variables:] |
|
1649 |
||
1650 |
[see also:] |
|
1651 |
||
1652 |
" |
|
5756 | 1653 |
' |
1654 |
]. |
|
1655 |
||
1656 |
self |
|
1657 |
compile:code |
|
6050 | 1658 |
forClass:metaClass |
5756 | 1659 |
inCategory:'documentation'. |
3712 | 1660 |
]. |
1661 |
! |
|
1662 |
||
1663 |
createExamplesMethodFor:aClass |
|
1664 |
"add examples method containing examples template |
|
1665 |
but only if not already present." |
|
1666 |
||
6050 | 1667 |
|nonMetaclass fragment| |
1668 |
||
1669 |
nonMetaclass := aClass theNonMetaclass. |
|
1670 |
(nonMetaclass isSubclassOf:ApplicationModel) ifFalse:[ |
|
1671 |
^ self |
|
1672 |
]. |
|
3712 | 1673 |
|
1674 |
(aClass includesSelector:#examples) ifFalse:[ |
|
6050 | 1675 |
(nonMetaclass isSubclassOf:ApplicationModel) ifTrue:[ |
3712 | 1676 |
fragment := ' Starting the application: |
1677 |
[exBegin] |
|
6050 | 1678 |
' , nonMetaclass name , ' open |
3712 | 1679 |
|
1680 |
[exEnd] |
|
1681 |
' |
|
1682 |
] ifFalse:[ |
|
1683 |
fragment := '' |
|
1684 |
]. |
|
1685 |
||
1686 |
self |
|
1687 |
compile: |
|
1688 |
'examples |
|
1689 |
" |
|
1690 |
' , fragment , ' |
|
1691 |
more examples to be added: |
|
1692 |
[exBegin] |
|
1693 |
... add code fragment for |
|
1694 |
... executable example here ... |
|
1695 |
[exEnd] |
|
1696 |
" |
|
1697 |
' |
|
1698 |
forClass:aClass |
|
1699 |
inCategory:'documentation'. |
|
1700 |
]. |
|
1701 |
! |
|
1702 |
||
3822
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1703 |
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
|
1704 |
|imageStoreStream mthd imageKey category| |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1705 |
|
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1706 |
anImage storeOn: (imageStoreStream := WriteStream on: ''). |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1707 |
|
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1708 |
"/ 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
|
1709 |
category := 'image specs'. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1710 |
(mthd := aClass compiledMethodAt:sel) notNil ifTrue:[ |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1711 |
category := mthd category. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1712 |
]. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1713 |
|
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1714 |
imageKey := (aClass name, ' ', sel) asSymbol. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1715 |
Icon constantNamed: imageKey put:nil. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1716 |
aClass |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1717 |
compile: ((sel, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1718 |
'\', comment, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1719 |
'\\' , |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1720 |
' "\', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1721 |
' self ' , sel , ' inspect\', |
3823 | 1722 |
' ImageEditor openOnClass:self andSelector:#', sel, '\', |
3822
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1723 |
' Icon flushCachedIcons', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1724 |
'\ "', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1725 |
'\\', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1726 |
' <resource: #image>', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1727 |
'\\', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1728 |
' ^Icon\') withCRs, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1729 |
' constantNamed:#''', imageKey, '''\' withCRs, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1730 |
' ifAbsentPut:[', imageStoreStream contents, ']') |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1731 |
classified: category. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1732 |
! |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
1733 |
|
3712 | 1734 |
createInitialHistoryMethodFor:aClass |
1735 |
"add history method containing created-entry |
|
1736 |
but only if not already present." |
|
1737 |
||
5758 | 1738 |
|code| |
1739 |
||
3712 | 1740 |
(aClass includesSelector:#history) ifFalse:[ |
1741 |
HistoryManager notNil ifTrue:[ |
|
5758 | 1742 |
code := HistoryManager codeForInitialHistoryMethodIn:aClass. |
1743 |
self |
|
1744 |
compile:code |
|
1745 |
forClass:aClass |
|
1746 |
inCategory:'documentation'. |
|
3712 | 1747 |
]. |
1748 |
]. |
|
1749 |
! |
|
1750 |
||
4512 | 1751 |
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass |
1752 |
"add an inst-creation method" |
|
1753 |
||
1754 |
|template| |
|
1755 |
||
1756 |
(aMetaClass includesSelector:selector) ifFalse:[ |
|
1757 |
template := Parser methodSpecificationForSelector:selector. |
|
1758 |
self |
|
1759 |
compile: |
|
1760 |
template , ' |
|
1761 |
^ self new ' , template , ' |
|
1762 |
' |
|
1763 |
forClass:aMetaClass |
|
1764 |
inCategory:category. |
|
1765 |
]. |
|
1766 |
! |
|
1767 |
||
3712 | 1768 |
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass |
1769 |
"create a multi-setter method for instvars." |
|
1770 |
||
1771 |
|source| |
|
1772 |
||
1773 |
source := ''. |
|
1774 |
aCollectionOfVarNames do:[:eachVar | |
|
1775 |
source := source , (eachVar , ':' , eachVar , 'Arg '). |
|
1776 |
]. |
|
1777 |
source := source , Character cr. |
|
6992 | 1778 |
(UserPreferences current generateCommentsForSetters) ifTrue:[ |
6993 | 1779 |
source := source , (' "set instance variables"' , Character cr , Character cr). |
6992 | 1780 |
]. |
3712 | 1781 |
aCollectionOfVarNames do:[:eachVar | |
1782 |
source := source , (' ' , eachVar , ' := ' , eachVar , 'Arg.' , Character cr). |
|
1783 |
]. |
|
1784 |
self compile:source forClass:aClass inCategory:'accessing'. |
|
1785 |
! |
|
1786 |
||
3800
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1787 |
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1788 |
"add a subclassResponsibility method; |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1789 |
but only if not already present." |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1790 |
|
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1791 |
(aClass includesSelector:aSelector) ifFalse:[ |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1792 |
|
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1793 |
self compile: |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1794 |
(Method methodDefinitionTemplateForSelector:aSelector) , |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1795 |
' |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1796 |
"raise an error: must be redefined in concrete subclass(es)" |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1797 |
|
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1798 |
^ self subclassResponsibility |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1799 |
' |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1800 |
forClass:aClass |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1801 |
inCategory:cat. |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1802 |
]. |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1803 |
! |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
1804 |
|
3712 | 1805 |
createUpdateMethodIn:aClass |
1806 |
"create an update:with:from:-method |
|
1807 |
(I'm tired of typing)" |
|
1808 |
||
1809 |
(aClass includesSelector:#'update:with:from:') ifFalse:[ |
|
1810 |
self |
|
1811 |
compile: |
|
1812 |
'update:something with:aParameter from:changedObject |
|
1813 |
"Invoked when an object that I depend upon sends a change notification." |
|
1814 |
||
1815 |
"stub code automatically generated - please change as required" |
|
1816 |
||
1817 |
"/ changedObject == someOfMyValueHolders ifTrue:[ |
|
4926 | 1818 |
"/ self doSomethingApropriate. |
1819 |
"/ ^ self. |
|
3712 | 1820 |
"/ ]. |
1821 |
super update:something with:aParameter from:changedObject |
|
1822 |
' |
|
1823 |
forClass:aClass |
|
1824 |
inCategory:'change & update'. |
|
1825 |
] |
|
1826 |
! |
|
1827 |
||
1828 |
createVersionMethodFor:aClass |
|
1829 |
"add version method containing RCS template |
|
1830 |
but only if not already present and its not a private class." |
|
1831 |
||
5756 | 1832 |
|code| |
1833 |
||
3712 | 1834 |
aClass isPrivate ifFalse:[ |
1835 |
(aClass includesSelector:#version) ifFalse:[ |
|
5756 | 1836 |
"/ ugly; should ask the class for that |
1837 |
aClass isJavaScriptClass ifTrue:[ |
|
1838 |
code:= ('function version() {\ return ("$' , 'Header$");\}') withCRs |
|
1839 |
] ifFalse:[ |
|
1840 |
code:= ('version\ ^ ''$' , 'Header$''') withCRs |
|
1841 |
]. |
|
1842 |
self |
|
1843 |
compile:code |
|
1844 |
forClass:aClass |
|
1845 |
inCategory:'documentation'. |
|
3712 | 1846 |
] |
1847 |
]. |
|
1848 |
! ! |
|
1849 |
||
6938 | 1850 |
!CodeGeneratorTool methodsFor:'compilation'! |
1851 |
||
1852 |
compile:theCode forClass:aClass inCategory:cat |
|
1853 |
"install some code for a class. |
|
1854 |
If refactory browser stuff is avaliable the refactory tools are used to support undo" |
|
1855 |
||
6972 | 1856 |
|change compiler selector oldMthd| |
6938 | 1857 |
|
1858 |
"/ skip if same |
|
1859 |
compiler := aClass compilerClass new. |
|
1860 |
compiler parseMethod:theCode in:aClass ignoreErrors:true ignoreWarnings:true. |
|
1861 |
||
6972 | 1862 |
selector := compiler selector. |
1863 |
selector notNil ifTrue:[ |
|
1864 |
oldMthd := aClass compiledMethodAt:selector. |
|
6938 | 1865 |
(oldMthd notNil and:[oldMthd source = theCode]) ifTrue:[ |
1866 |
^ self. |
|
1867 |
]. |
|
1868 |
]. |
|
1869 |
||
1870 |
self canUseRefactoringSupport ifFalse:[ |
|
1871 |
"/ compile immediately |
|
1872 |
aClass compile:theCode classified:cat. |
|
1873 |
^ self. |
|
1874 |
]. |
|
1875 |
||
1876 |
change := InteractiveAddMethodChange compile:(theCode asString) in:aClass classified:cat. |
|
1877 |
||
1878 |
"/ if collecting, add to changes (to be executed as one change at the end, |
|
1879 |
"/ in order to have only one change in the undo-list (instead of many) |
|
1880 |
compositeChangeCollector notNil ifTrue:[ |
|
1881 |
compositeChangeCollector addChange:change |
|
1882 |
] ifFalse:[ |
|
1883 |
RefactoryChangeManager instance performChange:change. |
|
1884 |
] |
|
1885 |
||
1886 |
"Modified: / 21-08-2006 / 18:39:06 / cg" |
|
1887 |
! ! |
|
3712 | 1888 |
|
5758 | 1889 |
!CodeGeneratorTool methodsFor:'private'! |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1890 |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1891 |
canUseRefactoringSupport |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1892 |
"check if refactory browser stuff is avaliable" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1893 |
|
5758 | 1894 |
^ self class canUseRefactoringSupport |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1895 |
! |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1896 |
|
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1897 |
privCreateClassResponsibleProtocolFor:aClass |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1898 |
"create stubs for the required protocol. |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1899 |
aClass may be a a MetaClass or a non-MetaClass" |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1900 |
|
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1901 |
|selectors| |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1902 |
|
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1903 |
selectors := IdentitySet new. |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1904 |
aClass allSuperclassesDo:[:eachSuperClass | |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1905 |
eachSuperClass methodDictionary keysAndValuesDo:[:eachSelector :eachMethod | |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1906 |
(eachMethod sends:#subclassResponsibility) ifTrue:[ |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1907 |
selectors add:eachSelector. |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1908 |
] |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1909 |
] |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1910 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1911 |
|
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1912 |
selectors do:[:eachSelector | |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1913 |
|mthd comment implClass methodBodyStream| |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1914 |
|
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1915 |
implClass := aClass whichClassIncludesSelector:eachSelector. |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1916 |
implClass ~~ aClass ifTrue:[ |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1917 |
mthd := implClass compiledMethodAt:eachSelector. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1918 |
(mthd sends:#subclassResponsibility) ifTrue:[ |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1919 |
methodBodyStream := '' writeStream. |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1920 |
methodBodyStream |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1921 |
nextPutAll:mthd methodDefinitionTemplate; cr; |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1922 |
nextPutAll:' "'. |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1923 |
|
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1924 |
comment := mthd methodComment. |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1925 |
comment isEmptyOrNil ifTrue:[ |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1926 |
methodBodyStream |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1927 |
nextPutAll:('Superclass <1s> says that I am responsible to implement this method' |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1928 |
expandMacrosWith:implClass name) |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1929 |
] ifFalse:[ |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1930 |
comment asStringCollection do:[:eachLine| |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1931 |
methodBodyStream nextPutAll:eachLine. |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1932 |
] separatedBy:[ |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1933 |
methodBodyStream cr; nextPutAll:' '. |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1934 |
]. |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1935 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1936 |
|
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1937 |
methodBodyStream |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1938 |
nextPut:$"; cr; cr; |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1939 |
nextPutAll:' self shouldImplement'; cr. |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1940 |
|
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1941 |
self |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1942 |
compile:methodBodyStream contents |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1943 |
forClass:aClass |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
1944 |
inCategory:mthd category. |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1945 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1946 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1947 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1948 |
! ! |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
1949 |
|
3712 | 1950 |
!CodeGeneratorTool class methodsFor:'documentation'! |
1951 |
||
1952 |
version |
|
6993 | 1953 |
^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.47 2006-08-25 13:41:38 cg Exp $' |
3712 | 1954 |
! ! |