Class.st
changeset 16020 fa71b75a7550
parent 15947 edce1c1a0ab9
child 16036 5f52c6b43b70
equal deleted inserted replaced
16019:b204c9d6ce6d 16020:fa71b75a7550
  1037 nameSpace
  1037 nameSpace
  1038     "return the namespace I am contained in;
  1038     "return the namespace I am contained in;
  1039      For private or anonymous classes, nil is returned -
  1039      For private or anonymous classes, nil is returned -
  1040      for public classes, Smalltalk is returned.
  1040      for public classes, Smalltalk is returned.
  1041      For now, this also returns Smalltalk for classes which are actually anonymous;
  1041      For now, this also returns Smalltalk for classes which are actually anonymous;
  1042      this is left in for a while (because many users f this method expect a non-nil return value).
  1042      this is left in for a while (because many users of this method expect a non-nil return value).
  1043      but will change in the future to return nil then.
  1043      but will change in the future to return nil then.
  1044      In the meantime, use containingNameSpace, which provides the correct answer"
  1044      In the meantime, use containingNameSpace, which provides the correct answer"
  1045 
  1045 
  1046     |idx nsName e|
  1046     |idx nsName e|
  1047 
  1047 
  1048     "/ cached in environment
  1048     "/ cached in environment
  1049     environment isNil ifTrue:[
  1049     environment isNil ifTrue:[
  1050 	e := Smalltalk. "/ default
  1050         e := Smalltalk. "/ default
  1051 
  1051 
  1052 	name notNil ifTrue:[
  1052         name notNil ifTrue:[
  1053 	    "/ due to the implementation, extract this from my name
  1053             "/ due to the implementation, extract this from my name
  1054 	    "/ (physically, all classes are found in Smalltalk)
  1054             "/ (physically, all classes are found in Smalltalk)
  1055 
  1055 
  1056 	    idx := name lastIndexOf:$:.
  1056             idx := name lastIndexOf:$:.
  1057 	    idx ~~ 0 ifTrue:[
  1057             idx ~~ 0 ifTrue:[
  1058 		(name at:idx-1) == $: ifTrue:[
  1058                 (name at:idx-1) == $: ifTrue:[
  1059 		    nsName := name copyTo:(idx - 2).
  1059                     nsName := name copyTo:(idx - 2).
  1060 		    e := Smalltalk at:nsName asSymbol.
  1060                     e := Smalltalk at:nsName asSymbol.
  1061 		]
  1061                 ]
  1062 	    ].
  1062             ].
  1063 	].
  1063         ].
  1064 	environment := e.
  1064         environment := e.
  1065     ].
  1065     ].
  1066     ^ environment
  1066     ^ environment
  1067 
  1067 
  1068     "Modified: / 20.7.1998 / 14:21:36 / cg"
  1068     "Modified: / 20.7.1998 / 14:21:36 / cg"
  1069 !
  1069 !
  5645 ! !
  5645 ! !
  5646 
  5646 
  5647 !Class class methodsFor:'documentation'!
  5647 !Class class methodsFor:'documentation'!
  5648 
  5648 
  5649 version
  5649 version
  5650     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.633 2014-02-05 17:12:55 cg Exp $'
  5650     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.634 2014-02-13 10:37:50 cg Exp $'
  5651 !
  5651 !
  5652 
  5652 
  5653 version_CVS
  5653 version_CVS
  5654     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.633 2014-02-05 17:12:55 cg Exp $'
  5654     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.634 2014-02-13 10:37:50 cg Exp $'
  5655 !
  5655 !
  5656 
  5656 
  5657 version_SVN
  5657 version_SVN
  5658     ^ '$ Id: Class.st 10643 2011-06-08 21:53:07Z vranyj1  $'
  5658     ^ '$ Id: Class.st 10643 2011-06-08 21:53:07Z vranyj1  $'
  5659 ! !
  5659 ! !