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