author | Stefan Vogel <sv@exept.de> |
Thu, 01 Jul 2004 12:06:47 +0200 | |
changeset 8431 | 3e06c959dcff |
parent 8382 | c3fe9de270ad |
child 8482 | 6ca4f0d2594d |
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 |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
55 |
all classes listed in that file, which do not exist already. |
2662 | 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 |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
65 |
LazyLoading <Boolean> if true, the loaded classes |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
66 |
methods will NOT be compiled at |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
67 |
autoload time, but instead when |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
68 |
first called. This allows for a |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
69 |
faster load. However, expect short |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
70 |
pauses later when the methods are |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
71 |
first executed. |
126 | 72 |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
73 |
AutoloadFailedSignal <Signal> signal raised if an autoloaded |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
74 |
classes source is not available. |
922 | 75 |
|
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
76 |
LoadedClasses <Collection> set of classes that heve been |
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
77 |
autoloaded (for later unload) |
1292 | 78 |
|
2662 | 79 |
[see also:] |
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
diff
changeset
|
80 |
Smalltalk |
2662 | 81 |
|
1292 | 82 |
[author:] |
7280
7afcccb7c856
Fix pidgin spelling: 'does not exists' and 'not exists'
Stefan Vogel <sv@exept.de>
parents:
7178
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:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
93 |
LazyLoading := false. |
2654 | 94 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
95 |
AutoloadFailedSignal := Error newSignalMayProceed:true. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
96 |
AutoloadFailedSignal nameClass:self message:#autoloadFailedSignal. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
97 |
AutoloadFailedSignal notifierString:'autoload failed'. |
197 | 98 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
99 |
self class changeClassTo:AutoloadMetaclass. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
100 |
self setSuperclass:nil. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
101 |
ObjectMemory flushCaches. |
5005 | 102 |
]. |
8316 | 103 |
LoadedClasses isNil ifTrue:[ |
104 |
LoadedClasses := IdentitySet new. |
|
105 |
]. |
|
5005 | 106 |
|
107 |
self ~~ Autoload ifTrue:[ |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7019
diff
changeset
|
108 |
^ self doesNotUnderstand:(Message selector:#initialize) |
5005 | 109 |
]. |
2223 | 110 |
|
4511
da0b327f3204
Use AutoloadMetaclass to load a class on unhandled class methods.
Stefan Vogel <sv@exept.de>
parents:
4496
diff
changeset
|
111 |
"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
|
112 |
"Modified: / 3.8.1999 / 14:23:30 / stefan" |
126 | 113 |
! ! |
114 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
115 |
!Autoload class methodsFor:'Signal constants'! |
126 | 116 |
|
117 |
autoloadFailedSignal |
|
118 |
"return the signal raised when an autoload fails" |
|
119 |
||
120 |
^ AutoloadFailedSignal |
|
121 |
! ! |
|
122 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
123 |
!Autoload class methodsFor:'adding/removing autoloaded classes'! |
359 | 124 |
|
216 | 125 |
addClass:aClassName |
4052 | 126 |
"given a name, install a corresponding autoload class stub for it. |
127 |
Return the (autoload-) stubClass or nil, if no new class was created." |
|
1277 | 128 |
|
4052 | 129 |
^ self addClass:aClassName inCategory:'autoloaded-Classes' |
216 | 130 |
|
131 |
" |
|
132 |
Autoload addClass:'Clock' |
|
133 |
" |
|
1277 | 134 |
|
135 |
"Modified: 24.4.1996 / 19:54:16 / cg" |
|
216 | 136 |
! |
137 |
||
138 |
addClass:aClassName inCategory:aCategory |
|
4052 | 139 |
"given a name, install a corresponding autoload class stub for it. |
140 |
Return the (autoload-) stubClass or nil, if no new class was created." |
|
1277 | 141 |
|
4052 | 142 |
|nameSymbol cls| |
216 | 143 |
|
144 |
nameSymbol := aClassName asSymbol. |
|
145 |
(Smalltalk at:nameSymbol) isNil ifTrue:[ |
|
5903 | 146 |
cls := Autoload |
147 |
subclass:nameSymbol |
|
148 |
instanceVariableNames:'' |
|
149 |
classVariableNames:'' |
|
150 |
poolDictionaries:'' |
|
151 |
category:aCategory. |
|
4052 | 152 |
]. |
153 |
^ cls |
|
154 |
||
216 | 155 |
" |
156 |
Autoload addClass:'Clock' inCategory:'autoloaded-Demos' |
|
157 |
" |
|
1277 | 158 |
|
159 |
"Modified: 24.4.1996 / 19:54:20 / cg" |
|
620 | 160 |
! |
161 |
||
162 |
removeClass:aClass |
|
1277 | 163 |
"remove a class from the list of loaded classes" |
164 |
||
620 | 165 |
LoadedClasses remove:aClass ifAbsent:[] |
1277 | 166 |
|
167 |
"Modified: 24.4.1996 / 19:54:35 / cg" |
|
620 | 168 |
! ! |
169 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
170 |
!Autoload class methodsFor:'fileout'! |
620 | 171 |
|
5345 | 172 |
basicFileOutDefinitionOn:aStream withNameSpace:forceNameSpace withPackage:withPackage |
620 | 173 |
"print an expression to define myself on aStream. |
8316 | 174 |
Since autoloaded classes don't know their real definition, simply |
620 | 175 |
output some comment string making things clear in the browser." |
176 |
||
5820 | 177 |
|myName fileName nm package| |
620 | 178 |
|
5345 | 179 |
(self == Autoload) ifTrue:[ |
7019 | 180 |
^ super |
181 |
basicFileOutDefinitionOn:aStream |
|
182 |
withNameSpace:forceNameSpace |
|
183 |
withPackage:withPackage |
|
5345 | 184 |
]. |
620 | 185 |
|
186 |
myName := self name. |
|
1952
18cfc11b49fa
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
1862
diff
changeset
|
187 |
aStream nextPutAll:'"' ; nextPutLine:'Notice from Autoload:'; cr; |
7019 | 188 |
spaces:4; nextPutLine:myName , ' is not yet loaded.'; cr. |
189 |
aStream nextPutLine:'to load, execute: '. |
|
190 |
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
|
191 |
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
|
192 |
aStream nextPutLine:'(double-click on the class will also load it).'. |
620 | 193 |
" |
194 |
the following is simply informative ... |
|
195 |
actually, its a hack & kludge - there ought to be a method for this |
|
196 |
in Smalltalk |
|
197 |
(knowing the details of loading here is no good coding style) |
|
198 |
" |
|
199 |
fileName := Smalltalk fileNameForClass:myName. |
|
200 |
(ObjectFileLoader notNil and:[Smalltalk loadBinaries]) ifTrue:[ |
|
7019 | 201 |
(nm := Smalltalk libraryFileNameOfClass:myName) notNil ifTrue:[ |
202 |
nm := nm , ' (a classLibrary, possibly including more classes)' |
|
203 |
] ifFalse:[ |
|
204 |
nm := Smalltalk getBinaryFileName:(fileName , '.so'). |
|
205 |
nm isNil ifTrue:[ |
|
206 |
nm := Smalltalk getBinaryFileName:(fileName , '.o') |
|
207 |
]. |
|
208 |
nm notNil ifTrue:[ |
|
209 |
nm := nm , ' (a classBinary)' |
|
210 |
] |
|
211 |
]. |
|
620 | 212 |
]. |
213 |
nm isNil ifTrue:[ |
|
7019 | 214 |
package := self package. |
215 |
package notNil ifTrue:[ |
|
216 |
nm := Smalltalk getSourceFileName:((package copyReplaceAll:$: with:$/) , '/' , fileName , '.st'). |
|
217 |
]. |
|
218 |
nm isNil ifTrue:[ |
|
219 |
nm := Smalltalk getSourceFileName:(fileName , '.st'). |
|
220 |
]. |
|
620 | 221 |
]. |
222 |
nm notNil ifTrue:[ |
|
7744 | 223 |
aStream |
224 |
cr; |
|
225 |
nextPutLine:'When accessed, ' , myName , ' will automatically be loaded'; |
|
226 |
nextPutLine:'from: '; spaces:4; nextPutAll:nm. |
|
227 |
||
7019 | 228 |
nm asFilename isSymbolicLink ifTrue:[ |
229 |
aStream cr; cr. |
|
7744 | 230 |
aStream |
231 |
nextPutLine:'which is a link to: '; |
|
232 |
spaces:4; |
|
233 |
nextPutAll:(nm asFilename linkInfo path). |
|
7019 | 234 |
] |
620 | 235 |
] ifFalse:[ |
7019 | 236 |
package := self package. |
237 |
(Smalltalk at:#SourceCodeManager) notNil ifTrue:[ |
|
238 |
aStream nextPutAll:' |
|
5076 | 239 |
When accessed, I''ll ask the sourceCodeManager to load the code |
240 |
from ''' , fileName , '.st'' in the ''' , package , ''' package.'. |
|
7019 | 241 |
] ifFalse:[ |
242 |
aStream nextPutAll:' |
|
5076 | 243 |
When accessed, I''ll search for a file named |
244 |
''' , 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
|
245 |
|
5076 | 246 |
Packages are tried along the packagePath, which is: |
247 |
' , ((Smalltalk packagePath asStringCollection collect:[:each| ' ' , each]) asStringWith:Character cr). |
|
7019 | 248 |
] |
620 | 249 |
]. |
250 |
aStream cr; nextPutAll:'"'. |
|
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
251 |
|
4025
d9b9a5e77f1a
when autoloading, allow for the stx-source subtree
Claus Gittinger <cg@exept.de>
parents:
4016
diff
changeset
|
252 |
"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
|
253 |
"Modified: / 6.6.1999 / 15:17:30 / cg" |
620 | 254 |
! ! |
255 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
256 |
!Autoload class methodsFor:'lazy compilation'! |
620 | 257 |
|
258 |
compileLazy |
|
259 |
"return the lazy loading flag - if on, fileIn is much faster, |
|
260 |
but pauses are to be expected later, since methods are compiled |
|
261 |
when first executed." |
|
262 |
||
263 |
^ LazyLoading |
|
264 |
! |
|
265 |
||
266 |
compileLazy:aBoolean |
|
267 |
"turn on/off lazy loading - if on, fileIn is much faster, |
|
268 |
but pauses are to be expected later, since methods are compiled |
|
269 |
when first executed. |
|
270 |
If you like it, add a line to your startup file." |
|
271 |
||
272 |
LazyLoading := aBoolean |
|
216 | 273 |
! ! |
274 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
275 |
!Autoload class methodsFor:'loading'! |
1 | 276 |
|
277 |
autoload |
|
278 |
"use this to force loading |
|
2062 | 279 |
- it is defined a noop in all non-autoloading classes" |
1 | 280 |
|
4033 | 281 |
|mySelf myName myNameSpace newClass oldMeta project prevMode |
5820 | 282 |
package| |
1 | 283 |
|
284 |
mySelf := self. |
|
164 | 285 |
myName := self name asSymbol. |
3027
7d677a5ced41
care for loaded classes namespace (vs. default namespace)
Claus Gittinger <cg@exept.de>
parents:
2691
diff
changeset
|
286 |
myNameSpace := self nameSpace. |
1 | 287 |
|
4775 | 288 |
"/ recheck - in case my class somehow came into the system |
289 |
"/ (by loading a binary...) |
|
290 |
(newClass := Smalltalk at:myName) ~~ self ifTrue:[ |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
291 |
(newClass isBehavior and:[newClass isLoaded]) ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
292 |
('Autoload [info]: already loaded: ', myName , '.') infoPrintCR. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
293 |
self class becomeSameAs:newClass class. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
294 |
self becomeSameAs:newClass. |
4775 | 295 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
296 |
ObjectMemory flushCaches. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
297 |
^ newClass |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
298 |
]. |
4775 | 299 |
]. |
300 |
||
2 | 301 |
"load it" |
1566 | 302 |
(Object infoPrinting and:[Smalltalk silentLoading ~~ true]) ifTrue:[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
303 |
Transcript showCR:('autoloading ', myName , ' ...'); endEntry. |
1564
f3f9736bd0fa
suppress load messages, if infoPrinting is turned off
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
304 |
]. |
1 | 305 |
|
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
306 |
[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
307 |
"remove myself - to avoid recompilation" |
8382
c3fe9de270ad
to be evaluated: no longer nil global of class being autoloaded.
Claus Gittinger <cg@exept.de>
parents:
8316
diff
changeset
|
308 |
"/ Smalltalk at:myName put:nil. |
5902 | 309 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
310 |
prevMode := ClassCategoryReader sourceMode. |
1720 | 311 |
"/ |
312 |
"/ no- do not do this; it may lead to trouble ... |
|
313 |
"/ ClassCategoryReader sourceMode:#reference. |
|
1694
29791fde790e
autoload classes keep source reference
Claus Gittinger <cg@exept.de>
parents:
1674
diff
changeset
|
314 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
315 |
"/ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
316 |
"/ 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
|
317 |
"/ temporarily set the currentProject to nil. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
318 |
"/ we will later set the classes package to something useful |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
319 |
"/ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
320 |
Project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
321 |
project := Project current. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
322 |
Project setProject:nil. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
323 |
]. |
2375
7eb1b35edc33
autoload into Smalltalk nameSpace - by default.
Claus Gittinger <cg@exept.de>
parents:
2366
diff
changeset
|
324 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
325 |
package := self package. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
326 |
Class nameSpaceQuerySignal answer:myNameSpace "Smalltalk" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
327 |
do:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
328 |
Class packageQuerySignal answer:package |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
329 |
do:[ |
6081
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
330 |
Class classConventionViolationConfirmationQuerySignal answer:true |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
331 |
do:[ |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
332 |
(Smalltalk |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
333 |
fileInClass:myName |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
334 |
package:package |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
335 |
initialize:false |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
336 |
lazy:LazyLoading |
8431
3e06c959dcff
#autoload - raise error if fileIn fails.
Stefan Vogel <sv@exept.de>
parents:
8382
diff
changeset
|
337 |
silent:nil) |
3e06c959dcff
#autoload - raise error if fileIn fails.
Stefan Vogel <sv@exept.de>
parents:
8382
diff
changeset
|
338 |
isNil ifTrue:[ |
6081
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
339 |
"/ temporary: try without stx/package prefix |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
340 |
"/ 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
|
341 |
"/ 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
|
342 |
((package startsWith:'stx/') |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
343 |
or:[package startsWith:'stx:']) ifTrue:[ |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
344 |
package := package copyFrom:5. |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
345 |
Smalltalk |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
346 |
fileInClass:myName |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
347 |
package:package |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
348 |
initialize:false |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
349 |
lazy:LazyLoading |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
350 |
silent:nil. |
fedbf974cfe8
dont ask for variable-name conventions while autoloading
Claus Gittinger <cg@exept.de>
parents:
6075
diff
changeset
|
351 |
] |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
352 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
353 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
354 |
] |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
355 |
]. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
356 |
ClassCategoryReader sourceMode:prevMode. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
357 |
project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
358 |
Project setProject:project. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
359 |
]. |
6602
04a98cfacbe1
Use #ifCurtailed: instead of #valueOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6251
diff
changeset
|
360 |
] ifCurtailed:[ |
8431
3e06c959dcff
#autoload - raise error if fileIn fails.
Stefan Vogel <sv@exept.de>
parents:
8382
diff
changeset
|
361 |
"something went wrong, restore previous state" |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
362 |
ClassCategoryReader sourceMode:prevMode. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
363 |
project notNil ifTrue:[ |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
364 |
Project setProject:project. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
365 |
]. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
366 |
Smalltalk at:myName put:mySelf. |
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
367 |
]. |
1 | 368 |
|
369 |
"did it work ?" |
|
164 | 370 |
newClass := Smalltalk at:myName. |
371 |
Smalltalk at:myName put:mySelf. "will be undone by become:" |
|
1 | 372 |
|
138 | 373 |
"no - report the error" |
8431
3e06c959dcff
#autoload - raise error if fileIn fails.
Stefan Vogel <sv@exept.de>
parents:
8382
diff
changeset
|
374 |
(newClass isNil or:[newClass isLoaded not]) ifTrue:[ |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
375 |
" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
376 |
this signal is raised, if an autoloaded class |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
377 |
cannot be loaded. Usually, this happends when |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
378 |
some sourcefile is missing, not readable or if |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
379 |
an entry is missing in the abbreviation file. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
380 |
Check for a readable file named <myName>.st |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
381 |
in the 'source' directory and (if its a long fileName) |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
382 |
for a corresponding entry in the abbreviation file |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
383 |
'include/abbrev.stc'. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
384 |
Finally, your searchpath could be set wrong - |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
385 |
both 'source' and 'include' directories must be found in |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
386 |
one of the directories named in systemPath. |
154 | 387 |
|
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
388 |
In the debugger, press 'abort' to continue execution. |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
389 |
" |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
390 |
AutoloadFailedSignal |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
391 |
raiseRequestWith:self |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
392 |
errorString:('autoload of ' , myName , ' failed'). |
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
393 |
^ nil |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
394 |
]. |
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 setPackage:package. |
6075
57f3ae8d2a28
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
5903
diff
changeset
|
397 |
newClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | mthd setPackage:package]. |
5527
2817d7e173de
set project of all autoloaded methods
Claus Gittinger <cg@exept.de>
parents:
5475
diff
changeset
|
398 |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
399 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
400 |
"/ 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
|
401 |
"/ 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
|
402 |
"/ info encoded. (binary classes have it) |
2057
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
403 |
"/ 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
|
404 |
"/ |
5463
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
405 |
"/ newClass setPackageFromRevision. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
406 |
"/ |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
407 |
"/ newPackage := newClass package. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
408 |
"/ (newPackage isNil or:[newPackage = 'no package']) ifTrue:[ |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
409 |
"/ (package notNil and:[package ~= 'no package']) ifTrue:[ |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
410 |
"/ newClass setPackage:package. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
411 |
"/ ]. |
18ec3ac68106
preserve the package when autoloading
Claus Gittinger <cg@exept.de>
parents:
5345
diff
changeset
|
412 |
"/ ]. |
1 | 413 |
|
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
414 |
LoadedClasses add:newClass. |
216 | 415 |
|
154 | 416 |
"wow - it worked. now the big trick ..." |
1 | 417 |
|
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
418 |
"/ 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
|
419 |
oldMeta := self class. |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
420 |
|
3267
870789c08fad
do not change the autoloaded classes name to '... (auto)'
Claus Gittinger <cg@exept.de>
parents:
3151
diff
changeset
|
421 |
"/ self setName:(self name , ' (auto)'). |
7178 | 422 |
self dependents do:[:aDependent | |
423 |
newClass addDependent:aDependent |
|
424 |
]. |
|
8316 | 425 |
Smalltalk changed:#aboutToAutoloadClass with:(self -> newClass). |
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
426 |
self becomeSameAs:newClass. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
427 |
oldMeta becomeSameAs:newClass class. |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
428 |
|
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
429 |
ObjectMemory flushCaches. |
216 | 430 |
LoadedClasses rehash. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
431 |
|
3443
d57ea75d3ac5
oops - must send #initialize to all privateClasses.
Claus Gittinger <cg@exept.de>
parents:
3287
diff
changeset
|
432 |
newClass initializeWithAllPrivateClasses. |
886 | 433 |
newClass postAutoload. |
5705
543d3e8ef7c6
send a change notification when autoloading
Claus Gittinger <cg@exept.de>
parents:
5527
diff
changeset
|
434 |
|
543d3e8ef7c6
send a change notification when autoloading
Claus Gittinger <cg@exept.de>
parents:
5527
diff
changeset
|
435 |
Smalltalk changed:#classDefinition with:newClass. |
7178 | 436 |
self changed:#loaded. |
886 | 437 |
^ newClass |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
438 |
|
4025
d9b9a5e77f1a
when autoloading, allow for the stx-source subtree
Claus Gittinger <cg@exept.de>
parents:
4016
diff
changeset
|
439 |
"Modified: / 5.3.1999 / 12:59:13 / cg" |
1 | 440 |
! ! |
441 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
442 |
!Autoload class methodsFor:'message catching'! |
1 | 443 |
|
6251 | 444 |
at:arg |
445 |
"catch at: - redefined because its understood" |
|
446 |
||
447 |
^ self doesNotUnderstand:(Message selector:#at: with:arg) |
|
448 |
! |
|
449 |
||
620 | 450 |
basicNew |
1277 | 451 |
"catch basicNew - load the class and send it to the real one" |
620 | 452 |
|
453 |
^ self doesNotUnderstand:(Message selector:#basicNew) |
|
1277 | 454 |
|
455 |
"Modified: 24.4.1996 / 19:53:10 / cg" |
|
620 | 456 |
! |
457 |
||
458 |
basicNew:arg |
|
1277 | 459 |
"catch basicNew: - load the class and send it to the real one" |
620 | 460 |
|
461 |
^ self doesNotUnderstand:(Message selector:#basicNew: with:arg) |
|
1277 | 462 |
|
463 |
"Modified: 24.4.1996 / 19:53:16 / cg" |
|
620 | 464 |
! |
465 |
||
8185 | 466 |
classResources |
8316 | 467 |
"catch classResources - load the class and resend to the real one" |
8185 | 468 |
|
469 |
^ self doesNotUnderstand:(Message selector:#classResources) |
|
470 |
! |
|
471 |
||
620 | 472 |
comment |
473 |
"return the classes comment. |
|
474 |
Autoloaded classes have no comment; but I myself have one" |
|
475 |
||
476 |
(self == Autoload) ifTrue:[^ super comment]. |
|
477 |
^ 'not yet loaded' |
|
478 |
! |
|
479 |
||
6768 | 480 |
copy |
481 |
"catch copy - load the class and resend #copy to the real one" |
|
482 |
||
483 |
^ self doesNotUnderstand:(Message selector:#copy) |
|
484 |
! |
|
485 |
||
1 | 486 |
doesNotUnderstand:aMessage |
2689 | 487 |
"caught a message; load the class and retry the message" |
1 | 488 |
|
489 |
|newClass| |
|
490 |
||
164 | 491 |
self ~~ Autoload ifTrue:[ |
7178 | 492 |
newClass := self autoload. |
493 |
newClass notNil ifTrue:[ |
|
494 |
^ aMessage sendTo:newClass |
|
495 |
] |
|
1 | 496 |
]. |
789
155eca125ef0
return value from doesNotUnderstand (so handler can return a value)
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
497 |
^ super doesNotUnderstand:aMessage |
1277 | 498 |
|
499 |
"Modified: 24.4.1996 / 19:53:27 / cg" |
|
1 | 500 |
! |
501 |
||
7574 | 502 |
error |
503 |
"catch error - load the class and resend #error to the real one" |
|
504 |
||
505 |
^ self doesNotUnderstand:(Message selector:#error) |
|
506 |
! |
|
507 |
||
1 | 508 |
new |
2663 | 509 |
"catch new - load the class and resend #new to the real one" |
1 | 510 |
|
511 |
^ self doesNotUnderstand:(Message selector:#new) |
|
1277 | 512 |
|
2663 | 513 |
"Modified: 26.5.1997 / 14:59:52 / cg" |
1 | 514 |
! |
515 |
||
516 |
new:arg |
|
2663 | 517 |
"catch new: - load the class and resend #new: it to the real one" |
1 | 518 |
|
519 |
^ self doesNotUnderstand:(Message selector:#new: with:arg) |
|
1277 | 520 |
|
2663 | 521 |
"Modified: 26.5.1997 / 14:59:58 / cg" |
1 | 522 |
! |
523 |
||
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
524 |
readFrom:aStream |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
525 |
"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
|
526 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
527 |
^ self doesNotUnderstand:(Message selector:#readFrom: with:aStream) |
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 |
"Created: 22.5.1996 / 23:44:23 / stefan" |
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 |
|
1437 | 532 |
readFrom:aStream onError:exceptionBlock |
533 |
"catch - load the class and send it to the real one" |
|
534 |
||
535 |
^ self doesNotUnderstand:(Message selector:#readFrom:onError: with:aStream with:exceptionBlock) |
|
536 |
||
537 |
"Created: 22.5.1996 / 23:03:39 / stefan" |
|
538 |
! |
|
539 |
||
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
540 |
readFromString:aString |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
541 |
"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
|
542 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
543 |
^ self doesNotUnderstand:(Message selector:#readFromString: with:aString) |
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 |
"Created: 22.5.1996 / 23:46:15 / stefan" |
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 |
|
1437 | 548 |
readFromString:aString onError:exceptionBlock |
549 |
"catch - load the class and send it to the real one" |
|
550 |
||
551 |
^ self doesNotUnderstand:(Message selector:#readFromString:onError: with:aString with:exceptionBlock) |
|
552 |
||
553 |
"Created: 22.5.1996 / 23:04:49 / stefan" |
|
554 |
! |
|
555 |
||
2691
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
556 |
respondsTo:aSelector |
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
557 |
"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
|
558 |
|
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
559 |
self == Autoload ifTrue:[ |
7178 | 560 |
^ super respondsTo:aSelector |
2691
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
561 |
]. |
33221e233f79
when asked via #respondsTo:, load & resend
Claus Gittinger <cg@exept.de>
parents:
2689
diff
changeset
|
562 |
^ self doesNotUnderstand:(Message selector:#respondsTo: with: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 |
"Modified: 26.5.1997 / 14:59:58 / cg" |
8306 | 565 |
! |
566 |
||
567 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
568 |
"create a new class as a subclass of an existing class (the receiver). |
|
569 |
The subclass will have indexed variables if the receiving-class has." |
|
570 |
||
571 |
^ self loadAndResendMessage |
|
572 |
! |
|
573 |
||
574 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat classInstanceVariableNames:classInstanceVariableNames |
|
575 |
"create a new class as a subclass of an existing class (the receiver). |
|
576 |
The subclass will have indexed variables if the receiving-class has." |
|
577 |
||
578 |
^ self loadAndResendMessage |
|
579 |
! |
|
580 |
||
581 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat inEnvironment:aNameSpace |
|
582 |
"create a new class as a subclass of an existing class (the receiver). |
|
583 |
The subclass will have indexed variables if the receiving-class has." |
|
584 |
||
585 |
^ self loadAndResendMessage |
|
586 |
! |
|
587 |
||
588 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
589 |
"create a new class as a subclass of an existing class (the receiver). |
|
590 |
The subclass will have indexed variables if the receiving-class has." |
|
591 |
||
592 |
^ self loadAndResendMessage |
|
593 |
! |
|
594 |
||
595 |
variableByteSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
596 |
"create a new class as a subclass of an existing class (the receiver) |
|
597 |
in which the subclass has indexable byte-sized nonpointer variables" |
|
598 |
||
599 |
^ self loadAndResendMessage |
|
600 |
! |
|
601 |
||
602 |
variableByteSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
603 |
"create a new class as a subclass of an existing class (the receiver) |
|
604 |
in which the subclass has indexable byte-sized nonpointer variables" |
|
605 |
||
606 |
^ self loadAndResendMessage |
|
607 |
! |
|
608 |
||
609 |
variableDoubleSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
610 |
"create a new class as a subclass of an existing class (the receiver) |
|
611 |
in which the subclass has indexable double-sized nonpointer variables" |
|
612 |
||
613 |
^ self loadAndResendMessage |
|
614 |
! |
|
615 |
||
616 |
variableDoubleSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
617 |
"create a new class as a subclass of an existing class (the receiver) |
|
618 |
in which the subclass has indexable double-sized nonpointer variables" |
|
619 |
||
620 |
^ self loadAndResendMessage |
|
621 |
! |
|
622 |
||
623 |
variableFloatSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
624 |
"create a new class as a subclass of an existing class (the receiver) |
|
625 |
in which the subclass has indexable float-sized nonpointer variables" |
|
626 |
||
627 |
^ self loadAndResendMessage |
|
628 |
! |
|
629 |
||
630 |
variableFloatSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
631 |
"create a new class as a subclass of an existing class (the receiver) |
|
632 |
in which the subclass has indexable float-sized nonpointer variables" |
|
633 |
||
634 |
^ self loadAndResendMessage |
|
635 |
! |
|
636 |
||
637 |
variableLongLongSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
638 |
"create a new class as a subclass of an existing class (the receiver) |
|
639 |
in which the subclass has indexable unsigned long-long-sized nonpointer variables" |
|
640 |
||
641 |
^ self loadAndResendMessage |
|
642 |
! |
|
643 |
||
644 |
variableLongLongSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
645 |
"create a new class as a subclass of an existing class (the receiver) |
|
646 |
in which the subclass has indexable longlong-sized nonpointer variables" |
|
647 |
||
648 |
^ self loadAndResendMessage |
|
649 |
! |
|
650 |
||
651 |
variableLongSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
652 |
"create a new class as a subclass of an existing class (the receiver) |
|
653 |
in which the subclass has indexable long-sized nonpointer variables" |
|
654 |
||
655 |
^ self loadAndResendMessage |
|
656 |
! |
|
657 |
||
658 |
variableLongSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
659 |
"create a new class as a subclass of an existing class (the receiver) |
|
660 |
in which the subclass has indexable long-sized nonpointer variables" |
|
661 |
||
662 |
^ self loadAndResendMessage |
|
663 |
! |
|
664 |
||
665 |
variableSignedLongLongSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
666 |
"create a new class as a subclass of an existing class (the receiver) |
|
667 |
in which the subclass has indexable signed long-long-sized nonpointer variables" |
|
668 |
||
669 |
^ self loadAndResendMessage |
|
670 |
! |
|
671 |
||
672 |
variableSignedLongLongSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
673 |
"create a new class as a subclass of an existing class (the receiver) |
|
674 |
in which the subclass has indexable signed longlong-sized nonpointer variables" |
|
675 |
||
676 |
^ self loadAndResendMessage |
|
677 |
! |
|
678 |
||
679 |
variableSignedLongSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
680 |
"create a new class as a subclass of an existing class (the receiver) |
|
681 |
in which the subclass has indexable signed long-sized nonpointer variables" |
|
682 |
||
683 |
^ self loadAndResendMessage |
|
684 |
! |
|
685 |
||
686 |
variableSignedLongSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
687 |
"create a new class as a subclass of an existing class (the receiver) |
|
688 |
in which the subclass has indexable signed long-sized nonpointer variables" |
|
689 |
||
690 |
^ self loadAndResendMessage |
|
691 |
! |
|
692 |
||
693 |
variableSignedWordSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
694 |
"create a new class as a subclass of an existing class (the receiver) |
|
695 |
in which the subclass has indexable word-sized signed nonpointer variables" |
|
696 |
||
697 |
^ self loadAndResendMessage |
|
698 |
! |
|
699 |
||
700 |
variableSignedWordSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
701 |
"create a new class as a subclass of an existing class (the receiver) |
|
702 |
in which the subclass has indexable word-sized signed nonpointer variables" |
|
703 |
||
704 |
^ self loadAndResendMessage |
|
705 |
! |
|
706 |
||
707 |
variableSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
708 |
"create a new class as a subclass of an existing class (the receiver) |
|
709 |
in which the subclass has indexable pointer variables" |
|
710 |
||
711 |
^ self loadAndResendMessage |
|
712 |
! |
|
713 |
||
714 |
variableSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat classInstanceVariableNames:classInstanceVariableNames |
|
715 |
"create a new class as a subclass of an existing class (the receiver) |
|
716 |
in which the subclass has indexable pointer variables" |
|
717 |
||
718 |
^ self loadAndResendMessage |
|
719 |
! |
|
720 |
||
721 |
variableSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
722 |
"create a new class as a subclass of an existing class (the receiver) |
|
723 |
in which the subclass has indexable pointer variables" |
|
724 |
||
725 |
^ self loadAndResendMessage |
|
726 |
! |
|
727 |
||
728 |
variableWordSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
|
729 |
"create a new class as a subclass of an existing class (the receiver) |
|
730 |
in which the subclass has indexable word-sized nonpointer variables" |
|
731 |
||
732 |
^ self loadAndResendMessage |
|
733 |
! |
|
734 |
||
735 |
variableWordSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:aClass |
|
736 |
"create a new class as a subclass of an existing class (the receiver) |
|
737 |
in which the subclass has indexable word-sized nonpointer variables" |
|
738 |
||
739 |
^ self loadAndResendMessage |
|
1 | 740 |
! ! |
11 | 741 |
|
8316 | 742 |
!Autoload class methodsFor:'private'! |
743 |
||
744 |
loadAndResendMessage |
|
745 |
"common helper to autoload a class and define a subclass of it by sending |
|
746 |
the sender-message again. |
|
747 |
This is invoked by all #subClass... definition messages." |
|
748 |
||
749 |
|sel args newClass| |
|
750 |
||
751 |
sel := thisContext sender selector. |
|
752 |
args := thisContext sender args. |
|
753 |
||
754 |
"take care: subclassing Autoload must still be possible" |
|
755 |
(self == Autoload) ifTrue:[ |
|
756 |
^ self perform:sel inClass:Autoload class superclass withArguments:args |
|
757 |
]. |
|
758 |
||
759 |
newClass := self autoload. |
|
760 |
newClass notNil ifTrue:[ |
|
761 |
^ newClass perform:sel withArguments:args |
|
762 |
]. |
|
763 |
^ nil |
|
764 |
||
765 |
"Created: 8.2.1997 / 19:42:47 / cg" |
|
766 |
! ! |
|
767 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
768 |
!Autoload class methodsFor:'queries'! |
356 | 769 |
|
5902 | 770 |
accepts:aSignal |
771 |
"redefined to avoid recursive autoload" |
|
772 |
||
773 |
|newClass| |
|
774 |
||
775 |
self isBeingLoaded ifFalse:[ |
|
7178 | 776 |
newClass := self autoload. |
777 |
newClass notNil ifTrue:[ |
|
778 |
^ newClass accepts:aSignal |
|
779 |
]. |
|
5902 | 780 |
]. |
781 |
^ false |
|
782 |
! |
|
783 |
||
620 | 784 |
isBehavior |
785 |
"return true if the recevier is some kind of class. |
|
786 |
Autoloaded classes are definitely; therefore return true." |
|
164 | 787 |
|
620 | 788 |
^ true |
789 |
! |
|
356 | 790 |
|
5902 | 791 |
isBeingLoaded |
5903 | 792 |
^ (self ~~ Autoload) and:[(Smalltalk at:self name) isNil ] |
5902 | 793 |
|
794 |
"Modified: / 16.2.1998 / 11:57:35 / stefan" |
|
795 |
! |
|
796 |
||
729 | 797 |
isBuiltInClass |
1266 | 798 |
"return true if this class is known by the run-time-system. |
799 |
Returns false here." |
|
800 |
||
729 | 801 |
^ false |
802 |
||
803 |
"Created: 10.12.1995 / 00:28:22 / cg" |
|
1266 | 804 |
"Modified: 23.4.1996 / 15:55:36 / cg" |
729 | 805 |
! |
806 |
||
620 | 807 |
isLoaded |
3287 | 808 |
"return true, if the class has been loaded. |
809 |
Autoload itself is loaded, subclasses are not. |
|
810 |
This allows testing wether a class has already been loaded." |
|
620 | 811 |
|
812 |
^ (self == Autoload) |
|
3287 | 813 |
|
814 |
"Modified: / 16.2.1998 / 11:57:35 / stefan" |
|
620 | 815 |
! |
816 |
||
922 | 817 |
loadedClasses |
818 |
"return the set of classes that were autoloaded" |
|
819 |
||
8316 | 820 |
^ LoadedClasses |
922 | 821 |
! |
822 |
||
4401
d9667432d35b
privateClasses and allPrivateClasses
Claus Gittinger <cg@exept.de>
parents:
4301
diff
changeset
|
823 |
privateClassesOrAll:allOfThem |
4000 | 824 |
"an autoloaded class has none" |
825 |
||
826 |
^ #() |
|
827 |
! |
|
828 |
||
620 | 829 |
wasAutoloaded:aClass |
922 | 830 |
"return true, if aClass was autoloaded" |
831 |
||
8316 | 832 |
^ LoadedClasses includes:aClass |
11 | 833 |
! ! |
620 | 834 |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
835 |
!Autoload class methodsFor:'documentation'! |
661 | 836 |
|
837 |
version |
|
8431
3e06c959dcff
#autoload - raise error if fileIn fails.
Stefan Vogel <sv@exept.de>
parents:
8382
diff
changeset
|
838 |
^ '$Header: /cvs/stx/stx/libbasic/Autoload.st,v 1.125 2004-07-01 10:06:47 stefan Exp $' |
661 | 839 |
! ! |
6768 | 840 |
|
620 | 841 |
Autoload initialize! |