NameSpace.st
author Claus Gittinger <cg@exept.de>
Thu, 31 May 2007 18:28:08 +0200
changeset 10587 d0e5f934141a
parent 10372 44ba935b47ba
child 11999 5c5947a4b464
child 17711 39faaaf888b4
permissions -rw-r--r--
+at:ifPresent:
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
"
5464
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
    12
"{ Package: 'stx:libbasic' }"
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
    13
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    14
Object subclass:#NameSpace
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
    15
	instanceVariableNames:'category'
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
    16
	classVariableNames:''
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
    17
	poolDictionaries:''
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
    18
	category:'Kernel-Classes'
1933
74a0bff1ad19 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1931
diff changeset
    19
!
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    20
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    21
!NameSpace class methodsFor:'documentation'!
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    22
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    23
copyright
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 (c) 1996 by Claus Gittinger
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    26
              All Rights Reserved
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    27
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    28
 This software is furnished under a license and may be used
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    29
 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
    30
 inclusion of the above copyright notice.   This software may not
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    31
 be provided or otherwise made available to, or used by, any
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    32
 other person.  No title to or ownership of the software is
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    33
 hereby transferred.
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    34
"
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    35
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    38
documentation
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    39
"
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    40
    A NameSpace is actually a dummy class, providing a home
2010
eaaa38e8bad0 commentary
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
    41
    for its private classes. 
eaaa38e8bad0 commentary
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
    42
    Thus, internally, the same mechanism is used for classes in
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    43
    a NameSpace and private classes.
2010
eaaa38e8bad0 commentary
Claus Gittinger <cg@exept.de>
parents: 2007
diff changeset
    44
    This has two advantages:
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    45
        - we only need one mechanism for both namespaces
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    46
          and private classes
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    47
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    48
        - there are no possible conflicts between a class
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    49
          and a namespace named alike.
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    50
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    52
    [author:]
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    53
        Claus Gittinger
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    54
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    55
    [see also:]
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    56
        Behavior ClassDescription Class Metaclass
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    57
        PrivateMetaclass
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    58
"
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
    59
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
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
    62
!NameSpace class methodsFor:'instance creation'!
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
    63
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    64
fullName:aFullNameSpacePathName
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
    65
    "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
    66
     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
    67
     bottom-level space."
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    68
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    69
    "/ 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
    70
    "/ create them as required.
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    71
7426
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
    72
    |list thisNamespace|
1931
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
    (aFullNameSpacePathName includes:$:) ifTrue:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
    75
        "/ old style
8744
73522a385e11 oops - fullName did not handle '::' correctly
Claus Gittinger <cg@exept.de>
parents: 7575
diff changeset
    76
        list := aFullNameSpacePathName asCollectionOfSubstringsSeparatedByAll:'::'.
7426
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
    77
    ] ifFalse:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
    78
        "/ new style
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
    79
        list := aFullNameSpacePathName asCollectionOfSubstringsSeparatedBy:$..
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    80
    ].
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    81
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    82
    "/ now, look and create 'em
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
    thisNamespace := nil.
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    85
    list do:[:aName |
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    86
        |key x|
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    87
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    88
        key := aName asSymbol.
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
        thisNamespace isNil ifTrue:[
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    91
            (Smalltalk includesKey:key) ifTrue:[
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    92
                thisNamespace := Smalltalk at:key.
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    93
                (thisNamespace notNil
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    94
                and:[thisNamespace isBehavior not]) ifTrue:[
4522
29a6625dc7b1 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 4457
diff changeset
    95
                    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
    96
                ]
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    97
            ].
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    98
            thisNamespace isNil ifTrue:[
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
    99
                thisNamespace := self name:key
8747
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   100
            ].
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   101
        ] ifFalse:[
7426
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   102
            thisNamespace isNameSpace ifTrue:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   103
                x := thisNamespace at:key.
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   104
            ] ifFalse:[
7426
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   105
                thisNamespace isBehavior ifTrue:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   106
                    x := thisNamespace privateClassesAt:key.
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   107
                ].
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   108
            ].
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   109
7426
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   110
            x isNil ifTrue:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   111
                thisNamespace isNameSpace ifTrue:[
8747
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   112
		    thisNamespace == Smalltalk ifTrue:[
8748
eab41f334788 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8747
diff changeset
   113
			x := self name:key
8747
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   114
		    ] ifFalse:[
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   115
                        x := thisNamespace name:key.
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   116
		    ]
7426
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   117
                ] ifFalse:[
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   118
                    x :=
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   119
                        self subclass:key
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   120
                           instanceVariableNames:''
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   121
                           classVariableNames:''
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   122
                           poolDictionaries:''
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   123
                           privateIn:thisNamespace.
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   124
                ].
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   125
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   126
                "/ nameSpaces are not in any package (yet)
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   127
                x setPackage:nil.
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   128
            ].
