author | Claus Gittinger <cg@exept.de> |
Wed, 16 Feb 2005 13:29:58 +0100 | |
changeset 8744 | 73522a385e11 |
parent 7575 | 80341bf0e03e |
child 8747 | 0cbc897606c2 |
permissions | -rw-r--r-- |
1827 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
13 |
|
5464 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
5331 | 16 |
Object subclass:#NameSpace |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
17 |
instanceVariableNames:'category' |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
18 |
classVariableNames:'' |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
19 |
poolDictionaries:'' |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
20 |
category:'Kernel-Classes' |
1933 | 21 |
! |
1827 | 22 |
|
5331 | 23 |
!NameSpace class methodsFor:'documentation'! |
1827 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
1816 | 38 |
! |
39 |
||
1827 | 40 |
documentation |
41 |
" |
|
5331 | 42 |
A NameSpace is actually a dummy class, providing a home |
2010 | 43 |
for its private classes. |
44 |
Thus, internally, the same mechanism is used for classes in |
|
5331 | 45 |
a NameSpace and private classes. |
2010 | 46 |
This has two advantages: |
1828 | 47 |
- we only need one mechanism for both namespaces |
48 |
and private classes |
|
49 |
||
50 |
- there are no possible conflicts between a class |
|
51 |
and a namespace named alike. |
|
52 |
||
1816 | 53 |
|
1827 | 54 |
[author:] |
55 |
Claus Gittinger |
|
56 |
||
57 |
[see also:] |
|
58 |
Behavior ClassDescription Class Metaclass |
|
59 |
PrivateMetaclass |
|
60 |
" |
|
61 |
||
62 |
! ! |
|
63 |
||
5331 | 64 |
!NameSpace class methodsFor:'instance creation'! |
1828 | 65 |
|
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
66 |
fullName:aFullNameSpacePathName |
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
67 |
"given a possibly nested name of a namespace, create all required |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
68 |
intermediate spaces (if not already existing) and return the |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
69 |
bottom-level space." |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
70 |
|
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
71 |
"/ break it up, check for all intermediate spaces to exist |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
72 |
"/ create them as required. |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
73 |
|
7426
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
74 |
|list thisNamespace| |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
75 |
|
7426
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
76 |
(aFullNameSpacePathName includes:$:) ifTrue:[ |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
77 |
"/ old style |
8744
73522a385e11
oops - fullName did not handle '::' correctly
Claus Gittinger <cg@exept.de>
parents:
7575
diff
changeset
|
78 |
list := aFullNameSpacePathName asCollectionOfSubstringsSeparatedByAll:'::'. |
7426
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
79 |
] ifFalse:[ |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
80 |
"/ new style |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
81 |
list := aFullNameSpacePathName asCollectionOfSubstringsSeparatedBy:$.. |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
82 |
]. |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
83 |
|
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
84 |
"/ now, look and create 'em |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
85 |
|
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
86 |
thisNamespace := nil. |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
87 |
list do:[:aName | |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
88 |
|key x| |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
89 |
|
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
90 |
key := aName asSymbol. |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
91 |
|
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
92 |
thisNamespace isNil ifTrue:[ |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
93 |
(Smalltalk includesKey:key) ifTrue:[ |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
94 |
thisNamespace := Smalltalk at:key. |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
95 |
(thisNamespace notNil |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
96 |
and:[thisNamespace isBehavior not]) ifTrue:[ |
4522
29a6625dc7b1
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
97 |
self error:'name conflict: namespace ' , aName , ' vs. global'. |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
98 |
] |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
99 |
]. |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
100 |
thisNamespace isNil ifTrue:[ |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
101 |
thisNamespace := self name:key |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
102 |
] |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
103 |
] ifFalse:[ |
7426
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
104 |
thisNamespace isNameSpace ifTrue:[ |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
105 |
x := thisNamespace at:key. |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
106 |
] ifFalse:[ |
7426
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
107 |
thisNamespace isBehavior ifTrue:[ |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
108 |
x := thisNamespace privateClassesAt:key. |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
109 |
]. |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
110 |
]. |
2055 | 111 |
|
7426
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
112 |
x isNil ifTrue:[ |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
113 |
thisNamespace isNameSpace ifTrue:[ |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
114 |
x := thisNamespace name:key. |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
115 |
] ifFalse:[ |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
116 |
x := |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
117 |
self subclass:key |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
118 |
instanceVariableNames:'' |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
119 |
classVariableNames:'' |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
120 |
poolDictionaries:'' |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
121 |
privateIn:thisNamespace. |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
122 |
]. |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
123 |
|
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
124 |
"/ nameSpaces are not in any package (yet) |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
125 |
x setPackage:nil. |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
126 |
]. |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
127 |
thisNamespace := x. |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
128 |
] |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
129 |
]. |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
130 |
|
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
131 |
^ thisNamespace |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
132 |
|
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
133 |
"Created: 8.11.1996 / 13:41:59 / cg" |
2055 | 134 |
"Modified: 4.1.1997 / 16:50:59 / cg" |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
135 |
! |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
136 |
|
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
137 |
name:aStringOrSymbol |
2177
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
138 |
"create a new nameSpace, named aStringOrSymbol. |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
139 |
Notice, that the nameSpace is created in the current one - |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
140 |
dont get confused; we recommend, not to nest them too much." |
1908 | 141 |
|
7575
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
142 |
|currentNameSpace newNameSpace existing ok nameSym fullName| |
1828 | 143 |
|
2024
71a088db4583
validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents:
2015
diff
changeset
|
144 |
ok := aStringOrSymbol first isLetter. |
71a088db4583
validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents:
2015
diff
changeset
|
145 |
ok ifTrue:[ |
2177
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
146 |
(aStringOrSymbol |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
147 |
findFirst:[:ch | (ch isLetterOrDigit or:[ch == $_]) not] |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
148 |
startingAt:2) ~~ 0 |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
149 |
ifTrue:[ |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
150 |
ok := false. |
2024
71a088db4583
validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents:
2015
diff
changeset
|
151 |
] |
71a088db4583
validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents:
2015
diff
changeset
|
152 |
]. |
71a088db4583
validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents:
2015
diff
changeset
|
153 |
ok ifFalse:[ |
2025 | 154 |
self error:'invalid namespace name:''' , aStringOrSymbol printString , ''' (must be a valid identifier)'. |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
155 |
]. |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
156 |
|
5249
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
157 |
nameSym := aStringOrSymbol asSymbol. |
3383 | 158 |
|
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
159 |
self == NameSpace ifTrue:[ |
7575
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
160 |
"/ currentNameSpace := Class nameSpaceQuerySignal query. |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
161 |
currentNameSpace isNil ifTrue:[ |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
162 |
currentNameSpace := Smalltalk |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
163 |
]. |
5249
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
164 |
fullName := nameSym |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
165 |
] ifFalse:[ |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
166 |
currentNameSpace := self. |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
167 |
fullName := (self name , '::' , nameSym) asSymbol |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
168 |
]. |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
169 |
|
3383 | 170 |
(existing := currentNameSpace at:nameSym) notNil ifTrue:[ |
2015 | 171 |
^ existing |
172 |
]. |
|
7575
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
173 |
newNameSpace := self |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
174 |
subclass:fullName |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
175 |
instanceVariableNames:'' |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
176 |
classVariableNames:'' |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
177 |
poolDictionaries:'' |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
178 |
category:'uncategorized namespace' |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
179 |
inEnvironment:Smalltalk. |
2144 | 180 |
|
2055 | 181 |
"/ nameSpaces are not in any package |
7575
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
182 |
newNameSpace notNil ifTrue:[newNameSpace setPackage:nil]. |
80341bf0e03e
bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents:
7433
diff
changeset
|
183 |
^ newNameSpace |
1901 | 184 |
|
185 |
" |
|
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
186 |
NameSpace name:'foo' |
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
187 |
(NameSpace name:'foo') category:'my name space' |
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
188 |
foo at:#bar put:(Metaclass new new) |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
189 |
(NameSpace name:'foo') name:'bar' |
1901 | 190 |
" |
2177
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
191 |
" |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
192 |
NameSpace name:'an-invalid++name' |
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
193 |
NameSpace name:'another:invalidName' |
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
194 |
NameSpace name:'another::invalidName' |
2177
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
195 |
" |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
196 |
|
4058
58987b73c0c7
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3383
diff
changeset
|
197 |
"Modified: / 14.9.1997 / 09:46:59 / cg" |
58987b73c0c7
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3383
diff
changeset
|
198 |
"Modified: / 18.3.1999 / 18:24:13 / stefan" |
1828 | 199 |
! |
200 |
||
201 |
new |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
202 |
"catch new - namespaces are not to be created by the user" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
203 |
|
1828 | 204 |
self error:'namespaces are not to be created with new' |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
205 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
206 |
"Modified: 8.11.1996 / 21:38:00 / cg" |
1828 | 207 |
! ! |
208 |
||
7298 | 209 |
!NameSpace class methodsFor:'Compatibility-VW5.4'! |
6450 | 210 |
|
211 |
defineClass: name |
|
212 |
superclass: superclass |
|
213 |
indexedType: indexed |
|
214 |
private: private |
|
215 |
instanceVariableNames: instVars |
|
216 |
classInstanceVariableNames: classInstVars |
|
217 |
imports: imports |
|
218 |
category: category |
|
219 |
||
220 |
^ self |
|
221 |
defineClass: name |
|
222 |
superclass: superclass |
|
223 |
indexedType: indexed |
|
224 |
private: private |
|
225 |
instanceVariableNames: instVars |
|
226 |
classInstanceVariableNames: classInstVars |
|
227 |
imports: imports |
|
228 |
category: category |
|
229 |
attributes: nil |
|
230 |
! |
|
231 |
||
232 |
defineClass: name |
|
7431 | 233 |
superclass: superclassOrName |
6450 | 234 |
indexedType: indexed |
235 |
private: private |
|
236 |
instanceVariableNames: instVars |
|
237 |
classInstanceVariableNames: classInstVars |
|
238 |
imports: imports |
|
239 |
category: category |
|
240 |
attributes: annotations |
|
241 |
||
242 |
"VW5i compatibility class/namespace creation" |
|
243 |
||
7431 | 244 |
|variable words pointers superclass| |
6450 | 245 |
|
246 |
variable := words := pointers := false. |
|
247 |
indexed ~~ #none ifTrue:[ |
|
7433 | 248 |
self shouldImplement. |
6450 | 249 |
]. |
7431 | 250 |
superclassOrName isSymbol ifTrue:[ |
251 |
superclass := Smalltalk at:superclassOrName. |
|
252 |
superclass isNil ifTrue:[ |
|
253 |
self error:'missing superclass: ' , superclassOrName. |
|
254 |
] |
|
255 |
] ifFalse:[ |
|
256 |
superclass := superclassOrName |
|
257 |
]. |
|
6450 | 258 |
^ superclass value class |
259 |
name:name |
|
6824
6fbe85d05646
...in:... -> ...inEnvironment:...
Claus Gittinger <cg@exept.de>
parents:
6450
diff
changeset
|
260 |
inEnvironment:self |
6450 | 261 |
subclassOf:superclass value |
262 |
instanceVariableNames:instVars |
|
263 |
variable:variable |
|
264 |
words:words |
|
265 |
pointers:pointers |
|
266 |
classVariableNames:'' |
|
267 |
poolDictionaries:'' |
|
268 |
category:category |
|
269 |
comment:nil |
|
270 |
changed:true |
|
271 |
classInstanceVariableNames:classInstVars |
|
272 |
! ! |
|
273 |
||
5331 | 274 |
!NameSpace class methodsFor:'accessing'! |
1827 | 275 |
|
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
276 |
allClasses |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
277 |
|classes| |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
278 |
|
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
279 |
classes := IdentitySet new. |
5581 | 280 |
self allClassesDo:[:aClass | classes add:aClass]. |
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
281 |
^ classes |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
282 |
|
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
283 |
"Modified: 20.12.1996 / 15:34:50 / cg" |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
284 |
! |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
285 |
|
4372
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
286 |
allClassesWithAllPrivateClasses |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
287 |
|classes| |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
288 |
|
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
289 |
classes := IdentitySet new. |
5581 | 290 |
self allClassesDo:[:aClass | |
4372
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
291 |
classes add:aClass. |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
292 |
aClass addAllPrivateClassesTo:classes. |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
293 |
]. |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
294 |
^ classes |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
295 |
|
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
296 |
"Modified: 20.12.1996 / 15:34:50 / cg" |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
297 |
! |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
298 |
|
1827 | 299 |
at:classNameSymbol |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
300 |
"return a class from the namespace defined by the receiver" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
301 |
|
1828 | 302 |
^ self privateClassesAt:classNameSymbol |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
303 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
304 |
"Modified: 8.11.1996 / 21:39:41 / cg" |
1827 | 305 |
! |
306 |
||
307 |
at:classNameSymbol ifAbsent:exceptionBlock |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
308 |
"return a class or an alternative |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
309 |
from the namespace defined by the receiver" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
310 |
|
1827 | 311 |
|cls| |
312 |
||
1828 | 313 |
cls := self privateClassesAt:classNameSymbol. |
1827 | 314 |
cls isNil ifTrue:[ |
315 |
^ exceptionBlock value |
|
316 |
]. |
|
317 |
^ cls |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
318 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
319 |
"Modified: 8.11.1996 / 21:40:01 / cg" |
1827 | 320 |
! |
321 |
||
322 |
at:classNameSymbol put:aClass |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
323 |
"add a class to the namespace defined by the receiver" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
324 |
|
1828 | 325 |
^ self privateClassesAt:classNameSymbol put:aClass |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
326 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
327 |
"Modified: 8.11.1996 / 21:40:12 / cg" |
2908 | 328 |
! |
329 |
||
330 |
classNamed:aString |
|
331 |
"return the class with name aString, or nil if absent. |
|
332 |
To get to the metaClass, append ' class' to the string." |
|
333 |
||
334 |
^ Smalltalk classNamed:(self name , '::' , aString) |
|
335 |
||
336 |
"Created: 9.9.1997 / 03:33:56 / cg" |
|
4397
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
337 |
! |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
338 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
339 |
includesKey:aClassNameStringOrSymbol |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
340 |
"{ Pragma: +optSpace }" |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
341 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
342 |
"return true if such a key is present" |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
343 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
344 |
|nmSym| |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
345 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
346 |
nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
347 |
nmSym isNil ifTrue:[^ false]. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
348 |
^ Smalltalk includesKey:nmSym. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
349 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
350 |
|
1827 | 351 |
! ! |
352 |
||
5331 | 353 |
!NameSpace class methodsFor:'enumerating'! |
1816 | 354 |
|
355 |
allBehaviorsDo:aBlock |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
356 |
"enumerate all classes in this namespace" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
357 |
|
2492 | 358 |
Smalltalk allBehaviorsDo:[:aClass | |
4068
ba1b46d15e70
skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
359 |
(aClass isBehavior and:[aClass isMeta not]) ifTrue:[ |
2583 | 360 |
aClass nameSpace == self ifTrue:[ |
361 |
aBlock value:aClass |
|
362 |
]. |
|
2492 | 363 |
] |
364 |
]. |
|
2583 | 365 |
|
4068
ba1b46d15e70
skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
366 |
"Modified: / 18.3.1999 / 17:21:06 / cg" |
4397
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
367 |
! |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
368 |
|
5581 | 369 |
allClassesDo:aBlock |
370 |
"enumerate all classes in this namespace" |
|
371 |
||
372 |
Smalltalk allClassesDo:[:aClass | |
|
373 |
(aClass isBehavior and:[aClass isMeta not]) ifTrue:[ |
|
374 |
aClass nameSpace == self ifTrue:[ |
|
375 |
aBlock value:aClass |
|
376 |
]. |
|
377 |
] |
|
378 |
]. |
|
379 |
||
380 |
"Modified: / 18.3.1999 / 17:21:06 / cg" |
|
381 |
! |
|
382 |
||
4397
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
383 |
keysDo:aBlock |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
384 |
"enumerate all class names in this namespace" |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
385 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
386 |
|prefix prefixLen| |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
387 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
388 |
prefix := self name , '::'. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
389 |
prefixLen := prefix size. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
390 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
391 |
Smalltalk keysAndValuesDo:[:aName :aClass | |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
392 |
|key| |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
393 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
394 |
(aName startsWith:prefix) ifTrue:[ |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
395 |
key := (aName copyFrom:prefixLen+1) asSymbol. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
396 |
aBlock value:key |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
397 |
] |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
398 |
]. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
399 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
400 |
" |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
401 |
Benchmarks keysDo:[:k | Transcript showCR:k] |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
402 |
" |
1816 | 403 |
! ! |
404 |
||
5331 | 405 |
!NameSpace class methodsFor:'fileOut'! |
1828 | 406 |
|
2058 | 407 |
fileOutDefinitionOn:aStream |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
408 |
"redefined to generate another definition message" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
409 |
|
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
410 |
self == NameSpace ifTrue:[ |
2058 | 411 |
super fileOutDefinitionOn:aStream |
1934 | 412 |
] ifFalse:[ |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
413 |
aStream nextPutAll:('NameSpace name:' , self name storeString) |
1934 | 414 |
] |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
415 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
416 |
"Modified: 8.11.1996 / 21:39:03 / cg" |
2058 | 417 |
"Created: 4.1.1997 / 20:36:32 / cg" |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
418 |
! ! |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
419 |
|
5464 | 420 |
!NameSpace class methodsFor:'fileOut-xml'! |
421 |
||
422 |
fileOutXMLDefinitionOn:aStream |
|
423 |
"redefined to generate another definition message" |
|
424 |
||
425 |
self == NameSpace ifTrue:[ |
|
426 |
super fileOutXMLDefinitionOn:aStream |
|
427 |
] ifFalse:[ |
|
428 |
aStream nextPutLine:'<name-space>'. |
|
429 |
aStream nextPutLine:' <name>' , self name , '</name>'. |
|
430 |
aStream nextPutLine:' <environment>Smalltalk</environment>'. |
|
431 |
aStream nextPutLine:' <private>false</private>'. |
|
432 |
aStream nextPutLine:' <imports>Smalltalk.*</imports>'. |
|
433 |
aStream nextPutLine:' <category>none</category>'. |
|
434 |
aStream nextPutLine:'</name-space>'. |
|
435 |
] |
|
436 |
! ! |
|
437 |
||
5331 | 438 |
!NameSpace class methodsFor:'inspecting'! |
4397
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
439 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
440 |
inspectorClass |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
441 |
"{ Pragma: +optSpace }" |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
442 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
443 |
"redefined to launch a DictionaryInspector |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
444 |
(instead of the default Inspector)." |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
445 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
446 |
^ DictionaryInspectorView |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
447 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
448 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
449 |
! ! |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
450 |
|
5331 | 451 |
!NameSpace class methodsFor:'printing & storing'! |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
452 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
453 |
displayString |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
454 |
"return a printed represenation - here, a reminder is appended, |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
455 |
that this is not a regular class" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
456 |
|
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
457 |
self == NameSpace ifTrue:[ |
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
458 |
^ super displayString |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
459 |
]. |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
460 |
^ self name , ' (* NameSpace *)' |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
461 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
462 |
"Created: 8.11.1996 / 21:37:24 / cg" |
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
463 |
"Modified: 20.12.1996 / 15:11:31 / cg" |
1828 | 464 |
! ! |
465 |
||
5331 | 466 |
!NameSpace class methodsFor:'queries'! |
1816 | 467 |
|
2031 | 468 |
allNamespaces |
2030 | 469 |
"return a list of all namespaces" |
470 |
||
6401 | 471 |
^ self allNamespacesIn:Smalltalk |
472 |
! |
|
473 |
||
474 |
allNamespacesIn:anEnvironment |
|
475 |
"return a list of all namespaces" |
|
476 |
||
2030 | 477 |
|set| |
478 |
||
6401 | 479 |
set := IdentitySet with:anEnvironment. |
480 |
anEnvironment allClassesDo:[:aClass | |
|
5327
5e5602d156fa
#isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents:
5305
diff
changeset
|
481 |
(aClass isNameSpace |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
482 |
and:[aClass ~~ NameSpace |
6401 | 483 |
and:[aClass ~~ anEnvironment |
484 |
and:[aClass ~~ Smalltalk]]]) ifTrue:[ |
|
2030 | 485 |
set add:aClass |
486 |
] |
|
487 |
]. |
|
488 |
^ set |
|
2055 | 489 |
! |
490 |
||
7317 | 491 |
hasNamespaces |
492 |
"return true - if I support sub-namespaces" |
|
493 |
||
494 |
^ false |
|
495 |
! |
|
496 |
||
5327
5e5602d156fa
#isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents:
5305
diff
changeset
|
497 |
isNameSpace |
2055 | 498 |
"return true - I am a namespace" |
499 |
||
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
500 |
self == NameSpace ifTrue:[^ false]. |
2055 | 501 |
^ true |
502 |
||
4457 | 503 |
! |
504 |
||
5464 | 505 |
isTopLevelNameSpace |
506 |
^ (self name includes:$:) not |
|
507 |
! |
|
508 |
||
4457 | 509 |
isTopLevelNamespace |
5365 | 510 |
"obsolete - use isTopLevelNameSpace" |
4457 | 511 |
|
7433 | 512 |
<resource:#obsolete> |
513 |
||
5365 | 514 |
^ (self name includes:$:) not |
1816 | 515 |
! ! |
516 |
||
5331 | 517 |
!NameSpace class methodsFor:'documentation'! |
1816 | 518 |
|
519 |
version |
|
8744
73522a385e11
oops - fullName did not handle '::' correctly
Claus Gittinger <cg@exept.de>
parents:
7575
diff
changeset
|
520 |
^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.52 2005-02-16 12:29:58 cg Exp $' |
1816 | 521 |
! ! |