summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdoc/manual/index.html11
-rw-r--r--src/java/com/sun/gluegen/CodeGenUtils.java3
-rw-r--r--src/java/com/sun/gluegen/JavaConfiguration.java13
-rw-r--r--src/java/com/sun/gluegen/JavaEmitter.java4
-rwxr-xr-xsrc/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java2
5 files changed, 30 insertions, 3 deletions
diff --git a/doc/manual/index.html b/doc/manual/index.html
index 1b8703c..2192af5 100755
--- a/doc/manual/index.html
+++ b/doc/manual/index.html
@@ -981,6 +981,17 @@ struct. Normally only those structs referenced directly by the parsed
C APIs have corresponding Java classes emitted.
+<dt><strong><a name="GlueGenRuntimePackage">GlueGenRuntimePackage</a></strong>
+<dd>Syntax: <code>GlueGenRuntimePackage [package name, like com.sun.gluegen.runtime]</code> <br>
+
+(optional) Changes the package in which the generated glue code
+expects to find its run-time helper classes (like BufferFactory, CPU,
+StructAccessor). Defaults to <CODE>com.sun.gluegen.runtime</CODE> (no
+quotes). This is useful if you want to bundle the runtime classes in
+your application without the possibility of interfering with other
+versions elsewhere in the system.
+
+
<dt><strong><a name="Extends">Extends</a></strong>
<dd>Syntax: <code>Extends [Java interface name] [interface name to
extend] </code> <br>
diff --git a/src/java/com/sun/gluegen/CodeGenUtils.java b/src/java/com/sun/gluegen/CodeGenUtils.java
index 553ef26..ab81bec 100644
--- a/src/java/com/sun/gluegen/CodeGenUtils.java
+++ b/src/java/com/sun/gluegen/CodeGenUtils.java
@@ -79,6 +79,7 @@ public class CodeGenUtils
PrintWriter w,
String packageName,
String className,
+ String gluegenRuntimePackage,
boolean isClassNotInterface,
String[] imports,
String[] accessModifiers,
@@ -94,7 +95,7 @@ public class CodeGenUtils
w.print(imports[i]);
w.println(';');
}
- w.println("import com.sun.gluegen.runtime.*;");
+ w.println("import " + gluegenRuntimePackage + ".*;");
w.println();
diff --git a/src/java/com/sun/gluegen/JavaConfiguration.java b/src/java/com/sun/gluegen/JavaConfiguration.java
index 7488a30..7f6efa9 100644
--- a/src/java/com/sun/gluegen/JavaConfiguration.java
+++ b/src/java/com/sun/gluegen/JavaConfiguration.java
@@ -89,6 +89,13 @@ public class JavaConfiguration {
*/
private List/*<String>*/ imports = new ArrayList();
/**
+ * The package in which the generated glue code expects to find its
+ * run-time helper classes (BufferFactory, CPU,
+ * StructAccessor). Defaults to "com.sun.gluegen.runtime".
+ */
+ private String gluegenRuntimePackage = "com.sun.gluegen.runtime";
+
+ /**
* The kind of exception raised by the generated code if run-time
* checks fail. Defaults to RuntimeException.
*/
@@ -248,6 +255,10 @@ public class JavaConfiguration {
return JavaEmitter.ACC_PUBLIC;
}
+ /** Returns the package in which the generated glue code expects to
+ find its run-time helper classes (BufferFactory, CPU,
+ StructAccessor). Defaults to "com.sun.gluegen.runtime". */
+ public String gluegenRuntimePackage() { return gluegenRuntimePackage; }
/** Returns the kind of exception to raise if run-time checks fail in the generated code. */
public String runtimeExceptionType() { return runtimeExceptionType; }
/** Returns the list of imports that should be emitted at the top of each .java file. */
@@ -681,6 +692,8 @@ public class JavaConfiguration {
//System.err.println("read cmd = [" + cmd + "]");
if (cmd.equalsIgnoreCase("Package")) {
packageName = readString("package", tok, filename, lineNo);
+ } else if (cmd.equalsIgnoreCase("GlueGenRuntimePackage")) {
+ gluegenRuntimePackage = readString("GlueGenRuntimePackage", tok, filename, lineNo);
} else if (cmd.equalsIgnoreCase("ImplPackage")) {
implPackageName = readString("ImplPackage", tok, filename, lineNo);
} else if (cmd.equalsIgnoreCase("JavaClass")) {
diff --git a/src/java/com/sun/gluegen/JavaEmitter.java b/src/java/com/sun/gluegen/JavaEmitter.java
index 5902430..bcda048 100644
--- a/src/java/com/sun/gluegen/JavaEmitter.java
+++ b/src/java/com/sun/gluegen/JavaEmitter.java
@@ -772,7 +772,7 @@ public class JavaEmitter implements GlueEmitter {
writer.println();
writer.println("import java.nio.*;");
writer.println();
- writer.println("import com.sun.gluegen.runtime.*;");
+ writer.println("import " + cfg.gluegenRuntimePackage() + ".*;");
writer.println();
List/*<String>*/ imports = cfg.imports();
for (Iterator iter = imports.iterator(); iter.hasNext(); ) {
@@ -1395,6 +1395,7 @@ public class JavaEmitter implements GlueEmitter {
javaWriter,
cfg.packageName(),
cfg.className(),
+ cfg.gluegenRuntimePackage(),
cfg.allStatic() ? true : false,
(String[]) cfg.imports().toArray(new String[] {}),
new String[] { "public" },
@@ -1431,6 +1432,7 @@ public class JavaEmitter implements GlueEmitter {
javaImplWriter,
cfg.implPackageName(),
cfg.implClassName(),
+ cfg.gluegenRuntimePackage(),
true,
(String[]) cfg.imports().toArray(new String[] {}),
new String[] { "public" },
diff --git a/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java
index 19d4fe3..397f157 100755
--- a/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java
+++ b/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java
@@ -342,7 +342,7 @@ public class ProcAddressEmitter extends JavaEmitter
w.println(" * it was statically linked.");
w.println(" */");
w.println(" public long getAddressFor(String functionName) {");
- w.println(" String addressFieldName = com.sun.gluegen.runtime.ProcAddressHelper.PROCADDRESS_VAR_PREFIX + functionName;");
+ w.println(" String addressFieldName = " + getProcAddressConfig().gluegenRuntimePackage() + ".ProcAddressHelper.PROCADDRESS_VAR_PREFIX + functionName;");
w.println(" try { ");
w.println(" java.lang.reflect.Field addressField = getClass().getField(addressFieldName);");
w.println(" return addressField.getLong(this);");