|
||||||||||
| 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.interpreter.type.AbstractAssignment
org.extex.unit.dynamic.NativeDef
public class NativeDef
This primitive provides a binding of a macro or active character to code in
some programming language. This code implements the primitive
\nativedef.
The primitive \nativedef assigns a definition to a macro or active
character. This is done in a similar way as \def works. The
difference is that the definition has to be provided in form of a Java class
which glues in native code.
The 〈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. This appropriate class
is loaded if needed and instantiated. The instance is bound as code to the
〈control sequence〉.
The 〈control sequence〉 is any macro or active character.
If this token is missing or of the wrong type then an error is raised.
The 〈name〉 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 passed to the binding class to specify the target. For instance
the Java binding requires this to be name of the Java class implementing the
functionality.
The primitive \nativedef is local to the enclosing group as is
\def. And similar to \def the modifier
\global can be used to make the definition in all groups instead
of the current group only.
The primitive \nativedef also respects the count register
\globaldefs to enable general global assignment.
Since the primitive is classified as assignment the value of
\afterassignment is applied.
This example shows how the control sequence \x is bound to the
Java class my.primitive.MyPrimitive. This definition is local to
the current group.
This example shows how the control sequence \x is bound to the
Java class my.primitive.MyPrimitive. This definition is performed
globally.
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.
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.
The Primitive \nativedef
Syntax
The general form of this primitive is
〈nativedef〉
→ \nativedef 〈type〉 〈control sequence〉 〈name〉
Examples
\nativedef{java}\x{my.primitive.MyPrimitive}
\global\nativedef{java}\x{my.primitive.MyPrimitive}
Configuration
<define name="nativedef"
class="org.extex.interpreter.primitives.dynamic.NativeDef">
<load name="java"
class="org.extex.interpreter.primitives.dynamic.java.JavaDef"/>
</define>
| Nested Class Summary | |
|---|---|
protected static class |
NativeDef.Factory
This inner class provides access to the functionality of an abstract factory. |
| Field Summary | |
|---|---|
protected static long |
serialVersionUID
The constant serialVersionUID contains the id for serialization. |
| Constructor Summary | |
|---|---|
NativeDef(CodeToken token)
Creates a new object. |
|
| Method Summary | |
|---|---|
void |
assign(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
The method assign is the core of the functionality of execute(). |
void |
configure(Configuration config)
Configure an object according to a given Configuration. |
void |
enableLogging(java.util.logging.Logger log)
Setter for the logger. |
protected java.util.logging.Logger |
getLogger()
Getter for logger. |
| Methods inherited from class org.extex.interpreter.type.AbstractAssignment |
|---|
execute |
| 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 NativeDef(CodeToken token)
token - the initial token for the primitive| Method Detail |
|---|
public void assign(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
throws ConfigurationException,
HelpingException,
TypesetterException
execute().
This method is preferable to execute() since the
execute() method provided in this class takes care of
\afterassignment and \globaldefs as well.
assign in class AbstractAssignmentprefix - the prefix controlling the executioncontext - the interpreter contextsource - the token sourcetypesetter - the typesetter
ConfigurationException - in case of an configuration error
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterAbstractAssignment.assign(
org.extex.interpreter.Flags, org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
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)protected java.util.logging.Logger getLogger()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||