|
Class: Autoload
nil
|
+--Autoload
This class inherits NOTHING - most messages will lead into doesNotUnderstand:
- Package:
- stx:libbasic
- Category:
- Kernel-Classes
- Version:
- rev:
1.189
date: 2022/07/01 15:44:37
- user: cg
- file: Autoload.st directory: libbasic
- module: stx stc-classLibrary: libbasic
Autoload is a stub for an 'as yet unloaded' class.
In memory limited systems (as my original 8Mb 386 system was),
all seldom-used classes were made subclasses of this class.
Autoload catches all messages sent to it, and files-in the real class's
code when first used. Then the caught message is resent to the (now existing) class.
A note from later days:
These days, systems usually have enough memory to allow
having all classes present, so many of the classes which used to be
autoloaded are no longer these days. However, a number of examples or
very seldom used frameworks are still present as autoloaded.
Instead of using autoloaded classes, it is now recommended to bundle
extra classes into packages, which are loaded en-bloque.
Packages can be compiled to a shared class library and thus be loaded
much faster (there is no need to parse and compile source files).
Lazy loading:
Class files are searched along the searchPath (see Smalltalk),
and any of binary-classFile, byteCode-classFile or sourceFile are loaded,
whichever is found first.
For binaries to be loaded, these must be found in a package-subdirectory
along the so called package path.
Sources in a package directory along the source path.
In practice, most Autoloaded classes are found and loaded as source file.
Initial Setup of Auoload Stubs:
At initial startup (i.e. when ST/X is NOT coming up with an image),
the 'patches' startup script recursively walks along all directories
below the TOP directory (that is one above the stx folder),
and installs autoload stubs for all .st class files found, for which no
corresponding class is already present.
As you can imagine, this takes a long time and makes the initial startup quite slow.
Therefore, this scheme is no longer the recommended one and we (at eXept)
always start ST/X with the '--quick' option, which skips this scan operation.
Late note:
--quick is now (7.1.1) the default.
To force an autoload scan, start stx with a --autoload argument.
Advantage of Autoload stubs:
Autoload stubs make it easier for a beginner to ST/X, to see what frameworks and classes
are there, as they appear in the browser with category and class name (although no
more details are initially visible.
[class variables:]
LazyLoading <Boolean> if true, the loaded classes
methods will NOT be compiled at
autoload time, but instead when
first called. This allows for a
faster load. However, expect short
pauses later when the methods are
first executed.
AutoloadFailedSignal <Signal> signal raised if an autoloaded
classes source is not available.
LoadedClasses <Collection> set of classes that heve been
autoloaded (for later unload)
copyrightCOPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
Signal constants
-
autoloadFailedSignal
-
return the signal raised when an autoload fails
adding/removing autoloaded classes
-
addClass: aClassName
-
given a name, install a corresponding autoload class stub for it.
Return the (autoload-) stubClass or nil, if no new class was created.
Usage example(s):
Autoload addClass:'Clock'
|
-
addClass: aClassName inCategory: aCategory
-
given a name, install a corresponding autoload class stub for it.
Return the (autoload-) stubClass or nil, if no new class was created.
Usage example(s):
Autoload addClass:'Clock' inCategory:'autoloaded-Demos'
|
-
removeClass: aClass
-
remove a class from the list of loaded classes
fileOut
-
basicFileOutDefinitionOn: aStream withNameSpace: forceNameSpace withPackage: withPackage
-
print an expression to define myself on aStream.
Since autoloaded classes don't know their real definition, simply
output some comment string making things clear in the browser.
initialization
-
initialize
-
initialize either the Autoload class
or load an autoloaded class and initialize it.
Usage example(s):
lazy compilation
-
compileLazy
-
return the lazy loading flag - if on, fileIn is much faster,
but pauses are to be expected later, since methods are compiled
when first executed.
-
compileLazy: aBoolean
-
turn on/off lazy loading - if on, fileIn is much faster,
but pauses are to be expected later, since methods are compiled
when first executed.
If you like it, add a line to your startup file.
loading
-
autoload
-
use this to force loading
- it is defined a noop in all non-autoloading classes.
Return the loaded class
Usage example(s):
Class is already being loaded.
In most cases we come here through the path:
subclass autoload
-> superclass autoload
-> superclass initialize/postAutoload
-> subclass autoload (hardcoded in initialize method).
Simply ignore it here
|
Usage example(s):
if filename is absolute, the autoload-class was created by an
|
Usage example(s):
explicit install-as-autoloaded via the fileBrowser.
|
Usage example(s):
reinstall the autoload class, this will be undone by #become:
|
Usage example(s):
USER INFORMATION:
this exception has been raised because an autoloaded class
could not be loaded. Usually, this happens when
the classes sourcefile is missing, unreadable or if
an entry is missing in the abbreviation file.
Check for a readable file named .st
in the 'source' directory and (if the fileName is not the same as the class name)
for a corresponding entry in the abbreviation file 'abbrev.stc'.
Finally, your searchpath could be set wrong -
the package might not be found along one of the directories named in systemPath.
In the debugger, press 'Abort' to continue execution.
|
Usage example(s):
autoloaded classes get their package from the revision (if present)
|
Usage example(s):
this only happens with autoloaded sourceFiles which have no package
|
message catching
-
askFor: aSelector
-
catch askFor: - load the class and resend #askFor: to the real one
Usage example(s):
Wrapper unload.
Wrapper askFor:#isSecret
|
-
at: arg
-
catch at: - redefined because it is understood
-
basicNew
-
catch basicNew - load the class and send it to the real one
-
basicNew: arg
-
catch basicNew: - load the class and send it to the real one
-
classResources
-
catch classResources - load the class and resend to the real one
-
comment
-
return the classes comment.
Autoloaded classes have no comment; but I myself have one
-
copy
-
catch copy - load the class and resend #copy to the real one
-
doesNotUnderstand: aMessage
-
caught a message; load the class and retry the message
-
error
-
catch error - load the class and resend #error to the real one
-
fromString: aString
-
catch - load the class and send it to the real one
-
handle: handler do: aBlock
-
autoload the class and resend
-
in: arg
-
catch new: - load the class and resend #in: to the real one
-
inspectorExtraAttributes
( an extension from the stx:libtool package )
-
extra (pseudo instvar) entries to be shown in an inspector.
-
isAbstract
-
actually: don't know, but do not want to load my class for this query
-
new
-
catch new - load the class and resend #new to the real one
-
new: arg
-
catch new: - load the class and resend #new: to the real one
-
privateClassesAt: aClassNameString
-
catch - load the class and send it to the real one
-
readFrom: aStream
-
catch - load the class and send it to the real one
-
readFrom: aStream onError: exceptionBlock
-
catch - load the class and send it to the real one
-
readFromString: aString
-
catch - load the class and send it to the real one
-
readFromString: aString onError: exceptionBlock
-
catch - load the class and send it to the real one
-
respondsTo: aSelector
-
catch respondsTo: - load the class and resend #respondsTo: to the real one
-
value
-
catch value - load the class and resend #value to the real one
private
-
loadAndResendMessage
-
common helper to autoload a class and define a subclass of it by sending
the sender-message again.
This is invoked by all #subClass... definition messages.
queries
-
accepts: aSignalOrExceptionClass
-
redefined to avoid recursive autoload.
(#autoload eventually raises QueryExceptions.
These exception may send #accepts: to exception classes
that are currently being loaded)
-
handles: anException
-
redefined to avoid recursive autoload.
(#autoload eventually raises QueryExceptions.
These exception may send #handles: to exception classes
that are currently being loaded)
-
isBehavior
-
return true, if the receiver is describing another object's' behavior.
Autoloaded classes are definitely; therefore return true.
-
isBeingLoaded
-
answer true if the class loading is currently in process
-
isBuiltInClass
-
return true if this class is known by the run-time-system.
Returns false here.
-
isLoaded
-
return true, if the class has been loaded.
Autoload itself is loaded, subclasses are not.
This allows testing whether a class has already been loaded.
-
loadedClasses
-
return the set of classes that were autoloaded
-
privateClassesOrAll: allOfThem
-
an autoloaded class has none
-
wasAutoloaded: aClass
-
return true, if aClass was autoloaded
utilities
-
withClass: aClass loadedDo: aBlock
-
ensure that aClass is loaded, while evaluating aBlock for it
Usage example(s):
Autoload withClass:Array loadedDo:[:cls | self assert:cls isLoaded]
Autoload withClass:Cons loadedDo:[:cls | self assert:cls isLoaded]
|
|