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