NameSpace.st
author Stefan Vogel <sv@exept.de>
Fri, 20 Jun 2003 09:24:24 +0200
changeset 7433 8bc88cc029fe
parent 7431 ba25eb29e77d
child 7575 80341bf0e03e
permissions -rw-r--r--
Mark obsolete methods
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
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
    78
        list := aFullNameSpacePathName asCollectionOfSubstringsSeparatedByAll:'..'.
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
    79
    ] ifFalse:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
    80
        "/ new style
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
    81
        list := aFullNameSpacePathName asCollectionOfSubstringsSeparatedBy:$..
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    82
    ].
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    83
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    84
    "/ now, look and create 'em
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    85
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    86
    thisNamespace := nil.
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    87
    list do:[:aName |
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    88
        |key x|
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    89
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    90
        key := aName asSymbol.
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    91
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    92
        thisNamespace isNil ifTrue:[
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    93
            (Smalltalk includesKey:key) ifTrue:[
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    94
                thisNamespace := Smalltalk at:key.
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    95
                (thisNamespace notNil
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    96
                and:[thisNamespace isBehavior not]) ifTrue:[
4522
29a6625dc7b1 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
    97
                    self error:'name conflict: namespace ' , aName , ' vs. global'.
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    98
                ]
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    99
            ].
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   100
            thisNamespace isNil ifTrue:[
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   101
                thisNamespace := self name:key
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   102
            ]
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   103
        ] ifFalse:[
7426
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   104
            thisNamespace isNameSpace ifTrue:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   105
                x := thisNamespace at:key.
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   106
            ] ifFalse:[
7426
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   107
                thisNamespace isBehavior ifTrue:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   108
                    x := thisNamespace privateClassesAt:key.
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   109
                ].
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   110
            ].
2055
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
5249
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
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
        ]
