NameSpace.st
author Claus Gittinger <cg@exept.de>
Wed, 30 Aug 2006 15:32:06 +0200
changeset 9814 1f92f9974325
parent 9675 e63287f4f7de
child 9934 0b61b2933bd4
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
     1
"
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
     2
 COPYRIGHT (c) 1996 by Claus Gittinger
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
     3
              All Rights Reserved
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
     4
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
     5
 This software is furnished under a license and may be used
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
     6
 only in accordance with the terms of that license and with the
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
     8
 be provided or otherwise made available to, or used by, any
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
     9
 other person.  No title to or ownership of the software is
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    10
 hereby transferred.
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    11
"
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    12
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
    13
5464
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
    14
"{ Package: 'stx:libbasic' }"
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
    15
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    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
74a0bff1ad19 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1931
diff changeset
    21
!
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    22
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    23
!NameSpace class methodsFor:'documentation'!
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    24
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    25
copyright
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    26
"
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    27
 COPYRIGHT (c) 1996 by Claus Gittinger
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    28
              All Rights Reserved
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    29
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    30
 This software is furnished under a license and may be used
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    31
 only in accordance with the terms of that license and with the
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    33
 be provided or otherwise made available to, or used by, any
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    34
 other person.  No title to or ownership of the software is
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    35
 hereby transferred.
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    36
"
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    37
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    40
documentation
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    41
"
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    42
    A NameSpace is actually a dummy class, providing a home
2010
eaaa38e8bad0 commentary
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
    43
    for its private classes. 
eaaa38e8bad0 commentary
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
    44
    Thus, internally, the same mechanism is used for classes in
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    45
    a NameSpace and private classes.
2010
eaaa38e8bad0 commentary
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
    46
    This has two advantages:
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    47
        - we only need one mechanism for both namespaces
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    48
          and private classes
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    49
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    50
        - there are no possible conflicts between a class
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    51
          and a namespace named alike.
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    52
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    54
    [author:]
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    55
        Claus Gittinger
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    56
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    57
    [see also:]
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    58
        Behavior ClassDescription Class Metaclass
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    59
        PrivateMetaclass
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    60
"
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    61
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    62
! !
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    63
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    64
!NameSpace class methodsFor:'instance creation'!
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    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
8747
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   102
            ].
1931
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
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   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:[
8747
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   114
		    thisNamespace == Smalltalk ifTrue:[
8748
eab41f334788 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8747
diff changeset
   115
			x := self name:key
8747
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   116
		    ] ifFalse:[
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   117
                        x := thisNamespace name:key.
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   118
		    ]
7426
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   119
                ] ifFalse:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   120
                    x :=
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   121
                        self subclass:key
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   122
                           instanceVariableNames:''
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   123
                           classVariableNames:''
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   124
                           poolDictionaries:''
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   125
                           privateIn:thisNamespace.
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
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   128
                "/ nameSpaces are not in any package (yet)
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   129
                x setPackage:nil.
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   130
            ].
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   131
            thisNamespace := x.
8747
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   132
        ].
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   133
    ].
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   134
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   135
    ^ thisNamespace
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   136
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   137
    "Created: 8.11.1996 / 13:41:59 / cg"
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   138
    "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
   139
!
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   140
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   141
name:aStringOrSymbol
2177
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   142
    "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
   143
     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
   144
     dont get confused; we recommend, not to nest them too much."
1908
aff3d44e4399 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1901
diff changeset
   145
7575
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   146
    |currentNameSpace newNameSpace existing ok nameSym fullName|
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   147
2024
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   148
    ok := aStringOrSymbol first isLetter.
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   149
    ok ifTrue:[
2177
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   150
        (aStringOrSymbol 
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   151
            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
   152
            startingAt:2) ~~ 0
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   153
        ifTrue:[
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   154
            ok := false.
2024
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   155
        ]
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   156
    ].
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   157
    ok ifFalse:[
2025
9ab95f23af33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   158
        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
   159
    ].
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   160
5249
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   161
    nameSym := aStringOrSymbol asSymbol.
3383
7837c591ecdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2924
diff changeset
   162
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   163
    self == NameSpace ifTrue:[
7575
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   164
        "/ currentNameSpace := Class nameSpaceQuerySignal query.
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   165
        currentNameSpace isNil ifTrue:[
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   166
            currentNameSpace := Smalltalk
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   167
        ].
5249
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   168
        fullName := nameSym
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   169
    ] ifFalse:[
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   170
        currentNameSpace := self.
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   171
        fullName := (self name , '::' , nameSym) asSymbol
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   172
    ].
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   173
3383
7837c591ecdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2924
diff changeset
   174
    (existing := currentNameSpace at:nameSym) notNil ifTrue:[
2015
7e6375a8e0f2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   175
        ^ existing
7e6375a8e0f2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   176
    ].
