Class NativeLoad

  extended byde.dante.extex.interpreter.type.AbstractCode
      extended byde.dante.extex.interpreter.primitives.dynamic.NativeLoad
All Implemented Interfaces:
Code, Configurable, Localizable, LogEnabled,

public class NativeLoad
extends AbstractCode
implements Configurable, LogEnabled

This primitive initiates the loading of native code and implements the primitive \nativeload

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 ExTeX in one junk. There is no need to declare each single macro with \def. It is even possible to define extension macros in other programming languages than the TeX language.


The general form of this primitive is
       → \nativeload ⟨type⟩ ⟨tokens⟩ 

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.

The ⟨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.


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 Loadable.

   package my.package;

   import de.dante.extex.interpreter.contect.Context;
   import de.dante.extex.typesetter.Typesetter;
   import de.dante.util.GeneralException;

   class MyModule implements Loadable {

     public MyModule() {
       // 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"
    <load name="java"

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.

$Revision: 1.14 $
Gerd Neugebauer
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
Constructor Summary
NativeLoad(java.lang.String codeName)
          Creates a new object.
Method Summary
 void configure(Configuration config)
          Configure an object according to a given Configuration.
 void enableLogging(java.util.logging.Logger theLogger)
          Setter for the logger.
 void execute(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method takes the first token and executes it.
protected  java.util.logging.Logger getLogger()
          Getter for logger.
Methods inherited from class de.dante.extex.interpreter.type.AbstractCode
enableLocalization, getLocalizer, getName, isIf, isOuter, printable, printableControlSequence, readResolve, setName, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail


protected static final long serialVersionUID
The constant serialVersionUID contains the id for serialization.

See Also:
Constant Field Values
Constructor Detail


public NativeLoad(java.lang.String codeName)
Creates a new object.

codeName - the name of the primitive
Method Detail


public void configure(Configuration config)
               throws ConfigurationException
Description copied from interface: Configurable
Configure an object according to a given Configuration.

Specified by:
configure in interface Configurable
config - the configuration object to consider
ConfigurationException - in case that something went wrong
See Also:
Configurable.configure( de.dante.util.framework.configuration.Configuration)


public void enableLogging(java.util.logging.Logger theLogger)
Description copied from interface: LogEnabled
Setter for the logger.

Specified by:
enableLogging in interface LogEnabled
theLogger - the logger to use
See Also:
LogEnabled.enableLogging( java.util.logging.Logger)


public void execute(Flags prefix,
                    Context context,
                    TokenSource source,
                    Typesetter typesetter)
             throws InterpreterException
Description copied from interface: Code
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.

Specified by:
execute in interface Code
execute in class AbstractCode
See Also:
Code.execute( de.dante.extex.interpreter.Flags, de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource, de.dante.extex.typesetter.Typesetter)


protected java.util.logging.Logger getLogger()
Getter for logger.

the logger