2177
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   152
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   153
"/        2 to:aStringOrSymbol size do:[:idx | |ch|
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   154
"/            ch := aStringOrSymbol at:idx.
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   155
"/            ok ifTrue:[
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   156
"/                ok := ch isLetterOrDigit or:[ch == $_].
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   157
"/            ]
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   158
"/        ]
2024
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   159
    ].
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   160
    ok ifFalse:[
2025
9ab95f23af33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   161
        self error:'invalid namespace name:''' , aStringOrSymbol printString , ''' (must be a valid identifier)'.
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   162
    ].
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   163
5249
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   164
    nameSym := aStringOrSymbol asSymbol.
3383
7837c591ecdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2924
diff changeset
   165
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   166
    self == NameSpace ifTrue:[
5249
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   167
        currentNameSpace := Class nameSpaceQuerySignal query.
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   168
        currentNameSpace isNil ifTrue:[currentNameSpace := Smalltalk].
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   169
        fullName := nameSym
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   170
    ] ifFalse:[
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   171
        currentNameSpace := self.
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   172
        fullName := (self name , '::' , nameSym) asSymbol
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   173
    ].
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   174
3383
7837c591ecdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2924
diff changeset
   175
    (existing := currentNameSpace at:nameSym) notNil ifTrue:[
2015
7e6375a8e0f2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   176
        ^ existing
7e6375a8e0f2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   177
    ].
7e6375a8e0f2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   178
5249
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   179
    newNamespace := self subclass:fullName
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   180
                         instanceVariableNames:''
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   181
                         classVariableNames:''
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   182
                         poolDictionaries:''
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   183
                         category:'uncategorized namespace'.
2144
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
2924
398bec06170f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   186
    newNamespace notNil ifTrue:[newNamespace setPackage:nil].
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
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
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   343
includesKey:aClassNameStringOrSymbol
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   344
    "{ Pragma: +optSpace }"
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   345
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   346
    "return true if such a key is present"
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   347
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   348
    |nmSym|
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   349
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   350
    nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   351
    nmSym isNil ifTrue:[^ false].
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   352
    ^ Smalltalk includesKey:nmSym.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   353
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   354
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   355
! !
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   356
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   357
!NameSpace class methodsFor:'enumerating'!
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
allBehaviorsDo:aBlock
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   360
    "enumerate all classes in this namespace"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   361
2492
ca
parents: 2177
diff changeset
   362
    Smalltalk allBehaviorsDo:[:aClass |
4068
ba1b46d15e70 skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents: 4058
diff changeset
   363
        (aClass isBehavior and:[aClass isMeta not]) ifTrue:[
2583
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   364
            aClass nameSpace == self ifTrue:[
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   365
                aBlock value:aClass
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   366
            ].
2492
ca
parents: 2177
diff changeset
   367
        ]
ca
parents: 2177
diff changeset
   368
    ].
2583
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   369
4068
ba1b46d15e70 skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents: 4058
diff changeset
   370
    "Modified: / 18.3.1999 / 17:21:06 / cg"
4397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   371
!
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   372
5581
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   373
allClassesDo:aBlock
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   374
    "enumerate all classes in this namespace"
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   375
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   376
    Smalltalk allClassesDo:[:aClass |
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   377
        (aClass isBehavior and:[aClass isMeta not]) ifTrue:[
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   378
            aClass nameSpace == self ifTrue:[
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   379
                aBlock value:aClass
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   380
            ].
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
    ].
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   383
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   384
    "Modified: / 18.3.1999 / 17:21:06 / cg"
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   385
!
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   386
4397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   387
keysDo:aBlock
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   388
    "enumerate all class names in this namespace"
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   389
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   390
    |prefix prefixLen|
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   391
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   392
    prefix := self name , '::'.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   393
    prefixLen := prefix size.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   394
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   395
    Smalltalk keysAndValuesDo:[:aName :aClass |
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   396
        |key|
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   398
        (aName startsWith:prefix) ifTrue:[
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   399
            key := (aName copyFrom:prefixLen+1) asSymbol.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   400
            aBlock value:key
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   401
        ]
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   402
    ].
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   403
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   404
    "
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   405
     Benchmarks keysDo:[:k | Transcript showCR:k]
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   406
    "
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
! !
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   409
!NameSpace class methodsFor:'fileOut'!
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   410
2058
09ea6d9cd607 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   411
fileOutDefinitionOn:aStream
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   412
    "redefined to generate another definition message"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   413
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   414
    self == NameSpace ifTrue:[
2058
09ea6d9cd607 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   415
        super fileOutDefinitionOn:aStream
1934
f21f70387dc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1933
diff changeset
   416
    ] ifFalse:[
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   417
        aStream nextPutAll:('NameSpace name:' , self name storeString)
1934
f21f70387dc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1933
diff changeset
   418
    ]
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   419
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   420
    "Modified: 8.11.1996 / 21:39:03 / cg"
2058
09ea6d9cd607 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   421
    "Created: 4.1.1997 / 20:36:32 / cg"
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   422
! !
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   423
5464
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   424
!NameSpace class methodsFor:'fileOut-xml'!
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   425
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   426
fileOutXMLDefinitionOn:aStream
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   427
    "redefined to generate another definition message"
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   428
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   429
    self == NameSpace ifTrue:[
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   430
        super fileOutXMLDefinitionOn:aStream
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   431
    ] ifFalse:[
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   432
        aStream nextPutLine:'<name-space>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   433
        aStream nextPutLine:'  <name>' , self name , '</name>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   434
        aStream nextPutLine:'  <environment>Smalltalk</environment>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   435
        aStream nextPutLine:'  <private>false</private>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   436
        aStream nextPutLine:'  <imports>Smalltalk.*</imports>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   437
        aStream nextPutLine:'  <category>none</category>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   438
        aStream nextPutLine:'</name-space>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   439
    ]
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   440
! !
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   441
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   442
!NameSpace class methodsFor:'inspecting'!
4397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   443
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   444
inspectorClass
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   445
    "{ Pragma: +optSpace }"
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   446
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   447
    "redefined to launch a DictionaryInspector
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   448
     (instead of the default Inspector)."
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   449
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   450
    ^ DictionaryInspectorView
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   451
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   452
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   453
! !
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   454
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   455
!NameSpace class methodsFor:'printing & storing'!
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   456
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   457
displayString
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   458
    "return a printed represenation - here, a reminder is appended,
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   459
     that this is not a regular class"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   460
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   461
    self == NameSpace ifTrue:[
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   462
        ^ super displayString
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   463
    ].
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   464
    ^ self name , ' (* NameSpace *)'
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   465
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   466
    "Created: 8.11.1996 / 21:37:24 / cg"
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   467
    "Modified: 20.12.1996 / 15:11:31 / cg"
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   468
! !
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   469
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   470
!NameSpace class methodsFor:'queries'!
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
2031
05484e955aaa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2030
diff changeset
   472
allNamespaces
2030
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   473
    "return a list of all namespaces"
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   474
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   475
    ^ self allNamespacesIn:Smalltalk
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   476
!
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   477
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   478
allNamespacesIn:anEnvironment
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   479
    "return a list of all namespaces"
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   480
2030
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   481
    |set|
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   482
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   483
    set := IdentitySet with:anEnvironment.
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   484
    anEnvironment allClassesDo:[:aClass |
5327
5e5602d156fa #isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents: 5305
diff changeset
   485
        (aClass isNameSpace 
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   486
        and:[aClass ~~ NameSpace
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   487
        and:[aClass ~~ anEnvironment
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   488
        and:[aClass ~~ Smalltalk]]]) ifTrue:[
2030
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   489
            set add:aClass
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   490
        ]
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   491
    ].
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   492
    ^ set
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   493
!
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   494
7317
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   495
hasNamespaces
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   496
    "return true - if I support sub-namespaces"
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   497
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   498
    ^ false
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   499
!
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   500
5327
5e5602d156fa #isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents: 5305
diff changeset
   501
isNameSpace
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   502
    "return true - I am a namespace"
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   503
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   504
    self == NameSpace ifTrue:[^ false].
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   505
    ^ true
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   506
4457
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   507
!
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   508
5464
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   509
isTopLevelNameSpace
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   510
    ^ (self name includes:$:) not
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   511
!
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   512
4457
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   513
isTopLevelNamespace
5365
95c615a40176 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5331
diff changeset
   514
    "obsolete - use isTopLevelNameSpace"
4457
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   515
7433
8bc88cc029fe Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 7431
diff changeset
   516
    <resource:#obsolete>
8bc88cc029fe Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 7431
diff changeset
   517
5365
95c615a40176 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5331
diff changeset
   518
    ^ (self name includes:$:) not
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
! !
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   521
!NameSpace class methodsFor:'documentation'!
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
version
7433
8bc88cc029fe Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 7431
diff changeset
   524
    ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.50 2003-06-20 07:24:24 stefan Exp $'
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
! !