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