summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/sun/gluegen')
-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
4 files changed, 19 insertions, 3 deletions
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);");