author | mawalch |
Wed, 17 Aug 2016 11:06:49 +0200 | |
changeset 20274 | 489c6a64846b |
parent 19694 | 974f6b10c7b5 |
child 20342 | 219a5a47e8b1 |
child 20597 | 592b6415b9ae |
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 |
||
18275 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
620 | 16 |
nil subclass:#Autoload |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
17 |
instanceVariableNames:'' |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
18 |
classVariableNames:'LazyLoading AutoloadFailedSignal LoadedClasses InProgressClasses' |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
19 |
poolDictionaries:'' |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
20 |
category:'Kernel-Classes' |
1 | 21 |
! |
22 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
23 |
!Autoload class methodsFor:'documentation'! |
68 | 24 |
|
88 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
154 | 28 |
All Rights Reserved |
88 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
68 | 39 |
documentation |
40 |
" |
|
17124 | 41 |
Autoload is a stub for an 'as yet unloaded' class. |
42 |
||
20274 | 43 |
In memory limited systems (as my original 8Mb 386 system was), |
44 |
all seldom-used classes were made subclasses of this class. |
|
45 |
Autoload catches all messages sent to it, and files-in the real class's |
|
17124 | 46 |
code when first used. Then the caught message is resent to the (now existing) class. |
2662 | 47 |
|
17124 | 48 |
A note from later days: |
20274 | 49 |
These days, systems usually have enough memory to allow |
17124 | 50 |
having all classes present, so many of the classes which used to be |
51 |
autoloaded are no longer these days. However, a number of examples or |
|
52 |
very seldom used frameworks are still present as autoloaded. |
|
53 |
Instead of using autoloaded classes, it is now recommended to bundle |
|
54 |
extra classes into packages, which are loaded en-bloque. |
|
55 |
Packages can be compiled to a shared class library and thus be loaded |
|
56 |
much faster (there is no need to parse and compile source files). |
|
57 |
||
58 |
Lazy loading: |
|
2662 | 59 |
Class files are searched along the searchPath (see Smalltalk), |
20274 | 60 |
and any of binary-classFile, byteCode-classFile or sourceFile are loaded, |
61 |
whichever is found first. |
|
17124 | 62 |
For binaries to be loaded, these must be found in a package-subdirectory |
20274 | 63 |
along the so called package path. |
17124 | 64 |
Sources in a package directory along the source path. |
65 |
In practice, most Autoloaded classes are found and loaded as source file. |
|
2662 | 66 |
|
17124 | 67 |
Initial Setup of Auoload Stubs: |
68 |
At initial startup (i.e. when ST/X is NOT coming up with an image), |
|
69 |
the 'patches' startup script recursively walks along all directories |
|
70 |
below the TOP directory (that is one above the stx folder), |
|
71 |
and installs autoload stubs for all .st class files found, for which no |
|
72 |
corresponding class is already present. |
|
73 |
As you can imagine, this takes a long time and makes the initial startup quite slow. |
|
74 |
Therefore, this scheme is no longer the recommended one and we (at exept) |
|
75 |
always start ST/X with the '--quick' option, which skips this scan operation. |
|
68 | 76 |
|
17124 | 77 |
Advantage of Autoload stubs: |
78 |
Autoload stubs make it easier for a beginner to ST/X, to see what frameworks and classes |
|
79 |
are there, as they appear in the browser with category and class name (although no |
|
80 |
more details are initially visible. |
|
68 | 81 |
|
1278 | 82 |
[class variables:] |
20274 | 83 |
|
84 |
LazyLoading <Boolean> if true, the loaded classes |
|
85 |
methods will NOT be compiled at |
|
86 |
autoload time, but instead when |
|
87 |
first called. This allows for a |
|
88 |
faster load. However, expect short |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
89 |
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
|
90 |
first executed. |
20274 | 91 |
|
92 |
AutoloadFailedSignal <Signal> signal raised if an autoloaded |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
93 |
classes source is not available. |
922 | 94 |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
95 |
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
|
96 |
autoloaded (for later unload) |
1292 | 97 |
|
2662 | 98 |
[see also:] |
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
99 |
Smalltalk |
2662 | 100 |
|
1292 | 101 |
[author:] |
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
102 |
Claus Gittinger |
68 | 103 |
" |
104 |
! ! |
|
105 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
106 |
!Autoload class methodsFor:'initialization'! |
126 | 107 |
|
108 |
initialize |
|
12252 | 109 |
"initialize either the Autoload class |
110 |
or load a autoloaded class and initialize it." |
|
2223 | 111 |
|
12252 | 112 |
self ~~ Autoload ifTrue:[ |
113 |
"subclass: catch initialize - load the class and resend #initialize to the real one" |
|
114 |
^ self doesNotUnderstand:(Message selector:#initialize) |
|
115 |
]. |
|
116 |
||
117 |
"initialize myself" |
|
126 | 118 |
AutoloadFailedSignal isNil ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
119 |
LazyLoading := false. |
2654 | 120 |
|
12252 | 121 |
AutoloadFailedSignal := ProceedableError newSignal |
122 |
nameClass:self message:#autoloadFailedSignal; |
|
123 |
notifierString:'autoload failed'. |
|
197 | 124 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
125 |
self class changeClassTo:AutoloadMetaclass. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
126 |
ObjectMemory flushCaches. |
5005 | 127 |
]. |
8316 | 128 |
LoadedClasses isNil ifTrue:[ |
129 |
LoadedClasses := IdentitySet new. |
|
12074 | 130 |
]. |
131 |
InProgressClasses isNil ifTrue:[ |
|
9461
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
132 |
InProgressClasses := IdentitySet new. |
8316 | 133 |
]. |
5005 | 134 |
|
2223 | 135 |
|
4511
da0b327f3204
Use AutoloadMetaclass to load a class on unhandled class methods.
Stefan Vogel <sv@exept.de>
parents:
4496
diff
changeset
|
136 |
"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
|
137 |
"Modified: / 3.8.1999 / 14:23:30 / stefan" |
126 | 138 |
! ! |
139 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
140 |
!Autoload class methodsFor:'Signal constants'! |
126 | 141 |
|
142 |
autoloadFailedSignal |
|
143 |
"return the signal raised when an autoload fails" |
|
144 |
||
145 |
^ AutoloadFailedSignal |
|
146 |
! ! |
|
147 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
148 |
!Autoload class methodsFor:'adding/removing autoloaded classes'! |
359 | 149 |
|
216 | 150 |
addClass:aClassName |
4052 | 151 |
"given a name, install a corresponding autoload class stub for it. |
152 |
Return the (autoload-) stubClass or nil, if no new class was created." |
|
1277 | 153 |
|
4052 | 154 |
^ self addClass:aClassName inCategory:'autoloaded-Classes' |
216 | 155 |
|
156 |
" |
|
157 |
Autoload addClass:'Clock' |
|
158 |
" |
|
1277 | 159 |
|
160 |
"Modified: 24.4.1996 / 19:54:16 / cg" |
|
216 | 161 |
! |
162 |
||
163 |
addClass:aClassName inCategory:aCategory |
|
4052 | 164 |
"given a name, install a corresponding autoload class stub for it. |
165 |
Return the (autoload-) stubClass or nil, if no new class was created." |
|
1277 | 166 |
|
4052 | 167 |
|nameSymbol cls| |
216 | 168 |
|
169 |
nameSymbol := aClassName asSymbol. |
|
170 |
(Smalltalk at:nameSymbol) isNil ifTrue:[ |
|
5903 | 171 |
cls := Autoload |
172 |
subclass:nameSymbol |
|
173 |
instanceVariableNames:'' |
|
174 |
classVariableNames:'' |
|
175 |
poolDictionaries:'' |
|
176 |
category:aCategory. |
|
4052 | 177 |
]. |
178 |
^ cls |
|
179 |
||
216 | 180 |
" |
181 |
Autoload addClass:'Clock' inCategory:'autoloaded-Demos' |
|
182 |
" |
|
1277 | 183 |
|
184 |
"Modified: 24.4.1996 / 19:54:20 / cg" |
|
620 | 185 |
! |
186 |
||
187 |
removeClass:aClass |
|
1277 | 188 |
"remove a class from the list of loaded classes" |
189 |
||
620 | 190 |
LoadedClasses remove:aClass ifAbsent:[] |
1277 | 191 |
|
192 |
"Modified: 24.4.1996 / 19:54:35 / cg" |
|
620 | 193 |
! ! |
194 |
||
11145 | 195 |
!Autoload class methodsFor:'fileOut'! |
620 | 196 |
|
5345 | 197 |
basicFileOutDefinitionOn:aStream withNameSpace:forceNameSpace withPackage:withPackage |
620 | 198 |
"print an expression to define myself on aStream. |
8316 | 199 |
Since autoloaded classes don't know their real definition, simply |
620 | 200 |
output some comment string making things clear in the browser." |
201 |
||
5820 | 202 |
|myName fileName nm package| |
620 | 203 |
|
5345 | 204 |
(self == Autoload) ifTrue:[ |
7019 | 205 |
^ super |
206 |
basicFileOutDefinitionOn:aStream |
|
207 |
withNameSpace:forceNameSpace |
|
208 |
withPackage:withPackage |
|
5345 | 209 |
]. |
620 | 210 |
|
211 |
myName := self name. |
|
11205 | 212 |
aStream nextPutAll:'"' ; nextPutLine:'Notice:'; cr; |
213 |
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
|
214 |
aStream nextPutLine:'It will automatically load itself when accessed (instantiated).'. |
192aa172da63
changed: #basicFileOutDefinitionOn:withNameSpace:withPackage:
Claus Gittinger <cg@exept.de>
parents:
14410
diff
changeset
|
215 |
aStream nextPutLine:'To force loading now, execute: '. |
7019 | 216 |
aStream cr; spaces:4; nextPutLine:myName , ' autoload'. |
14411
192aa172da63
changed: #basicFileOutDefinitionOn:withNameSpace:withPackage:
Claus Gittinger <cg@exept.de>
parents:
14410
diff
changeset
|
217 |
aStream cr; nextPutLine:'or use the browser''s load function (in the classList''s ''Special''-menu)'. |
11205 | 218 |
aStream nextPutLine:'(a double-click on the class will also load it).'. |
620 | 219 |
" |
220 |
the following is simply informative ... |
|
221 |
actually, its a hack & kludge - there ought to be a method for this |
|
222 |
in Smalltalk |
|
223 |
(knowing the details of loading here is no good coding style) |
|
224 |
" |
|
10052 | 225 |
fileName := (Smalltalk fileNameForClass:myName). |
620 | 226 |
(ObjectFileLoader notNil and:[Smalltalk loadBinaries]) ifTrue:[ |
7019 | 227 |
(nm := Smalltalk libraryFileNameOfClass:myName) notNil ifTrue:[ |
228 |
nm := nm , ' (a classLibrary, possibly including more classes)' |
|
229 |
] ifFalse:[ |
|
230 |
nm := Smalltalk getBinaryFileName:(fileName , '.so'). |
|
231 |
nm isNil ifTrue:[ |
|
232 |
nm := Smalltalk getBinaryFileName:(fileName , '.o') |
|
233 |
]. |
|
234 |
nm notNil ifTrue:[ |
|
235 |
nm := nm , ' (a classBinary)' |
|
236 |
] |
|
237 |
]. |
|
620 | 238 |
]. |
239 |
nm isNil ifTrue:[ |
|
7019 | 240 |
package := self package. |
241 |
package notNil ifTrue:[ |
|
242 |
nm := Smalltalk getSourceFileName:((package copyReplaceAll:$: with:$/) , '/' , fileName , '.st'). |
|
243 |
]. |
|
244 |
nm isNil ifTrue:[ |
|
245 |
nm := Smalltalk getSourceFileName:(fileName , '.st'). |
|
246 |
]. |
|
620 | 247 |
]. |
248 |
nm notNil ifTrue:[ |
|
7744 | 249 |
aStream |
250 |
cr; |
|
251 |
nextPutLine:'When accessed, ' , myName , ' will automatically be loaded'; |
|
252 |
nextPutLine:'from: '; spaces:4; nextPutAll:nm. |
|
253 |
||
7019 | 254 |
nm asFilename isSymbolicLink ifTrue:[ |
255 |
aStream cr; cr. |
|
7744 | 256 |
aStream |
257 |
nextPutLine:'which is a link to: '; |
|
258 |
spaces:4; |
|
259 |
nextPutAll:(nm asFilename linkInfo path). |
|
7019 | 260 |
] |
620 | 261 |
] ifFalse:[ |
7019 | 262 |
package := self package. |
263 |
(Smalltalk at:#SourceCodeManager) notNil ifTrue:[ |
|
264 |
aStream nextPutAll:' |
|
5076 | 265 |
When accessed, I''ll ask the sourceCodeManager to load the code |
266 |
from ''' , fileName , '.st'' in the ''' , package , ''' package.'. |
|
7019 | 267 |
] ifFalse:[ |
268 |
aStream nextPutAll:' |
|
5076 | 269 |
When accessed, I''ll search for a file named |
270 |
''' , 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
|
271 |
|
5076 | 272 |
Packages are tried along the packagePath, which is: |
273 |
' , ((Smalltalk packagePath asStringCollection collect:[:each| ' ' , each]) asStringWith:Character cr). |
|
7019 | 274 |
] |
620 | 275 |
]. |
276 |
aStream cr; nextPutAll:'"'. |
|
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
277 |
|
10052 | 278 |
"Created: / 05-01-1997 / 14:31:33 / cg" |
279 |
"Modified: / 06-10-2006 / 16:17:18 / cg" |
|
620 | 280 |
! ! |
281 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
282 |
!Autoload class methodsFor:'lazy compilation'! |
620 | 283 |
|
284 |
compileLazy |
|
285 |
"return the lazy loading flag - if on, fileIn is much faster, |
|
286 |
but pauses are to be expected later, since methods are compiled |
|
287 |
when first executed." |
|
288 |
||
289 |
^ LazyLoading |
|
290 |
! |
|
291 |
||
292 |
compileLazy:aBoolean |
|
293 |
"turn on/off lazy loading - if on, fileIn is much faster, |
|
294 |
but pauses are to be expected later, since methods are compiled |
|
295 |
when first executed. |
|
296 |
If you like it, add a line to your startup file." |
|
297 |
||
298 |
LazyLoading := aBoolean |
|
216 | 299 |
! ! |
300 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
301 |
!Autoload class methodsFor:'loading'! |
1 | 302 |
|
303 |
autoload |
|
304 |
"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
|
305 |
- 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
|
306 |
Return the loaded class" |
1 | 307 |
|
9554 | 308 |
|myName myNameSpace newClass project prevMode packageID |
15054 | 309 |
packageDefinitionClass packageExtensionsFile| |
1 | 310 |
|
12252 | 311 |
self == Autoload ifTrue:[ |
312 |
"already loaded" |
|
313 |
^ self. |
|
314 |
]. |
|
315 |
||
164 | 316 |
myName := self name asSymbol. |
3027
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
317 |
myNameSpace := self nameSpace. |
1 | 318 |
|
9428 | 319 |
(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
|
320 |
"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
|
321 |
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
|
322 |
subclass autoload |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
323 |
-> superclass autoload |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
324 |
-> superclass initialize/postAutoload |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
325 |
-> 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
|
326 |
Simply ignore it here" |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
327 |
|
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
328 |
"/ AutoloadFailedSignal |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
329 |
"/ raiseRequestWith:self |
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
330 |
"/ 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
|
331 |
|
791adb50075f
avoid "recursive autoload" error when doing explicit autoload of subclasses
Stefan Vogel <sv@exept.de>
parents:
9428
diff
changeset
|
332 |
"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
|
333 |
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
|
334 |
^ self. |
9422 | 335 |
]. |
336 |
||
4775 | 337 |
"/ recheck - in case my class somehow came into the system |
338 |
"/ (by loading a binary...) |
|
339 |
(newClass := Smalltalk at:myName) ~~ self ifTrue:[ |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
340 |
(newClass isBehavior and:[newClass isLoaded]) ifTrue:[ |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
341 |
(Object infoPrinting and:[Smalltalk silentLoading ~~ true]) ifTrue:[ |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
342 |
Transcript showCR:('Autoload [info]: already loaded: ', myName , '.'); endEntry. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
343 |
]. |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
344 |
self class becomeSameAs:newClass class. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
345 |
self becomeSameAs:newClass. |
4775 | 346 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
347 |
ObjectMemory flushCaches. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
348 |
^ newClass |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
349 |
]. |
4775 | 350 |
]. |
351 |
||
1566 | 352 |
(Object infoPrinting and:[Smalltalk silentLoading ~~ true]) ifTrue:[ |
10128 | 353 |
"/ thisContext fullPrintAll. |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
354 |
Transcript showCR:('autoloading ', myName , ' ...'); endEntry. |
1564
f3f9736bd0fa
suppress load messages, if infoPrinting is turned off
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
355 |
]. |
1 | 356 |
|
9554 | 357 |
packageID := self package. |
18275 | 358 |
packageID == PackageId noProjectID ifTrue:[ |
359 |
Transcript showCR:('Autoload [warning]: bad packageID (__NoProject__) in ', myName); endEntry. |
|
360 |
] ifFalse:[ |
|
361 |
"if there is a package-definition, make sure it is loaded first" |
|
362 |
packageDefinitionClass := ProjectDefinition definitionClassForPackage: packageID. |
|
363 |
(packageDefinitionClass notNil) ifTrue:[ |
|
364 |
(packageDefinitionClass ~~ self) ifTrue:[ |
|
365 |
(packageDefinitionClass isBehavior) ifTrue:[ |
|
366 |
(packageDefinitionClass isLoaded) ifFalse:[ |
|
367 |
packageDefinitionClass autoload. |
|
368 |
]. |
|
369 |
"/ make sure that my package's extensions are also present |
|
370 |
(packageDefinitionClass isLoaded) ifTrue:[ |
|
371 |
packageDefinitionClass loadExtensions |
|
372 |
] |
|
9554 | 373 |
]. |
374 |
]. |
|
18275 | 375 |
] ifFalse:[ |
376 |
"/ no package definition class - look for extensions anyway |
|
377 |
packageExtensionsFile := (Smalltalk projectDirectoryForPackage:packageID) asFilename / 'extensions.st'. |
|
378 |
packageExtensionsFile exists ifTrue:[ |
|
379 |
packageExtensionsFile fileIn. |
|
380 |
]. |
|
15054 | 381 |
]. |
9554 | 382 |
]. |
383 |
||
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
384 |
[ |
9428 | 385 |
InProgressClasses add:myName. |
5902 | 386 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
387 |
prevMode := ClassCategoryReader sourceMode. |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
388 |
"/ 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
|
389 |
"/ ClassCategoryReader sourceMode:#reference. |
1694
29791fde790e
autoload classes keep source reference
Claus Gittinger <cg@exept.de>
parents:
1674
diff
changeset
|
390 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
391 |
"/ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
392 |
"/ 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
|
393 |
"/ temporarily set the currentProject to nil. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
394 |
"/ we will later set the classes package to something useful |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
395 |
"/ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
396 |
Project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
397 |
project := Project current. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
398 |
Project setProject:nil. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
399 |
]. |
2375
7eb1b35edc33
autoload into Smalltalk nameSpace - by default.
Claus Gittinger <cg@exept.de>
parents:
2366
diff
changeset
|
400 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
401 |
Class nameSpaceQuerySignal answer:myNameSpace "Smalltalk" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
402 |
do:[ |
9554 | 403 |
Class packageQuerySignal answer:packageID |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
404 |
do:[ |
6081
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
405 |
Class classConventionViolationConfirmationQuerySignal answer:true |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
406 |
do:[ |
15054 | 407 |
|classFileName| |
408 |
||
409 |
classFileName := self classFilename. |
|
15056 | 410 |
(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
|
411 |
"/ 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
|
412 |
"/ explicit install-as-autoloaded via the fileBrowser. |
15056 | 413 |
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
|
414 |
] ifFalse:[ |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
415 |
(Smalltalk |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
416 |
fileInClass:myName |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
417 |
package:packageID |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
418 |
initialize:false |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
419 |
lazy:LazyLoading |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
420 |
silent:nil) |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
421 |
isNil ifTrue:[ |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
422 |
"/ temporary: try without stx/package prefix |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
423 |
"/ 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
|
424 |
"/ 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
|
425 |
((packageID startsWith:'stx/') |
12260 | 426 |
or:[packageID startsWith:'stx:']) ifTrue:[ |
10926
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
427 |
Smalltalk |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
428 |
fileInClass:myName |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
429 |
package:(packageID copyFrom:5) |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
430 |
initialize:false |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
431 |
lazy:LazyLoading |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
432 |
silent:nil. |
64ffe2fe2340
load of explicitly install-as-autoloaded classes:
Claus Gittinger <cg@exept.de>
parents:
10128
diff
changeset
|
433 |
] |
6081
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
434 |
] |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
435 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
436 |
] |
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 |
]. |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
439 |
] ensure:[ |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
440 |
"restore previous state" |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
441 |
ClassCategoryReader sourceMode:prevMode. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
442 |
project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
443 |
Project setProject:project. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
444 |
]. |
9428 | 445 |
InProgressClasses remove:myName ifAbsent:[]. |
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
446 |
]. |
1 | 447 |
|
8588
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 |
NOTE: ClassLoader did already perform a #becomeSameAs: |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
450 |
of the loaded class to the new class. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
451 |
|
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
452 |
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
|
453 |
" |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
454 |
|
1 | 455 |
"did it work ?" |
164 | 456 |
newClass := Smalltalk at:myName. |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
457 |
newClass ~~ self ifTrue:[ |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
458 |
"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
|
459 |
Smalltalk at:myName put:self. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
460 |
]. |
1 | 461 |
|
138 | 462 |
"no - report the error" |
8431
3e06c959dcff
#autoload - raise error if fileIn fails.
Stefan Vogel <sv@exept.de>
parents:
8382
diff
changeset
|
463 |
(newClass isNil or:[newClass isLoaded not]) ifTrue:[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
464 |
" |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
465 |
USER INFORMATION: |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
466 |
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
|
467 |
could not be loaded. Usually, this happens when |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
468 |
the classes sourcefile is missing, unreadable or if |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
469 |
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
|
470 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
471 |
Check for a readable file named <myName>.st |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
472 |
in the 'source' directory and (if its a long fileName) |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
473 |
for a corresponding entry in the abbreviation file |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
474 |
'include/abbrev.stc'. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
475 |
Finally, your searchpath could be set wrong - |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
476 |
both 'source' and 'include' directories must be found in |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
477 |
one of the directories named in systemPath. |
154 | 478 |
|
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
479 |
In the debugger, press 'Abort' to continue execution. |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
480 |
" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
481 |
AutoloadFailedSignal |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
482 |
raiseRequestWith:self |
12791 | 483 |
errorString:('autoload of %1 failed (%2)' |
484 |
bindWith:myName |
|
485 |
with:(newClass isNil ifTrue:['nil result'] ifFalse:['still unloaded'])). |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
486 |
^ nil |
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 |
|
9554 | 489 |
newClass setPackage:packageID. |
9564 | 490 |
newClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | mthd setPackage:packageID]. |
5527
2817d7e173de
set project of all autoloaded methods
Claus Gittinger <cg@exept.de>
parents:
5475
diff
changeset
|
491 |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
492 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
493 |
"/ 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
|
494 |
"/ 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
|
495 |
"/ info encoded. (binary classes have it) |
2057
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
496 |
"/ 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
|
497 |
"/ |
5463
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
498 |
"/ newClass setPackageFromRevision. |
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 |
"/ newPackage := newClass package. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
501 |
"/ (newPackage isNil or:[newPackage = 'no package']) ifTrue:[ |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
502 |
"/ (package notNil and:[package ~= 'no package']) ifTrue:[ |
9564 | 503 |
"/ newClass setPackage:packageID. |
5463
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
504 |
"/ ]. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
505 |
"/ ]. |
1 | 506 |
|
216 | 507 |
|
154 | 508 |
"wow - it worked. now the big trick ..." |
1 | 509 |
|
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
510 |
"/ 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
|
511 |
"/ 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
|
512 |
|
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
513 |
Smalltalk changed:#aboutToAutoloadClass with:(self -> newClass). |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
514 |
newClass ~~ self ifTrue:[ |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
515 |
self dependents do:[:aDependent | |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
516 |
newClass addDependent:aDependent |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
517 |
]. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
518 |
self class becomeSameAs:newClass class. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
519 |
self becomeSameAs:newClass. |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
520 |
|
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
521 |
ObjectMemory flushCaches. |
12702 | 522 |
Class flushSubclassInfoFor:self. |
7178 | 523 |
]. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
524 |
|
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
525 |
"the rehash here is pure superstition" |
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
526 |
LoadedClasses rehash; add:newClass. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
527 |
|
9520 | 528 |
newClass postAutoload. |
3443
d57ea75d3ac5
oops - must send #initialize to all privateClasses.
Claus Gittinger <cg@exept.de>
parents:
3287
diff
changeset
|
529 |
newClass initializeWithAllPrivateClasses. |
5705
543d3e8ef7c6
send a change notification when autoloading
Claus Gittinger <cg@exept.de>
parents:
5527
diff
changeset
|
530 |
|
543d3e8ef7c6
send a change notification when autoloading
Claus Gittinger <cg@exept.de>
parents:
5527
diff
changeset
|
531 |
Smalltalk changed:#classDefinition with:newClass. |
8588
4bf5e572f5d9
Fix recursive autoloading of exception classes.
Stefan Vogel <sv@exept.de>
parents:
8482
diff
changeset
|
532 |
self changed:#loaded with:newClass. |
886 | 533 |
^ newClass |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
534 |
|
10128 | 535 |
"Modified: / 23-10-2006 / 18:12:21 / cg" |
1 | 536 |
! ! |
537 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
538 |
!Autoload class methodsFor:'message catching'! |
1 | 539 |
|
6251 | 540 |
at:arg |
541 |
"catch at: - redefined because its understood" |
|
542 |
||
8482 | 543 |
^ self doesNotUnderstand:(Message selector:#at: argument:arg) |
6251 | 544 |
! |
545 |
||
620 | 546 |
basicNew |
1277 | 547 |
"catch basicNew - load the class and send it to the real one" |
620 | 548 |
|
549 |
^ self doesNotUnderstand:(Message selector:#basicNew) |
|
1277 | 550 |
|
551 |
"Modified: 24.4.1996 / 19:53:10 / cg" |
|
620 | 552 |
! |
553 |
||
554 |
basicNew:arg |
|
1277 | 555 |
"catch basicNew: - load the class and send it to the real one" |
620 | 556 |
|
8482 | 557 |
^ self doesNotUnderstand:(Message selector:#basicNew: argument:arg) |
1277 | 558 |
|
559 |
"Modified: 24.4.1996 / 19:53:16 / cg" |
|
620 | 560 |
! |
561 |
||
8185 | 562 |
classResources |
8316 | 563 |
"catch classResources - load the class and resend to the real one" |
8185 | 564 |
|
565 |
^ self doesNotUnderstand:(Message selector:#classResources) |
|
566 |
! |
|
567 |
||
620 | 568 |
comment |
569 |
"return the classes comment. |
|
570 |
Autoloaded classes have no comment; but I myself have one" |
|
571 |
||
572 |
(self == Autoload) ifTrue:[^ super comment]. |
|
573 |
^ 'not yet loaded' |
|
574 |
! |
|
575 |
||
6768 | 576 |
copy |
577 |
"catch copy - load the class and resend #copy to the real one" |
|
578 |
||
579 |
^ self doesNotUnderstand:(Message selector:#copy) |
|
580 |
! |
|
581 |
||
1 | 582 |
doesNotUnderstand:aMessage |
2689 | 583 |
"caught a message; load the class and retry the message" |
1 | 584 |
|
585 |
|newClass| |
|
586 |
||
164 | 587 |
self ~~ Autoload ifTrue:[ |
7178 | 588 |
newClass := self autoload. |
10095 | 589 |
(newClass notNil and:[newClass isLoaded]) ifTrue:[ |
7178 | 590 |
^ aMessage sendTo:newClass |
591 |
] |
|
1 | 592 |
]. |
789
155eca125ef0
return value from doesNotUnderstand (so handler can return a value)
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
593 |
^ super doesNotUnderstand:aMessage |
1277 | 594 |
|
10095 | 595 |
"Modified: / 16-10-2006 / 16:52:20 / cg" |
1 | 596 |
! |
597 |
||
7574 | 598 |
error |
599 |
"catch error - load the class and resend #error to the real one" |
|
600 |
||
601 |
^ self doesNotUnderstand:(Message selector:#error) |
|
602 |
! |
|
603 |
||
8709
25088287bbd0
Catch #fromString: (for autoloaded classes from Dolphin)
Stefan Vogel <sv@exept.de>
parents:
8590
diff
changeset
|
604 |
fromString:aString |
25088287bbd0
Catch #fromString: (for autoloaded classes from Dolphin)
Stefan Vogel <sv@exept.de>
parents:
8590
diff
changeset
|
605 |
"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
|
606 |
|
25088287bbd0
Catch #fromString: (for autoloaded classes from Dolphin)
Stefan Vogel <sv@exept.de>
parents:
8590
diff
changeset
|
607 |
^ self doesNotUnderstand:(Message selector:#fromString: argument:aString) |
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 |
|
16026 | 610 |
handle:handler do:aBlock |
19694 | 611 |
"autoload the class and resend" |
612 |
||
613 |
^ self doesNotUnderstand:(Message selector:#handle:do: argument:handler argument:aBlock) |
|
16026 | 614 |
! |
615 |
||
14503 | 616 |
isAbstract |
18911 | 617 |
^ false "/ actually: don't know, but do not want to load my class for this query |
14503 | 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 |
||
19694 | 656 |
^ self doesNotUnderstand:(Message selector:#readFrom:onError: argument:aStream argument:exceptionBlock) |
1437 | 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 |
||
19694 | 672 |
^ self doesNotUnderstand:(Message selector:#readFromString:onError: argument:aString argument:exceptionBlock) |
1437 | 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 |
|
18911 | 850 |
^ '$Header$' |
12074 | 851 |
! |
852 |
||
853 |
version_CVS |
|
18911 | 854 |
^ '$Header$' |
661 | 855 |
! ! |
6768 | 856 |
|
15054 | 857 |
|
620 | 858 |
Autoload initialize! |