|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.extex.interpreter.type.AbstractCode
org.extex.unit.dynamic.NativeLoad
public class NativeLoad
This primitive initiates the loading of native code and implements the
primitive \nativeload.
The primitive \nativeload loads some native language code. As
parameter the type of the native extension and a specification of the loader
to be used are given.
With this method it is possible to load larger extensions of
The
The
The following example illustrates the use of this primitive:
For the loading of the Java class it is necessary that this Java class
implements the interface The Primitive \nativeload
Syntax
The general form of this primitive is
〈nativeload〉
→ \nativeload 〈type〉 〈tokens〉
〈type〉 is any specification of a list of tokens
like a constant list enclosed in braces or a token register. The value of
these tokens are taken and resolved via the configuration.
〈tokens〉 is any specification of a list of tokens
like a constant list enclosed in braces or a tokens register. For the Java
loader the value of these tokens are taken and interpreted as the name of a
Java class. This class is loaded if needed, instantiated, and its method
init() is invoked. The instantiation requires the empty constructor to be
visible.
Examples
\nativeload{java}{my.unit.MyUnitLoader}
Loadable.
package my.package;
import org.extex.interpreter.context.Context;
import org.extex.interpreter.primitives.dynamic.java.Loadable;
import org.extex.typesetter.Typesetter;
import org.extex.util.exception.GeneralException;
class MyModule implements Loadable {
public MyModule() {
super();
// initialization code – if required
}
public void init(final Context context, final Typesetter
typesetter )
throws GeneralException {
// implement the initialization code here
}
}
The supported types are determined in the configuration of the unit which defines the primitive. Here a mapping is specified assigning a binding class for each supported type. Thus it is possible to configure in the support for several extension types. Currently a binding for Java is provided. In the future other languages can be added easily.
<define name="nativeload"
class="org.extex.interpreter.primitives.dynamic.NativeLoad">
<load name="java"
class="org.extex.interpreter.primitives.dynamic.java.JavaLoad"/>
</define>
The body of the define tag for the primitive may contain an arbitrary number of load sections. Each load has the attribute name and class. The attribute name determines the type. This corresponds to the type given in the first argument of the primitive invocation.
The class attribute names the class which provides the binding to the target programming language.
| Field Summary | |
|---|---|
protected static long |
serialVersionUID
The constant serialVersionUID contains the id for serialization. |
| Constructor Summary | |
|---|---|
NativeLoad(CodeToken token)
Creates a new object. |
|
| Method Summary | |
|---|---|
void |
configure(Configuration config)
Configure an object according to a given Configuration. |
void |
enableLogging(java.util.logging.Logger log)
Setter for the logger. |
void |
execute(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
This method takes the first token and executes it. The result is placed on the stack. This operation might have side effects. To execute a token it might be necessary to consume further tokens. |
protected java.util.logging.Logger |
getLogger()
Getter for logger. |
| Methods inherited from class org.extex.interpreter.type.AbstractCode |
|---|
getLocalizer, getName, getToken, isIf, isOuter, readResolve, toString, toText, toText |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final long serialVersionUID
| Constructor Detail |
|---|
public NativeLoad(CodeToken token)
token - the initial token for the primitive| Method Detail |
|---|
public void configure(Configuration config)
throws ConfigurationException
configure in interface Configurableconfig - the configuration object to consider
ConfigurationException - in case that something went wrongConfigurable.configure(org.extex.framework.configuration.Configuration)public void enableLogging(java.util.logging.Logger log)
enableLogging in interface LogEnabledlog - the logger to useLogEnabled.enableLogging(java.util.logging.Logger)
public void execute(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
execute in interface Codeexecute in class AbstractCodeprefix - the prefix controlling the executioncontext - the interpreter contextsource - the token sourcetypesetter - the typesetter
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterAbstractCode.execute(org.extex.interpreter.Flags,
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)protected java.util.logging.Logger getLogger()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||