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