author | Stefan Vogel <sv@exept.de> |
Tue, 28 Apr 2020 14:41:21 +0200 | |
changeset 25372 | 389daab3ee10 |
parent 25194 | 504dea634320 |
permissions | -rw-r--r-- |
25194 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1991 by Claus Gittinger |
154 | 5 |
All Rights Reserved |
1 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
5345 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
18275 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
620 | 18 |
nil subclass:#Autoload |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
19 |
instanceVariableNames:'' |
25194 | 20 |
classVariableNames:'AutoloadFailedSignal InProgressClasses LazyLoading LoadedClasses' |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
21 |
poolDictionaries:'' |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
22 |
category:'Kernel-Classes' |
1 | 23 |
! |
24 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
25 |
!Autoload class methodsFor:'documentation'! |
68 | 26 |
|
88 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
154 | 30 |
All Rights Reserved |
88 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
68 | 41 |
documentation |
42 |
" |
|
17124 | 43 |
Autoload is a stub for an 'as yet unloaded' class. |
44 |
||
20274 | 45 |
In memory limited systems (as my original 8Mb 386 system was), |
46 |
all seldom-used classes were made subclasses of this class. |
|
47 |
Autoload catches all messages sent to it, and files-in the real class's |
|
17124 | 48 |
code when first used. Then the caught message is resent to the (now existing) class. |
2662 | 49 |
|
17124 | 50 |
A note from later days: |
20274 | 51 |
These days, systems usually have enough memory to allow |
17124 | 52 |
having all classes present, so many of the classes which used to be |
53 |
autoloaded are no longer these days. However, a number of examples or |
|
54 |
very seldom used frameworks are still present as autoloaded. |
|
55 |
Instead of using autoloaded classes, it is now recommended to bundle |
|
56 |
extra classes into packages, which are loaded en-bloque. |
|
57 |
Packages can be compiled to a shared class library and thus be loaded |
|
58 |
much faster (there is no need to parse and compile source files). |
|
59 |
||
60 |
Lazy loading: |
|
2662 | 61 |
Class files are searched along the searchPath (see Smalltalk), |
20274 | 62 |
and any of binary-classFile, byteCode-classFile or sourceFile are loaded, |
63 |
whichever is found first. |
|
17124 | 64 |
For binaries to be loaded, these must be found in a package-subdirectory |
20274 | 65 |
along the so called package path. |
17124 | 66 |
Sources in a package directory along the source path. |
67 |
In practice, most Autoloaded classes are found and loaded as source file. |
|
2662 | 68 |
|
17124 | 69 |
Initial Setup of Auoload Stubs: |
70 |
At initial startup (i.e. when ST/X is NOT coming up with an image), |
|
71 |
the 'patches' startup script recursively walks along all directories |
|
72 |
below the TOP directory (that is one above the stx folder), |
|
73 |
and installs autoload stubs for all .st class files found, for which no |
|
74 |
corresponding class is already present. |
|
75 |
As you can imagine, this takes a long time and makes the initial startup quite slow. |
|
21767 | 76 |
Therefore, this scheme is no longer the recommended one and we (at eXept) |
17124 | 77 |
always start ST/X with the '--quick' option, which skips this scan operation. |
21767 | 78 |
Late note: |
79 |
--quick is now (7.1.1) the default. |
|
20597 | 80 |
To force an autoload scan, start stx with a --autoload argument. |
21767 | 81 |
|
82 |
||
17124 | 83 |
Advantage of Autoload stubs: |
84 |
Autoload stubs make it easier for a beginner to ST/X, to see what frameworks and classes |
|
85 |
are there, as they appear in the browser with category and class name (although no |
|
86 |
more details are initially visible. |
|
68 | 87 |
|
1278 | 88 |
[class variables:] |
20274 | 89 |
|
90 |
LazyLoading <Boolean> if true, the loaded classes |
|
91 |
methods will NOT be compiled at |
|
92 |
autoload time, but instead when |
|
93 |
first called. This allows for a |
|
94 |
faster load. However, expect short |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
95 |
pauses later when the methods are |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
96 |
first executed. |
20274 | 97 |
|
98 |
AutoloadFailedSignal <Signal> signal raised if an autoloaded |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
99 |
classes source is not available. |
922 | 100 |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
101 |
LoadedClasses <Collection> set of classes that heve been |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
102 |
autoloaded (for later unload) |
1292 | 103 |
|
2662 | 104 |
[see also:] |
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
105 |
Smalltalk |
2662 | 106 |
|
1292 | 107 |
[author:] |
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
108 |
Claus Gittinger |
68 | 109 |
" |
110 |
! ! |
|
111 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
112 |
!Autoload class methodsFor:'initialization'! |
126 | 113 |
|
114 |
initialize |
|
12252 | 115 |
"initialize either the Autoload class |
21767 | 116 |
or load an autoloaded class and initialize it." |
2223 | 117 |
|
12252 | 118 |
self ~~ Autoload ifTrue:[ |
119 |
"subclass: catch initialize - load the class and resend #initialize to the real one" |
|
120 |
^ self doesNotUnderstand:(Message selector:#initialize) |
|
121 |
]. |
|
122 |
||
123 |
"initialize myself" |
|
126 | 124 |
AutoloadFailedSignal isNil ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
125 |
LazyLoading := false. |
2654 | 126 |
|
12252 | 127 |
AutoloadFailedSignal := ProceedableError newSignal |
128 |
nameClass:self message:#autoloadFailedSignal; |
|
129 |
notifierString:'autoload failed'. |
|
197 | 130 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
131 |
self class changeClassTo:AutoloadMetaclass. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
132 |
ObjectMemory flushCaches. |
5005 | 133 |
]. |
8316 | 134 |
LoadedClasses isNil ifTrue:[ |
135 |
LoadedClasses := IdentitySet new. |
|
12074 | 136 |
]. |
137 |
InProgressClasses isNil ifTrue:[ |
|
9461
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
138 |
InProgressClasses := IdentitySet new. |
8316 | 139 |
]. |
5005 | 140 |
|
21767 | 141 |
"Modified: / 20-05-1997 / 19:06:25 / cg" |
142 |
"Modified: / 03-08-1999 / 14:23:30 / stefan" |
|
143 |
"Modified (comment): / 22-05-2017 / 18:31:47 / mawalch" |
|
126 | 144 |
! ! |
145 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
146 |
!Autoload class methodsFor:'Signal constants'! |
126 | 147 |
|
148 |
autoloadFailedSignal |
|
149 |
"return the signal raised when an autoload fails" |
|
150 |
||
151 |
^ AutoloadFailedSignal |
|
152 |
! ! |
|
153 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
154 |
!Autoload class methodsFor:'adding/removing autoloaded classes'! |
359 | 155 |
|
216 | 156 |
addClass:aClassName |
4052 | 157 |
"given a name, install a corresponding autoload class stub for it. |
158 |
Return the (autoload-) stubClass or nil, if no new class was created." |
|
1277 | 159 |
|
4052 | 160 |
^ self addClass:aClassName inCategory:'autoloaded-Classes' |
216 | 161 |
|
162 |
" |
|
163 |
Autoload addClass:'Clock' |
|
164 |
" |
|
1277 | 165 |
|
166 |
"Modified: 24.4.1996 / 19:54:16 / cg" |
|
216 | 167 |
! |
168 |
||
169 |
addClass:aClassName inCategory:aCategory |
|
4052 | 170 |
"given a name, install a corresponding autoload class stub for it. |
171 |
Return the (autoload-) stubClass or nil, if no new class was created." |
|
1277 | 172 |
|
4052 | 173 |
|nameSymbol cls| |
216 | 174 |
|
175 |
nameSymbol := aClassName asSymbol. |
|
176 |
(Smalltalk at:nameSymbol) isNil ifTrue:[ |
|
21216 | 177 |
cls := self |
178 |
subclass:nameSymbol |
|
179 |
instanceVariableNames:'' |
|
180 |
classVariableNames:'' |
|
181 |
poolDictionaries:'' |
|
182 |
category:aCategory. |
|
4052 | 183 |
]. |
184 |
^ cls |
|
185 |
||
216 | 186 |
" |
187 |
Autoload addClass:'Clock' inCategory:'autoloaded-Demos' |
|
188 |
" |
|
1277 | 189 |
|
190 |
"Modified: 24.4.1996 / 19:54:20 / cg" |
|
620 | 191 |
! |
192 |
||
193 |
removeClass:aClass |
|
1277 | 194 |
"remove a class from the list of loaded classes" |
195 |
||
620 | 196 |
LoadedClasses remove:aClass ifAbsent:[] |
1277 | 197 |
|
198 |
"Modified: 24.4.1996 / 19:54:35 / cg" |
|
620 | 199 |
! ! |
200 |
||
11145 | 201 |
!Autoload class methodsFor:'fileOut'! |
620 | 202 |
|
5345 | 203 |
basicFileOutDefinitionOn:aStream withNameSpace:forceNameSpace withPackage:withPackage |
620 | 204 |
"print an expression to define myself on aStream. |
8316 | 205 |
Since autoloaded classes don't know their real definition, simply |
620 | 206 |
output some comment string making things clear in the browser." |
207 |
||
5820 | 208 |
|myName fileName nm package| |
620 | 209 |
|
5345 | 210 |
(self == Autoload) ifTrue:[ |
7019 | 211 |
^ super |
212 |
basicFileOutDefinitionOn:aStream |
|
213 |
withNameSpace:forceNameSpace |
|
214 |
withPackage:withPackage |
|
5345 | 215 |
]. |
620 | 216 |
|
217 |
myName := self name. |
|
11205 | 218 |
aStream nextPutAll:'"' ; nextPutLine:'Notice:'; cr; |
219 |
spaces:4; nextPutLine:'The ',myName,' class is not yet loaded.'; cr. |
|
14411
192aa172da63
changed: #basicFileOutDefinitionOn:withNameSpace:withPackage:
Claus Gittinger <cg@exept.de>
parents:
14410
diff
changeset
|
220 |
aStream nextPutLine:'It will automatically load itself when accessed (instantiated).'. |
192aa172da63
changed: #basicFileOutDefinitionOn:withNameSpace:withPackage:
Claus Gittinger <cg@exept.de>
parents:
14410
diff
changeset
|
221 |
aStream nextPutLine:'To force loading now, execute: '. |
7019 | 222 |
aStream cr; spaces:4; nextPutLine:myName , ' autoload'. |
14411
192aa172da63
changed: #basicFileOutDefinitionOn:withNameSpace:withPackage:
Claus Gittinger <cg@exept.de>
parents:
14410
diff
changeset
|
223 |
aStream cr; nextPutLine:'or use the browser''s load function (in the classList''s ''Special''-menu)'. |
11205 | 224 |
aStream nextPutLine:'(a double-click on the class will also load it).'. |
620 | 225 |
" |
226 |
the following is simply informative ... |
|
227 |
actually, its a hack & kludge - there ought to be a method for this |
|
228 |
in Smalltalk |
|
229 |
(knowing the details of loading here is no good coding style) |
|
230 |
" |
|
10052 | 231 |
fileName := (Smalltalk fileNameForClass:myName). |
620 | 232 |
(ObjectFileLoader notNil and:[Smalltalk loadBinaries]) ifTrue:[ |
7019 | 233 |
(nm := Smalltalk libraryFileNameOfClass:myName) notNil ifTrue:[ |
234 |
nm := nm , ' (a classLibrary, possibly including more classes)' |
|
235 |
] ifFalse:[ |
|
236 |
nm := Smalltalk getBinaryFileName:(fileName , '.so'). |
|
237 |
nm isNil ifTrue:[ |
|
238 |
nm := Smalltalk getBinaryFileName:(fileName , '.o') |
|
239 |
]. |
|
240 |
nm notNil ifTrue:[ |
|
241 |
nm := nm , ' (a classBinary)' |
|
242 |
] |
|
243 |
]. |
|
620 | 244 |
]. |
245 |
nm isNil ifTrue:[ |
|
7019 | 246 |
package := self package. |
247 |
package notNil ifTrue:[ |
|
248 |
nm := Smalltalk getSourceFileName:((package copyReplaceAll:$: with:$/) , '/' , fileName , '.st'). |
|
249 |
]. |
|
250 |
nm isNil ifTrue:[ |
|
251 |
nm := Smalltalk getSourceFileName:(fileName , '.st'). |
|
252 |
]. |
|
620 | 253 |
]. |
254 |
nm notNil ifTrue:[ |
|
7744 | 255 |
aStream |
256 |
cr; |
|
257 |
nextPutLine:'When accessed, ' , myName , ' will automatically be loaded'; |
|
258 |
nextPutLine:'from: '; spaces:4; nextPutAll:nm. |
|
259 |
||
7019 | 260 |
nm asFilename isSymbolicLink ifTrue:[ |
261 |
aStream cr; cr. |
|
7744 | 262 |
aStream |
263 |
nextPutLine:'which is a link to: '; |
|
264 |
spaces:4; |
|
265 |
nextPutAll:(nm asFilename linkInfo path). |
|
7019 | 266 |
] |
620 | 267 |
] ifFalse:[ |
7019 | 268 |
package := self package. |
269 |
(Smalltalk at:#SourceCodeManager) notNil ifTrue:[ |
|
270 |
aStream nextPutAll:' |
|
5076 | 271 |
When accessed, I''ll ask the sourceCodeManager to load the code |
272 |
from ''' , fileName , '.st'' in the ''' , package , ''' package.'. |
|
7019 | 273 |
] ifFalse:[ |
274 |
aStream nextPutAll:' |
|
5076 | 275 |
When accessed, I''ll search for a file named |
276 |
''' , fileName , '.st'' in the ''' , package , ''' package. |
|
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
277 |
|
5076 | 278 |
Packages are tried along the packagePath, which is: |
279 |
' , ((Smalltalk packagePath asStringCollection collect:[:each| ' ' , each]) asStringWith:Character cr). |
|
7019 | 280 |
] |
620 | 281 |
]. |
282 |
aStream cr; nextPutAll:'"'. |
|
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
283 |
|
10052 | 284 |
"Created: / 05-01-1997 / 14:31:33 / cg" |
285 |
"Modified: / 06-10-2006 / 16:17:18 / cg" |
|
620 | 286 |
! ! |
287 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
288 |
!Autoload class methodsFor:'lazy compilation'! |
620 | 289 |
|
290 |
compileLazy |
|
291 |
"return the lazy loading flag - if on, fileIn is much faster, |
|
292 |
but pauses are to be expected later, since methods are compiled |
|
293 |
when first executed." |
|
294 |
||
295 |
^ LazyLoading |
|
296 |
! |
|
297 |
||
298 |
compileLazy:aBoolean |
|
299 |
"turn on/off lazy loading - if on, fileIn is much faster, |
|
300 |
but pauses are to be expected later, since methods are compiled |
|
301 |
when first executed. |
|
302 |
If you like it, add a line to your startup file." |
|
303 |
||
304 |
LazyLoading := aBoolean |
|
216 | 305 |
! ! |
306 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
307 |
!Autoload class methodsFor:'loading'! |
1 | 308 |
|
309 |
autoload |
|
310 |
"use this to force loading |
|
9461
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
311 |
- it is defined a noop in all non-autoloading classes. |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
312 |
Return the loaded class" |
1 | 313 |
|
9554 | 314 |
|myName myNameSpace newClass project prevMode packageID |
25188 | 315 |
packageDefinitionClass packageExtensionsFile prjDir| |
1 | 316 |
|
12252 | 317 |
self == Autoload ifTrue:[ |
318 |
"already loaded" |
|
319 |
^ self. |
|
320 |
]. |
|
321 |
||
164 | 322 |
myName := self name asSymbol. |
3027
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
323 |
myNameSpace := self nameSpace. |
1 | 324 |
|
9428 | 325 |
(InProgressClasses includes:myName) ifTrue:[ |
9461
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
326 |
"Class is already being loaded. |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
327 |
In most cases we come here through the path: |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
328 |
subclass autoload |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
329 |
-> superclass autoload |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
330 |
-> superclass initialize/postAutoload |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
331 |
-> subclass autoload (hardcoded in initialize method). |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
332 |
Simply ignore it here" |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
333 |
|
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
334 |
"/ AutoloadFailedSignal |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
335 |
"/ raiseRequestWith:self |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
336 |
"/ errorString:('autoload of ' , myName , ' failed (recursive invocation)'). |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
337 |
|
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
338 |
"self is not yet the loaded class - but it will be after the #become: |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
339 |
that is done eventually by some sender above." |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
340 |
^ self. |
9422 | 341 |
]. |
342 |
||
4775 | 343 |
"/ recheck - in case my class somehow came into the system |
344 |
"/ (by loading a binary...) |
|
345 |
(newClass := Smalltalk at:myName) ~~ self ifTrue:[ |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
346 |
(newClass isBehavior and:[newClass isLoaded]) ifTrue:[ |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
347 |
(Object infoPrinting and:[Smalltalk silentLoading ~~ true]) ifTrue:[ |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
348 |
Transcript showCR:('Autoload [info]: already loaded: ', myName , '.'); endEntry. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
349 |
]. |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
350 |
self class becomeSameAs:newClass class. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
351 |
self becomeSameAs:newClass. |
4775 | 352 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
353 |
ObjectMemory flushCaches. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
354 |
^ newClass |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
355 |
]. |
4775 | 356 |
]. |
357 |
||
1566 | 358 |
(Object infoPrinting and:[Smalltalk silentLoading ~~ true]) ifTrue:[ |
10128 | 359 |
"/ thisContext fullPrintAll. |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
360 |
Transcript showCR:('autoloading ', myName , ' ...'); endEntry. |
1564
f3f9736bd0fa
suppress load messages, if infoPrinting is turned off
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
361 |
]. |
1 | 362 |
|
9554 | 363 |
packageID := self package. |
18275 | 364 |
packageID == PackageId noProjectID ifTrue:[ |
365 |
Transcript showCR:('Autoload [warning]: bad packageID (__NoProject__) in ', myName); endEntry. |
|
366 |
] ifFalse:[ |
|
367 |
"if there is a package-definition, make sure it is loaded first" |
|
368 |
packageDefinitionClass := ProjectDefinition definitionClassForPackage: packageID. |
|
369 |
(packageDefinitionClass notNil) ifTrue:[ |
|
370 |
(packageDefinitionClass ~~ self) ifTrue:[ |
|
371 |
(packageDefinitionClass isBehavior) ifTrue:[ |
|
372 |
(packageDefinitionClass isLoaded) ifFalse:[ |
|
373 |
packageDefinitionClass autoload. |
|
374 |
]. |
|
375 |
"/ make sure that my package's extensions are also present |
|
376 |
(packageDefinitionClass isLoaded) ifTrue:[ |
|
377 |
packageDefinitionClass loadExtensions |
|
378 |
] |
|
9554 | 379 |
]. |
380 |
]. |
|
18275 | 381 |
] ifFalse:[ |
382 |
"/ no package definition class - look for extensions anyway |
|
25188 | 383 |
(prjDir := Smalltalk projectDirectoryForPackage:packageID) notNil ifTrue:[ |
384 |
packageExtensionsFile := prjDir asFilename / 'extensions.st'. |
|
385 |
packageExtensionsFile exists ifTrue:[ |
|
386 |
packageExtensionsFile fileIn. |
|
387 |
]. |
|
18275 | 388 |
]. |
15054 | 389 |
]. |
9554 | 390 |
]. |
391 |
||
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
392 |
[ |
9428 | 393 |
InProgressClasses add:myName. |
5902 | 394 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
395 |
prevMode := ClassCategoryReader sourceMode. |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
396 |
"/ no- do not do this; it may lead to trouble ... |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
397 |
"/ ClassCategoryReader sourceMode:#reference. |
1694
29791fde790e
autoload classes keep source reference
Claus Gittinger <cg@exept.de>
parents:
1674
diff
changeset
|
398 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
399 |
"/ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
400 |
"/ in order to not get a package of private (or whatever), |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
401 |
"/ temporarily set the currentProject to nil. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
402 |
"/ we will later set the classes package to something useful |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
403 |
"/ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
404 |
Project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
405 |
project := Project current. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
406 |
Project setProject:nil. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
407 |
]. |
2375
7eb1b35edc33
autoload into Smalltalk nameSpace - by default.
Claus Gittinger <cg@exept.de>
parents:
2366
diff
changeset
|
408 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
409 |
Class nameSpaceQuerySignal answer:myNameSpace "Smalltalk" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
410 |
do:[ |
9554 | 411 |
Class packageQuerySignal answer:packageID |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
412 |
do:[ |
6081
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
413 |
Class classConventionViolationConfirmationQuerySignal answer:true |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
414 |
do:[ |
15054 | 415 |
|classFileName| |
416 |
||
417 |
classFileName := self classFilename. |
|
15056 | 418 |
(classFileName notNil and:[classFileName asFilename isAbsolute]) ifTrue:[ |
10926
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
419 |
"/ if filename is absolute, the autoload-class was created by an |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
420 |
"/ explicit install-as-autoloaded via the fileBrowser. |
15056 | 421 |
Smalltalk fileIn:classFileName lazy:false silent:nil. |
10926
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
422 |
] ifFalse:[ |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
423 |
(Smalltalk |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
424 |
fileInClass:myName |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
425 |
package:packageID |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
426 |
initialize:false |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
427 |
lazy:LazyLoading |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
428 |
silent:nil) |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
429 |
isNil ifTrue:[ |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
430 |
"/ temporary: try without stx/package prefix |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
431 |
"/ this will vanish as soon as source-directory |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
432 |
"/ is always guaranteed to contain an stx-subtree |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
433 |
((packageID startsWith:'stx/') |
12260 | 434 |
or:[packageID startsWith:'stx:']) ifTrue:[ |
10926
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
435 |
Smalltalk |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
436 |
fileInClass:myName |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
437 |
package:(packageID copyFrom:5) |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
438 |
initialize:false |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
439 |
lazy:LazyLoading |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
440 |
silent:nil. |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
441 |
] |
6081
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
442 |
] |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
443 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
444 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
445 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
446 |
]. |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
447 |
] ensure:[ |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
448 |
"restore previous state" |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
449 |
ClassCategoryReader sourceMode:prevMode. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
450 |
project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
451 |
Project setProject:project. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
452 |
]. |
9428 | 453 |
InProgressClasses remove:myName ifAbsent:[]. |
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
454 |
]. |
1 | 455 |
|
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
456 |
" |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
457 |
NOTE: ClassLoader did already perform a #becomeSameAs: |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
458 |
of the loaded class to the new class. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
459 |
|
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
460 |
So some of the code below is no longer needed. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
461 |
" |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
462 |
|
1 | 463 |
"did it work ?" |
164 | 464 |
newClass := Smalltalk at:myName. |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
465 |
newClass ~~ self ifTrue:[ |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
466 |
"reinstall the autoload class, this will be undone by #become:" |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
467 |
Smalltalk at:myName put:self. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
468 |
]. |
1 | 469 |
|
138 | 470 |
"no - report the error" |
8431
3e06c959dcff
#autoload - raise error if fileIn fails.
Stefan Vogel <sv@exept.de>
parents:
8382
diff
changeset
|
471 |
(newClass isNil or:[newClass isLoaded not]) ifTrue:[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
472 |
" |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
473 |
USER INFORMATION: |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
474 |
this exception has been raised because an autoloaded class |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
475 |
could not be loaded. Usually, this happens when |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
476 |
the classes sourcefile is missing, unreadable or if |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
477 |
an entry is missing in the abbreviation file. |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
478 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
479 |
Check for a readable file named <myName>.st |
21403 | 480 |
in the 'source' directory and (if the fileName is not the same as the class name) |
481 |
for a corresponding entry in the abbreviation file 'abbrev.stc'. |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
482 |
Finally, your searchpath could be set wrong - |
21403 | 483 |
the package might not be found along one of the directories named in systemPath. |
154 | 484 |
|
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
485 |
In the debugger, press 'Abort' to continue execution. |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
486 |
" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
487 |
AutoloadFailedSignal |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
488 |
raiseRequestWith:self |
12791 | 489 |
errorString:('autoload of %1 failed (%2)' |
490 |
bindWith:myName |
|
491 |
with:(newClass isNil ifTrue:['nil result'] ifFalse:['still unloaded'])). |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
492 |
^ nil |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
493 |
]. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
494 |
|
9554 | 495 |
newClass setPackage:packageID. |
9564 | 496 |
newClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | mthd setPackage:packageID]. |
5527
2817d7e173de
set project of all autoloaded methods
Claus Gittinger <cg@exept.de>
parents:
5475
diff
changeset
|
497 |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
498 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
499 |
"/ autoloaded classes get their package from the revision (if present) |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
500 |
"/ this only happens with autoloaded sourceFiles which have no package |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
501 |
"/ info encoded. (binary classes have it) |
2057
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
502 |
"/ If there is no such information, give it my package (if I have one) |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
503 |
"/ |
21403 | 504 |
"/ newClass setPackageFromRevision. |
505 |
"/ |
|
506 |
"/ newPackage := newClass package. |
|
507 |
"/ (newPackage isNil or:[newPackage = 'no package']) ifTrue:[ |
|
508 |
"/ (package notNil and:[package ~= 'no package']) ifTrue:[ |
|
509 |
"/ newClass setPackage:packageID. |
|
510 |
"/ ]. |
|
511 |
"/ ]. |
|
1 | 512 |
|
216 | 513 |
|
154 | 514 |
"wow - it worked. now the big trick ..." |
1 | 515 |
|
21403 | 516 |
"/ don't do this: |
517 |
"/ newClass class setSoleInstance:self. |
|
518 |
"/ self setName:(self name , ' (auto)'). |
|
519 |
"/ as it will be undone by become ... |
|
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
520 |
|
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
521 |
Smalltalk changed:#aboutToAutoloadClass with:(self -> newClass). |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
522 |
newClass ~~ self ifTrue:[ |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
523 |
self dependents do:[:aDependent | |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
524 |
newClass addDependent:aDependent |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
525 |
]. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
526 |
self class becomeSameAs:newClass class. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
527 |
self becomeSameAs:newClass. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
528 |
|
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
529 |
ObjectMemory flushCaches. |
12702 | 530 |
Class flushSubclassInfoFor:self. |
7178 | 531 |
]. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
532 |
|
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
533 |
"the rehash here is pure superstition" |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
534 |
LoadedClasses rehash; add:newClass. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
535 |
|
9520 | 536 |
newClass postAutoload. |
3443
d57ea75d3ac5
oops - must send #initialize to all privateClasses.
Claus Gittinger <cg@exept.de>
parents:
3287
diff
changeset
|
537 |
newClass initializeWithAllPrivateClasses. |
5705
543d3e8ef7c6
send a change notification when autoloading
Claus Gittinger <cg@exept.de>
parents:
5527
diff
changeset
|
538 |
|
543d3e8ef7c6
send a change notification when autoloading
Claus Gittinger <cg@exept.de>
parents:
5527
diff
changeset
|
539 |
Smalltalk changed:#classDefinition with:newClass. |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
540 |
self changed:#loaded with:newClass. |
886 | 541 |
^ newClass |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
542 |
|
10128 | 543 |
"Modified: / 23-10-2006 / 18:12:21 / cg" |
21403 | 544 |
"Modified (comment): / 12-02-2017 / 10:48:13 / cg" |
1 | 545 |
! ! |
546 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
547 |
!Autoload class methodsFor:'message catching'! |
1 | 548 |
|
25194 | 549 |
askFor:aSelector |
550 |
"catch askFor: - load the class and resend #askFor: to the real one" |
|
551 |
||
552 |
self == Autoload ifTrue:[ |
|
553 |
^ super askFor:aSelector |
|
554 |
]. |
|
555 |
^ self doesNotUnderstand:(Message selector:#askFor: argument:aSelector) |
|
556 |
||
557 |
" |
|
558 |
Wrapper unload. |
|
559 |
Wrapper askFor:#isSecret |
|
560 |
" |
|
561 |
||
562 |
"Created: / 21-01-2020 / 15:24:04 / Stefan Vogel" |
|
563 |
! |
|
564 |
||
6251 | 565 |
at:arg |
21767 | 566 |
"catch at: - redefined because it is understood" |
6251 | 567 |
|
8482 | 568 |
^ self doesNotUnderstand:(Message selector:#at: argument:arg) |
21767 | 569 |
|
570 |
"Modified (comment): / 22-05-2017 / 18:31:12 / mawalch" |
|
6251 | 571 |
! |
572 |
||
620 | 573 |
basicNew |
1277 | 574 |
"catch basicNew - load the class and send it to the real one" |
620 | 575 |
|
576 |
^ self doesNotUnderstand:(Message selector:#basicNew) |
|
1277 | 577 |
|
578 |
"Modified: 24.4.1996 / 19:53:10 / cg" |
|
620 | 579 |
! |
580 |
||
581 |
basicNew:arg |
|
1277 | 582 |
"catch basicNew: - load the class and send it to the real one" |
620 | 583 |
|
8482 | 584 |
^ self doesNotUnderstand:(Message selector:#basicNew: argument:arg) |
1277 | 585 |
|
586 |
"Modified: 24.4.1996 / 19:53:16 / cg" |
|
620 | 587 |
! |
588 |
||
8185 | 589 |
classResources |
8316 | 590 |
"catch classResources - load the class and resend to the real one" |
8185 | 591 |
|
592 |
^ self doesNotUnderstand:(Message selector:#classResources) |
|
593 |
! |
|
594 |
||
620 | 595 |
comment |
596 |
"return the classes comment. |
|
597 |
Autoloaded classes have no comment; but I myself have one" |
|
598 |
||
599 |
(self == Autoload) ifTrue:[^ super comment]. |
|
600 |
^ 'not yet loaded' |
|
601 |
! |
|
602 |
||
6768 | 603 |
copy |
604 |
"catch copy - load the class and resend #copy to the real one" |
|
605 |
||
606 |
^ self doesNotUnderstand:(Message selector:#copy) |
|
607 |
! |
|
608 |
||
1 | 609 |
doesNotUnderstand:aMessage |
2689 | 610 |
"caught a message; load the class and retry the message" |
1 | 611 |
|
612 |
|newClass| |
|
613 |
||
164 | 614 |
self ~~ Autoload ifTrue:[ |
7178 | 615 |
newClass := self autoload. |
10095 | 616 |
(newClass notNil and:[newClass isLoaded]) ifTrue:[ |
7178 | 617 |
^ aMessage sendTo:newClass |
618 |
] |
|
1 | 619 |
]. |
789
155eca125ef0
return value from doesNotUnderstand (so handler can return a value)
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
620 |
^ super doesNotUnderstand:aMessage |
1277 | 621 |
|
10095 | 622 |
"Modified: / 16-10-2006 / 16:52:20 / cg" |
1 | 623 |
! |
624 |
||
7574 | 625 |
error |
626 |
"catch error - load the class and resend #error to the real one" |
|
627 |
||
628 |
^ self doesNotUnderstand:(Message selector:#error) |
|
629 |
! |
|
630 |
||
8709
25088287bbd0
Catch #fromString: (for autoloaded classes from Dolphin)
Stefan Vogel <sv@exept.de>
parents:
8590
diff
changeset
|
631 |
fromString:aString |
25088287bbd0
Catch #fromString: (for autoloaded classes from Dolphin)
Stefan Vogel <sv@exept.de>
parents:
8590
diff
changeset
|
632 |
"catch - load the class and send it to the real one" |
25088287bbd0
Catch #fromString: (for autoloaded classes from Dolphin)
Stefan Vogel <sv@exept.de>
parents:
8590
diff
changeset
|
633 |
|
25088287bbd0
Catch #fromString: (for autoloaded classes from Dolphin)
Stefan Vogel <sv@exept.de>
parents:
8590
diff
changeset
|
634 |
^ self doesNotUnderstand:(Message selector:#fromString: argument:aString) |
25088287bbd0
Catch #fromString: (for autoloaded classes from Dolphin)
Stefan Vogel <sv@exept.de>
parents:
8590
diff
changeset
|
635 |
! |
25088287bbd0
Catch #fromString: (for autoloaded classes from Dolphin)
Stefan Vogel <sv@exept.de>
parents:
8590
diff
changeset
|
636 |
|
16026 | 637 |
handle:handler do:aBlock |
19694 | 638 |
"autoload the class and resend" |
639 |
||
640 |
^ self doesNotUnderstand:(Message selector:#handle:do: argument:handler argument:aBlock) |
|
16026 | 641 |
! |
642 |
||
14503 | 643 |
isAbstract |
18911 | 644 |
^ false "/ actually: don't know, but do not want to load my class for this query |
14503 | 645 |
! |
646 |
||
1 | 647 |
new |
2663 | 648 |
"catch new - load the class and resend #new to the real one" |
1 | 649 |
|
650 |
^ self doesNotUnderstand:(Message selector:#new) |
|
1277 | 651 |
|
2663 | 652 |
"Modified: 26.5.1997 / 14:59:52 / cg" |
1 | 653 |
! |
654 |
||
655 |
new:arg |
|
21767 | 656 |
"catch new: - load the class and resend #new: to the real one" |
1 | 657 |
|
8482 | 658 |
^ self doesNotUnderstand:(Message selector:#new: argument:arg) |
1277 | 659 |
|
21767 | 660 |
"Modified: / 26-05-1997 / 14:59:58 / cg" |
661 |
"Modified (comment): / 22-05-2017 / 18:32:43 / mawalch" |
|
1 | 662 |
! |
663 |
||
9373
e312f2f2901c
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9218
diff
changeset
|
664 |
privateClassesAt:aClassNameString |
e312f2f2901c
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9218
diff
changeset
|
665 |
"catch - load the class and send it to the real one" |
e312f2f2901c
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9218
diff
changeset
|
666 |
|
e312f2f2901c
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9218
diff
changeset
|
667 |
self == Autoload ifTrue:[ |
e312f2f2901c
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9218
diff
changeset
|
668 |
^ super privateClassesAt:aClassNameString. |
e312f2f2901c
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9218
diff
changeset
|
669 |
]. |
e312f2f2901c
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9218
diff
changeset
|
670 |
^ self doesNotUnderstand:(Message selector:#privateClassesAt: argument:aClassNameString) |
e312f2f2901c
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9218
diff
changeset
|
671 |
! |
e312f2f2901c
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9218
diff
changeset
|
672 |
|
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
673 |
readFrom:aStream |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
674 |
"catch - load the class and send it to the real one" |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
675 |
|
8482 | 676 |
^ self doesNotUnderstand:(Message selector:#readFrom: argument:aStream) |
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
677 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
678 |
"Created: 22.5.1996 / 23:44:23 / stefan" |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
679 |
! |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
680 |
|
1437 | 681 |
readFrom:aStream onError:exceptionBlock |
682 |
"catch - load the class and send it to the real one" |
|
683 |
||
19694 | 684 |
^ self doesNotUnderstand:(Message selector:#readFrom:onError: argument:aStream argument:exceptionBlock) |
1437 | 685 |
|
686 |
"Created: 22.5.1996 / 23:03:39 / stefan" |
|
687 |
! |
|
688 |
||
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
689 |
readFromString:aString |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
690 |
"catch - load the class and send it to the real one" |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
691 |
|
8482 | 692 |
^ self doesNotUnderstand:(Message selector:#readFromString: argument:aString) |
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
693 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
694 |
"Created: 22.5.1996 / 23:46:15 / stefan" |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
695 |
! |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
696 |
|
1437 | 697 |
readFromString:aString onError:exceptionBlock |
698 |
"catch - load the class and send it to the real one" |
|
699 |
||
19694 | 700 |
^ self doesNotUnderstand:(Message selector:#readFromString:onError: argument:aString argument:exceptionBlock) |
1437 | 701 |
|
702 |
"Created: 22.5.1996 / 23:04:49 / stefan" |
|
703 |
! |
|
704 |
||
2691
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
705 |
respondsTo:aSelector |
21767 | 706 |
"catch respondsTo: - load the class and resend #respondsTo: to the real one" |
2691
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
707 |
|
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
708 |
self == Autoload ifTrue:[ |
7178 | 709 |
^ super respondsTo:aSelector |
2691
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
710 |
]. |
8482 | 711 |
^ self doesNotUnderstand:(Message selector:#respondsTo: argument:aSelector) |
2691
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
712 |
|
21767 | 713 |
"Modified: / 26-05-1997 / 14:59:58 / cg" |
714 |
"Modified (comment): / 22-05-2017 / 18:33:08 / mawalch" |
|
8306 | 715 |
! |
716 |
||
11058 | 717 |
value |
718 |
"catch value - load the class and resend #value to the real one" |
|
719 |
||
720 |
^ self doesNotUnderstand:(Message selector:#value) |
|
1 | 721 |
! ! |
11 | 722 |
|
8316 | 723 |
!Autoload class methodsFor:'private'! |
724 |
||
725 |
loadAndResendMessage |
|
726 |
"common helper to autoload a class and define a subclass of it by sending |
|
727 |
the sender-message again. |
|
728 |
This is invoked by all #subClass... definition messages." |
|
729 |
||
730 |
|sel args newClass| |
|
731 |
||
732 |
sel := thisContext sender selector. |
|
733 |
args := thisContext sender args. |
|
734 |
||
735 |
"take care: subclassing Autoload must still be possible" |
|
736 |
(self == Autoload) ifTrue:[ |
|
12260 | 737 |
^ self perform:sel inClass:self class superclass withArguments:args |
8316 | 738 |
]. |
739 |
||
740 |
newClass := self autoload. |
|
741 |
newClass notNil ifTrue:[ |
|
9556 | 742 |
newClass isLoaded ifTrue:[ |
743 |
^ newClass perform:sel withArguments:args |
|
744 |
]. |
|
745 |
Transcript showCR:'Autoload [warning]: failed to autoload ',self name. |
|
8316 | 746 |
]. |
747 |
^ nil |
|
748 |
||
9556 | 749 |
"Created: / 08-02-1997 / 19:42:47 / cg" |
750 |
"Modified: / 17-08-2006 / 11:12:24 / cg" |
|
8316 | 751 |
! ! |
752 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
753 |
!Autoload class methodsFor:'queries'! |
356 | 754 |
|
23306 | 755 |
accepts:aSignalOrExceptionClass |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
756 |
"redefined to avoid recursive autoload. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
757 |
(#autoload eventually raises QueryExceptions. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
758 |
These exception may send #accepts: to exception classes |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
759 |
that are currently being loaded)" |
5902 | 760 |
|
761 |
|newClass| |
|
762 |
||
763 |
self isBeingLoaded ifFalse:[ |
|
7178 | 764 |
newClass := self autoload. |
765 |
newClass notNil ifTrue:[ |
|
23306 | 766 |
^ newClass accepts:aSignalOrExceptionClass |
7178 | 767 |
]. |
5902 | 768 |
]. |
769 |
^ false |
|
23306 | 770 |
|
771 |
"Modified (format): / 28-08-2018 / 11:15:13 / Claus Gittinger" |
|
5902 | 772 |
! |
773 |
||
15236 | 774 |
handles:anException |
775 |
"redefined to avoid recursive autoload. |
|
776 |
(#autoload eventually raises QueryExceptions. |
|
777 |
These exception may send #handles: to exception classes |
|
778 |
that are currently being loaded)" |
|
779 |
||
780 |
|newClass| |
|
781 |
||
782 |
self isBeingLoaded ifFalse:[ |
|
783 |
newClass := self autoload. |
|
784 |
newClass notNil ifTrue:[ |
|
785 |
^ newClass handles:anException |
|
786 |
]. |
|
787 |
]. |
|
788 |
^ false |
|
789 |
! |
|
790 |
||
620 | 791 |
isBehavior |
22937 | 792 |
"return true, if the receiver is describing another object's' behavior. |
620 | 793 |
Autoloaded classes are definitely; therefore return true." |
164 | 794 |
|
620 | 795 |
^ true |
796 |
! |
|
356 | 797 |
|
5902 | 798 |
isBeingLoaded |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
799 |
"answer true if the class loading is currently in process" |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
800 |
|
9461
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
801 |
^ (self ~~ Autoload) and:[InProgressClasses includes:self name asSymbol] |
5902 | 802 |
|
803 |
"Modified: / 16.2.1998 / 11:57:35 / stefan" |
|
804 |
! |
|
805 |
||
729 | 806 |
isBuiltInClass |
1266 | 807 |
"return true if this class is known by the run-time-system. |
808 |
Returns false here." |
|
809 |
||
729 | 810 |
^ false |
811 |
||
812 |
"Created: 10.12.1995 / 00:28:22 / cg" |
|
1266 | 813 |
"Modified: 23.4.1996 / 15:55:36 / cg" |
729 | 814 |
! |
815 |
||
620 | 816 |
isLoaded |
3287 | 817 |
"return true, if the class has been loaded. |
818 |
Autoload itself is loaded, subclasses are not. |
|
15563 | 819 |
This allows testing whether a class has already been loaded." |
620 | 820 |
|
25194 | 821 |
^ self == Autoload |
3287 | 822 |
|
15563 | 823 |
"Modified: / 16-02-1998 / 11:57:35 / stefan" |
824 |
"Modified (comment): / 27-07-2013 / 15:35:01 / cg" |
|
25194 | 825 |
"Modified (format): / 21-01-2020 / 15:25:27 / Stefan Vogel" |
620 | 826 |
! |
827 |
||
922 | 828 |
loadedClasses |
829 |
"return the set of classes that were autoloaded" |
|
830 |
||
8316 | 831 |
^ LoadedClasses |
922 | 832 |
! |
833 |
||
4401
d9667432d35b
privateClasses and allPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4301
diff
changeset
|
834 |
privateClassesOrAll:allOfThem |
4000 | 835 |
"an autoloaded class has none" |
836 |
||
837 |
^ #() |
|
838 |
! |
|
839 |
||
620 | 840 |
wasAutoloaded:aClass |
922 | 841 |
"return true, if aClass was autoloaded" |
842 |
||
8316 | 843 |
^ LoadedClasses includes:aClass |
11 | 844 |
! ! |
620 | 845 |
|
13288
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
846 |
!Autoload class methodsFor:'utilities'! |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
847 |
|
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
848 |
withClass:aClass loadedDo:aBlock |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
849 |
"ensure that aClass is loaded, while evaluating aBlock for it" |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
850 |
|
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
851 |
|wasLoaded loadedClass| |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
852 |
|
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
853 |
wasLoaded := aClass isLoaded. |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
854 |
wasLoaded ifTrue:[ |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
855 |
^ aBlock value:aClass |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
856 |
]. |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
857 |
|
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
858 |
ParserFlags |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
859 |
withSTCCompilation:#never |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
860 |
do:[ |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
861 |
loadedClass := aClass autoload. |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
862 |
]. |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
863 |
|
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
864 |
|
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
865 |
^ [ |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
866 |
aBlock value:loadedClass |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
867 |
] ensure:[ |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
868 |
aClass unload |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
869 |
] |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
870 |
|
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
871 |
" |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
872 |
Autoload withClass:Array loadedDo:[:cls | self assert:cls isLoaded] |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
873 |
Autoload withClass:Cons loadedDo:[:cls | self assert:cls isLoaded] |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
874 |
" |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
875 |
|
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
876 |
"Created: / 08-02-2011 / 20:01:32 / cg" |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
877 |
! ! |
c525954778c6
added: #withClass:loadedDo:
Claus Gittinger <cg@exept.de>
parents:
12791
diff
changeset
|
878 |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
879 |
!Autoload class methodsFor:'documentation'! |
661 | 880 |
|
881 |
version |
|
18911 | 882 |
^ '$Header$' |
12074 | 883 |
! |
884 |
||
885 |
version_CVS |
|
18911 | 886 |
^ '$Header$' |
661 | 887 |
! ! |
6768 | 888 |
|
15054 | 889 |
|
620 | 890 |
Autoload initialize! |