158 ! ! |
160 ! ! |
159 |
161 |
160 !Metaclass methodsFor:'compiler interface'! |
162 !Metaclass methodsFor:'compiler interface'! |
161 |
163 |
162 browserClass |
164 browserClass |
163 "return the browser to use for this class - |
165 "return the browser to use for this class - |
164 this can be redefined in special classes, to get different browsers" |
166 this can be redefined in special classes, to get different browsers" |
165 |
167 |
166 ^ UserPreferences systemBrowserClass. |
168 ^ UserPreferences systemBrowserClass. |
167 |
169 |
168 "Created: 3.5.1996 / 12:36:40 / cg" |
170 "Created: 3.5.1996 / 12:36:40 / cg" |
169 ! |
171 ! |
170 |
172 |
171 compilerClass |
173 compilerClass |
172 "return the compiler to use for this class - |
174 "return the compiler to use for this class - |
173 this can be redefined in special classes, to compile classes with |
175 this can be redefined in special classes, to compile classes with |
174 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
176 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
175 |
177 |
176 ^ Compiler |
178 ^ self programmingLanguage compilerClass. |
|
179 |
|
180 " |
|
181 Array compilerClass |
|
182 " |
177 ! |
183 ! |
178 |
184 |
179 evaluatorClass |
185 evaluatorClass |
180 "return the compiler to use for expression evaluation for this class - |
186 "return the compiler to use for expression evaluation for this class - |
181 this can be redefined in special classes, to evaluate expressions with |
187 this can be redefined in special classes, to evaluate expressions with |
182 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
188 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
183 |
189 |
184 ^ Compiler |
190 ^ self programmingLanguage evaluatorClass. |
|
191 |
|
192 " |
|
193 Array evaluatorClass |
|
194 " |
185 ! |
195 ! |
186 |
196 |
187 formatterClass |
197 formatterClass |
188 "return the parser to use for formatting (prettyPrinting) this class - |
198 "return the parser to use for formatting (prettyPrinting) this class - |
189 this can be redefined in special classes, to format classes with |
199 this can be redefined in special classes, to format classes with |
190 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
200 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
191 |
201 |
192 ^ Parser |
202 ^ self programmingLanguage formatterClass. |
193 |
203 |
194 "Created: / 27.4.1998 / 15:33:34 / cg" |
204 " |
195 ! |
205 Array formatterClass |
196 |
206 " |
197 language |
207 ! |
198 |
208 |
199 ^SmalltalkLanguage instance |
209 parserClass |
|
210 "return the parser to use for parsing this class - |
|
211 this can be redefined in special classes, to parse classes with |
|
212 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
213 |
|
214 ^ self programmingLanguage parserClass. |
|
215 |
|
216 " |
|
217 Array parserClass |
|
218 " |
|
219 ! |
|
220 |
|
221 programmingLanguage |
|
222 "return the programming language in which this class is written" |
|
223 |
|
224 ^ SmalltalkLanguage instance |
200 |
225 |
201 "Created: / 15-08-2009 / 09:06:25 / Jan Vrany <vranyj1@fel.cvut.cz>" |
226 "Created: / 15-08-2009 / 09:06:25 / Jan Vrany <vranyj1@fel.cvut.cz>" |
202 "Modified: / 16-08-2009 / 10:37:08 / Jan Vrany <vranyj1@fel.cvut.cz>" |
227 "Modified: / 16-08-2009 / 10:37:08 / Jan Vrany <vranyj1@fel.cvut.cz>" |
203 ! |
228 ! |
204 |
229 |
205 parserClass |
|
206 "return the parser to use for parsing this class - |
|
207 this can be redefined in special classes, to parse classes with |
|
208 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
209 |
|
210 ^ Parser |
|
211 |
|
212 "Created: 18.4.1997 / 21:02:41 / cg" |
|
213 ! |
|
214 |
|
215 realSubclassDefinerClass |
230 realSubclassDefinerClass |
216 ^ self evaluatorClass |
231 ^ self evaluatorClass |
217 ! |
232 ! |
218 |
233 |
219 subclassDefinerClass |
234 subclassDefinerClass |
220 "Answer an evaluator class appropriate for evaluating definitions of new |
235 "Answer an evaluator class appropriate for evaluating definitions of new |
221 subclasses of this class." |
236 subclasses of this class." |
222 |
237 |
223 ^ self evaluatorClass |
238 ^ self evaluatorClass |
224 |
239 |
225 |
240 |
226 ! |
241 ! |
227 |
242 |
228 syntaxHighlighterClass |
243 syntaxHighlighterClass |
229 "return the class to use for syntaxHighlighting (prettyPrinting) this class - |
244 "return the class to use for syntaxHighlighting (prettyPrinting) this class - |
230 this can be redefined in special classes, to highlight classes with |
245 this can be redefined in special classes, to highlight classes with |
231 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
246 Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
232 |
247 |
233 ^ SyntaxHighlighter |
248 ^ self programmingLanguage syntaxHighlighterClass. |
234 |
249 |
235 "Created: / 27.4.1998 / 15:34:08 / cg" |
250 " |
|
251 Array syntaxHighlighterClass |
|
252 " |
236 ! ! |
253 ! ! |
237 |
254 |
238 !Metaclass methodsFor:'copying'! |
255 !Metaclass methodsFor:'copying'! |
239 |
256 |
240 postCopy |
257 postCopy |
244 ! ! |
261 ! ! |
245 |
262 |
246 !Metaclass methodsFor:'creating classes'! |
263 !Metaclass methodsFor:'creating classes'! |
247 |
264 |
248 name:newName inEnvironment:aNameSpaceOrOwningClass |
265 name:newName inEnvironment:aNameSpaceOrOwningClass |
249 subclassOf:aClass |
266 subclassOf:aClass |
250 instanceVariableNames:stringOfInstVarNames |
267 instanceVariableNames:stringOfInstVarNames |
251 variable:variableBoolean |
268 variable:variableBoolean |
252 words:wordsBoolean |
269 words:wordsBoolean |
253 pointers:pointersBoolean |
270 pointers:pointersBoolean |
254 classVariableNames:stringOfClassVarNames |
271 classVariableNames:stringOfClassVarNames |
255 poolDictionaries:stringOfPoolNames |
272 poolDictionaries:stringOfPoolNames |
256 category:categoryString |
273 category:categoryString |
257 comment:commentString |
274 comment:commentString |
258 changed:changed |
275 changed:changed |
259 |
276 |
260 ^ self |
277 ^ self |
261 name:newName |
278 name:newName |
262 inEnvironment:aNameSpaceOrOwningClass |
279 inEnvironment:aNameSpaceOrOwningClass |
263 subclassOf:aClass |
280 subclassOf:aClass |
264 instanceVariableNames:stringOfInstVarNames |
281 instanceVariableNames:stringOfInstVarNames |
265 variable:variableBoolean |
282 variable:variableBoolean |
266 words:wordsBoolean |
283 words:wordsBoolean |
267 pointers:pointersBoolean |
284 pointers:pointersBoolean |
268 classVariableNames:stringOfClassVarNames |
285 classVariableNames:stringOfClassVarNames |
269 poolDictionaries:stringOfPoolNames |
286 poolDictionaries:stringOfPoolNames |
270 category:categoryString |
287 category:categoryString |
271 comment:commentString |
288 comment:commentString |
272 changed:changed |
289 changed:changed |
273 classInstanceVariableNames:nil |
290 classInstanceVariableNames:nil |
274 |
291 |
275 "Modified: 16.6.1997 / 11:53:58 / cg" |
292 "Modified: 16.6.1997 / 11:53:58 / cg" |
276 ! |
293 ! |
277 |
294 |
278 name:newName inEnvironment:aNameSpaceOrOwningClass |
295 name:newName inEnvironment:aNameSpaceOrOwningClass |
279 subclassOf:aClass |
296 subclassOf:aClass |
280 instanceVariableNames:stringOfInstVarNames |
297 instanceVariableNames:stringOfInstVarNames |
281 variable:variableBoolean |
298 variable:variableBoolean |
282 words:wordsBoolean |
299 words:wordsBoolean |
283 pointers:pointersBoolean |
300 pointers:pointersBoolean |
284 classVariableNames:stringOfClassVarNames |
301 classVariableNames:stringOfClassVarNames |
285 poolDictionaries:stringOfPoolNames |
302 poolDictionaries:stringOfPoolNames |
286 category:categoryString |
303 category:categoryString |
287 comment:commentString |
304 comment:commentString |
288 changed:changed |
305 changed:changed |
289 classInstanceVariableNames:stringOfClassInstVarNamesOrNil |
306 classInstanceVariableNames:stringOfClassInstVarNamesOrNil |
290 |
307 |
291 "this is the main workhorse for installing new classes - special care |
308 "this is the main workhorse for installing new classes - special care |
292 has to be taken, when changing an existing classes definition. In this |
309 has to be taken, when changing an existing classes definition. In this |
293 case, some or all of the methods and subclasses methods have to be |
310 case, some or all of the methods and subclasses methods have to be |
294 recompiled. |
311 recompiled. |
295 Also, the old class(es) are still kept (but not accessable as a global), |
312 Also, the old class(es) are still kept (but not accessable as a global), |
296 to allow existing instances some life. |
313 to allow existing instances some life. |
297 This might change in the future. |
314 This might change in the future. |
298 " |
315 " |
299 |builder| |
316 |builder| |
300 |
317 |
301 builder := self newClassBuilder. |
318 builder := self newClassBuilder. |
302 builder name:newName |
319 builder name:newName |
303 inEnvironment:aNameSpaceOrOwningClass |
320 inEnvironment:aNameSpaceOrOwningClass |
304 subclassOf:aClass |
321 subclassOf:aClass |
305 instanceVariableNames:stringOfInstVarNames |
322 instanceVariableNames:stringOfInstVarNames |
306 variable:variableBoolean |
323 variable:variableBoolean |
307 words:wordsBoolean |
324 words:wordsBoolean |
308 pointers:pointersBoolean |
325 pointers:pointersBoolean |
309 classVariableNames:stringOfClassVarNames |
326 classVariableNames:stringOfClassVarNames |
310 poolDictionaries:stringOfPoolNames |
327 poolDictionaries:stringOfPoolNames |
311 category:categoryString |
328 category:categoryString |
312 comment:commentString |
329 comment:commentString |
313 changed:changed |
330 changed:changed |
314 classInstanceVariableNames:stringOfClassInstVarNamesOrNil. |
331 classInstanceVariableNames:stringOfClassInstVarNamesOrNil. |
315 ^ builder buildClass. |
332 ^ builder buildClass. |
316 ! |
333 ! |
317 |
334 |
318 new |
335 new |
319 "create & return a new metaclass (a classes class). |
336 "create & return a new metaclass (a classes class). |
356 |
373 |
357 "metaclasses are not found via Smalltalk allClassesDo: |
374 "metaclasses are not found via Smalltalk allClassesDo: |
358 here, walk over classes and enumerate corresponding metas" |
375 here, walk over classes and enumerate corresponding metas" |
359 |
376 |
360 self soleInstance subclassesDo:[:aSubClass | |
377 self soleInstance subclassesDo:[:aSubClass | |
361 aBlock value:aSubClass class |
378 aBlock value:aSubClass class |
362 ]. |
379 ]. |
363 ! ! |
380 ! ! |
364 |
381 |
365 !Metaclass methodsFor:'fileOut'! |
382 !Metaclass methodsFor:'fileOut'! |
366 |
383 |
367 basicFileOutDefinitionOf:aClass on:aStream withNameSpace:forceNameSpace withPackage:showPackage |
384 basicFileOutDefinitionOf:aClass on:aStream withNameSpace:forceNameSpace withPackage:showPackage |
368 "append an expression on aStream, which defines myself." |
385 "append an expression on aStream, which defines myself." |
369 |
386 |
370 |syntaxHilighting| |
387 |syntaxHilighting| |
371 |
388 |
372 UserPreferences isNil ifTrue:[ |
389 UserPreferences isNil ifTrue:[ |
373 syntaxHilighting := false |
390 syntaxHilighting := false |
374 ] ifFalse:[ |
391 ] ifFalse:[ |
375 syntaxHilighting := UserPreferences current syntaxColoring. |
392 syntaxHilighting := UserPreferences current syntaxColoring. |
376 ]. |
393 ]. |
377 self |
394 self |
378 basicFileOutDefinitionOf:aClass |
395 basicFileOutDefinitionOf:aClass |
379 on:aStream |
396 on:aStream |
380 withNameSpace:forceNameSpace |
397 withNameSpace:forceNameSpace |
381 withPackage:showPackage |
398 withPackage:showPackage |
382 syntaxHilighting:syntaxHilighting |
399 syntaxHilighting:syntaxHilighting |
383 ! |
400 ! |
384 |
401 |
385 basicFileOutDefinitionOf:aClass on:aStream withNameSpace:forceNameSpace withPackage:showPackage syntaxHilighting:syntaxHilighting |
402 basicFileOutDefinitionOf:aClass on:aStream withNameSpace:forceNameSpace withPackage:showPackage syntaxHilighting:syntaxHilighting |
386 "append an expression on aStream, which defines myself." |
403 "append an expression on aStream, which defines myself." |
387 |
404 |
447 "/ exists in my owning class, |
464 "/ exists in my owning class, |
448 "/ THEN we MUST add the smalltalk-prefix. |
465 "/ THEN we MUST add the smalltalk-prefix. |
449 "/ (otherwise, we get the private class as superclass when accepting the |
466 "/ (otherwise, we get the private class as superclass when accepting the |
450 "/ next time) |
467 "/ next time) |
451 (owner notNil |
468 (owner notNil |
452 and:[ superclassNamespace == Smalltalk |
469 and:[ superclassNamespace == Smalltalk |
453 and:[ (owner privateClassesAt:superclass name) notNil ]]) ifTrue:[ |
470 and:[ (owner privateClassesAt:superclass name) notNil ]]) ifTrue:[ |
454 s := superclass nameWithNameSpacePrefix. |
471 s := superclass nameWithNameSpacePrefix. |
455 ] ifFalse:[ |
472 ] ifFalse:[ |
456 fullName ifTrue:[ |
473 fullName ifTrue:[ |
457 s := superclass name. |
474 s := superclass name. |
458 ] ifFalse:[ |
475 ] ifFalse:[ |
459 (ns == superclassNamespace |
476 (ns == superclassNamespace |
460 and:[superclass owningClass isNil]) ifTrue:[ |
477 and:[superclass owningClass isNil]) ifTrue:[ |
461 "/ superclass is in the same namespace and not private; |
478 "/ superclass is in the same namespace and not private; |
462 "/ still prepend namespace prefix for private classes, |
479 "/ still prepend namespace prefix for private classes, |
463 "/ to avoid confusing stc, which needs that information. |
480 "/ to avoid confusing stc, which needs that information. |
464 "/ LATE note (AUG2002) - no longer; stc was fixed. |
481 "/ LATE note (AUG2002) - no longer; stc was fixed. |
491 s := superclassNamespace name , '::' , superNameWithoutNameSpacePrefix |
508 s := superclassNamespace name , '::' , superNameWithoutNameSpacePrefix |
492 ] ifFalse:[ |
509 ] ifFalse:[ |
493 "/ no class with that name found in my namespace ... |
510 "/ no class with that name found in my namespace ... |
494 "/ if the superclass resides in Smalltalk, |
511 "/ if the superclass resides in Smalltalk, |
495 "/ suppress prefix; otherwise, use full prefix. |
512 "/ suppress prefix; otherwise, use full prefix. |
496 (superclassNamespace notNil |
513 (superclassNamespace notNil |
497 and:[superclassNamespace ~~ Smalltalk]) ifTrue:[ |
514 and:[superclassNamespace ~~ Smalltalk]) ifTrue:[ |
498 (owner notNil |
515 (owner notNil |
499 and:[(topOwner := owner topOwningClass) notNil |
516 and:[(topOwner := owner topOwningClass) notNil |
500 and:[superclass topOwningClass notNil |
517 and:[superclass topOwningClass notNil |
501 and:[topOwner nameSpace == superclass topOwningClass "owningClass" nameSpace] |
518 and:[topOwner nameSpace == superclass topOwningClass "owningClass" nameSpace] |
598 "append an expression to define my classInstanceVariables on aStream" |
615 "append an expression to define my classInstanceVariables on aStream" |
599 |
616 |
600 |anySuperClassInstVar| |
617 |anySuperClassInstVar| |
601 |
618 |
602 myClass isLoaded ifFalse:[ |
619 myClass isLoaded ifFalse:[ |
603 ^ myClass basicFileOutDefinitionOn:aStream withNameSpace:withNameSpace |
620 ^ myClass basicFileOutDefinitionOn:aStream withNameSpace:withNameSpace |
604 ]. |
621 ]. |
605 |
622 |
606 withNameSpace ifTrue:[ |
623 withNameSpace ifTrue:[ |
607 myClass name printOn:aStream. |
624 myClass name printOn:aStream. |
608 ] ifFalse:[ |
625 ] ifFalse:[ |
609 myClass printClassNameOn:aStream. |
626 myClass printClassNameOn:aStream. |
610 ]. |
627 ]. |
611 aStream nextPutAll:' class instanceVariableNames:'''. |
628 aStream nextPutAll:' class instanceVariableNames:'''. |
612 self printInstVarNamesOn:aStream indent:8. |
629 self printInstVarNamesOn:aStream indent:8. |
613 aStream nextPutAll:''''. |
630 aStream nextPutAll:''''. |
614 |
631 |
615 "mhmh - good idea; saw this in SmallDraw sourcecode ..." |
632 "mhmh - good idea; saw this in SmallDraw sourcecode ..." |
616 |
633 |
617 anySuperClassInstVar := false. |
634 anySuperClassInstVar := false. |
618 myClass allSuperclassesDo:[:aSuperClass | |
635 myClass allSuperclassesDo:[:aSuperClass | |
619 aSuperClass class instVarNames do:[:ignored | anySuperClassInstVar := true]. |
636 aSuperClass class instVarNames do:[:ignored | anySuperClassInstVar := true]. |
620 ]. |
637 ]. |
621 |
638 |
622 aStream cr; cr; nextPut:(Character doubleQuote); cr; space. |
639 aStream cr; cr; nextPut:(Character doubleQuote); cr; space. |
623 anySuperClassInstVar ifFalse:[ |
640 anySuperClassInstVar ifFalse:[ |
624 aStream |
641 aStream |
625 nextPutLine:'No other class instance variables are inherited by this class.'. |
642 nextPutLine:'No other class instance variables are inherited by this class.'. |
626 ] ifTrue:[ |
643 ] ifTrue:[ |
627 aStream |
644 aStream |
628 nextPutLine:'The following class instance variables are inherited by this class:'. |
645 nextPutLine:'The following class instance variables are inherited by this class:'. |
629 aStream cr. |
646 aStream cr. |
630 myClass allSuperclassesDo:[:aSuperClass | |
647 myClass allSuperclassesDo:[:aSuperClass | |
631 aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '. |
648 aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '. |
632 aStream nextPutLine:(aSuperClass class instanceVariableString). |
649 aStream nextPutLine:(aSuperClass class instanceVariableString). |
633 ]. |
650 ]. |
634 |
651 |
635 ]. |
652 ]. |
636 aStream nextPut:(Character doubleQuote); cr. |
653 aStream nextPut:(Character doubleQuote); cr. |
637 |
654 |
638 "Created: / 10.12.1995 / 16:31:25 / cg" |
655 "Created: / 10.12.1995 / 16:31:25 / cg" |
652 If initIt is true, and the class implements a class-initialize method, |
669 If initIt is true, and the class implements a class-initialize method, |
653 append a corresponding doIt expression for initialization. |
670 append a corresponding doIt expression for initialization. |
654 The order by which the fileOut is done is used to put the version string at the end. |
671 The order by which the fileOut is done is used to put the version string at the end. |
655 Thus, if the version string is expanded (by CVS), the characterPositions of methods should not move" |
672 Thus, if the version string is expanded (by CVS), the characterPositions of methods should not move" |
656 |
673 |
657 self language sourceFileWriterClass new |
674 self programmingLanguage sourceFileWriterClass new |
658 fileOut:myClass on:outStreamArg withTimeStamp:stampIt |
675 fileOut:myClass on:outStreamArg withTimeStamp:stampIt |
659 withInitialize:initIt withDefinition:withDefinition |
676 withInitialize:initIt withDefinition:withDefinition |
660 methodFilter:methodFilter encoder:encoderOrNil |
677 methodFilter:methodFilter encoder:encoderOrNil |
661 |
678 ! ! |
662 "Modified: / 16-08-2009 / 09:52:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
679 |
663 ! ! |
680 !Metaclass methodsFor:'method templates'! |
664 |
681 |
|
682 versionMethodTemplateForSourceCodeManager:aSourceCodeManager |
|
683 ^ aSourceCodeManager versionMethodTemplateForSmalltalk |
|
684 ! ! |
|
685 |
|
686 !Metaclass methodsFor:'misc ui support'! |
|
687 |
|
688 iconInBrowserSymbol |
|
689 "can be redefined for a private icon in the browser. |
|
690 The returned symbol must be a selector of the ToolbarIconLibrary." |
|
691 |
|
692 ^ nil |
|
693 ! ! |
665 |
694 |
666 !Metaclass methodsFor:'private'! |
695 !Metaclass methodsFor:'private'! |
667 |
696 |
668 setSoleInstance:aClass |
697 setSoleInstance:aClass |
669 myClass := aClass |
698 myClass := aClass |
670 |
699 |
671 "Created: 12.12.1995 / 13:46:22 / cg" |
700 "Created: 12.12.1995 / 13:46:22 / cg" |
672 ! ! |
701 ! ! |
673 |
702 |
674 !Metaclass methodsFor:'queries'! |
703 !Metaclass methodsFor:'queries'! |
675 |
704 |
676 category |
705 category |
677 "return my category" |
706 "return my category" |
678 |
707 |
679 myClass isNil ifTrue:[^ nil]. |
708 myClass isNil ifTrue:[^ nil]. |
680 ^ myClass category |
709 ^ myClass category |
681 |
710 |
682 "Created: 2.4.1997 / 00:46:11 / stefan" |
711 "Created: 2.4.1997 / 00:46:11 / stefan" |
683 ! |
712 ! |
684 |
713 |