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