7575
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   177
    newNameSpace := self 
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   178
        subclass:fullName
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   179
        instanceVariableNames:''
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   180
        classVariableNames:''
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   181
        poolDictionaries:''
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   182
        category:'uncategorized namespace'
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   183
        inEnvironment:Smalltalk.
2144
76dd062d32a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   184
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   185
    "/ nameSpaces are not in any package
7575
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   186
    newNameSpace notNil ifTrue:[newNameSpace setPackage:nil].
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   187
    ^ newNameSpace
1901
8eebbd3c7232 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1828
diff changeset
   188
8eebbd3c7232 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1828
diff changeset
   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
8eebbd3c7232 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1828
diff changeset
   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
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   203
!
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   204
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   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
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   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
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   211
! !
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   212
7298
9b3c69eb2c5d category
Claus Gittinger <cg@exept.de>
parents: 6824
diff changeset
   213
!NameSpace class methodsFor:'Compatibility-VW5.4'!
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   214
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   215
defineClass: name
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   216
                superclass: superclass
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   217
                indexedType: indexed
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   218
                private: private
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   219
                instanceVariableNames: instVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   220
                classInstanceVariableNames: classInstVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   221
                imports: imports
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   222
                category: category
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   223
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   224
    ^ self
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   225
        defineClass: name
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   226
        superclass: superclass
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   227
        indexedType: indexed
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   228
        private: private
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   229
        instanceVariableNames: instVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   230
        classInstanceVariableNames: classInstVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   231
        imports: imports
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   232
        category: category
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   233
        attributes: nil
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   234
!
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   235
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   236
defineClass: name
7431
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   237
                superclass: superclassOrName
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   238
                indexedType: indexed
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   239
                private: private
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   240
                instanceVariableNames: instVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   241
                classInstanceVariableNames: classInstVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   242
                imports: imports
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   243
                category: category
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   244
                attributes: annotations
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   245
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   246
    "VW5i compatibility class/namespace creation"
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   247
7431
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   248
    |variable words pointers superclass|
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   249
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   250
    variable := words := pointers := false.
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   251
    indexed ~~ #none ifTrue:[
7433
8bc88cc029fe Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 7431
diff changeset
   252
        self shouldImplement.
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   253
    ].
7431
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   254
    superclassOrName isSymbol ifTrue:[
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   255
        superclass := Smalltalk at:superclassOrName.
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   256
        superclass isNil ifTrue:[
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   257
            self error:'missing superclass: ' , superclassOrName.
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   258
        ]
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   259
    ] ifFalse:[   
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   260
        superclass := superclassOrName
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   261
    ].
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   262
    ^ superclass value class
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   263
        name:name 
6824
6fbe85d05646 ...in:... -> ...inEnvironment:...
Claus Gittinger <cg@exept.de>
parents: 6450
diff changeset
   264
        inEnvironment:self
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   265
        subclassOf:superclass value
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   266
        instanceVariableNames:instVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   267
        variable:variable
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   268
        words:words
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   269
        pointers:pointers
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   270
        classVariableNames:''
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   271
        poolDictionaries:''
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   272
        category:category
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   273
        comment:nil
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   274
        changed:true
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   275
        classInstanceVariableNames:classInstVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   276
! !
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   277
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   278
!NameSpace class methodsFor:'accessing'!
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   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
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   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
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   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
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   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
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   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
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   309
!
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   310
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   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
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   315
    |cls|
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   316
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   317
    cls := self privateClassesAt:classNameSymbol.
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   318
    cls isNil ifTrue:[
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   319
        ^ exceptionBlock value
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   320
    ].
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   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
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   324
!
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   325
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   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
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   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
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   332
!
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   333
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   334
classNamed:aString
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   335
    "return the class with name aString, or nil if absent.
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   336
     To get to the metaClass, append ' class' to the string."
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   337
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   338
    ^ Smalltalk classNamed:(self name , '::' , aString)
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   339
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   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
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   343
classNames
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   344
    ^ self allClasses collect:[:each | each nameWithoutPrefix]
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   345
!
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   346
4397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   347
includesKey:aClassNameStringOrSymbol
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   348
    "{ Pragma: +optSpace }"
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
    "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
   351
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   352
    |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
    nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   355
    nmSym isNil ifTrue:[^ false].
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   356
    ^ Smalltalk includesKey:nmSym.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   357
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   358
9546
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   359
!
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   360
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   361
package
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   362
    self isNameSpace ifTrue:[    
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   363
        ^ nil       "all nameSpaces are outside of any package"
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   364
    ].
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   365
    ^ super package "the nameSpace class itself has a package"
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   366
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   367
    "Created: / 16-08-2006 / 18:48:29 / User"
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   368
! !
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   369
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   370
!NameSpace class methodsFor:'enumerating'!
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
allBehaviorsDo:aBlock
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   373
    "enumerate all classes in this namespace"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   374
