author | Stefan Vogel <sv@exept.de> |
Fri, 20 Jun 2003 09:24:24 +0200 | |
changeset 7433 | 8bc88cc029fe |
parent 7431 | ba25eb29e77d |
child 7575 | 80341bf0e03e |
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 |
4059d00c81d7
also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents:
7317
diff
changeset
|
78 |
list := aFullNameSpacePathName asCollectionOfSubstringsSeparatedByAll:'..'. |
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 |
|
5249
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
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 |
] |
2177
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
152 |
|
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
153 |
"/ 2 to:aStringOrSymbol size do:[:idx | |ch| |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
154 |
"/ ch := aStringOrSymbol at:idx. |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
155 |
"/ ok ifTrue:[ |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
156 |
"/ ok := ch isLetterOrDigit or:[ch == $_]. |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
157 |
"/ ] |
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
158 |
"/ ] |
2024
71a088db4583
validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents:
2015
diff
changeset
|
159 |
]. |
71a088db4583
validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents:
2015
diff
changeset
|
160 |
ok ifFalse:[ |
2025 | 161 |
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
|
162 |
]. |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
163 |
|
5249
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
164 |
nameSym := aStringOrSymbol asSymbol. |
3383 | 165 |
|
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
166 |
self == NameSpace ifTrue:[ |
5249
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
167 |
currentNameSpace := Class nameSpaceQuerySignal query. |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
168 |
currentNameSpace isNil ifTrue:[currentNameSpace := Smalltalk]. |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
169 |
fullName := nameSym |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
170 |
] ifFalse:[ |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
171 |
currentNameSpace := self. |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
172 |
fullName := (self name , '::' , nameSym) asSymbol |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
173 |
]. |
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
174 |
|
3383 | 175 |
(existing := currentNameSpace at:nameSym) notNil ifTrue:[ |
2015 | 176 |
^ existing |
177 |
]. |
|
178 |
||
5249
77cad45f94f8
fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
179 |
newNamespace := self subclass:fullName |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
180 |
instanceVariableNames:'' |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
181 |
classVariableNames:'' |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
182 |
poolDictionaries:'' |
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
183 |
category:'uncategorized namespace'. |
2144 | 184 |
|
2055 | 185 |
"/ nameSpaces are not in any package |
2924 | 186 |
newNamespace notNil ifTrue:[newNamespace setPackage:nil]. |
1828 | 187 |
^ newNamespace |
1901 | 188 |
|
189 |
" |
|
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
190 |
NameSpace name:'foo' |
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
191 |
(NameSpace name:'foo') category:'my name space' |
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
192 |
foo at:#bar put:(Metaclass new new) |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
193 |
(NameSpace name:'foo') name:'bar' |
1901 | 194 |
" |
2177
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
195 |
" |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
196 |
NameSpace name:'an-invalid++name' |
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
197 |
NameSpace name:'another:invalidName' |
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
198 |
NameSpace name:'another::invalidName' |
2177
80f6ec11f797
create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents:
2144
diff
changeset
|
199 |
" |
1931
5f60d3e5ba6e
moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents:
1908
diff
changeset
|
200 |
|
4058
58987b73c0c7
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3383
diff
changeset
|
201 |
"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
|
202 |
"Modified: / 18.3.1999 / 18:24:13 / stefan" |
1828 | 203 |
! |
204 |
||
205 |
new |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
206 |
"catch new - namespaces are not to be created by the user" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
207 |
|
1828 | 208 |
self error:'namespaces are not to be created with new' |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
209 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
210 |
"Modified: 8.11.1996 / 21:38:00 / cg" |
1828 | 211 |
! ! |
212 |
||
7298 | 213 |
!NameSpace class methodsFor:'Compatibility-VW5.4'! |
6450 | 214 |
|
215 |
defineClass: name |
|
216 |
superclass: superclass |
|
217 |
indexedType: indexed |
|
218 |
private: private |
|
219 |
instanceVariableNames: instVars |
|
220 |
classInstanceVariableNames: classInstVars |
|
221 |
imports: imports |
|
222 |
category: category |
|
223 |
||
224 |
^ self |
|
225 |
defineClass: name |
|
226 |
superclass: superclass |
|
227 |
indexedType: indexed |
|
228 |
private: private |
|
229 |
instanceVariableNames: instVars |
|
230 |
classInstanceVariableNames: classInstVars |
|
231 |
imports: imports |
|
232 |
category: category |
|
233 |
attributes: nil |
|
234 |
! |
|
235 |
||
236 |
defineClass: name |
|
7431 | 237 |
superclass: superclassOrName |
6450 | 238 |
indexedType: indexed |
239 |
private: private |
|
240 |
instanceVariableNames: instVars |
|
241 |
classInstanceVariableNames: classInstVars |
|
242 |
imports: imports |
|
243 |
category: category |
|
244 |
attributes: annotations |
|
245 |
||
246 |
"VW5i compatibility class/namespace creation" |
|
247 |
||
7431 | 248 |
|variable words pointers superclass| |
6450 | 249 |
|
250 |
variable := words := pointers := false. |
|
251 |
indexed ~~ #none ifTrue:[ |
|
7433 | 252 |
self shouldImplement. |
6450 | 253 |
]. |
7431 | 254 |
superclassOrName isSymbol ifTrue:[ |
255 |
superclass := Smalltalk at:superclassOrName. |
|
256 |
superclass isNil ifTrue:[ |
|
257 |
self error:'missing superclass: ' , superclassOrName. |
|
258 |
] |
|
259 |
] ifFalse:[ |
|
260 |
superclass := superclassOrName |
|
261 |
]. |
|
6450 | 262 |
^ superclass value class |
263 |
name:name |
|
6824
6fbe85d05646
...in:... -> ...inEnvironment:...
Claus Gittinger <cg@exept.de>
parents:
6450
diff
changeset
|
264 |
inEnvironment:self |
6450 | 265 |
subclassOf:superclass value |
266 |
instanceVariableNames:instVars |
|
267 |
variable:variable |
|
268 |
words:words |
|
269 |
pointers:pointers |
|
270 |
classVariableNames:'' |
|
271 |
poolDictionaries:'' |
|
272 |
category:category |
|
273 |
comment:nil |
|
274 |
changed:true |
|
275 |
classInstanceVariableNames:classInstVars |
|
276 |
! ! |
|
277 |
||
5331 | 278 |
!NameSpace class methodsFor:'accessing'! |
1827 | 279 |
|
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
280 |
allClasses |
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 |
classes := IdentitySet new. |
5581 | 284 |
self allClassesDo:[:aClass | classes add:aClass]. |
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
285 |
^ classes |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
286 |
|
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
287 |
"Modified: 20.12.1996 / 15:34:50 / cg" |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
288 |
! |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
289 |
|
4372
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
290 |
allClassesWithAllPrivateClasses |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
291 |
|classes| |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
292 |
|
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
293 |
classes := IdentitySet new. |
5581 | 294 |
self allClassesDo:[:aClass | |
4372
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
295 |
classes add:aClass. |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
296 |
aClass addAllPrivateClassesTo:classes. |
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 |
^ classes |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
299 |
|
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
300 |
"Modified: 20.12.1996 / 15:34:50 / cg" |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
301 |
! |
eaba7e085030
added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4068
diff
changeset
|
302 |
|
1827 | 303 |
at:classNameSymbol |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
304 |
"return a class from the namespace defined by the receiver" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
305 |
|
1828 | 306 |
^ self privateClassesAt:classNameSymbol |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
307 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
308 |
"Modified: 8.11.1996 / 21:39:41 / cg" |
1827 | 309 |
! |
310 |
||
311 |
at:classNameSymbol ifAbsent:exceptionBlock |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
312 |
"return a class or an alternative |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
313 |
from the namespace defined by the receiver" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
314 |
|
1827 | 315 |
|cls| |
316 |
||
1828 | 317 |
cls := self privateClassesAt:classNameSymbol. |
1827 | 318 |
cls isNil ifTrue:[ |
319 |
^ exceptionBlock value |
|
320 |
]. |
|
321 |
^ cls |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
322 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
323 |
"Modified: 8.11.1996 / 21:40:01 / cg" |
1827 | 324 |
! |
325 |
||
326 |
at:classNameSymbol put:aClass |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
327 |
"add a class to the namespace defined by the receiver" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
328 |
|
1828 | 329 |
^ self privateClassesAt:classNameSymbol put:aClass |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
330 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
331 |
"Modified: 8.11.1996 / 21:40:12 / cg" |
2908 | 332 |
! |
333 |
||
334 |
classNamed:aString |
|
335 |
"return the class with name aString, or nil if absent. |
|
336 |
To get to the metaClass, append ' class' to the string." |
|
337 |
||
338 |
^ Smalltalk classNamed:(self name , '::' , aString) |
|
339 |
||
340 |
"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
|
341 |
! |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
342 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
343 |
includesKey:aClassNameStringOrSymbol |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
344 |
"{ Pragma: +optSpace }" |
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 |
"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
|
347 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
348 |
|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 |
nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
351 |
nmSym isNil ifTrue:[^ false]. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
352 |
^ Smalltalk includesKey:nmSym. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
353 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
354 |
|
1827 | 355 |
! ! |
356 |
||
5331 | 357 |
!NameSpace class methodsFor:'enumerating'! |
1816 | 358 |
|
359 |
allBehaviorsDo:aBlock |
|
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
360 |
"enumerate all classes in this namespace" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
361 |
|
2492 | 362 |
Smalltalk allBehaviorsDo:[:aClass | |
4068
ba1b46d15e70
skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
363 |
(aClass isBehavior and:[aClass isMeta not]) ifTrue:[ |
2583 | 364 |
aClass nameSpace == self ifTrue:[ |
365 |
aBlock value:aClass |
|
366 |
]. |
|
2492 | 367 |
] |
368 |
]. |
|
2583 | 369 |
|
4068
ba1b46d15e70
skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents:
4058
diff
changeset
|
370 |
"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
|
371 |
! |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
372 |
|
5581 | 373 |
allClassesDo:aBlock |
374 |
"enumerate all classes in this namespace" |
|
375 |
||
376 |
Smalltalk allClassesDo:[:aClass | |
|
377 |
(aClass isBehavior and:[aClass isMeta not]) ifTrue:[ |
|
378 |
aClass nameSpace == self ifTrue:[ |
|
379 |
aBlock value:aClass |
|
380 |
]. |
|
381 |
] |
|
382 |
]. |
|
383 |
||
384 |
"Modified: / 18.3.1999 / 17:21:06 / cg" |
|
385 |
! |
|
386 |
||
4397
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
387 |
keysDo:aBlock |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
388 |
"enumerate all class names in this namespace" |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
389 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
390 |
|prefix prefixLen| |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
391 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
392 |
prefix := self name , '::'. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
393 |
prefixLen := prefix size. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
394 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
395 |
Smalltalk keysAndValuesDo:[:aName :aClass | |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
396 |
|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 |
(aName startsWith:prefix) ifTrue:[ |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
399 |
key := (aName copyFrom:prefixLen+1) asSymbol. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
400 |
aBlock value:key |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
401 |
] |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
402 |
]. |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
403 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
404 |
" |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
405 |
Benchmarks keysDo:[:k | Transcript showCR:k] |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
406 |
" |
1816 | 407 |
! ! |
408 |
||
5331 | 409 |
!NameSpace class methodsFor:'fileOut'! |
1828 | 410 |
|
2058 | 411 |
fileOutDefinitionOn:aStream |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
412 |
"redefined to generate another definition message" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
413 |
|
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
414 |
self == NameSpace ifTrue:[ |
2058 | 415 |
super fileOutDefinitionOn:aStream |
1934 | 416 |
] ifFalse:[ |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
417 |
aStream nextPutAll:('NameSpace name:' , self name storeString) |
1934 | 418 |
] |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
419 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
420 |
"Modified: 8.11.1996 / 21:39:03 / cg" |
2058 | 421 |
"Created: 4.1.1997 / 20:36:32 / cg" |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
422 |
! ! |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
423 |
|
5464 | 424 |
!NameSpace class methodsFor:'fileOut-xml'! |
425 |
||
426 |
fileOutXMLDefinitionOn:aStream |
|
427 |
"redefined to generate another definition message" |
|
428 |
||
429 |
self == NameSpace ifTrue:[ |
|
430 |
super fileOutXMLDefinitionOn:aStream |
|
431 |
] ifFalse:[ |
|
432 |
aStream nextPutLine:'<name-space>'. |
|
433 |
aStream nextPutLine:' <name>' , self name , '</name>'. |
|
434 |
aStream nextPutLine:' <environment>Smalltalk</environment>'. |
|
435 |
aStream nextPutLine:' <private>false</private>'. |
|
436 |
aStream nextPutLine:' <imports>Smalltalk.*</imports>'. |
|
437 |
aStream nextPutLine:' <category>none</category>'. |
|
438 |
aStream nextPutLine:'</name-space>'. |
|
439 |
] |
|
440 |
! ! |
|
441 |
||
5331 | 442 |
!NameSpace class methodsFor:'inspecting'! |
4397
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
443 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
444 |
inspectorClass |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
445 |
"{ Pragma: +optSpace }" |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
446 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
447 |
"redefined to launch a DictionaryInspector |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
448 |
(instead of the default Inspector)." |
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 |
^ DictionaryInspectorView |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
451 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
452 |
|
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
453 |
! ! |
bfcf41484c1f
added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
4372
diff
changeset
|
454 |
|
5331 | 455 |
!NameSpace class methodsFor:'printing & storing'! |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
456 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
457 |
displayString |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
458 |
"return a printed represenation - here, a reminder is appended, |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
459 |
that this is not a regular class" |
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
460 |
|
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
461 |
self == NameSpace ifTrue:[ |
2007
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
462 |
^ super displayString |
57434c08d720
namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
463 |
]. |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
464 |
^ self name , ' (* NameSpace *)' |
1943
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
465 |
|
0ec17e4627ae
better displayString & commentary
Claus Gittinger <cg@exept.de>
parents:
1934
diff
changeset
|
466 |
"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
|
467 |
"Modified: 20.12.1996 / 15:11:31 / cg" |
1828 | 468 |
! ! |
469 |
||
5331 | 470 |
!NameSpace class methodsFor:'queries'! |
1816 | 471 |
|
2031 | 472 |
allNamespaces |
2030 | 473 |
"return a list of all namespaces" |
474 |
||
6401 | 475 |
^ self allNamespacesIn:Smalltalk |
476 |
! |
|
477 |
||
478 |
allNamespacesIn:anEnvironment |
|
479 |
"return a list of all namespaces" |
|
480 |
||
2030 | 481 |
|set| |
482 |
||
6401 | 483 |
set := IdentitySet with:anEnvironment. |
484 |
anEnvironment allClassesDo:[:aClass | |
|
5327
5e5602d156fa
#isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents:
5305
diff
changeset
|
485 |
(aClass isNameSpace |
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
486 |
and:[aClass ~~ NameSpace |
6401 | 487 |
and:[aClass ~~ anEnvironment |
488 |
and:[aClass ~~ Smalltalk]]]) ifTrue:[ |
|
2030 | 489 |
set add:aClass |
490 |
] |
|
491 |
]. |
|
492 |
^ set |
|
2055 | 493 |
! |
494 |
||
7317 | 495 |
hasNamespaces |
496 |
"return true - if I support sub-namespaces" |
|
497 |
||
498 |
^ false |
|
499 |
! |
|
500 |
||
5327
5e5602d156fa
#isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents:
5305
diff
changeset
|
501 |
isNameSpace |
2055 | 502 |
"return true - I am a namespace" |
503 |
||
5328
319b8e3ee60e
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
5327
diff
changeset
|
504 |
self == NameSpace ifTrue:[^ false]. |
2055 | 505 |
^ true |
506 |
||
4457 | 507 |
! |
508 |
||
5464 | 509 |
isTopLevelNameSpace |
510 |
^ (self name includes:$:) not |
|
511 |
! |
|
512 |
||
4457 | 513 |
isTopLevelNamespace |
5365 | 514 |
"obsolete - use isTopLevelNameSpace" |
4457 | 515 |
|
7433 | 516 |
<resource:#obsolete> |
517 |
||
5365 | 518 |
^ (self name includes:$:) not |
1816 | 519 |
! ! |
520 |
||
5331 | 521 |
!NameSpace class methodsFor:'documentation'! |
1816 | 522 |
|
523 |
version |
|
7433 | 524 |
^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.50 2003-06-20 07:24:24 stefan Exp $' |
1816 | 525 |
! ! |