4059d00c81d7 also allow '.' as ns-separator
Claus Gittinger <cg@exept.de>
parents: 7317
diff changeset
   129
            thisNamespace := x.
8747
0cbc897606c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8744
diff changeset
   130
        ].
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   131
    ].
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
    ^ thisNamespace
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   134
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   135
    "Created: 8.11.1996 / 13:41:59 / cg"
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   136
    "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
   137
!
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   138
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   139
name:aStringOrSymbol
2177
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   140
    "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
   141
     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
   142
     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
   143
7575
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   144
    |currentNameSpace newNameSpace existing ok nameSym fullName|
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   145
2024
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   146
    ok := aStringOrSymbol first isLetter.
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   147
    ok ifTrue:[
2177
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   148
        (aStringOrSymbol 
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   149
            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
   150
            startingAt:2) ~~ 0
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   151
        ifTrue:[
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   152
            ok := false.
2024
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   153
        ]
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   154
    ].
71a088db4583 validate nameSpaces name for being a valid identifier.
Claus Gittinger <cg@exept.de>
parents: 2015
diff changeset
   155
    ok ifFalse:[
2025
9ab95f23af33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   156
        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
   157
    ].
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   158
5249
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   159
    nameSym := aStringOrSymbol asSymbol.
3383
7837c591ecdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2924
diff changeset
   160
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   161
    self == NameSpace ifTrue:[
7575
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   162
        "/ currentNameSpace := Class nameSpaceQuerySignal query.
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   163
        currentNameSpace isNil ifTrue:[
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   164
            currentNameSpace := Smalltalk
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   165
        ].
5249
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   166
        fullName := nameSym
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   167
    ] ifFalse:[
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   168
        currentNameSpace := self.
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   169
        fullName := (self name , '::' , nameSym) asSymbol
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   170
    ].
77cad45f94f8 fixed sub-namespace creation
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   171
3383
7837c591ecdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2924
diff changeset
   172
    (existing := currentNameSpace at:nameSym) notNil ifTrue:[
2015
7e6375a8e0f2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   173
        ^ existing
7e6375a8e0f2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   174
    ].
7575
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   175
    newNameSpace := self 
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   176
        subclass:fullName
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   177
        instanceVariableNames:''
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   178
        classVariableNames:''
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   179
        poolDictionaries:''
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   180
        category:'uncategorized namespace'
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   181
        inEnvironment:Smalltalk.
2144
76dd062d32a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2058
diff changeset
   182
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   183
    "/ nameSpaces are not in any package
7575
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   184
    newNameSpace notNil ifTrue:[newNameSpace setPackage:nil].
80341bf0e03e bug: created sub-nameSpace Foo::Foo,
Claus Gittinger <cg@exept.de>
parents: 7433
diff changeset
   185
    ^ newNameSpace
1901
8eebbd3c7232 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1828
diff changeset
   186
8eebbd3c7232 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1828
diff changeset
   187
    "
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   188
     NameSpace name:'foo'
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   189
     (NameSpace name:'foo') category:'my name space'
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   190
     foo at:#bar put:(Metaclass new new)
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   191
     (NameSpace name:'foo') name:'bar'
1901
8eebbd3c7232 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1828
diff changeset
   192
    "
2177
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   193
    "
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   194
     NameSpace name:'an-invalid++name'
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   195
     NameSpace name:'another:invalidName'
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   196
     NameSpace name:'another::invalidName'
2177
80f6ec11f797 create new namespaces in the current nameSpace (by default)
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   197
    "
1931
5f60d3e5ba6e moved namespace creation completely to Namespace class.
Claus Gittinger <cg@exept.de>
parents: 1908
diff changeset
   198