2492
ca
parents: 2177
diff changeset
   375
    Smalltalk allBehaviorsDo:[:aClass |
4068
ba1b46d15e70 skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents: 4058
diff changeset
   376
        (aClass isBehavior and:[aClass isMeta not]) ifTrue:[
2583
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   377
            aClass nameSpace == self ifTrue:[
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   378
                aBlock value:aClass
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   379
            ].
2492
ca
parents: 2177
diff changeset
   380
        ]
ca
parents: 2177
diff changeset
   381
    ].
2583
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   382
4068
ba1b46d15e70 skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents: 4058
diff changeset
   383
    "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
   384
!
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   385
5581
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   386
allClassesDo:aBlock
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   387
    "enumerate all classes in this namespace"
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   388
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   389
    Smalltalk allClassesDo:[:aClass |
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   390
        (aClass isBehavior and:[aClass isMeta not]) ifTrue:[
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   391
            aClass nameSpace == self ifTrue:[
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   392
                aBlock value:aClass
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   393
            ].
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   394
        ]
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   395
    ].
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   396
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   397
    "Modified: / 18.3.1999 / 17:21:06 / cg"
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   398
!
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   399
9289
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   400
keys
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   401
    "enumerate all class names in this namespace"
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   402
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   403
    |setOfKeys|
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   404
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   405
    setOfKeys := OrderedCollection new.
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   406
    self keysDo:[:eachKey |setOfKeys add:eachKey].
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   407
    ^ setOfKeys
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   408
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   409
    "
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   410
     Benchmarks keys
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   411
    "
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   412
!
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   413
4397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   414
keysDo:aBlock
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   415
    "enumerate all class names in this namespace"
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   416
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   417
    |prefix prefixLen|
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   418
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   419
    prefix := self name , '::'.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   420
    prefixLen := prefix size.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   421
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   422
    Smalltalk keysAndValuesDo:[:aName :aClass |
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   423
        |key|
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   424
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   425
        (aName startsWith:prefix) ifTrue:[
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   426
            key := (aName copyFrom:prefixLen+1) asSymbol.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   427
            aBlock value:key
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   428
        ]
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   429
    ].
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   430
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   431
    "
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   432
     Benchmarks keysDo:[:k | Transcript showCR:k]
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   433
    "
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
! !
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   436
!NameSpace class methodsFor:'fileOut'!
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   437
2058
09ea6d9cd607 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   438
fileOutDefinitionOn:aStream
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   439
    "redefined to generate another definition message"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   440
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   441
    self == NameSpace ifTrue:[
2058
09ea6d9cd607 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   442
        super fileOutDefinitionOn:aStream
1934
f21f70387dc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1933
diff changeset
   443
    ] ifFalse:[
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   444
        aStream nextPutAll:('NameSpace name:' , self name storeString)
1934
f21f70387dc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1933
diff changeset
   445
    ]
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   446
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   447
    "Modified: 8.11.1996 / 21:39:03 / cg"
