author | Claus Gittinger <cg@exept.de> |
Wed, 07 Feb 1996 15:11:43 +0100 | |
changeset 939 | ffee570b0f09 |
parent 938 | a23bc7f62ed1 |
child 1148 | 9f69b4df970b |
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 |
||
68 | 20 |
!Autoload class methodsFor:'documentation'! |
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 |
||
46 |
class variables: |
|
92 | 47 |
|
154 | 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 |
|
154 | 56 |
AutoloadFailedSignal <Signal> signal raised if an autoloaded |
57 |
classes source is not available. |
|
922 | 58 |
|
59 |
LoadedClasses <Collection> set of classes that heve been |
|
60 |
autoloaded (for later unload) |
|
68 | 61 |
" |
62 |
! ! |
|
63 |
||
126 | 64 |
!Autoload class methodsFor:'initialization'! |
65 |
||
66 |
initialize |
|
67 |
AutoloadFailedSignal isNil ifTrue:[ |
|
624
f09ad5cf21d4
cannot access Objects classVars directly in nil-subclass
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
68 |
AutoloadFailedSignal := Object errorSignal newSignalMayProceed:true. |
154 | 69 |
AutoloadFailedSignal nameClass:self message:#autoloadFailedSignal. |
70 |
AutoloadFailedSignal notifierString:'autoload failed '. |
|
197 | 71 |
|
72 |
self setSuperclass:nil. |
|
73 |
ObjectMemory flushCaches. |
|
126 | 74 |
] |
75 |
! ! |
|
76 |
||
345 | 77 |
!Autoload class methodsFor:'Signal constants'! |
126 | 78 |
|
79 |
autoloadFailedSignal |
|
80 |
"return the signal raised when an autoload fails" |
|
81 |
||
82 |
^ AutoloadFailedSignal |
|
83 |
! ! |
|
84 |
||
359 | 85 |
!Autoload class methodsFor:'adding/removing autoloaded classes'! |
86 |
||
216 | 87 |
addClass:aClassName |
88 |
self addClass:aClassName inCategory:'autoloaded-Classes' |
|
89 |
||
90 |
" |
|
91 |
Autoload addClass:'Clock' |
|
92 |
" |
|
93 |
! |
|
94 |
||
95 |
addClass:aClassName inCategory:aCategory |
|
96 |
|nameSymbol| |
|
97 |
||
98 |
nameSymbol := aClassName asSymbol. |
|
99 |
(Smalltalk at:nameSymbol) isNil ifTrue:[ |
|
100 |
Autoload subclass:nameSymbol |
|
101 |
instanceVariableNames:'' |
|
102 |
classVariableNames:'' |
|
103 |
poolDictionaries:'' |
|
104 |
category:aCategory. |
|
105 |
] |
|
106 |
" |
|
107 |
Autoload addClass:'Clock' inCategory:'autoloaded-Demos' |
|
108 |
" |
|
620 | 109 |
! |
110 |
||
111 |
removeClass:aClass |
|
112 |
LoadedClasses remove:aClass ifAbsent:[] |
|
113 |
! ! |
|
114 |
||
115 |
!Autoload class methodsFor:'fileout'! |
|
116 |
||
117 |
fileOutDefinitionOn:aStream |
|
118 |
"print an expression to define myself on aStream. |
|
119 |
Since autoloaded classes dont know their real definition, simply |
|
120 |
output some comment string making things clear in the browser." |
|
121 |
||
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
122 |
|myName fileName nm mgr classFileName packageDir| |
620 | 123 |
|
124 |
(self == Autoload) ifTrue:[^ super fileOutDefinitionOn:aStream]. |
|
125 |
||
126 |
myName := self name. |
|
127 |
aStream nextPutAll:'"' ; nextPutAll:'Notice from Autoload:'; cr; cr; |
|
739
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
128 |
spaces:4; nextPutAll:myName , ' is not yet loaded.'; cr; cr. |
620 | 129 |
aStream nextPutAll:'to load, execute: '. |
130 |
aStream cr; cr; spaces:4; nextPutAll:myName , ' autoload'; cr. |
|
131 |
||
132 |
" |
|
133 |
the following is simply informative ... |
|
134 |
actually, its a hack & kludge - there ought to be a method for this |
|
135 |
in Smalltalk |
|
136 |
(knowing the details of loading here is no good coding style) |
|
137 |
" |
|
138 |
fileName := Smalltalk fileNameForClass:myName. |
|
139 |
(ObjectFileLoader notNil and:[Smalltalk loadBinaries]) ifTrue:[ |
|
739
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
140 |
(nm := Smalltalk libraryFileNameOfClass:myName) notNil ifTrue:[ |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
141 |
nm := nm , ' (a classLibrary, possibly including more classes)' |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
142 |
] ifFalse:[ |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
143 |
nm := Smalltalk getBinaryFileName:(fileName , '.so'). |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
144 |
nm isNil ifTrue:[ |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
145 |
nm := Smalltalk getBinaryFileName:(fileName , '.o') |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
146 |
]. |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
147 |
nm notNil ifTrue:[ |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
148 |
nm := nm , ' (a classBinary)' |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
149 |
] |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
150 |
]. |
620 | 151 |
]. |
152 |
nm isNil ifTrue:[ |
|
739
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
153 |
nm := Smalltalk getFileInFileName:(fileName , '.st'). |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
154 |
nm isNil ifTrue:[ |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
155 |
nm := Smalltalk getSourceFileName:(fileName , '.st'). |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
156 |
]. |
620 | 157 |
]. |
158 |
nm notNil ifTrue:[ |
|
739
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
159 |
aStream cr; nextPutAll:'When accessed, ' , myName , ' will automatically be loaded'; cr. |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
160 |
aStream nextPutAll:'from: '; cr; spaces:4; nextPutAll:nm. |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
161 |
nm asFilename isSymbolicLink ifTrue:[ |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
162 |
aStream cr; cr. |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
163 |
aStream nextPutAll:'which is a link to: '; cr; spaces:4; |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
164 |
nextPutAll:(nm asFilename linkInfo at:#path). |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
165 |
] |
620 | 166 |
] ifFalse:[ |
739
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
167 |
aStream cr; nextPutAll:'There is currently no file to load ' , myName , ' from.'; cr; cr. |
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
168 |
|
739
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
169 |
(mgr := Smalltalk at:#SourceCodeManager) notNil ifTrue:[ |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
170 |
classFileName := Smalltalk fileNameForClass:myName. |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
171 |
packageDir := Smalltalk sourceDirectoryNameOfClass:myName. |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
172 |
]. |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
173 |
(classFileName notNil and:[packageDir notNil]) ifTrue:[ |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
174 |
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
|
175 |
from "' , classFileName , '.st" in the "' , packageDir , '" package.'. |
739
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
176 |
] ifFalse:[ |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
177 |
aStream nextPutAll:'When accessed, an error will be reported.'. |
63566c9b691a
oops - after autoloading, the metaClasses soleInstance still pointed to the
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
178 |
] |
620 | 179 |
]. |
180 |
aStream cr; nextPutAll:'"'. |
|
709
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
181 |
|
c31cbd5e5323
more info for autoloaded classes (for browsers definition text)
Claus Gittinger <cg@exept.de>
parents:
661
diff
changeset
|
182 |
"Created: 8.12.1995 / 00:31:53 / cg" |
727
475d224376d3
careful with empty source info in descriptive message
Claus Gittinger <cg@exept.de>
parents:
709
diff
changeset
|
183 |
"Modified: 9.12.1995 / 22:31:02 / cg" |
620 | 184 |
! ! |
185 |
||
186 |
!Autoload class methodsFor:'lazy compilation'! |
|
187 |
||
188 |
compileLazy |
|
189 |
"return the lazy loading flag - if on, fileIn is much faster, |
|
190 |
but pauses are to be expected later, since methods are compiled |
|
191 |
when first executed." |
|
192 |
||
193 |
^ LazyLoading |
|
194 |
! |
|
195 |
||
196 |
compileLazy:aBoolean |
|
197 |
"turn on/off lazy loading - if on, fileIn is much faster, |
|
198 |
but pauses are to be expected later, since methods are compiled |
|
199 |
when first executed. |
|
200 |
If you like it, add a line to your startup file." |
|
201 |
||
202 |
LazyLoading := aBoolean |
|
216 | 203 |
! ! |
204 |
||
1 | 205 |
!Autoload class methodsFor:'loading'! |
206 |
||
207 |
autoload |
|
208 |
"use this to force loading |
|
209 |
- it is defined a noop in all non-autoloading clases" |
|
210 |
||
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
211 |
|mySelf myName newClass oldMeta project| |
1 | 212 |
|
213 |
mySelf := self. |
|
164 | 214 |
myName := self name asSymbol. |
1 | 215 |
|
216 |
"remove myself - to avoid recompilation" |
|
164 | 217 |
Smalltalk at:myName put:nil. |
1 | 218 |
|
2 | 219 |
"load it" |
68 | 220 |
Transcript showCr:('autoloading ', myName , ' ...'); endEntry. |
1 | 221 |
|
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
222 |
[ |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
223 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
224 |
"/ 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
|
225 |
"/ temporarily set the currentProject to nil. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
226 |
"/ 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
|
227 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
228 |
Project notNil ifTrue:[ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
229 |
project := Project current. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
230 |
Project setProject:nil. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
231 |
]. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
232 |
Smalltalk fileInClass:myName initialize:false lazy:LazyLoading. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
233 |
project notNil ifTrue:[ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
234 |
Project setProject:project. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
235 |
]. |
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
236 |
] valueOnUnwindDo:[ |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
237 |
project notNil ifTrue:[ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
238 |
Project setProject:project. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
239 |
]. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
240 |
Smalltalk at:myName put:mySelf. |
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
241 |
]. |
1 | 242 |
|
243 |
"did it work ?" |
|
164 | 244 |
newClass := Smalltalk at:myName. |
245 |
Smalltalk at:myName put:mySelf. "will be undone by become:" |
|
1 | 246 |
|
138 | 247 |
"no - report the error" |
1 | 248 |
newClass isNil ifTrue:[ |
938
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 |
this signal is raised, if an autoloaded class |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
251 |
cannot be loaded. Usually, this happends when |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
252 |
some sourcefile is missing, not readable or if |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
253 |
an entry is missing in the abbreviation file. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
254 |
Check for a readable file named <myName>.st |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
255 |
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
|
256 |
for a corresponding entry in the abbreviation file |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
257 |
'include/abbrev.stc'. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
258 |
Finally, your searchpath could be set wrong - |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
259 |
both 'source' and 'include' directories must be found in |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
260 |
one of the directories named in systemPath. |
154 | 261 |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
262 |
In the debugger, press 'abort' to continue execution. |
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 |
AutoloadFailedSignal |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
265 |
raiseRequestWith:self |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
266 |
errorString:('autoload of ' , myName , ' failed'). |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
267 |
^ nil |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
268 |
]. |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
269 |
|
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
270 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
271 |
"/ 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
|
272 |
"/ 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
|
273 |
"/ info encoded. (binary classes have it) |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
274 |
"/ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
275 |
newClass package isNil ifTrue:[ |
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
276 |
newClass setPackageFromRevision. |
1 | 277 |
]. |
278 |
||
216 | 279 |
LoadedClasses isNil ifTrue:[ |
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
280 |
LoadedClasses := IdentitySet new. |
216 | 281 |
]. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
282 |
LoadedClasses add:newClass. |
216 | 283 |
|
154 | 284 |
"wow - it worked. now the big trick ..." |
1 | 285 |
|
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
286 |
"/ 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
|
287 |
oldMeta := self class. |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
288 |
|
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
289 |
self setName:(self name , ' (auto)'). |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
290 |
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
|
291 |
|
860
b3ffea40999a
use new becomeSameAs: to migrate to new class.
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
292 |
self becomeSameAs:newClass. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
293 |
oldMeta becomeSameAs:newClass class. |
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
294 |
|
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
295 |
ObjectMemory flushCaches. |
216 | 296 |
LoadedClasses rehash. |
921
4db7603f9506
rename myself (just in case) & flush caches after loading
Claus Gittinger <cg@exept.de>
parents:
886
diff
changeset
|
297 |
|
886 | 298 |
newClass initialize. |
299 |
newClass postAutoload. |
|
300 |
^ newClass |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
301 |
|
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
302 |
"Modified: 7.2.1996 / 14:38:57 / cg" |
1 | 303 |
! ! |
304 |
||
305 |
!Autoload class methodsFor:'message catching'! |
|
306 |
||
620 | 307 |
basicNew |
308 |
"catch basicNew" |
|
309 |
||
310 |
^ self doesNotUnderstand:(Message selector:#basicNew) |
|
311 |
! |
|
312 |
||
313 |
basicNew:arg |
|
314 |
"catch basicNew:" |
|
315 |
||
316 |
^ self doesNotUnderstand:(Message selector:#basicNew: with:arg) |
|
317 |
! |
|
318 |
||
319 |
comment |
|
320 |
"return the classes comment. |
|
321 |
Autoloaded classes have no comment; but I myself have one" |
|
322 |
||
323 |
(self == Autoload) ifTrue:[^ super comment]. |
|
324 |
^ 'not yet loaded' |
|
325 |
! |
|
326 |
||
1 | 327 |
doesNotUnderstand:aMessage |
328 |
"cought a message; load class and retry" |
|
329 |
||
330 |
|newClass| |
|
331 |
||
164 | 332 |
self ~~ Autoload ifTrue:[ |
333 |
newClass := self autoload. |
|
334 |
newClass notNil ifTrue:[ |
|
335 |
^ newClass perform:(aMessage selector) |
|
336 |
withArguments:(aMessage arguments) |
|
337 |
] |
|
1 | 338 |
]. |
789
155eca125ef0
return value from doesNotUnderstand (so handler can return a value)
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
339 |
^ super doesNotUnderstand:aMessage |
1 | 340 |
! |
341 |
||
342 |
new |
|
343 |
"catch new" |
|
344 |
||
345 |
^ self doesNotUnderstand:(Message selector:#new) |
|
346 |
! |
|
347 |
||
348 |
new:arg |
|
349 |
"catch new:" |
|
350 |
||
351 |
^ self doesNotUnderstand:(Message selector:#new: with:arg) |
|
352 |
! |
|
353 |
||
354 |
subclass:a1 instanceVariableNames:a2 classVariableNames:a3 poolDictionaries:a4 category:a5 |
|
2 | 355 |
"catch subclass creation - this forces missing superclasses to be |
356 |
loaded first" |
|
357 |
||
68 | 358 |
|newClass sel args| |
1 | 359 |
|
2 | 360 |
"take care: subclassing Autoload must still be possible" |
1 | 361 |
(self == Autoload) ifTrue:[ |
154 | 362 |
^ super |
363 |
subclass:a1 |
|
364 |
instanceVariableNames:a2 |
|
365 |
classVariableNames:a3 |
|
366 |
poolDictionaries:a4 |
|
367 |
category:a5 |
|
1 | 368 |
]. |
369 |
newClass := self autoload. |
|
68 | 370 |
sel := thisContext selector. |
371 |
args := thisContext args. |
|
1 | 372 |
newClass notNil ifTrue:[ |
154 | 373 |
^ newClass perform:sel withArguments:args |
1 | 374 |
]. |
375 |
^ nil |
|
376 |
! ! |
|
11 | 377 |
|
620 | 378 |
!Autoload class methodsFor:'queries'! |
356 | 379 |
|
620 | 380 |
isBehavior |
381 |
"return true if the recevier is some kind of class. |
|
382 |
Autoloaded classes are definitely; therefore return true." |
|
164 | 383 |
|
620 | 384 |
^ true |
385 |
! |
|
356 | 386 |
|
729 | 387 |
isBuiltInClass |
388 |
^ false |
|
389 |
||
390 |
"Created: 10.12.1995 / 00:28:22 / cg" |
|
391 |
! |
|
392 |
||
620 | 393 |
isLoaded |
394 |
"return true, if the class has been loaded; redefined in Autoload; |
|
395 |
see comment there. this allows testing for a class been already loaded." |
|
396 |
||
397 |
^ (self == Autoload) |
|
398 |
! |
|
399 |
||
922 | 400 |
loadedClasses |
401 |
"return the set of classes that were autoloaded" |
|
402 |
||
403 |
^ LoadedClasses |
|
404 |
! |
|
405 |
||
620 | 406 |
wasAutoloaded:aClass |
922 | 407 |
"return true, if aClass was autoloaded" |
408 |
||
620 | 409 |
^ LoadedClasses notNil and:[LoadedClasses includes:aClass] |
11 | 410 |
! ! |
620 | 411 |
|
661 | 412 |
!Autoload class methodsFor:'documentation'! |
413 |
||
414 |
version |
|
938
a23bc7f62ed1
set package info when autoloading
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
415 |
^ '$Header: /cvs/stx/stx/libbasic/Autoload.st,v 1.42 1996-02-07 14:10:54 cg Exp $' |
661 | 416 |
! ! |
620 | 417 |
Autoload initialize! |