author | Claus Gittinger <cg@exept.de> |
Mon, 16 Feb 2009 10:46:56 +0100 | |
changeset 11550 | eea8c88e8de7 |
parent 11305 | 83f14d00b6a7 |
child 12169 | 8fcbd9a9237e |
child 17711 | 39faaaf888b4 |
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 |
|
43 |
them at least. |
|
44 |
" |
|
45 |
! ! |
|
46 |
||
9091 | 47 |
!SharedPool class methodsFor:'Compatibility-V''Age'! |
48 |
||
49 |
declareConstant:constantName value:value |
|
50 |
self == SharedPool ifTrue:[ self error ]. |
|
51 |
||
52 |
(self classVarNames includes:constantName) ifFalse:[ |
|
53 |
self addClassVarName:constantName |
|
54 |
]. |
|
55 |
||
56 |
self classVarAt:constantName put:value. |
|
57 |
! ! |
|
58 |
||
8538 | 59 |
!SharedPool class methodsFor:'name lookup'! |
60 |
||
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
61 |
at:name ifAbsent:aBlock |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
62 |
(self includesKey:name) ifFalse:[^ aBlock value]. |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
63 |
^ self classVarAt:name |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
64 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
65 |
|
8538 | 66 |
bindingOf: varName |
67 |
"Answer the binding of some variable resolved in the scope of the receiver" |
|
68 |
||
69 |
| aSymbol binding | |
|
70 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
71 |
self shouldImplement. "not yet finished" |
8538 | 72 |
aSymbol := varName asSymbol. |
73 |
||
74 |
"First look in classVar dictionary." |
|
75 |
binding := self classPool bindingOf: aSymbol. |
|
76 |
binding ifNotNil:[^binding]. |
|
77 |
||
78 |
"Next look in shared pools." |
|
79 |
self sharedPools do:[:pool | |
|
80 |
binding := pool bindingOf: aSymbol. |
|
81 |
binding ifNotNil:[^binding]. |
|
82 |
]. |
|
83 |
||
84 |
"subclassing and environment are not preserved" |
|
85 |
^nil |
|
86 |
! |
|
87 |
||
88 |
bindingsDo: aBlock |
|
89 |
self halt:'unfinished implementation'. |
|
90 |
^ self classPool bindingsDo: aBlock |
|
91 |
! |
|
92 |
||
93 |
classBindingOf: varName |
|
94 |
"For initialization messages grant the regular scope" |
|
95 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
96 |
self shouldImplement. "not yet finished" |
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
97 |
^ super bindingOf: varName |
8551 | 98 |
! |
99 |
||
100 |
includesKey:aSymbol |
|
101 |
^ self keys includes:aSymbol |
|
102 |
||
103 |
" |
|
104 |
OpenGLConstants includesKey:#GL3Bytes |
|
105 |
" |
|
106 |
! |
|
107 |
||
108 |
keys |
|
109 |
^ self classVarNames |
|
110 |
||
111 |
" |
|
112 |
OpenGLConstants keys |
|
113 |
" |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
114 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
115 |
|
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
116 |
keysDo:aBlock |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
117 |
^ self keys do:aBlock |
8551 | 118 |
! ! |
119 |
||
120 |
!SharedPool class methodsFor:'printing & storing'! |
|
121 |
||
122 |
displayString |
|
123 |
"return a printed represenation - here, a reminder is appended, |
|
124 |
that this is not a regular class" |
|
125 |
||
126 |
self == SharedPool ifTrue:[ |
|
127 |
^ super displayString |
|
128 |
]. |
|
129 |
^ self name , ' (* SharedPool *)' |
|
8538 | 130 |
! ! |
131 |
||
132 |
!SharedPool class methodsFor:'queries'! |
|
133 |
||
134 |
isSharedPool |
|
135 |
^ self ~~ SharedPool |
|
136 |
! ! |
|
137 |
||
138 |
!SharedPool class methodsFor:'documentation'! |
|
139 |
||
140 |
version |
|
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
141 |
^ '$Header: /cvs/stx/stx/libbasic/SharedPool.st,v 1.6 2008-11-03 11:22:46 stefan Exp $' |
8538 | 142 |
! ! |