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 |
|
|
13 |
|
1908
|
14 |
Object subclass:#Namespace
|
1816
|
15 |
instanceVariableNames:''
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
1827
|
18 |
category:'Kernel-Classes'
|
|
19 |
!
|
|
20 |
|
|
21 |
!Namespace class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 1996 by Claus Gittinger
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
|
1816
|
36 |
!
|
|
37 |
|
1827
|
38 |
documentation
|
|
39 |
"
|
|
40 |
A Namespace is actually a dummy class, providing a home
|
1828
|
41 |
for its private classes. This has two advantages:
|
|
42 |
- we only need one mechanism for both namespaces
|
|
43 |
and private classes
|
|
44 |
|
|
45 |
- there are no possible conflicts between a class
|
|
46 |
and a namespace named alike.
|
|
47 |
|
1816
|
48 |
|
1827
|
49 |
[author:]
|
|
50 |
Claus Gittinger
|
|
51 |
|
|
52 |
[see also:]
|
|
53 |
Behavior ClassDescription Class Metaclass
|
|
54 |
PrivateMetaclass
|
|
55 |
"
|
|
56 |
|
|
57 |
! !
|
|
58 |
|
1828
|
59 |
!Namespace class methodsFor:'instance creation'!
|
|
60 |
|
|
61 |
name:aSymbol
|
1908
|
62 |
"create a new nameSpace, named aSymbol"
|
|
63 |
|
1828
|
64 |
|newNamespace|
|
|
65 |
|
1908
|
66 |
newNamespace := self subclass:aSymbol
|
|
67 |
instanceVariableNames:''
|
|
68 |
classVariableNames:''
|
|
69 |
poolDictionaries:''
|
|
70 |
category:(aSymbol , ' (* namespace *)').
|
|
71 |
|
1828
|
72 |
^ newNamespace
|
1901
|
73 |
|
|
74 |
"
|
|
75 |
Namespace name:'foo'
|
|
76 |
(Namespace name:'foo') category:'my name space'
|
|
77 |
"
|
1828
|
78 |
!
|
|
79 |
|
|
80 |
new
|
|
81 |
self error:'namespaces are not to be created with new'
|
|
82 |
! !
|
|
83 |
|
1908
|
84 |
!Namespace class methodsFor:'accessing'!
|
1827
|
85 |
|
|
86 |
at:classNameSymbol
|
1828
|
87 |
^ self privateClassesAt:classNameSymbol
|
1827
|
88 |
!
|
|
89 |
|
|
90 |
at:classNameSymbol ifAbsent:exceptionBlock
|
|
91 |
|cls|
|
|
92 |
|
1828
|
93 |
cls := self privateClassesAt:classNameSymbol.
|
1827
|
94 |
cls isNil ifTrue:[
|
|
95 |
^ exceptionBlock value
|
|
96 |
].
|
|
97 |
^ cls
|
|
98 |
!
|
|
99 |
|
|
100 |
at:classNameSymbol put:aClass
|
1828
|
101 |
^ self privateClassesAt:classNameSymbol put:aClass
|
1827
|
102 |
! !
|
|
103 |
|
1908
|
104 |
!Namespace class methodsFor:'enumerating'!
|
1816
|
105 |
|
|
106 |
allBehaviorsDo:aBlock
|
1828
|
107 |
self privateClassesDo:aBlock
|
1816
|
108 |
|
|
109 |
"Created: 26.10.1996 / 12:29:01 / cg"
|
|
110 |
! !
|
|
111 |
|
1908
|
112 |
!Namespace class methodsFor:'fileOut'!
|
1828
|
113 |
|
|
114 |
basicFileOutDefinitionOn:aStream
|
1908
|
115 |
aStream nextPutAll:('Namespace name:' , self name storeString)
|
1828
|
116 |
! !
|
|
117 |
|
1908
|
118 |
!Namespace class methodsFor:'queries'!
|
1816
|
119 |
|
|
120 |
isNamespace
|
|
121 |
^ true
|
|
122 |
|
|
123 |
"Created: 26.10.1996 / 11:13:36 / cg"
|
|
124 |
! !
|
|
125 |
|
|
126 |
!Namespace class methodsFor:'documentation'!
|
|
127 |
|
|
128 |
version
|
1908
|
129 |
^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.5 1996-11-06 20:42:22 cg Exp $'
|
1816
|
130 |
! !
|