author | Claus Gittinger <cg@exept.de> |
Sat, 15 Jan 2011 14:20:27 +0100 | |
changeset 13210 | 2ceae489a80b |
parent 13208 | 3e8317f5e070 |
child 13211 | c64d16143d54 |
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 |
||
13181 | 60 |
!SharedPool class methodsFor:'code generation'! |
61 |
||
62 |
initializeFrom:aDictionary |
|
13207
5f62183ab0e9
comment/format in: #initializeFrom:
Claus Gittinger <cg@exept.de>
parents:
13181
diff
changeset
|
63 |
"given a dictionary, generate my classvars and the init code" |
13181 | 64 |
|
65 |
|code| |
|
66 |
||
13210 | 67 |
self addClassVarNames:(aDictionary keys asSortedCollection). |
13181 | 68 |
|
69 |
code := String streamContents:[:s | |
|
70 |
s nextPutLine:'initialize'. |
|
71 |
aDictionary keys asSortedCollection do:[:k | |
|
72 |
|v| |
|
73 |
||
74 |
v := aDictionary at:k. |
|
75 |
s nextPutLine:(' %1 := %2.' bindWith:k with:v storeString). |
|
76 |
]. |
|
77 |
]. |
|
78 |
self class compile:code classified:'initialization' |
|
79 |
||
80 |
" |
|
81 |
OLEStatusCodeConstants initializeFrom:aDictionary |
|
82 |
" |
|
83 |
||
84 |
"Created: / 21-12-2010 / 17:58:25 / cg" |
|
13210 | 85 |
"Modified: / 15-01-2011 / 14:19:59 / cg" |
13181 | 86 |
! ! |
87 |
||
13207
5f62183ab0e9
comment/format in: #initializeFrom:
Claus Gittinger <cg@exept.de>
parents:
13181
diff
changeset
|
88 |
|
13097
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
89 |
!SharedPool class methodsFor:'misc ui support'! |
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
90 |
|
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
91 |
iconInBrowserSymbol |
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
92 |
<resource: #programImage> |
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
93 |
|
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
94 |
self == SharedPool ifTrue:[^ super iconInBrowserSymbol]. |
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
95 |
^ #sharedPoolBrowserIcon |
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
96 |
|
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
97 |
"Created: / 14-10-2010 / 12:04:32 / cg" |
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
98 |
! ! |
d07ec91b3105
added: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
13005
diff
changeset
|
99 |
|
8538 | 100 |
!SharedPool class methodsFor:'name lookup'! |
101 |
||
12169 | 102 |
at:name |
103 |
"retrieve a pool variable by name" |
|
104 |
||
105 |
^ self at:name ifAbsent:[self errorKeyNotFound:name] |
|
106 |
! |
|
107 |
||
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
108 |
at:name ifAbsent:aBlock |
12169 | 109 |
"retrieve a pool variable by name" |
110 |
||
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
111 |
(self includesKey:name) ifFalse:[^ aBlock value]. |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
112 |
^ self classVarAt:name |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
113 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
114 |
|
8538 | 115 |
bindingOf: varName |
116 |
"Answer the binding of some variable resolved in the scope of the receiver" |
|
117 |
||
118 |
| aSymbol binding | |
|
119 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
120 |
self shouldImplement. "not yet finished" |
8538 | 121 |
aSymbol := varName asSymbol. |
122 |
||
123 |
"First look in classVar dictionary." |
|
124 |
binding := self classPool bindingOf: aSymbol. |
|
13005 | 125 |
binding notNil ifTrue:[^binding]. |
8538 | 126 |
|
127 |
"Next look in shared pools." |
|
128 |
self sharedPools do:[:pool | |
|
13005 | 129 |
binding := pool bindingOf: aSymbol. |
130 |
binding notNil ifTrue:[^binding]. |
|
8538 | 131 |
]. |
132 |
||
133 |
"subclassing and environment are not preserved" |
|
134 |
^nil |
|
13005 | 135 |
|
136 |
"Modified: / 08-08-2010 / 14:46:09 / cg" |
|
8538 | 137 |
! |
138 |
||
139 |
bindingsDo: aBlock |
|
140 |
self halt:'unfinished implementation'. |
|
141 |
^ self classPool bindingsDo: aBlock |
|
142 |
! |
|
143 |
||
144 |
classBindingOf: varName |
|
145 |
"For initialization messages grant the regular scope" |
|
146 |
||
11305
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
147 |
self shouldImplement. "not yet finished" |
83f14d00b6a7
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
10853
diff
changeset
|
148 |
^ super bindingOf: varName |
8551 | 149 |
! |
150 |
||
151 |
includesKey:aSymbol |
|
152 |
^ self keys includes:aSymbol |
|
153 |
||
154 |
" |
|
155 |
OpenGLConstants includesKey:#GL3Bytes |
|
156 |
" |
|
157 |
! |
|
158 |
||
159 |
keys |
|
160 |
^ self classVarNames |
|
161 |
||
162 |
" |
|
163 |
OpenGLConstants keys |
|
164 |
" |
|
10853
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
165 |
! |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
166 |
|
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
167 |
keysDo:aBlock |
72acafda369f
dictionary compatible protocol added
Claus Gittinger <cg@exept.de>
parents:
9091
diff
changeset
|
168 |
^ self keys do:aBlock |
8551 | 169 |
! ! |
170 |
||
171 |
!SharedPool class methodsFor:'printing & storing'! |
|
172 |
||
173 |
displayString |
|
174 |
"return a printed represenation - here, a reminder is appended, |
|
175 |
that this is not a regular class" |
|
176 |
||
177 |
self == SharedPool ifTrue:[ |
|
178 |
^ super displayString |
|
179 |
]. |
|
180 |
^ self name , ' (* SharedPool *)' |
|
8538 | 181 |
! ! |
182 |
||
183 |
!SharedPool class methodsFor:'queries'! |
|
184 |
||
185 |
isSharedPool |
|
186 |
^ self ~~ SharedPool |
|
187 |
! ! |
|
188 |
||
189 |
!SharedPool class methodsFor:'documentation'! |
|
190 |
||
191 |
version |
|
13210 | 192 |
^ '$Header: /cvs/stx/stx/libbasic/SharedPool.st,v 1.14 2011-01-15 13:20:27 cg Exp $' |
12169 | 193 |
! |
194 |
||
195 |
version_CVS |
|
13210 | 196 |
^ '$Header: /cvs/stx/stx/libbasic/SharedPool.st,v 1.14 2011-01-15 13:20:27 cg Exp $' |
8538 | 197 |
! ! |