author | Claus Gittinger <cg@exept.de> |
Sun, 05 Jan 1997 00:40:36 +0100 | |
changeset 2061 | d6f224b06999 |
parent 2057 | 35003ed4b817 |
child 2062 | 762e951d42b8 |
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 |
|
39 |
subclasses of this class. Autoload catches all messages and |
|
40 |
files-In the corresponding code when first used. Then the cought message |
|
41 |
is resent to the (now existing) class. |
|
42 |
||
43 |
Late addition: above comment is no longer true - I have made now almost |
|
44 |
all Demos & Goodies be autoloaded ... even for big systems. |
|
45 |
||
1278 | 46 |
[class variables:] |
92 | 47 |
|
1278 | 48 |
LazyLoading <Boolean> if true, the loaded classes |
49 |
methods will NOT be compiled at |
|
50 |
autoload time, but instead when |
|
51 |
first called. This allows for a |
|
52 |
faster load. However, expect short |
|
53 |
pauses later when the methods are |
|
54 |
first executed. |
|
126 | 55 |
|
1278 | 56 |
AutoloadFailedSignal <Signal> signal raised if an autoloaded |
57 |
classes source is not available. |
|
922 | 58 |
|
1278 | 59 |
LoadedClasses <Collection> set of classes that heve been |
60 |
autoloaded (for later unload) |
|
1292 | 61 |
|
62 |
[author:] |
|
63 |
Claus Gittinger |
|
68 | 64 |
" |
65 |
! ! |
|
66 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
67 |
!Autoload class methodsFor:'initialization'! |
126 | 68 |
|
69 |
initialize |
|
70 |
AutoloadFailedSignal isNil ifTrue:[ |
|
624
f09ad5cf21d4
cannot access Objects classVars directly in nil-subclass
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
71 |
AutoloadFailedSignal := Object errorSignal newSignalMayProceed:true. |
154 | 72 |
AutoloadFailedSignal nameClass:self message:#autoloadFailedSignal. |
73 |
AutoloadFailedSignal notifierString:'autoload failed '. |
|
197 | 74 |
|
75 |
self setSuperclass:nil. |
|
76 |
ObjectMemory flushCaches. |
|
126 | 77 |
] |
78 |
! ! |
|
79 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
80 |
!Autoload class methodsFor:'Signal constants'! |
126 | 81 |
|
82 |
autoloadFailedSignal |
|
83 |
"return the signal raised when an autoload fails" |
|
84 |
||
85 |
^ AutoloadFailedSignal |
|
86 |
! ! |
|
87 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
88 |
!Autoload class methodsFor:'adding/removing autoloaded classes'! |
359 | 89 |
|
216 | 90 |
addClass:aClassName |
1277 | 91 |
"given a name, install a corresponding autoload class stub for it" |
92 |
||
216 | 93 |
self addClass:aClassName inCategory:'autoloaded-Classes' |
94 |
||
95 |
" |
|
96 |
Autoload addClass:'Clock' |
|
97 |
" |
|
1277 | 98 |
|
99 |
"Modified: 24.4.1996 / 19:54:16 / cg" |
|
216 | 100 |
! |
101 |
||
102 |
addClass:aClassName inCategory:aCategory |
|
1277 | 103 |
"given a name, install a corresponding autoload class stub for it" |
104 |
||
216 | 105 |
|nameSymbol| |
106 |
||
107 |
nameSymbol := aClassName asSymbol. |
|
108 |
(Smalltalk at:nameSymbol) isNil ifTrue:[ |
|
1277 | 109 |
Autoload subclass:nameSymbol |
110 |
instanceVariableNames:'' |
|
111 |
classVariableNames:'' |
|
112 |
poolDictionaries:'' |
|
113 |
category:aCategory. |
|
216 | 114 |
] |
115 |
" |
|
116 |
Autoload addClass:'Clock' inCategory:'autoloaded-Demos' |
|
117 |
" |
|
1277 | 118 |
|
119 |
"Modified: 24.4.1996 / 19:54:20 / cg" |
|
620 | 120 |
! |
121 |
||
122 |
removeClass:aClass |
|
1277 | 123 |
"remove a class from the list of loaded classes" |
124 |
||
620 | 125 |
LoadedClasses remove:aClass ifAbsent:[] |
1277 | 126 |
|
127 |
"Modified: 24.4.1996 / 19:54:35 / cg" |
|
620 | 128 |
! ! |
129 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
130 |
!Autoload class methodsFor:'fileout'! |
620 | 131 |
|
132 |
fileOutDefinitionOn:aStream |
|
133 |
"print an expression to define myself on aStream. |
|
134 |
Since autoloaded classes dont know their real definition, simply |
|
135 |
output some comment string making things clear in the browser." |
|
136 |
||
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
137 |
|myName fileName nm mgr classFileName packageDir| |
620 | 138 |
|
139 |
(self == Autoload) ifTrue:[^ super fileOutDefinitionOn:aStream]. |
|
140 |
||
141 |
myName := self name. |
|
1952
18cfc11b49fa
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
1862
diff
changeset
|
142 |
aStream nextPutAll:'"' ; nextPutLine:'Notice from Autoload:'; cr; |
18cfc11b49fa
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
1862
diff
changeset
|
143 |
spaces:4; nextPutLine:myName , ' is not yet loaded.'; cr. |
620 | 144 |
aStream nextPutAll:'to load, execute: '. |
1952
18cfc11b49fa
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
1862
diff
changeset
|
145 |
aStream cr; cr; spaces:4; nextPutLine:myName , ' autoload'. |
2019 | 146 |
aStream cr; nextPutLine:'or use the browsers load-function (in the class menu).'. |
620 | 147 |
" |
148 |
the following is simply informative ... |
|
149 |
actually, its a hack & kludge - there ought to be a method for this |
|
150 |
in Smalltalk |
|
151 |
(knowing the details of loading here is no good coding style) |
|
152 |
" |
|
153 |
fileName := Smalltalk fileNameForClass:myName. |
|
154 |
(ObjectFileLoader notNil and:[Smalltalk loadBinaries]) ifTrue:[ |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
155 |
(nm := Smalltalk libraryFileNameOfClass:myName) notNil ifTrue:[ |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
156 |
nm := nm , ' (a classLibrary, possibly including more classes)' |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
157 |
] ifFalse:[ |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
158 |
nm := Smalltalk getBinaryFileName:(fileName , '.so'). |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
159 |
nm isNil ifTrue:[ |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
160 |
nm := Smalltalk getBinaryFileName:(fileName , '.o') |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
161 |
]. |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
162 |
nm notNil ifTrue:[ |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
163 |
nm := nm , ' (a classBinary)' |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
164 |
] |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
165 |
]. |
620 | 166 |
]. |
167 |
nm isNil ifTrue:[ |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
168 |
nm := Smalltalk getFileInFileName:(fileName , '.st'). |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
169 |
nm isNil ifTrue:[ |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
170 |
nm := Smalltalk getSourceFileName:(fileName , '.st'). |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
171 |
]. |
620 | 172 |
]. |
173 |
nm notNil ifTrue:[ |
|
1952
18cfc11b49fa
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
1862
diff
changeset
|
174 |
aStream cr; nextPutLine:'When accessed, ' , myName , ' will automatically be loaded'. |
18cfc11b49fa
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
1862
diff
changeset
|
175 |
aStream nextPutLine:'from: '; spaces:4; nextPutAll:nm. |
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
176 |
nm asFilename isSymbolicLink ifTrue:[ |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
177 |
aStream cr; cr. |
1952
18cfc11b49fa
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
1862
diff
changeset
|
178 |
aStream nextPutLine:'which is a link to: '; spaces:4; |
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
179 |
nextPutAll:(nm asFilename linkInfo path). |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
180 |
] |
620 | 181 |
] ifFalse:[ |
1952
18cfc11b49fa
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
1862
diff
changeset
|
182 |
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
|
183 |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
184 |
(mgr := Smalltalk at:#SourceCodeManager) notNil ifTrue:[ |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
185 |
classFileName := Smalltalk fileNameForClass:myName. |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
186 |
packageDir := Smalltalk sourceDirectoryNameOfClass:myName. |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
187 |
]. |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
188 |
(classFileName notNil and:[packageDir notNil]) ifTrue:[ |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
189 |
aStream nextPutAll:'When accessed, I''ll ask the sourceCodeManager to load the code |
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
190 |
from "' , classFileName , '.st" in the "' , packageDir , '" package.'. |
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
191 |
] ifFalse:[ |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
192 |
aStream nextPutAll:'When accessed, an error will be reported.'. |
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
193 |
] |
620 | 194 |
]. |
195 |
aStream cr; nextPutAll:'"'. |
|
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
196 |
|
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
197 |
"Created: 8.12.1995 / 00:31:53 / cg" |
2019 | 198 |
"Modified: 30.12.1996 / 17:25:15 / cg" |
620 | 199 |
! ! |
200 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
201 |
!Autoload class methodsFor:'lazy compilation'! |
620 | 202 |
|
203 |
compileLazy |
|
204 |
"return the lazy loading flag - if on, fileIn is much faster, |
|
205 |
but pauses are to be expected later, since methods are compiled |
|
206 |
when first executed." |
|
207 |
||
208 |
^ LazyLoading |
|
209 |
! |
|
210 |
||
211 |
compileLazy:aBoolean |
|
212 |
"turn on/off lazy loading - if on, fileIn is much faster, |
|
213 |
but pauses are to be expected later, since methods are compiled |
|
214 |
when first executed. |
|
215 |
If you like it, add a line to your startup file." |
|
216 |
||
217 |
LazyLoading := aBoolean |
|
216 | 218 |
! ! |
219 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
220 |
!Autoload class methodsFor:'loading'! |
1 | 221 |
|
222 |
autoload |
|
223 |
"use this to force loading |
|
224 |
- it is defined a noop in all non-autoloading clases" |
|
225 |
||
2061 | 226 |
|mySelf myName newClass oldMeta project prevMode package| |
1 | 227 |
|
228 |
mySelf := self. |
|
164 | 229 |
myName := self name asSymbol. |
1 | 230 |
|
231 |
"remove myself - to avoid recompilation" |
|
164 | 232 |
Smalltalk at:myName put:nil. |
1 | 233 |
|
2 | 234 |
"load it" |
1566 | 235 |
(Object infoPrinting and:[Smalltalk silentLoading ~~ true]) ifTrue:[ |
1564
f3f9736bd0fa
suppress load messages, if infoPrinting is turned off
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
236 |
Transcript showCR:('autoloading ', myName , ' ...'); endEntry. |
f3f9736bd0fa
suppress load messages, if infoPrinting is turned off
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
237 |
]. |
1 | 238 |
|
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
239 |
[ |
1694
29791fde790e
autoload classes keep source reference
Claus Gittinger <cg@exept.de>
parents:
1674
diff
changeset
|
240 |
prevMode := ClassCategoryReader sourceMode. |
1720 | 241 |
"/ |
242 |
"/ no- do not do this; it may lead to trouble ... |
|
243 |
"/ ClassCategoryReader sourceMode:#reference. |
|
1694
29791fde790e
autoload classes keep source reference
Claus Gittinger <cg@exept.de>
parents:
1674
diff
changeset
|
244 |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
245 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
246 |
"/ in order to not get a package of private (or whatever), |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
247 |
"/ temporarily set the currentProject to nil. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
248 |
"/ we will later set the classes package to something useful |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
249 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
250 |
Project notNil ifTrue:[ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
251 |
project := Project current. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
252 |
Project setProject:nil. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
253 |
]. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
254 |
Smalltalk fileInClass:myName initialize:false lazy:LazyLoading. |
1694
29791fde790e
autoload classes keep source reference
Claus Gittinger <cg@exept.de>
parents:
1674
diff
changeset
|
255 |
ClassCategoryReader sourceMode:prevMode. |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
256 |
project notNil ifTrue:[ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
257 |
Project setProject:project. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
258 |
]. |
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
259 |
] valueOnUnwindDo:[ |
1694
29791fde790e
autoload classes keep source reference
Claus Gittinger <cg@exept.de>
parents:
1674
diff
changeset
|
260 |
ClassCategoryReader sourceMode:prevMode. |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
261 |
project notNil ifTrue:[ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
262 |
Project setProject:project. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
263 |
]. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
264 |
Smalltalk at:myName put:mySelf. |
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
265 |
]. |
1 | 266 |
|
267 |
"did it work ?" |
|
164 | 268 |
newClass := Smalltalk at:myName. |
269 |
Smalltalk at:myName put:mySelf. "will be undone by become:" |
|
1 | 270 |
|
138 | 271 |
"no - report the error" |
1 | 272 |
newClass isNil ifTrue:[ |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
273 |
" |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
274 |
this signal is raised, if an autoloaded class |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
275 |
cannot be loaded. Usually, this happends when |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
276 |
some sourcefile is missing, not readable or if |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
277 |
an entry is missing in the abbreviation file. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
278 |
Check for a readable file named <myName>.st |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
279 |
in the 'source' directory and (if its a long fileName) |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
280 |
for a corresponding entry in the abbreviation file |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
281 |
'include/abbrev.stc'. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
282 |
Finally, your searchpath could be set wrong - |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
283 |
both 'source' and 'include' directories must be found in |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
284 |
one of the directories named in systemPath. |
154 | 285 |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
286 |
In the debugger, press 'abort' to continue execution. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
287 |
" |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
288 |
AutoloadFailedSignal |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
289 |
raiseRequestWith:self |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
290 |
errorString:('autoload of ' , myName , ' failed'). |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
291 |
^ nil |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
292 |
]. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
293 |
|
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
294 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
295 |
"/ 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
|
296 |
"/ 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
|
297 |
"/ info encoded. (binary classes have it) |
2057
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
298 |
"/ 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
|
299 |
"/ |
2057
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
300 |
newClass setPackageFromRevision. |
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
301 |
(newClass package isNil |
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
302 |
or:[newClass package = 'no package']) ifTrue:[ |
2061 | 303 |
package := self package. |
2057
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
304 |
(package notNil and:[package ~= 'no package']) |
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
305 |
ifTrue:[ |
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
306 |
newClass setPackage:package. |
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
307 |
]. |
1 | 308 |
]. |
309 |
||
216 | 310 |
LoadedClasses isNil ifTrue:[ |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
311 |
LoadedClasses := IdentitySet new. |
216 | 312 |
]. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
313 |
LoadedClasses add:newClass. |
216 | 314 |
|
154 | 315 |
"wow - it worked. now the big trick ..." |
1 | 316 |
|
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
317 |
"/ 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
|
318 |
oldMeta := self class. |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
319 |
|
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
320 |
self setName:(self name , ' (auto)'). |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
321 |
self class setName:(self class name , ' (auto)'). |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
322 |
|
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
323 |
self becomeSameAs:newClass. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
324 |
oldMeta becomeSameAs:newClass class. |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
325 |
|
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
326 |
ObjectMemory flushCaches. |
216 | 327 |
LoadedClasses rehash. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
328 |
|
1148 | 329 |
(newClass class implements:#initialize) ifTrue:[ |
330 |
newClass initialize. |
|
331 |
]. |
|
886 | 332 |
newClass postAutoload. |
333 |
^ newClass |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
334 |
|
2057
35003ed4b817
care for the package ID when autoloading
Claus Gittinger <cg@exept.de>
parents:
2019
diff
changeset
|
335 |
"Modified: 4.1.1997 / 19:56:44 / cg" |
1 | 336 |
! ! |
337 |
||
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
338 |
!Autoload class methodsFor:'message catching'! |
1 | 339 |
|
620 | 340 |
basicNew |
1277 | 341 |
"catch basicNew - load the class and send it to the real one" |
620 | 342 |
|
343 |
^ self doesNotUnderstand:(Message selector:#basicNew) |
|
1277 | 344 |
|
345 |
"Modified: 24.4.1996 / 19:53:10 / cg" |
|
620 | 346 |
! |
347 |
||
348 |
basicNew:arg |
|
1277 | 349 |
"catch basicNew: - load the class and send it to the real one" |
620 | 350 |
|
351 |
^ self doesNotUnderstand:(Message selector:#basicNew: with:arg) |
|
1277 | 352 |
|
353 |
"Modified: 24.4.1996 / 19:53:16 / cg" |
|
620 | 354 |
! |
355 |
||
356 |
comment |
|
357 |
"return the classes comment. |
|
358 |
Autoloaded classes have no comment; but I myself have one" |
|
359 |
||
360 |
(self == Autoload) ifTrue:[^ super comment]. |
|
361 |
^ 'not yet loaded' |
|
362 |
! |
|
363 |
||
1 | 364 |
doesNotUnderstand:aMessage |
1277 | 365 |
"cought a message; load the class and retry the message" |
1 | 366 |
|
367 |
|newClass| |
|
368 |
||
164 | 369 |
self ~~ Autoload ifTrue:[ |
1277 | 370 |
newClass := self autoload. |
371 |
newClass notNil ifTrue:[ |
|
372 |
^ newClass perform:(aMessage selector) |
|
373 |
withArguments:(aMessage arguments) |
|
374 |
] |
|
1 | 375 |
]. |
789
155eca125ef0
return value from doesNotUnderstand (so handler can return a value)
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
376 |
^ super doesNotUnderstand:aMessage |
1277 | 377 |
|
378 |
"Modified: 24.4.1996 / 19:53:27 / cg" |
|
1 | 379 |
! |
380 |
||
381 |
new |
|
1277 | 382 |
"catch new - load the class and send it to the real one" |
1 | 383 |
|
384 |
^ self doesNotUnderstand:(Message selector:#new) |
|
1277 | 385 |
|
386 |
"Modified: 24.4.1996 / 19:53:30 / cg" |
|
1 | 387 |
! |
388 |
||
389 |
new:arg |
|
1277 | 390 |
"catch new: - load the class and send it to the real one" |
1 | 391 |
|
392 |
^ self doesNotUnderstand:(Message selector:#new: with:arg) |
|
1277 | 393 |
|
394 |
"Modified: 24.4.1996 / 19:53:32 / cg" |
|
1 | 395 |
! |
396 |
||
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
397 |
readFrom:aStream |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
398 |
"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
|
399 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
400 |
^ self doesNotUnderstand:(Message selector:#readFrom: with:aStream) |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
401 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
402 |
"Created: 22.5.1996 / 23:44:23 / stefan" |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
403 |
! |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
404 |
|
1437 | 405 |
readFrom:aStream onError:exceptionBlock |
406 |
"catch - load the class and send it to the real one" |
|
407 |
||
408 |
^ self doesNotUnderstand:(Message selector:#readFrom:onError: with:aStream with:exceptionBlock) |
|
409 |
||
410 |
"Created: 22.5.1996 / 23:03:39 / stefan" |
|
411 |
! |
|
412 |
||
1438
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
413 |
readFromString:aString |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
414 |
"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
|
415 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
416 |
^ self doesNotUnderstand:(Message selector:#readFromString: with:aString) |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
417 |
|
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
418 |
"Created: 22.5.1996 / 23:46:15 / stefan" |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
419 |
! |
76fdecf85f9e
Catch readFrom: and readFromString: too.
Stefan Vogel <sv@exept.de>
parents:
1437
diff
changeset
|
420 |
|
1437 | 421 |
readFromString:aString onError:exceptionBlock |
422 |
"catch - load the class and send it to the real one" |
|
423 |
||
424 |
^ self doesNotUnderstand:(Message selector:#readFromString:onError: with:aString with:exceptionBlock) |
|
425 |
||
426 |
"Created: 22.5.1996 / 23:04:49 / stefan" |
|
427 |
! |
|
428 |
||
1 | 429 |
subclass:a1 instanceVariableNames:a2 classVariableNames:a3 poolDictionaries:a4 category:a5 |
2 | 430 |
"catch subclass creation - this forces missing superclasses to be |
431 |
loaded first" |
|
432 |
||
68 | 433 |
|newClass sel args| |
1 | 434 |
|
2 | 435 |
"take care: subclassing Autoload must still be possible" |
1 | 436 |
(self == Autoload) ifTrue:[ |
154 | 437 |
^ super |
438 |
subclass:a1 |
|
439 |
instanceVariableNames:a2 |
|
440 |
classVariableNames:a3 |
|
441 |
poolDictionaries:a4 |
|
442 |
category:a5 |
|
1 | 443 |
]. |
444 |
newClass := self autoload. |
|
68 | 445 |
sel := thisContext selector. |
446 |
args := thisContext args. |
|
1 | 447 |
newClass notNil ifTrue:[ |
154 | 448 |
^ newClass perform:sel withArguments:args |
1 | 449 |
]. |
450 |
^ nil |
|
451 |
! ! |
|
11 | 452 |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
453 |
!Autoload class methodsFor:'queries'! |
356 | 454 |
|
620 | 455 |
isBehavior |
456 |
"return true if the recevier is some kind of class. |
|
457 |
Autoloaded classes are definitely; therefore return true." |
|
164 | 458 |
|
620 | 459 |
^ true |
460 |
! |
|
356 | 461 |
|
729 | 462 |
isBuiltInClass |
1266 | 463 |
"return true if this class is known by the run-time-system. |
464 |
Returns false here." |
|
465 |
||
729 | 466 |
^ false |
467 |
||
468 |
"Created: 10.12.1995 / 00:28:22 / cg" |
|
1266 | 469 |
"Modified: 23.4.1996 / 15:55:36 / cg" |
729 | 470 |
! |
471 |
||
620 | 472 |
isLoaded |
473 |
"return true, if the class has been loaded; redefined in Autoload; |
|
474 |
see comment there. this allows testing for a class been already loaded." |
|
475 |
||
476 |
^ (self == Autoload) |
|
477 |
! |
|
478 |
||
922 | 479 |
loadedClasses |
480 |
"return the set of classes that were autoloaded" |
|
481 |
||
482 |
^ LoadedClasses |
|
483 |
! |
|
484 |
||
620 | 485 |
wasAutoloaded:aClass |
922 | 486 |
"return true, if aClass was autoloaded" |
487 |
||
620 | 488 |
^ LoadedClasses notNil and:[LoadedClasses includes:aClass] |
11 | 489 |
! ! |
620 | 490 |
|
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1720
diff
changeset
|
491 |
!Autoload class methodsFor:'documentation'! |
661 | 492 |
|
493 |
version |
|
2061 | 494 |
^ '$Header: /cvs/stx/stx/libbasic/Autoload.st,v 1.60 1997-01-04 23:40:36 cg Exp $' |
661 | 495 |
! ! |
620 | 496 |
Autoload initialize! |