4058
58987b73c0c7 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 3383
diff changeset
   199
    "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
   200
    "Modified: / 18.3.1999 / 18:24:13 / stefan"
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   201
!
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   202
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   203
new
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   204
    "catch new - namespaces are not to be created by the user"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   205
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   206
    self error:'namespaces are not to be created with new'
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   207
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   208
    "Modified: 8.11.1996 / 21:38:00 / cg"
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   209
! !
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   210
7298
9b3c69eb2c5d category
Claus Gittinger <cg@exept.de>
parents: 6824
diff changeset
   211
!NameSpace class methodsFor:'Compatibility-VW5.4'!
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   212
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   213
defineClass: name
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   214
                superclass: superclass
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   215
                indexedType: indexed
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   216
                private: private
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   217
                instanceVariableNames: instVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   218
                classInstanceVariableNames: classInstVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   219
                imports: imports
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   220
                category: category
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   221
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   222
    ^ self
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   223
        defineClass: name
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   224
        superclass: superclass
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   225
        indexedType: indexed
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   226
        private: private
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   227
        instanceVariableNames: instVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   228
        classInstanceVariableNames: classInstVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   229
        imports: imports
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   230
        category: category
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   231
        attributes: nil
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   232
!
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   233
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   234
defineClass: name
7431
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   235
                superclass: superclassOrName
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   236
                indexedType: indexed
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   237
                private: private
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   238
                instanceVariableNames: instVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   239
                classInstanceVariableNames: classInstVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   240
                imports: imports
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   241
                category: category
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   242
                attributes: annotations
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   243
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   244
    "VW5i compatibility class/namespace creation"
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   245
7431
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   246
    |variable words pointers superclass|
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   247
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   248
    variable := words := pointers := false.
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   249
    indexed ~~ #none ifTrue:[
7433
8bc88cc029fe Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 7431
diff changeset
   250
        self shouldImplement.
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   251
    ].
7431
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   252
    superclassOrName isSymbol ifTrue:[
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   253
        superclass := Smalltalk at:superclassOrName.
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   254
        superclass isNil ifTrue:[
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   255
            self error:'missing superclass: ' , superclassOrName.
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   256
        ]
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   257
    ] ifFalse:[   
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   258
        superclass := superclassOrName
ba25eb29e77d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7426
diff changeset
   259
    ].
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   260
    ^ superclass value class
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   261
        name:name 
6824
6fbe85d05646 ...in:... -> ...inEnvironment:...
Claus Gittinger <cg@exept.de>
parents: 6450
diff changeset
   262
        inEnvironment:self
6450
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   263
        subclassOf:superclass value
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   264
        instanceVariableNames:instVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   265
        variable:variable
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   266
        words:words
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   267
        pointers:pointers
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   268
        classVariableNames:''
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   269
        poolDictionaries:''
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   270
        category:category
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   271
        comment:nil
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   272
        changed:true
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   273
        classInstanceVariableNames:classInstVars
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   274
! !
eede800067ad category change
Claus Gittinger <cg@exept.de>
parents: 6449
diff changeset
   275
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   276
!NameSpace class methodsFor:'accessing'!
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   277
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   278
allClasses
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   279
    |classes|
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   280
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   281
    classes := IdentitySet new.
5581
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   282
    self allClassesDo:[:aClass | classes add:aClass].
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   283
    ^ classes
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
    "Modified: 20.12.1996 / 15:34:50 / cg"
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
4372
eaba7e085030 added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents: 4068
diff changeset
   288
allClassesWithAllPrivateClasses
eaba7e085030 added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents: 4068
diff changeset
   289
    |classes|
eaba7e085030 added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents: 4068
diff changeset
   290
eaba7e085030 added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents: 4068
diff changeset
   291
    classes := IdentitySet new.
