author | penk |
Mon, 10 Feb 2003 17:39:23 +0100 | |
changeset 7019 | 6591ea303fbd |
parent 6768 | 4ccf91dfeba2 |
child 7092 | 630807cd320f |
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 |
" |
|
12 |
||
5345 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
620 | 15 |
nil subclass:#Autoload |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
16 |
instanceVariableNames:'' |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
17 |
classVariableNames:'LazyLoading AutoloadFailedSignal LoadedClasses' |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
18 |
poolDictionaries:'' |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
19 |
category:'Kernel-Classes' |
1 | 20 |
! |
21 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
22 |
!Autoload class methodsFor:'documentation'! |
68 | 23 |
|
88 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
154 | 27 |
All Rights Reserved |
88 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
68 | 38 |
documentation |
39 |
" |
|
40 |
In memory limited systems (as my 8Mb 386 is) all seldom-used classes are made |
|
2662 | 41 |
subclasses of this class. |
42 |
Autoload catches all messages and files-In the corresponding code |
|
43 |
when first used. |
|
2689 | 44 |
Then the caught message is resent to the (now existing) class. |
2662 | 45 |
|
46 |
Class files are searched along the searchPath (see Smalltalk), |
|
47 |
and any of binary-classFile, byteCode-classFile or sourceFile are |
|
48 |
loaded, whichever is found first. For binaries to be loaded, |
|
49 |
these must be found in the 'bin' directory. Sources must be found |
|
50 |
in the 'source' directory. |
|
51 |
(Usually, Autoload classes finds the source file and loads that one). |
|
52 |
||
53 |
When started, the patches startup script arranges for the abbreviation |
|
54 |
file 'include/abbrev.stc' to be read and installs autoload stubs for |
|
55 |
all classes listed in that file, which do not exists already. |
|
56 |
The abbreviation file is maintained by the production environment |
|
57 |
and updated by makefile rules - therefore, it should not be edited |
|
58 |
manually. |
|
68 | 59 |
|
60 |
Late addition: above comment is no longer true - I have made now almost |
|
61 |
all Demos & Goodies be autoloaded ... even for big systems. |
|
62 |
||
1278 | 63 |
[class variables:] |
92 | 64 |
|
3027
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
65 |
LazyLoading <Boolean> if true, the loaded classes |
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
66 |
methods will NOT be compiled at |
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
67 |
autoload time, but instead when |
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
68 |
first called. This allows for a |
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
69 |
faster load. However, expect short |
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
70 |
pauses later when the methods are |
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
71 |
first executed. |
126 | 72 |
|
3027
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
73 |
AutoloadFailedSignal <Signal> signal raised if an autoloaded |
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
74 |
classes source is not available. |
922 | 75 |
|
3027
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
76 |
LoadedClasses <Collection> set of classes that heve been |
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
77 |
autoloaded (for later unload) |
1292 | 78 |
|
2662 | 79 |
[see also:] |
3027
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
80 |
Smalltalk |
2662 | 81 |
|
1292 | 82 |
[author:] |
3027
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
83 |
Claus Gittinger |
68 | 84 |
" |
85 |
! ! |
|
86 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
87 |
!Autoload class methodsFor:'initialization'! |
126 | 88 |
|
89 |
initialize |
|
2223 | 90 |
"initialize the failure-signal" |
91 |
||
126 | 92 |
AutoloadFailedSignal isNil ifTrue:[ |
5903 | 93 |
LazyLoading := false. |
2654 | 94 |
|
5903 | 95 |
AutoloadFailedSignal := Object errorSignal newSignalMayProceed:true. |
96 |
AutoloadFailedSignal nameClass:self message:#autoloadFailedSignal. |
|
97 |
AutoloadFailedSignal notifierString:'autoload failed'. |
|
197 | 98 |
|
5903 | 99 |
self class changeClassTo:AutoloadMetaclass. |
100 |
self setSuperclass:nil. |
|
101 |
ObjectMemory flushCaches. |
|
5005 | 102 |
]. |
103 |
||
104 |
self ~~ Autoload ifTrue:[ |
|
5903 | 105 |
^ self doesNotUnderstand:(Message selector:#initialize) |
5005 | 106 |
]. |
2223 | 107 |
|
4511
da0b327f3204
Use AutoloadMetaclass to load a class on unhandled class methods.
Stefan Vogel <sv@exept.de>
parents:
4496
diff
changeset
|
108 |
"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
|
109 |
"Modified: / 3.8.1999 / 14:23:30 / stefan" |
126 | 110 |
! ! |
111 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
112 |
!Autoload class methodsFor:'Signal constants'! |
126 | 113 |
|
114 |
autoloadFailedSignal |
|
115 |
"return the signal raised when an autoload fails" |
|
116 |
||
117 |
^ AutoloadFailedSignal |
|
118 |
! ! |
|
119 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
120 |
!Autoload class methodsFor:'adding/removing autoloaded classes'! |
359 | 121 |
|
216 | 122 |
addClass:aClassName |
4052 | 123 |
"given a name, install a corresponding autoload class stub for it. |
124 |
Return the (autoload-) stubClass or nil, if no new class was created." |
|
1277 | 125 |
|
4052 | 126 |
^ self addClass:aClassName inCategory:'autoloaded-Classes' |
216 | 127 |
|
128 |
" |
|
129 |
Autoload addClass:'Clock' |
|
130 |
" |
|
1277 | 131 |
|
132 |
"Modified: 24.4.1996 / 19:54:16 / cg" |
|
216 | 133 |
! |
134 |
||
135 |
addClass:aClassName inCategory:aCategory |
|
4052 | 136 |
"given a name, install a corresponding autoload class stub for it. |
137 |
Return the (autoload-) stubClass or nil, if no new class was created." |
|
1277 | 138 |
|
4052 | 139 |
|nameSymbol cls| |
216 | 140 |
|
141 |
nameSymbol := aClassName asSymbol. |
|
142 |
(Smalltalk at:nameSymbol) isNil ifTrue:[ |
|
5903 | 143 |
cls := Autoload |
144 |
subclass:nameSymbol |
|
145 |
instanceVariableNames:'' |
|
146 |
classVariableNames:'' |
|
147 |
poolDictionaries:'' |
|
148 |
category:aCategory. |
|
4052 | 149 |
]. |
150 |
^ cls |
|
151 |
||
216 | 152 |
" |
153 |
Autoload addClass:'Clock' inCategory:'autoloaded-Demos' |
|
154 |
" |
|
1277 | 155 |
|
156 |
"Modified: 24.4.1996 / 19:54:20 / cg" |
|
620 | 157 |
! |
158 |
||
159 |
removeClass:aClass |
|
1277 | 160 |
"remove a class from the list of loaded classes" |
161 |
||
620 | 162 |
LoadedClasses remove:aClass ifAbsent:[] |
1277 | 163 |
|
164 |
"Modified: 24.4.1996 / 19:54:35 / cg" |
|
620 | 165 |
! ! |
166 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
167 |
!Autoload class methodsFor:'fileout'! |
620 | 168 |
|
5345 | 169 |
basicFileOutDefinitionOn:aStream withNameSpace:forceNameSpace withPackage:withPackage |
620 | 170 |
"print an expression to define myself on aStream. |
171 |
Since autoloaded classes dont know their real definition, simply |
|
172 |
output some comment string making things clear in the browser." |
|
173 |
||
5820 | 174 |
|myName fileName nm package| |
620 | 175 |
|
5345 | 176 |
(self == Autoload) ifTrue:[ |
7019 | 177 |
^ super |
178 |
basicFileOutDefinitionOn:aStream |
|
179 |
withNameSpace:forceNameSpace |
|
180 |
withPackage:withPackage |
|
5345 | 181 |
]. |
620 | 182 |
|
183 |
myName := self name. |
|
1952
18cfc11b49fa
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
1862
diff
changeset
|
184 |
aStream nextPutAll:'"' ; nextPutLine:'Notice from Autoload:'; cr; |
7019 | 185 |
spaces:4; nextPutLine:myName , ' is not yet loaded.'; cr. |
186 |
aStream nextPutLine:'to load, execute: '. |
|
187 |
aStream cr; spaces:4; nextPutLine:myName , ' autoload'. |
|
4280
f100fa94428f
oops - dont put dQuotes inside a comment-string
Claus Gittinger <cg@exept.de>
parents:
4279
diff
changeset
|
188 |
aStream cr; nextPutLine:'or use the browsers load-function (in the class menu)'. |
f100fa94428f
oops - dont put dQuotes inside a comment-string
Claus Gittinger <cg@exept.de>
parents:
4279
diff
changeset
|
189 |
aStream nextPutLine:'(double-click on the class will also load it).'. |
620 | 190 |
" |
191 |
the following is simply informative ... |
|
192 |
actually, its a hack & kludge - there ought to be a method for this |
|
193 |
in Smalltalk |
|
194 |
(knowing the details of loading here is no good coding style) |
|
195 |
" |
|
196 |
fileName := Smalltalk fileNameForClass:myName. |
|
197 |
(ObjectFileLoader notNil and:[Smalltalk loadBinaries]) ifTrue:[ |
|
7019 | 198 |
(nm := Smalltalk libraryFileNameOfClass:myName) notNil ifTrue:[ |
199 |
nm := nm , ' (a classLibrary, possibly including more classes)' |
|
200 |
] ifFalse:[ |
|
201 |
nm := Smalltalk getBinaryFileName:(fileName , '.so'). |
|
202 |
nm isNil ifTrue:[ |
|
203 |
nm := Smalltalk getBinaryFileName:(fileName , '.o') |
|
204 |
]. |
|
205 |
nm notNil ifTrue:[ |
|
206 |
nm := nm , ' (a classBinary)' |
|
207 |
] |
|
208 |
]. |
|
620 | 209 |
]. |
210 |
nm isNil ifTrue:[ |
|
7019 | 211 |
package := self package. |
212 |
package notNil ifTrue:[ |
|
213 |
nm := Smalltalk getSourceFileName:((package copyReplaceAll:$: with:$/) , '/' , fileName , '.st'). |
|
214 |
]. |
|
215 |
nm isNil ifTrue:[ |
|
216 |
nm := Smalltalk getSourceFileName:(fileName , '.st'). |
|
217 |
]. |
|
620 | 218 |
]. |
219 |
nm notNil ifTrue:[ |
|
7019 | 220 |
aStream cr; nextPutLine:'When accessed, ' , myName , ' will automatically be loaded'. |
221 |
aStream nextPutLine:'from: '; spaces:4; nextPutAll:nm. |
|
222 |
nm asFilename isSymbolicLink ifTrue:[ |
|
223 |
aStream cr; cr. |
|
224 |
aStream nextPutLine:'which is a link to: '; spaces:4; |
|
225 |
nextPutAll:(nm asFilename linkInfo path). |
|
226 |
] |
|
620 | 227 |
] ifFalse:[ |
7019 | 228 |
package := self package. |
229 |
(Smalltalk at:#SourceCodeManager) notNil ifTrue:[ |
|
230 |
aStream nextPutAll:' |
|
5076 | 231 |
When accessed, I''ll ask the sourceCodeManager to load the code |
232 |
from ''' , fileName , '.st'' in the ''' , package , ''' package.'. |
|
7019 | 233 |
] ifFalse:[ |
234 |
aStream nextPutAll:' |
|
5076 | 235 |
When accessed, I''ll search for a file named |
236 |
''' , 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
|
237 |
|
5076 | 238 |
Packages are tried along the packagePath, which is: |
239 |
' , ((Smalltalk packagePath asStringCollection collect:[:each| ' ' , each]) asStringWith:Character cr). |
|
7019 | 240 |
] |
620 | 241 |
]. |
242 |
aStream cr; nextPutAll:'"'. |
|
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
243 |
|
4025
d9b9a5e77f1a
when autoloading, allow for the stx-source subtree
Claus Gittinger <cg@exept.de>
parents:
4016
diff
changeset
|
244 |
"Created: / 5.1.1997 / 14:31:33 / cg" |
4280
f100fa94428f
oops - dont put dQuotes inside a comment-string
Claus Gittinger <cg@exept.de>
parents:
4279
diff
changeset
|
245 |
"Modified: / 6.6.1999 / 15:17:30 / cg" |
620 | 246 |
! ! |
247 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
248 |
!Autoload class methodsFor:'lazy compilation'! |
620 | 249 |
|
250 |
compileLazy |
|
251 |
"return the lazy loading flag - if on, fileIn is much faster, |
|
252 |
but pauses are to be expected later, since methods are compiled |
|
253 |
when first executed." |
|
254 |
||
255 |
^ LazyLoading |
|
256 |
! |
|
257 |
||
258 |
compileLazy:aBoolean |
|
259 |
"turn on/off lazy loading - if on, fileIn is much faster, |
|
260 |
but pauses are to be expected later, since methods are compiled |
|
261 |
when first executed. |
|
262 |
If you like it, add a line to your startup file." |
|
263 |
||
264 |
LazyLoading := aBoolean |
|
216 | 265 |
! ! |
266 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
267 |
!Autoload class methodsFor:'loading'! |
1 | 268 |
|
269 |
autoload |
|
270 |
"use this to force loading |
|
2062 | 271 |
- it is defined a noop in all non-autoloading classes" |
1 | 272 |
|
4033 | 273 |
|mySelf myName myNameSpace newClass oldMeta project prevMode |
5820 | 274 |
package| |
1 | 275 |
|
276 |
mySelf := self. |
|
164 | 277 |
myName := self name asSymbol. |
3027
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
278 |
myNameSpace := self nameSpace. |
1 | 279 |
|
4775 | 280 |
"/ recheck - in case my class somehow came into the system |
281 |
"/ (by loading a binary...) |
|
282 |
(newClass := Smalltalk at:myName) ~~ self ifTrue:[ |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
283 |
(newClass isBehavior and:[newClass isLoaded]) ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
284 |
('Autoload [info]: already loaded: ', myName , '.') infoPrintCR. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
285 |
self class becomeSameAs:newClass class. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
286 |
self becomeSameAs:newClass. |
4775 | 287 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
288 |
ObjectMemory flushCaches. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
289 |
^ newClass |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
290 |
]. |
4775 | 291 |
]. |
292 |
||
2 | 293 |
"load it" |
1566 | 294 |
(Object infoPrinting and:[Smalltalk silentLoading ~~ true]) ifTrue:[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
295 |
Transcript showCR:('autoloading ', myName , ' ...'); endEntry. |
1564
f3f9736bd0fa
suppress load messages, if infoPrinting is turned off
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
296 |
]. |
1 | 297 |
|
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
298 |
[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
299 |
"remove myself - to avoid recompilation" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
300 |
Smalltalk at:myName put:nil. |
5902 | 301 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
302 |
prevMode := ClassCategoryReader sourceMode. |
1720 | 303 |
"/ |
304 |
"/ no- do not do this; it may lead to trouble ... |
|
305 |
"/ ClassCategoryReader sourceMode:#reference. |
|
1694
29791fde790e
autoload classes keep source reference
Claus Gittinger <cg@exept.de>
parents:
1674
diff
changeset
|
306 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
307 |
"/ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
308 |
"/ 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
|
309 |
"/ temporarily set the currentProject to nil. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
310 |
"/ we will later set the classes package to something useful |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
311 |
"/ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
312 |
Project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
313 |
project := Project current. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
314 |
Project setProject:nil. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
315 |
]. |
2375
7eb1b35edc33
autoload into Smalltalk nameSpace - by default.
Claus Gittinger <cg@exept.de>
parents:
2366
diff
changeset
|
316 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
317 |
package := self package. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
318 |
Class nameSpaceQuerySignal answer:myNameSpace "Smalltalk" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
319 |
do:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
320 |
Class packageQuerySignal answer:package |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
321 |
do:[ |
6081
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
322 |
Class classConventionViolationConfirmationQuerySignal answer:true |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
323 |
do:[ |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
324 |
(Smalltalk |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
325 |
fileInClass:myName |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
326 |
package:package |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
327 |
initialize:false |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
328 |
lazy:LazyLoading |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
329 |
silent:nil) isNil |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
330 |
ifTrue:[ |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
331 |
"/ temporary: try without stx/package prefix |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
332 |
"/ this will vanish as soon as source-directory |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
333 |
"/ is always guaranteed to contain an stx-subtree |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
334 |
((package startsWith:'stx/') |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
335 |
or:[package startsWith:'stx:']) ifTrue:[ |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
336 |
package := package copyFrom:5. |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
337 |
Smalltalk |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
338 |
fileInClass:myName |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
339 |
package:package |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
340 |
initialize:false |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
341 |
lazy:LazyLoading |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
342 |
silent:nil. |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
343 |
] |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
344 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
345 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
346 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
347 |
]. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
348 |
ClassCategoryReader sourceMode:prevMode. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
349 |
project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
350 |
Project setProject:project. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
351 |
]. |
6602
04a98cfacbe1
Use #ifCurtailed: instead of #valueOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6251
diff
changeset
|
352 |
] ifCurtailed:[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
353 |
ClassCategoryReader sourceMode:prevMode. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
354 |
project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
355 |
Project setProject:project. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
356 |
]. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
357 |
Smalltalk at:myName put:mySelf. |
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
358 |
]. |
1 | 359 |
|
360 |
"did it work ?" |
|
164 | 361 |
newClass := Smalltalk at:myName. |
362 |
Smalltalk at:myName put:mySelf. "will be undone by become:" |
|
1 | 363 |
|
138 | 364 |
"no - report the error" |
1 | 365 |
newClass isNil ifTrue:[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
366 |
" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
367 |
this signal is raised, if an autoloaded class |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
368 |
cannot be loaded. Usually, this happends when |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
369 |
some sourcefile is missing, not readable or if |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
370 |
an entry is missing in the abbreviation file. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
371 |
Check for a readable file named <myName>.st |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
372 |
in the 'source' directory and (if its a long fileName) |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
373 |
for a corresponding entry in the abbreviation file |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
374 |
'include/abbrev.stc'. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
375 |
Finally, your searchpath could be set wrong - |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
376 |
both 'source' and 'include' directories must be found in |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
377 |
one of the directories named in systemPath. |
154 | 378 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
379 |
In the debugger, press 'abort' to continue execution. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
380 |
" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
381 |
AutoloadFailedSignal |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
382 |
raiseRequestWith:self |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
383 |
errorString:('autoload of ' , myName , ' failed'). |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
384 |
^ nil |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
385 |
]. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
386 |
|
5463
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
387 |
newClass setPackage:package. |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
388 |
newClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | mthd setPackage:package]. |
5527
2817d7e173de
set project of all autoloaded methods
Claus Gittinger <cg@exept.de>
parents:
5475
diff
changeset
|
389 |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
390 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
391 |
"/ 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
|
392 |
"/ 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
|
393 |
"/ info encoded. (binary classes have it) |
2057
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
394 |
"/ 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
|
395 |
"/ |
5463
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
396 |
"/ newClass setPackageFromRevision. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
397 |
"/ |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
398 |
"/ newPackage := newClass package. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
399 |
"/ (newPackage isNil or:[newPackage = 'no package']) ifTrue:[ |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
400 |
"/ (package notNil and:[package ~= 'no package']) ifTrue:[ |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
401 |
"/ newClass setPackage:package. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
402 |
"/ ]. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
403 |
"/ ]. |
1 | 404 |
|
216 | 405 |
LoadedClasses isNil ifTrue:[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
406 |
LoadedClasses := IdentitySet new. |
216 | 407 |
]. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
408 |
LoadedClasses add:newClass. |
216 | 409 |
|
154 | 410 |
"wow - it worked. now the big trick ..." |
1 | 411 |
|
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
412 |
"/ newClass class setSoleInstance:self. "/ will be undone by become ... |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
413 |
oldMeta := self class. |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
414 |
|
3267
870789c08fad
do not change the autoloaded classes name to '... (auto)'
Claus Gittinger <cg@exept.de>
parents:
3151
diff
changeset
|
415 |
"/ 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
|
416 |
|
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
417 |
self becomeSameAs:newClass. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
418 |
oldMeta becomeSameAs:newClass class. |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
419 |
|
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
420 |
ObjectMemory flushCaches. |
216 | 421 |
LoadedClasses rehash. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
422 |
|
3443
d57ea75d3ac5
oops - must send #initialize to all privateClasses.
Claus Gittinger <cg@exept.de>
parents:
3287
diff
changeset
|
423 |
newClass initializeWithAllPrivateClasses. |
886 | 424 |
newClass postAutoload. |
5705
543d3e8ef7c6
send a change notification when autoloading
Claus Gittinger <cg@exept.de>
parents:
5527
diff
changeset
|
425 |
|
543d3e8ef7c6
send a change notification when autoloading
Claus Gittinger <cg@exept.de>
parents:
5527
diff
changeset
|
426 |
Smalltalk changed:#classDefinition with:newClass. |
886 | 427 |
^ newClass |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
428 |
|
4025
d9b9a5e77f1a
when autoloading, allow for the stx-source subtree
Claus Gittinger <cg@exept.de>
parents:
4016
diff
changeset
|
429 |
"Modified: / 5.3.1999 / 12:59:13 / cg" |
1 | 430 |
! ! |
431 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
432 |
!Autoload class methodsFor:'message catching'! |
1 | 433 |
|
6251 | 434 |
at:arg |
435 |
"catch at: - redefined because its understood" |
|
436 |
||
437 |
^ self doesNotUnderstand:(Message selector:#at: with:arg) |
|
438 |
! |
|
439 |
||
620 | 440 |
basicNew |
1277 | 441 |
"catch basicNew - load the class and send it to the real one" |
620 | 442 |
|
443 |
^ self doesNotUnderstand:(Message selector:#basicNew) |
|
1277 | 444 |
|
445 |
"Modified: 24.4.1996 / 19:53:10 / cg" |
|
620 | 446 |
! |
447 |
||
448 |
basicNew:arg |
|
1277 | 449 |
"catch basicNew: - load the class and send it to the real one" |
620 | 450 |
|
451 |
^ self doesNotUnderstand:(Message selector:#basicNew: with:arg) |
|
1277 | 452 |
|
453 |
"Modified: 24.4.1996 / 19:53:16 / cg" |
|
620 | 454 |
! |
455 |
||
456 |
comment |
|
457 |
"return the classes comment. |
|
458 |
Autoloaded classes have no comment; but I myself have one" |
|
459 |
||
460 |
(self == Autoload) ifTrue:[^ super comment]. |
|
461 |
^ 'not yet loaded' |
|
462 |
! |
|
463 |
||
6768 | 464 |
copy |
465 |
"catch copy - load the class and resend #copy to the real one" |
|
466 |
||
467 |
^ self doesNotUnderstand:(Message selector:#copy) |
|
468 |
! |
|
469 |
||
1 | 470 |
doesNotUnderstand:aMessage |
2689 | 471 |
"caught a message; load the class and retry the message" |
1 | 472 |
|
473 |
|newClass| |
|
474 |
||
164 | 475 |
self ~~ Autoload ifTrue:[ |
5903 | 476 |
newClass := self autoload. |
477 |
newClass notNil ifTrue:[ |
|
478 |
^ aMessage sendTo:newClass |
|
479 |
] |
|
1 | 480 |
]. |
789
155eca125ef0
return value from doesNotUnderstand (so handler can return a value)
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
481 |
^ super doesNotUnderstand:aMessage |
1277 | 482 |
|
483 |
"Modified: 24.4.1996 / 19:53:27 / cg" |
|
1 | 484 |
! |
485 |
||
4301
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
486 |
loadAndResendMessage |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
487 |
"common helper to autoload a class and define a subclass of it by sending |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
488 |
the sender-message again. |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
489 |
This is invoked by all #subClass... definition messages." |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
490 |
|
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
491 |
|sel args newClass| |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
492 |
|
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
493 |
sel := thisContext sender selector. |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
494 |
args := thisContext sender args. |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
495 |
|
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
496 |
"take care: subclassing Autoload must still be possible" |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
497 |
(self == Autoload) ifTrue:[ |
5903 | 498 |
^ self perform:sel inClass:Autoload class superclass withArguments:args |
4301
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
499 |
]. |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
500 |
|
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
501 |
newClass := self autoload. |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
502 |
newClass notNil ifTrue:[ |
5903 | 503 |
^ newClass perform:sel withArguments:args |
4301
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
504 |
]. |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
505 |
^ nil |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
506 |
|
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
507 |
"Created: 8.2.1997 / 19:42:47 / cg" |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
508 |
! |
e74e49f4e8e2
changed the way subclass-creation messages are handled
Claus Gittinger <cg@exept.de>
parents:
4280
diff
changeset
|
509 |
|
1 | 510 |
new |
2663 | 511 |
"catch new - load the class and resend #new to the real one" |
1 | 512 |
|
513 |
^ self doesNotUnderstand:(Message selector:#new) |
|
1277 | 514 |
|
2663 | 515 |
"Modified: 26.5.1997 / 14:59:52 / cg" |
1 | 516 |
! |
517 |
||
518 |
new:arg |
|
2663 | 519 |
"catch new: - load the class and resend #new: it to the real one" |
1 | 520 |
|
521 |
^ self doesNotUnderstand:(Message selector:#new: with:arg) |
|
1277 | 522 |
|
2663 | 523 |
"Modified: 26.5.1997 / 14:59:58 / cg" |
1 | 524 |
! |
525 |
||
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
526 |
readFrom:aStream |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
527 |
"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
|
528 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
529 |
^ self doesNotUnderstand:(Message selector:#readFrom: with:aStream) |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
530 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
531 |
"Created: 22.5.1996 / 23:44:23 / stefan" |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
532 |
! |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
533 |
|
1437 | 534 |
readFrom:aStream onError:exceptionBlock |
535 |
"catch - load the class and send it to the real one" |
|
536 |
||
537 |
^ self doesNotUnderstand:(Message selector:#readFrom:onError: with:aStream with:exceptionBlock) |
|
538 |
||
539 |
"Created: 22.5.1996 / 23:03:39 / stefan" |
|
540 |
! |
|
541 |
||
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
542 |
readFromString:aString |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
543 |
"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
|
544 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
545 |
^ self doesNotUnderstand:(Message selector:#readFromString: with:aString) |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
546 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
547 |
"Created: 22.5.1996 / 23:46:15 / stefan" |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
548 |
! |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
549 |
|
1437 | 550 |
readFromString:aString onError:exceptionBlock |
551 |
"catch - load the class and send it to the real one" |
|
552 |
||
553 |
^ self doesNotUnderstand:(Message selector:#readFromString:onError: with:aString with:exceptionBlock) |
|
554 |
||
555 |
"Created: 22.5.1996 / 23:04:49 / stefan" |
|
556 |
! |
|
557 |
||
2691
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
558 |
respondsTo:aSelector |
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
559 |
"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
|
560 |
|
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
561 |
self == Autoload ifTrue:[ |
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
562 |
^ super respondsTo:aSelector |
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
563 |
]. |
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
564 |
^ self doesNotUnderstand:(Message selector:#respondsTo: with:aSelector) |
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
565 |
|
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
566 |
"Modified: 26.5.1997 / 14:59:58 / cg" |
1 | 567 |
! ! |
11 | 568 |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
569 |
!Autoload class methodsFor:'queries'! |
356 | 570 |
|
5902 | 571 |
accepts:aSignal |
572 |
"redefined to avoid recursive autoload" |
|
573 |
||
574 |
|newClass| |
|
575 |
||
576 |
self isBeingLoaded ifFalse:[ |
|
5903 | 577 |
newClass := self autoload. |
578 |
newClass notNil ifTrue:[ |
|
579 |
^ newClass accepts:aSignal |
|
580 |
]. |
|
5902 | 581 |
]. |
582 |
^ false |
|
583 |
! |
|
584 |
||
620 | 585 |
isBehavior |
586 |
"return true if the recevier is some kind of class. |
|
587 |
Autoloaded classes are definitely; therefore return true." |
|
164 | 588 |
|
620 | 589 |
^ true |
590 |
! |
|
356 | 591 |
|
5902 | 592 |
isBeingLoaded |
5903 | 593 |
^ (self ~~ Autoload) and:[(Smalltalk at:self name) isNil ] |
5902 | 594 |
|
595 |
"Modified: / 16.2.1998 / 11:57:35 / stefan" |
|
596 |
! |
|
597 |
||
729 | 598 |
isBuiltInClass |
1266 | 599 |
"return true if this class is known by the run-time-system. |
600 |
Returns false here." |
|
601 |
||
729 | 602 |
^ false |
603 |
||
604 |
"Created: 10.12.1995 / 00:28:22 / cg" |
|
1266 | 605 |
"Modified: 23.4.1996 / 15:55:36 / cg" |
729 | 606 |
! |
607 |
||
620 | 608 |
isLoaded |
3287 | 609 |
"return true, if the class has been loaded. |
610 |
Autoload itself is loaded, subclasses are not. |
|
611 |
This allows testing wether a class has already been loaded." |
|
620 | 612 |
|
613 |
^ (self == Autoload) |
|
3287 | 614 |
|
615 |
"Modified: / 16.2.1998 / 11:57:35 / stefan" |
|
620 | 616 |
! |
617 |
||
922 | 618 |
loadedClasses |
619 |
"return the set of classes that were autoloaded" |
|
620 |
||
4496 | 621 |
^ LoadedClasses ? #() |
922 | 622 |
! |
623 |
||
4401
d9667432d35b
privateClasses and allPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4301
diff
changeset
|
624 |
privateClassesOrAll:allOfThem |
4000 | 625 |
"an autoloaded class has none" |
626 |
||
627 |
^ #() |
|
628 |
! |
|
629 |
||
620 | 630 |
wasAutoloaded:aClass |
922 | 631 |
"return true, if aClass was autoloaded" |
632 |
||
620 | 633 |
^ LoadedClasses notNil and:[LoadedClasses includes:aClass] |
11 | 634 |
! ! |
620 | 635 |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
636 |
!Autoload class methodsFor:'documentation'! |
661 | 637 |
|
638 |
version |
|
7019 | 639 |
^ '$Header: /cvs/stx/stx/libbasic/Autoload.st,v 1.115 2003-02-10 16:38:46 penk Exp $' |
661 | 640 |
! ! |
6768 | 641 |
|
620 | 642 |
Autoload initialize! |