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