5581
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   292
    self allClassesDo:[:aClass | 
4372
eaba7e085030 added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents: 4068
diff changeset
   293
        classes add:aClass.
eaba7e085030 added #allClassesWithAllPrivateClasses
Claus Gittinger <cg@exept.de>
parents: 4068
diff changeset
   294
        aClass addAllPrivateClassesTo: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
    ^ 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
    "Modified: 20.12.1996 / 15:34:50 / cg"
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
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   301
at:classNameSymbol
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   302
    "return a class from the namespace defined by the receiver"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   303
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   304
    ^ self privateClassesAt:classNameSymbol
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   305
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   306
    "Modified: 8.11.1996 / 21:39:41 / cg"
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   307
!
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   308
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   309
at:classNameSymbol ifAbsent:exceptionBlock
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   310
    "return a class or an alternative
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   311
     from the namespace defined by the receiver"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   312
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   313
    |cls|
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   314
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   315
    cls := self privateClassesAt:classNameSymbol.
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   316
    cls isNil ifTrue:[
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   317
        ^ exceptionBlock value
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   318
    ].
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   319
    ^ cls
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   320
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   321
    "Modified: 8.11.1996 / 21:40:01 / cg"
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   322
!
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   323
10587
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   324
at:aKey ifPresent:aBlock
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   325
    "try to retrieve the value stored at aKey.
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   326
     If there is nothing stored under this key, do nothing.
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   327
     Otherwise, evaluate aBlock, passing the retrieved value as argument."
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   328
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   329
    (self includesKey:aKey) ifTrue:[
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   330
        ^ aBlock value:(self at:aKey)
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   331
    ].
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   332
    ^ nil
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   333
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   334
    "Modified: / 31-05-2007 / 17:50:46 / cg"
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   335
!
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   336
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   337
at:classNameSymbol put:aClass
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   338
    "add a class to the namespace defined by the receiver"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   339
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   340
    ^ self privateClassesAt:classNameSymbol put:aClass
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   341
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   342
    "Modified: 8.11.1996 / 21:40:12 / cg"
2908
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   343
!
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   344
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   345
classNamed:aString
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   346
    "return the class with name aString, or nil if absent.
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   347
     To get to the metaClass, append ' class' to the string."
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   348
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   349
    ^ Smalltalk classNamed:(self name , '::' , aString)
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   350
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
   351
    "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
   352
!
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   353
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   354
classNames
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   355
    ^ self allClasses collect:[:each | each nameWithoutPrefix]
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   356
!
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   357
4397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   358
includesKey:aClassNameStringOrSymbol
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   359
    "{ Pragma: +optSpace }"
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   360
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   361
    "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
   362
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   363
    |nmSym|
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   364
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   365
    nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   366
    nmSym isNil ifTrue:[^ false].
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   367
    ^ Smalltalk includesKey:nmSym.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   368
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   369
9546
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   370
!
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   371
10372
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   372
loadedClassNamed:aString
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   373
    "return the class with name aString, or nil if absent.
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   374
     To get to the metaClass, append ' class' to the string.
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   375
     Do not autoload the owning class of a private class."
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   376
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   377
    ^ Smalltalk loadedClassNamed:(self name , '::' , aString)
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   378
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   379
    "Created: 9.9.1997 / 03:33:56 / cg"
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   380
!
44ba935b47ba #loadedClassNamed
Stefan Vogel <sv@exept.de>
parents: 10176
diff changeset
   381
9546
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   382
package
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   383
    self isNameSpace ifTrue:[    
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   384
        ^ nil       "all nameSpaces are outside of any package"
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   385
    ].
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   386
    ^ super package "the nameSpace class itself has a package"
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   387
1e45da4681d4 Namespaces have no package
fm
parents: 9372
diff changeset
   388
    "Created: / 16-08-2006 / 18:48:29 / User"
1827
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   389
! !
fa0017393e3b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
   390
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   391
!NameSpace class methodsFor:'enumerating'!
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
allBehaviorsDo:aBlock
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   394
    "enumerate all classes in this namespace"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   395
2492
ca
parents: 2177
diff changeset
   396
    Smalltalk allBehaviorsDo:[:aClass |
4068
ba1b46d15e70 skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents: 4058
diff changeset
   397
        (aClass isBehavior and:[aClass isMeta not]) ifTrue:[
2583
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   398
            aClass nameSpace == self ifTrue:[
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   399
                aBlock value:aClass
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   400
            ].
2492
ca
parents: 2177
diff changeset
   401
        ]
ca
parents: 2177
diff changeset
   402
    ].
2583
16b1872c068d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
   403
4068
ba1b46d15e70 skip metaclasses when enumerating behaviors of a namespace
Claus Gittinger <cg@exept.de>
parents: 4058
diff changeset
   404
    "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
   405
!
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   406
5581
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   407
allClassesDo:aBlock
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   408
    "enumerate all classes in this namespace"
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   409
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   410
    Smalltalk allClassesDo:[:aClass |
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   411
        (aClass isBehavior and:[aClass isMeta not]) ifTrue:[
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   412
            aClass nameSpace == self ifTrue:[
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   413
                aBlock value:aClass
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   414
            ].
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   415
        ]
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   416
    ].
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   417
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   418
    "Modified: / 18.3.1999 / 17:21:06 / cg"
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   419
!
7bef1c75fb06 allBehaviors vs. allClasses
Claus Gittinger <cg@exept.de>
parents: 5571
diff changeset
   420
9289
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   421
keys
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   422
    "enumerate all class names in this namespace"
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   423
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   424
    |setOfKeys|
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   425
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   426
    setOfKeys := OrderedCollection new.
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   427
    self keysDo:[:eachKey |setOfKeys add:eachKey].
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   428
    ^ setOfKeys
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   429
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   430
    "
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   431
     Benchmarks keys
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   432
    "
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   433
!
a919b3a085ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9267
diff changeset
   434
4397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   435
keysDo:aBlock
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   436
    "enumerate all class names in this namespace"
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   437
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   438
    |prefix prefixLen|
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
    prefix := self name , '::'.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   441
    prefixLen := prefix size.
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
    Smalltalk keysAndValuesDo:[:aName :aClass |
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   444
        |key|
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
        (aName startsWith:prefix) ifTrue:[
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   447
            key := (aName copyFrom:prefixLen+1) asSymbol.
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   448
            aBlock value:key
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
    ].
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
     Benchmarks keysDo:[:k | Transcript showCR:k]
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   454
    "
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
! !
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   457
!NameSpace class methodsFor:'fileOut'!
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   458
2058
09ea6d9cd607 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   459
fileOutDefinitionOn:aStream
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   460
    "redefined to generate another definition message"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   461
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   462
    self == NameSpace ifTrue:[
2058
09ea6d9cd607 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   463
        super fileOutDefinitionOn:aStream
1934
f21f70387dc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1933
diff changeset
   464
    ] ifFalse:[
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   465
        aStream nextPutAll:('NameSpace name:' , self name storeString)
1934
f21f70387dc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1933
diff changeset
   466
    ]
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   467
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   468
    "Modified: 8.11.1996 / 21:39:03 / cg"
2058
09ea6d9cd607 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   469
    "Created: 4.1.1997 / 20:36:32 / cg"
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   470
! !
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   471
5464
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   472
!NameSpace class methodsFor:'fileOut-xml'!
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   473
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   474
fileOutXMLDefinitionOn:aStream
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   475
    "redefined to generate another definition message"
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   476
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   477
    self == NameSpace ifTrue:[
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   478
        super fileOutXMLDefinitionOn:aStream
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   479
    ] ifFalse:[
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   480
        aStream nextPutLine:'<name-space>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   481
        aStream nextPutLine:'  <name>' , self name , '</name>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   482
        aStream nextPutLine:'  <environment>Smalltalk</environment>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   483
        aStream nextPutLine:'  <private>false</private>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   484
        aStream nextPutLine:'  <imports>Smalltalk.*</imports>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   485
        aStream nextPutLine:'  <category>none</category>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   486
        aStream nextPutLine:'</name-space>'.
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   487
    ]
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   488
! !
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   489
4397
bfcf41484c1f added keysDo: and includesKey: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
   490
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   491
!NameSpace class methodsFor:'printing & storing'!
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   492
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   493
displayString
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   494
    "return a printed represenation - here, a reminder is appended,
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   495
     that this is not a regular class"
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   496
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   497
    self == NameSpace ifTrue:[
2007
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   498
        ^ super displayString
57434c08d720 namespace itself is not a namespace
Claus Gittinger <cg@exept.de>
parents: 1943
diff changeset
   499
    ].
5328
319b8e3ee60e renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents: 5327
diff changeset
   500
    ^ self name , ' (* NameSpace *)'
1943
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   501
0ec17e4627ae better displayString & commentary
Claus Gittinger <cg@exept.de>
parents: 1934
diff changeset
   502
    "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
   503
    "Modified: 20.12.1996 / 15:11:31 / cg"
1828
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   504
! !
92e8ede212e7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1827
diff changeset
   505
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   506
!NameSpace class methodsFor:'queries'!
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   508
allNameSpaces
2030
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   509
    "return a list of all namespaces"
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   510
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   511
    ^ self allNameSpacesIn:Smalltalk
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   512
!
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   513
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   514
allNameSpacesIn:anEnvironment
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   515
    "return a list of all namespaces"
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   516
2030
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   517
    |set|
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   518
6401
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   519
    set := IdentitySet with:anEnvironment.
6df8939407df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
   520
    anEnvironment allClassesDo:[:aClass |
10176
70833704c6ae use isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 10170
diff changeset
   521
        (aClass isRealNameSpace 
70833704c6ae use isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 10170
diff changeset
   522
        and:[aClass ~~ anEnvironment]) ifTrue:[
2030
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   523
            set add:aClass
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   524
        ]
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   525
    ].
94800ed9cdc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2025
diff changeset
   526
    ^ set
10176
70833704c6ae use isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 10170
diff changeset
   527
70833704c6ae use isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 10170
diff changeset
   528
    "Modified: / 10-11-2006 / 17:12:02 / cg"
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   529
!
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   530
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   531
allNamespaces
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   532
    "return a list of all namespaces"
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   533
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   534
    <resource: #obsolete>
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   535
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   536
    ^ self allNameSpaces
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   537
!
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   538
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   539
allNamespacesIn:anEnvironment
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   540
    "return a list of all namespaces"
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   541
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   542
    <resource: #obsolete>
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   543
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   544
    ^ self allNameSpacesIn:anEnvironment
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   545
!
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   546
9814
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   547
canHaveExtensions
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   548
    "return true, if this class allows extensions from other packages.
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   549
     Private classes, namespaces and projectDefinitions dont allow this"
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   550
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   551
    ^ self == NameSpace
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   552
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   553
    "
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   554
     Smalltalk allClasses select:[:each | each canHaveExtensions not]
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   555
    "
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   556
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   557
    "Created: / 30-08-2006 / 15:28:39 / cg"
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   558
!
1f92f9974325 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9675
diff changeset
   559
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   560
hasNameSpaces
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   561
    "return true - if I support sub-namespaces"
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   562
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   563
    ^ false
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   564
!
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   565
7317
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   566
hasNamespaces
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   567
    "return true - if I support sub-namespaces"
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   568
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   569
    <resource: #obsolete>
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   570
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   571
    ^ self hasNameSpaces
7317
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   572
!
461d6124fd63 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7298
diff changeset
   573
5327
5e5602d156fa #isNamespace renamed to #isNameSpace
Claus Gittinger <cg@exept.de>
parents: 5305
diff changeset
   574
isNameSpace
9217
e8e6eee6b187 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8748
diff changeset
   575
    "return true, if the receiver is a nameSpace.
10170
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   576
     Unconditionally true here for subclasses - my subclasses are namespaces"
2055
fe4e60ded02a namespaces have no package
Claus Gittinger <cg@exept.de>
parents: 2031
diff changeset
   577
9372
3e8b8e54a66d comment
Stefan Vogel <sv@exept.de>
parents: 9289
diff changeset
   578
    ^ self ~~ NameSpace .
10170
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   579
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   580
    "Modified: / 10-11-2006 / 17:01:56 / cg"
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   581
!
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   582
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   583
isRealNameSpace
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   584
    "return true, if the receiver is a nameSpace, but not Smalltalk (which is also a class).
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   585
     Unconditionally true here for subclasses - my subclasses are namespaces"
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   586
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   587
    ^ self ~~ NameSpace .
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   588
a0f93c718081 +isRealNameSpace
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
   589
    "Created: / 10-11-2006 / 17:01:52 / cg"
4457
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   590
!
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   591
5464
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   592
isTopLevelNameSpace
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   593
    ^ (self name includes:$:) not
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   594
!
af5c4f052b20 xml fileOut
Claus Gittinger <cg@exept.de>
parents: 5365
diff changeset
   595
4457
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   596
isTopLevelNamespace
5365
95c615a40176 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5331
diff changeset
   597
    "obsolete - use isTopLevelNameSpace"
4457
001af8a9bd46 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4397
diff changeset
   598
9267
78ecc4a28bef Namespace -> NameSpace
Claus Gittinger <cg@exept.de>
parents: 9217
diff changeset
   599
    <resource: #obsolete>
7433
8bc88cc029fe Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 7431
diff changeset
   600
5365
95c615a40176 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5331
diff changeset
   601
    ^ (self name includes:$:) not
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
! !
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
5331
f6b7c392b899 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5328
diff changeset
   604
!NameSpace class methodsFor:'documentation'!
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
version
10587
d0e5f934141a +at:ifPresent:
Claus Gittinger <cg@exept.de>
parents: 10372
diff changeset
   607
    ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.66 2007-05-31 16:28:08 cg Exp $'
1816
b063c5b47433 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
! !