2058
09ea6d9cd607 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   448
    "Created: 4.1.1997 / 20:36:32 / cg"
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   449
! !
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   450
5464
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   451
!NameSpace class methodsFor:'fileOut-xml'!
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   452
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   453
fileOutXMLDefinitionOn:aStream
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   454
    "redefined to generate another definition message"
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   455
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   456
    self == NameSpace ifTrue:[
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   457
        super fileOutXMLDefinitionOn:aStream
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   458
    ] ifFalse:[
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   459
        aStream nextPutLine:'<name-space>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   460
        aStream nextPutLine:'  <name>' , self name , '</name>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   461
        aStream nextPutLine:'  <environment>Smalltalk</environment>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   462
        aStream nextPutLine:'  <private>false</private>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   463
        aStream nextPutLine:'  <imports>Smalltalk.*</imports>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   464
        aStream nextPutLine:'  <category>none</category>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   465
        aStream nextPutLine:'</name-space>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   466
    ]
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   467
! !
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   468
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   469
!NameSpace class methodsFor:'inspecting'!
4397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   470
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   471
inspectorClass
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   472
    "{ Pragma: +optSpace }"
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   473
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   474
    "redefined to launch a DictionaryInspector
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   475
     (instead of the default Inspector)."
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   476
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   477
    ^ DictionaryInspectorView
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   478
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   479
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   480
! !
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   481
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   482
!NameSpace class methodsFor:'printing & storing'!
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   483
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   484
displayString
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   485
    "return a printed represenation - here, a reminder is appended,
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   486
     that this is not a regular class"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   487
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   488
    self == NameSpace ifTrue:[
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   489
        ^ super displayString
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   490
    ].
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   491
    ^ self name , ' (* NameSpace *)'
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   492
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   493
    "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
   494
    "Modified: 20.12.1996 / 15:11:31 / cg"
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   495
! !
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   496
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   497
!NameSpace class methodsFor:'queries'!
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   499
allNameSpaces
2030
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   500
    "return a list of all namespaces"
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   501
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   502
    ^ self allNameSpacesIn:Smalltalk
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   503
!
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   504
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   505
allNameSpacesIn:anEnvironment
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   506
    "return a list of all namespaces"
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   507
2030
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   508
    |set|
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   509
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   510
    set := IdentitySet with:anEnvironment.
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   511
    anEnvironment allClassesDo:[:aClass |
5327
5e5602d156fa #isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents: 5305
diff changeset
   512
        (aClass isNameSpace 
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   513
        and:[aClass ~~ anEnvironment
9675
e63287f4f7de *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9546
diff changeset
   514
        and:[aClass ~~ Smalltalk]]) ifTrue:[
2030
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   515
            set add:aClass
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   516
        ]
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   517
    ].
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   518
    ^ set
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   519
!
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   520
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   521
allNamespaces
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   522
    "return a list of all namespaces"
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   523
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   524
    <resource: #obsolete>
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   525
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   526
    ^ self allNameSpaces
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   527
!
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   528
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   529
allNamespacesIn:anEnvironment
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   530
    "return a list of all namespaces"
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   531
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   532
    <resource: #obsolete>
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   533
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   534
    ^ self allNameSpacesIn:anEnvironment
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   535
!
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   536
9814
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   537
canHaveExtensions
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   538
    "return true, if this class allows extensions from other packages.
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   539
     Private classes, namespaces and projectDefinitions dont allow this"
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   540
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   541
    ^ self == NameSpace
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   542
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   543
    "
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   544
     Smalltalk allClasses select:[:each | each canHaveExtensions not]
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   545
    "
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   546
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   547
    "Created: / 30-08-2006 / 15:28:39 / cg"
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   548
!
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   549
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   550
hasNameSpaces
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   551
    "return true - if I support sub-namespaces"
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   552
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   553
    ^ false
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   554
!
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   555
7317
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   556
hasNamespaces
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   557
    "return true - if I support sub-namespaces"
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   558
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   559
    <resource: #obsolete>
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   560
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   561
    ^ self hasNameSpaces
7317
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   562
!
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   563
5327
5e5602d156fa #isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents: 5305
diff changeset
   564
isNameSpace
9217
e8e6eee6b187 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8748
diff changeset
   565
    "return true, if the receiver is a nameSpace.
9372
3e8b8e54a66d comment
Stefan Vogel <sv@exept.de>
parents: 9289
diff changeset
   566
     Unconditionally true here - my subclasses are namespaces"
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   567
9372
3e8b8e54a66d comment
Stefan Vogel <sv@exept.de>
parents: 9289
diff changeset
   568
    ^ self ~~ NameSpace .
4457
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   569
!
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   570
5464
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   571
isTopLevelNameSpace
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   572
    ^ (self name includes:$:) not
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   573
!
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   574
4457
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   575
isTopLevelNamespace
5365
95c615a40176 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5331
diff changeset
   576
    "obsolete - use isTopLevelNameSpace"
4457
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   577
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   578
    <resource: #obsolete>
7433
8bc88cc029fe Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 7431
diff changeset
   579
5365
95c615a40176 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5331
diff changeset
   580
    ^ (self name includes:$:) not
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
! !
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   583
!NameSpace class methodsFor:'documentation'!
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
version
9814
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   586
    ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.61 2006-08-30 13:32:06 cg Exp $'
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
! !