382 "Created: / 27.10.1997 / 16:42:05 / cg" |
382 "Created: / 27.10.1997 / 16:42:05 / cg" |
383 ! ! |
383 ! ! |
384 |
384 |
385 !Class methodsFor:'accessing'! |
385 !Class methodsFor:'accessing'! |
386 |
386 |
|
387 addChangeRecordForClass:aClass andNotifyChangeOf:aspect |
|
388 "writes a change record and notifies dependents." |
|
389 |
|
390 |namespace| |
|
391 |
|
392 self addChangeRecordForClass:aClass. |
|
393 |
|
394 aClass changed:#definition. |
|
395 |
|
396 namespace := aClass nameSpace. |
|
397 namespace changed:#classDefinition with:aClass. |
|
398 namespace ~~ Smalltalk ifTrue:[ |
|
399 Smalltalk changed:#classDefinition with:aClass. |
|
400 ]. |
|
401 namespace changed:aspect with:aClass. |
|
402 namespace ~~ Smalltalk ifTrue:[ |
|
403 Smalltalk changed:aspect with:aClass. |
|
404 ]. |
|
405 ! |
|
406 |
387 addClassVarName:aString |
407 addClassVarName:aString |
388 "add a class variable if not already there and initialize it with nil. |
408 "add a class variable if not already there and initialize it with nil. |
389 Also writes a change record and notifies dependents." |
409 Also writes a change record and notifies dependents." |
390 |
|
391 |namespace| |
|
392 |
410 |
393 (self classVarNames includes:aString) ifFalse:[ |
411 (self classVarNames includes:aString) ifFalse:[ |
394 self classVariableString:(self classVariableString , ' ' , aString). |
412 self classVariableString:(self classVariableString , ' ' , aString). |
395 Class withoutUpdatingChangesDo:[ |
413 Class withoutUpdatingChangesDo:[ |
396 self withAllSubclasses do:[:cls| |
414 self withAllSubclasses do:[:cls| |
397 cls recompileMethodsAccessingAnyClassvarOrGlobal: |
415 cls recompileMethodsAccessingAnyClassvarOrGlobal: |
398 (Array with:aString asSymbol) |
416 (Array with:aString asSymbol) |
399 ]. |
417 ]. |
400 ]. |
418 ]. |
401 self addChangeRecordForClass:self. |
419 self addChangeRecordForClass:self andNotifyChangeOf:#classVariables. |
402 |
|
403 self changed:#definition. |
|
404 (namespace := self nameSpace) changed:#classDefinition with:self. |
|
405 namespace ~~ Smalltalk ifTrue:[ |
|
406 Smalltalk changed:#classDefinition with:self. |
|
407 ]. |
|
408 (namespace := self nameSpace) changed:#classVariables with:self. |
|
409 namespace ~~ Smalltalk ifTrue:[ |
|
410 Smalltalk changed:#classVariables with:self. |
|
411 ]. |
|
412 ] |
420 ] |
413 |
421 |
414 "Created: / 29.10.1995 / 19:40:51 / cg" |
422 "Created: / 29.10.1995 / 19:40:51 / cg" |
415 "Modified: / 23.1.1998 / 15:46:23 / stefan" |
423 "Modified: / 23.1.1998 / 15:46:23 / stefan" |
416 ! |
424 ! |
469 this hides the (current) implementation of classVariables |
477 this hides the (current) implementation of classVariables |
470 from the outside world. Currently, classvars are stored in |
478 from the outside world. Currently, classvars are stored in |
471 the Smalltalk dictionary with a funny name, since there are |
479 the Smalltalk dictionary with a funny name, since there are |
472 no classPools yet. |
480 no classPools yet. |
473 " |
481 " |
474 ^ Smalltalk at:(self name , ':' , aSymbol) asSymbol |
482 ^ Smalltalk at:(self globalKeyForClassVar:aSymbol) |
475 ! |
483 ! |
476 |
484 |
477 classVarAt:aSymbol ifAbsent:exceptionBlock |
485 classVarAt:aSymbol ifAbsent:exceptionBlock |
478 "return the value of a class variable. |
486 "return the value of a class variable. |
479 Currently, this returns nil if there is no such classvar - |
487 Currently, this returns nil if there is no such classvar - |
483 this hides the (current) implementation of classVariables |
491 this hides the (current) implementation of classVariables |
484 from the outside world. Currently, classvars are stored in |
492 from the outside world. Currently, classvars are stored in |
485 the Smalltalk dictionary with a funny name, since there are |
493 the Smalltalk dictionary with a funny name, since there are |
486 no classPools yet. |
494 no classPools yet. |
487 " |
495 " |
488 ^ Smalltalk at:(self name , ':' , aSymbol) asSymbol ifAbsent:exceptionBlock |
496 ^ Smalltalk at:(self globalKeyForClassVar:aSymbol) ifAbsent:exceptionBlock |
489 ! |
497 ! |
490 |
498 |
491 classVarAt:aSymbol put:something |
499 classVarAt:aSymbol put:something |
492 "store something in a classvariable. |
500 "store something in a classvariable. |
493 Currently this creates a global with a funny name if no such |
501 Currently this creates a global with a funny name if no such |
497 this hides the (current) implementation of classVariables |
505 this hides the (current) implementation of classVariables |
498 from the outside world. Currently, classvars are stored in |
506 from the outside world. Currently, classvars are stored in |
499 the Smalltalk dictionary with a funny name, since there are |
507 the Smalltalk dictionary with a funny name, since there are |
500 no classPools yet. |
508 no classPools yet. |
501 " |
509 " |
502 Smalltalk at:(self name , ':' , aSymbol) asSymbol put:something. |
510 Smalltalk at:(self globalKeyForClassVar:aSymbol) put:something. |
503 ! |
511 ! |
504 |
512 |
505 classVarNames |
513 classVarNames |
506 "return a collection of the class variable name-strings. |
514 "return a collection of the class variable name-strings. |
507 Only names of class variables defined in this class are included |
515 Only names of class variables defined in this class are included |
629 |
637 |
630 environment |
638 environment |
631 "return the namespace I am contained in; ST-80 compatible name" |
639 "return the namespace I am contained in; ST-80 compatible name" |
632 |
640 |
633 ^ self nameSpace |
641 ^ self nameSpace |
|
642 ! |
|
643 |
|
644 globalKeyForClassVar:aStringOrSymbol |
|
645 "this helps to encapsulate the (current) implementation of classVariables |
|
646 from the outside world. Currently, classvars are stored in |
|
647 the Smalltalk dictionary with a funny name, since there are |
|
648 no classPools yet. |
|
649 " |
|
650 ^ (self name , ':' , aStringOrSymbol) asSymbol |
634 ! |
651 ! |
635 |
652 |
636 name |
653 name |
637 "return the name of the class. |
654 "return the name of the class. |
638 This returns a symbol (but notice, that other smalltalks might return a string)." |
655 This returns a symbol (but notice, that other smalltalks might return a string)." |
988 "{ Pragma: +optSpace }" |
1005 "{ Pragma: +optSpace }" |
989 |
1006 |
990 "remove a class variable if not already there. |
1007 "remove a class variable if not already there. |
991 Also writes a change record and notifies dependents." |
1008 Also writes a change record and notifies dependents." |
992 |
1009 |
993 |names newNames namespace| |
1010 |names newNames| |
994 |
1011 |
995 names := self classVarNames. |
1012 names := self classVarNames. |
996 (names includes:aString) ifTrue:[ |
1013 (names includes:aString) ifTrue:[ |
997 newNames := ''. |
1014 newNames := ''. |
998 names do:[:nm | nm ~= aString ifTrue:[newNames := newNames , nm , ' ']]. |
1015 names do:[:nm | nm ~= aString ifTrue:[newNames := newNames , nm , ' ']]. |
1001 self withAllSubclasses do:[:cls| |
1018 self withAllSubclasses do:[:cls| |
1002 cls recompileMethodsAccessingAnyClassvarOrGlobal: |
1019 cls recompileMethodsAccessingAnyClassvarOrGlobal: |
1003 (Array with:aString asSymbol) |
1020 (Array with:aString asSymbol) |
1004 ]. |
1021 ]. |
1005 ]. |
1022 ]. |
1006 self addChangeRecordForClass:self. |
1023 self addChangeRecordForClass:self andNotifyChangeOf:#classVariables. |
1007 |
|
1008 self changed:#definition. |
|
1009 (namespace := self nameSpace) changed:#classDefinition with:self. |
|
1010 namespace ~~ Smalltalk ifTrue:[ |
|
1011 Smalltalk changed:#classDefinition with:self. |
|
1012 ]. |
|
1013 (namespace := self nameSpace) changed:#classVariables with:self. |
|
1014 namespace ~~ Smalltalk ifTrue:[ |
|
1015 Smalltalk changed:#classVariables with:self. |
|
1016 ]. |
|
1017 ] |
1024 ] |
1018 |
1025 |
1019 "Created: / 29.10.1995 / 19:42:08 / cg" |
1026 "Created: / 29.10.1995 / 19:42:08 / cg" |
1020 "Modified: / 23.1.1998 / 15:46:33 / stefan" |
1027 "Modified: / 23.1.1998 / 15:46:33 / stefan" |
1021 ! |
1028 ! |
1980 ]. |
1987 ]. |
1981 |
1988 |
1982 fullName := FileOutNameSpaceQuerySignal query == true. |
1989 fullName := FileOutNameSpaceQuerySignal query == true. |
1983 |
1990 |
1984 owner := self owningClass. |
1991 owner := self owningClass. |
1985 owner isNil ifTrue:[ |
1992 ns := self topNameSpace. |
1986 ns := self nameSpace. |
|
1987 ] ifFalse:[ |
|
1988 ns := self topOwningClass nameSpace. |
|
1989 ]. |
|
1990 |
1993 |
1991 (showPackage and:[owner isNil]) ifTrue:[ |
1994 (showPackage and:[owner isNil]) ifTrue:[ |
1992 aStream nextPutAll:'"{ Package: '''. |
1995 aStream nextPutAll:'"{ Package: '''. |
1993 aStream nextPutAll:self package asString. |
1996 aStream nextPutAll:self package asString. |
1994 aStream nextPutAll:''' }"'; cr; cr. |
1997 aStream nextPutAll:''' }"'; cr; cr. |