--- a/Class.st Thu Jan 24 16:50:52 2013 +0100
+++ b/Class.st Thu Jan 24 16:51:02 2013 +0100
@@ -448,7 +448,6 @@
! !
-
!Class methodsFor:'Compatibility-Dolphin'!
defaultCategoryForDolphinClasses
@@ -963,6 +962,21 @@
]
!
+containingNameSpace
+ "return the namespace I am really contained in;
+ For private or anonymous classes, nil is returned -
+ for public classes, Smalltalk is returned."
+
+ |e|
+
+ e := self nameSpace.
+ "/ validate
+ (e at:name ifAbsent:nil) == self ifFalse:[
+ ^ nil
+ ].
+ ^ e
+!
+
environment
"return the namespace I am contained in; ST-80 compatible name"
@@ -1025,27 +1039,31 @@
nameSpace
"return the namespace I am contained in;
For private or anonymous classes, nil is returned -
- for public classes, Smalltalk is returned."
+ for public classes, Smalltalk is returned.
+ For now, this also returns Smalltalk for classes which are actually anonymous;
+ this is left in for a while (because many users f this method expect a non-nil return value).
+ but will change in the future to return nil then.
+ In the meantime, use containingNameSpace, which provides the correct answer"
|idx nsName e|
"/ cached in environment
environment isNil ifTrue:[
- e := Smalltalk. "/ default
-
- name notNil ifTrue:[
- "/ due to the implementation, extract this from my name
- "/ (physically, all classes are found in Smalltalk)
-
- idx := name lastIndexOf:$:.
- idx ~~ 0 ifTrue:[
- (name at:idx-1) == $: ifTrue:[
- nsName := name copyTo:(idx - 2).
- e := Smalltalk at:nsName asSymbol.
- ]
- ].
- ].
- environment := e.
+ e := Smalltalk. "/ default
+
+ name notNil ifTrue:[
+ "/ due to the implementation, extract this from my name
+ "/ (physically, all classes are found in Smalltalk)
+
+ idx := name lastIndexOf:$:.
+ idx ~~ 0 ifTrue:[
+ (name at:idx-1) == $: ifTrue:[
+ nsName := name copyTo:(idx - 2).
+ e := Smalltalk at:nsName asSymbol.
+ ]
+ ].
+ ].
+ environment := e.
].
^ environment
@@ -5498,11 +5516,11 @@
!Class class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.614 2013-01-23 22:03:22 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.615 2013-01-24 15:51:02 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.614 2013-01-23 22:03:22 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.615 2013-01-24 15:51:02 cg Exp $'
!
version_SVN