author | Claus Gittinger <cg@exept.de> |
Mon, 12 Oct 2009 21:09:14 +0200 | |
changeset 12220 | c26b8b402a71 |
parent 12169 | 8fcbd9a9237e |
child 13005 | 2ba0600be7aa |
permissions | -rw-r--r-- |
8728 | 1 |
" |
2 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
8538 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
14 |
Object subclass:#SharedPool |
|
15 |
instanceVariableNames:'' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Kernel-Classes' |
|
19 |
! |
|
20 |
||
21 |
!SharedPool class methodsFor:'documentation'! |
|
22 |
||
8728 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
8538 | 37 |
documentation |
38 |
" |
|
39 |
A shared pool represents a set of bindings which are accessible to all classes |
|
40 |
which import the pool in its 'pool dictionaries'. |
|
41 |
SharedPool is NOT a dictionary but rather a name space. |
|
42 |
Bindings are represented by 'class variables' - as long as we have no better way to represent |
|
12220 | 43 |
them at least. This is done to make stc happy (or at least, to not be forced to adapt it |
44 |
to any new semantics). |
|
8538 | 45 |
" |
46 |
! ! |
|
47 |
||
9091 | 48 |
!SharedPool class methodsFor:'Compatibility-V''Age'! |
49 |
||
50 |
declareConstant:constantName value:value |
|
51 |
self == SharedPool ifTrue:[ self error ]. |
|
52 |
||
53 |
(self classVarNames includes:constantName) ifFalse:[ |
|
54 |
self addClassVarName:constantName |
|
55 |
]. |
|
56 |
||
57 |
self classVarAt:constantName put:value. |
|
58 |
! ! |
|
59 |
||
8538 | 60 |
!SharedPool class methodsFor:'name lookup'! |
61 |
||
12169 | 62 |
at:name |
63 |
"retrieve a pool variable by name" |
|
64 |
||
65 |
^ self at:name ifAbsent:[self errorKeyNotFound:name] |
|
66 |
! |
|
67 |
||
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
68 |
at:name ifAbsent:aBlock |
12169 | 69 |
"retrieve a pool variable by name" |
70 |
||
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
71 |
(self includesKey:name) ifFalse:[^ aBlock value]. |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
72 |
^ self classVarAt:name |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
73 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
74 |
|
8538 | 75 |
bindingOf: varName |
76 |
"Answer the binding of some variable resolved in the scope of the receiver" |
|
77 |
||
78 |
| aSymbol binding | |
|
79 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
80 |
self shouldImplement. "not yet finished" |
8538 | 81 |
aSymbol := varName asSymbol. |
82 |
||
83 |
"First look in classVar dictionary." |
|
84 |
binding := self classPool bindingOf: aSymbol. |
|
85 |
binding ifNotNil:[^binding]. |
|
86 |
||
87 |
"Next look in shared pools." |
|
88 |
self sharedPools do:[:pool | |
|
89 |
binding := pool bindingOf: aSymbol. |
|
90 |
binding ifNotNil:[^binding]. |
|
91 |
]. |
|
92 |
||
93 |
"subclassing and environment are not preserved" |
|
94 |
^nil |
|
95 |
! |
|
96 |
||
97 |
bindingsDo: aBlock |
|
98 |
self halt:'unfinished implementation'. |
|
99 |
^ self classPool bindingsDo: aBlock |
|
100 |
! |
|
101 |
||
102 |
classBindingOf: varName |
|
103 |
"For initialization messages grant the regular scope" |
|
104 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
105 |
self shouldImplement. "not yet finished" |
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
106 |
^ super bindingOf: varName |
8551 | 107 |
! |
108 |
||
109 |
includesKey:aSymbol |
|
110 |
^ self keys includes:aSymbol |
|
111 |
||
112 |
" |
|
113 |
OpenGLConstants includesKey:#GL3Bytes |
|
114 |
" |
|
115 |
! |
|
116 |
||
117 |
keys |
|
118 |
^ self classVarNames |
|
119 |
||
120 |
" |
|
121 |
OpenGLConstants keys |
|
122 |
" |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
123 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
124 |
|
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
125 |
keysDo:aBlock |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
126 |
^ self keys do:aBlock |
8551 | 127 |
! ! |
128 |
||
129 |
!SharedPool class methodsFor:'printing & storing'! |
|
130 |
||
131 |
displayString |
|
132 |
"return a printed represenation - here, a reminder is appended, |
|
133 |
that this is not a regular class" |
|
134 |
||
135 |
self == SharedPool ifTrue:[ |
|
136 |
^ super displayString |
|
137 |
]. |
|
138 |
^ self name , ' (* SharedPool *)' |
|
8538 | 139 |
! ! |
140 |
||
141 |
!SharedPool class methodsFor:'queries'! |
|
142 |
||
143 |
isSharedPool |
|
144 |
^ self ~~ SharedPool |
|
145 |
! ! |
|
146 |
||
147 |
!SharedPool class methodsFor:'documentation'! |
|
148 |
||
149 |
version |
|
12220 | 150 |
^ '$Header: /cvs/stx/stx/libbasic/SharedPool.st,v 1.8 2009-10-12 19:09:14 cg Exp $' |
12169 | 151 |
! |
152 |
||
153 |
version_CVS |
|
12220 | 154 |
^ '$Header: /cvs/stx/stx/libbasic/SharedPool.st,v 1.8 2009-10-12 19:09:14 cg Exp $' |
8538 | 155 |
! ! |