NameSpace.st
changeset 17510 a56a2f138fc2
parent 17443 aace790cb58b
child 18120 e3a375d5f6a8
child 20805 5e4783d33953
equal deleted inserted replaced
17509:f5e1bb810210 17510:a56a2f138fc2
    66 fullName:aFullNameSpacePathName
    66 fullName:aFullNameSpacePathName
    67     "given a possibly nested name of a namespace, create all required
    67     "given a possibly nested name of a namespace, create all required
    68      intermediate spaces (if not already existing) and return the
    68      intermediate spaces (if not already existing) and return the
    69      bottom-level space."
    69      bottom-level space."
    70 
    70 
       
    71     ^ self fullName:aFullNameSpacePathName createIfAbsent:true
       
    72 
       
    73     "Created: 8.11.1996 / 13:41:59 / cg"
       
    74     "Modified: 4.1.1997 / 16:50:59 / cg"
       
    75 !
       
    76 
       
    77 fullName:aFullNameSpacePathName createIfAbsent:createIfAbsent
       
    78     "given a possibly nested name of a namespace, lookup and return
       
    79      a namespace instance for it.
       
    80      If createIfAbsent is true, create all required intermediate spaces (if not already existing) 
       
    81      and return the bottom-level space.
       
    82      If false, and if any namespace along the path does not exist, reutrn nil."
       
    83 
       
    84     |list thisNamespace|
       
    85 
    71     "/ break it up, check for all intermediate spaces to exist
    86     "/ break it up, check for all intermediate spaces to exist
    72     "/ create them as required.
    87     "/ create them as required.
    73 
       
    74     |list thisNamespace|
       
    75 
    88 
    76     (aFullNameSpacePathName includes:$:) ifTrue:[
    89     (aFullNameSpacePathName includes:$:) ifTrue:[
    77         "/ old style
    90         "/ old style
    78         list := aFullNameSpacePathName asCollectionOfSubstringsSeparatedByAll:'::'.
    91         list := aFullNameSpacePathName asCollectionOfSubstringsSeparatedByAll:'::'.
    79     ] ifFalse:[
    92     ] ifFalse:[
    92         thisNamespace isNil ifTrue:[
   105         thisNamespace isNil ifTrue:[
    93             (Smalltalk includesKey:key) ifTrue:[
   106             (Smalltalk includesKey:key) ifTrue:[
    94                 thisNamespace := Smalltalk at:key.
   107                 thisNamespace := Smalltalk at:key.
    95                 (thisNamespace notNil
   108                 (thisNamespace notNil
    96                 and:[thisNamespace isBehavior not]) ifTrue:[
   109                 and:[thisNamespace isBehavior not]) ifTrue:[
       
   110                     createIfAbsent ifFalse:[ ^ nil ].
    97                     self error:'name conflict: namespace ' , aName , ' vs. global'.
   111                     self error:'name conflict: namespace ' , aName , ' vs. global'.
    98                 ]
   112                 ]
    99             ].
   113             ].
   100             thisNamespace isNil ifTrue:[
   114             thisNamespace isNil ifTrue:[
       
   115                 createIfAbsent ifFalse:[ ^ nil ].
   101                 thisNamespace := self name:key
   116                 thisNamespace := self name:key
   102             ].
   117             ].
   103         ] ifFalse:[
   118         ] ifFalse:[
   104             thisNamespace isNameSpace ifTrue:[
   119             thisNamespace isNameSpace ifTrue:[
   105                 x := thisNamespace at:key.
   120                 x := thisNamespace at:key.
   108                     x := thisNamespace privateClassesAt:key.
   123                     x := thisNamespace privateClassesAt:key.
   109                 ].
   124                 ].
   110             ].
   125             ].
   111 
   126 
   112             x isNil ifTrue:[
   127             x isNil ifTrue:[
       
   128                 createIfAbsent ifFalse:[ ^ nil ].
   113                 thisNamespace isNameSpace ifTrue:[
   129                 thisNamespace isNameSpace ifTrue:[
   114 		    thisNamespace == Smalltalk ifTrue:[
   130                     thisNamespace == Smalltalk ifTrue:[
   115 			x := self name:key
   131                         x := self name:key
   116 		    ] ifFalse:[
   132                     ] ifFalse:[
   117                         x := thisNamespace name:key.
   133                         x := thisNamespace name:key.
   118 		    ]
   134                     ]
   119                 ] ifFalse:[
   135                 ] ifFalse:[
   120                     x :=
   136                     x :=
   121                         self subclass:key
   137                         self subclass:key
   122                            instanceVariableNames:''
   138                            instanceVariableNames:''
   123                            classVariableNames:''
   139                            classVariableNames:''
   738 ! !
   754 ! !
   739 
   755 
   740 !NameSpace class methodsFor:'documentation'!
   756 !NameSpace class methodsFor:'documentation'!
   741 
   757 
   742 version_CVS
   758 version_CVS
   743     ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.78 2015-02-07 15:39:13 cg Exp $'
   759     ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.79 2015-02-19 09:44:38 cg Exp $'
   744 !
   760 !
   745 
   761 
   746 version_SVN
   762 version_SVN
   747     ^ '$ Id: NameSpace.st 10643 2011-06-08 21:53:07Z vranyj1  $'
   763     ^ '$ Id: NameSpace.st 10643 2011-06-08 21:53:07Z vranyj1  $'
   748 ! !
   764 ! !