aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/procaddress
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-08-27 03:52:07 +0000
committerKenneth Russel <[email protected]>2006-08-27 03:52:07 +0000
commit295c0331e911c9cd75c2c03597ce9a20ec995bd6 (patch)
tree0e1ec9b6561a94581e861a2301b8ae3db54dfd94 /src/java/com/sun/gluegen/procaddress
parentd289b0d2b3e36a87112a2c843e7e91700078c160 (diff)
Changed NativeLibrary.open() to accept boolean argument indicating
whether to search the system path first; perhaps useful if applications ship only a backup version of native libraries associated with a particular Java binding. In the case of JOAL we plan to ship a recent OpenAL implementation so we will not need to search the system path first. Changed ForceProcAddressGen directive to force call-through-function-pointer semantics for the targeted function. Changed JOAL to not link directly against the OpenAL library at all, but instead to look up all entry points using the GlueGen NativeLibrary class (instead of the custom dlsym code, now removed) in particular to solve DSO versioning problems on Linux. Updated EAX binding to work with dynamically loading OpenAL. Tested on Windows so far; more testing needed on Linux in Java Web Start scenarios. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@42 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/java/com/sun/gluegen/procaddress')
-rwxr-xr-xsrc/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java19
-rwxr-xr-xsrc/java/com/sun/gluegen/procaddress/ProcAddressConfiguration.java5
-rwxr-xr-xsrc/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java17
3 files changed, 39 insertions, 2 deletions
diff --git a/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java b/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
index 423f009..8dc46ee 100755
--- a/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
@@ -46,12 +46,14 @@ import com.sun.gluegen.cgram.types.*;
public class ProcAddressCMethodBindingEmitter extends CMethodBindingEmitter {
private boolean callThroughProcAddress;
+ private boolean needsLocalTypedef;
private static String procAddressJavaTypeName =
JavaType.createForClass(Long.TYPE).jniTypeName();
private ProcAddressEmitter emitter;
public ProcAddressCMethodBindingEmitter(CMethodBindingEmitter methodToWrap,
final boolean callThroughProcAddress,
+ boolean needsLocalTypedef,
ProcAddressEmitter emitter) {
super(
new MethodBinding(methodToWrap.getBinding()) {
@@ -91,6 +93,7 @@ public class ProcAddressCMethodBindingEmitter extends CMethodBindingEmitter {
setCommentEmitter(defaultCommentEmitter);
this.callThroughProcAddress = callThroughProcAddress;
+ this.needsLocalTypedef = needsLocalTypedef;
this.emitter = emitter;
}
@@ -112,10 +115,24 @@ public class ProcAddressCMethodBindingEmitter extends CMethodBindingEmitter {
protected void emitBodyVariableDeclarations(PrintWriter writer) {
if (callThroughProcAddress) {
// create variable for the function pointer with the right type, and set
- // it to the value of the passed-in glProcAddress
+ // it to the value of the passed-in proc address
FunctionSymbol cSym = getBinding().getCSymbol();
String funcPointerTypedefName =
emitter.getFunctionPointerTypedefName(cSym);
+
+ if (needsLocalTypedef) {
+ // We (probably) didn't get a typedef for this function
+ // pointer type in the header file; the user requested that we
+ // forcibly generate one. Here we force the emission of one.
+ PointerType funcPtrType = new PointerType(null, cSym.getType(), 0);
+ // Just for safety, emit this name slightly differently than
+ // the mangling would otherwise produce
+ funcPointerTypedefName = "_local_" + funcPointerTypedefName;
+
+ writer.print(" typedef ");
+ writer.print(funcPtrType.toString(funcPointerTypedefName));
+ writer.println(";");
+ }
writer.print(" ");
writer.print(funcPointerTypedefName);
diff --git a/src/java/com/sun/gluegen/procaddress/ProcAddressConfiguration.java b/src/java/com/sun/gluegen/procaddress/ProcAddressConfiguration.java
index 54dd2cb..e5edd0d 100755
--- a/src/java/com/sun/gluegen/procaddress/ProcAddressConfiguration.java
+++ b/src/java/com/sun/gluegen/procaddress/ProcAddressConfiguration.java
@@ -52,6 +52,7 @@ public class ProcAddressConfiguration extends JavaConfiguration
private String tableClassName = "ProcAddressTable";
private Set/*<String>*/ skipProcAddressGen = new HashSet();
private List/*<String>*/ forceProcAddressGen = new ArrayList();
+ private Set/*<String>*/ forceProcAddressGenSet = new HashSet();
private String getProcAddressTableExpr;
private ConvNode procAddressNameConverter;
@@ -78,6 +79,7 @@ public class ProcAddressConfiguration extends JavaConfiguration
{
String sym = readString("ForceProcAddressGen", tok, filename, lineNo);
forceProcAddressGen.add(sym);
+ forceProcAddressGenSet.add(sym);
}
else if (cmd.equalsIgnoreCase("GetProcAddressTableExpr"))
{
@@ -253,4 +255,7 @@ public class ProcAddressConfiguration extends JavaConfiguration
return procAddressNameConverter.convert(funcName);
}
+ public boolean forceProcAddressGen(String funcName) {
+ return forceProcAddressGenSet.contains(funcName);
+ }
}
diff --git a/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java
index 75fb59c..19d4fe3 100755
--- a/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java
+++ b/src/java/com/sun/gluegen/procaddress/ProcAddressEmitter.java
@@ -58,6 +58,7 @@ public class ProcAddressEmitter extends JavaEmitter
protected static final String WRAP_PREFIX = "dispatch_";
private TypeDictionary typedefDictionary;
private PrintWriter tableWriter;
+ private Set emittedTableEntries;
private String tableClassPackage;
private String tableClassName;
@@ -219,6 +220,7 @@ public class ProcAddressEmitter extends JavaEmitter
{
// See whether we need a proc address entry for this one
boolean callThroughProcAddress = needsProcAddressWrapper(baseCEmitter.getBinding().getCSymbol());
+ boolean forceProcAddress = getProcAddressConfig().forceProcAddressGen(baseCEmitter.getBinding().getCSymbol().getName());
// Note that we don't care much about the naming of the C argument
// variables so to keep things simple we ignore the buffer object
// property for the binding
@@ -226,7 +228,10 @@ public class ProcAddressEmitter extends JavaEmitter
// The C-side JNI binding for this particular function will have an
// extra final argument, which is the address (the OpenGL procedure
// address) of the function it needs to call
- ProcAddressCMethodBindingEmitter res = new ProcAddressCMethodBindingEmitter(baseCEmitter, callThroughProcAddress, this);
+ ProcAddressCMethodBindingEmitter res = new ProcAddressCMethodBindingEmitter(baseCEmitter,
+ callThroughProcAddress,
+ forceProcAddress,
+ this);
MessageFormat exp = baseCEmitter.getReturnValueCapacityExpression();
if (exp != null) {
res.setReturnValueCapacityExpression(exp);
@@ -250,6 +255,10 @@ public class ProcAddressEmitter extends JavaEmitter
shouldWrap = false;
}
+ if (config.forceProcAddressGen(symName)) {
+ shouldWrap = true;
+ }
+
if (shouldWrap)
{
// Hoist argument names from function pointer if not supplied in prototype
@@ -281,6 +290,7 @@ public class ProcAddressEmitter extends JavaEmitter
CodeGenUtils.packageAsPath(implPackageName);
tableWriter = openFile(jImplRoot + File.separator + tableClassName + ".java");
+ emittedTableEntries = new HashSet();
CodeGenUtils.emitAutogeneratedWarning(tableWriter, this);
@@ -358,6 +368,11 @@ public class ProcAddressEmitter extends JavaEmitter
protected void emitProcAddressTableEntryForString(String str)
{
+ // Deal gracefully with forced proc address generation in the face
+ // of having the function pointer typedef in the header file too
+ if (emittedTableEntries.contains(str))
+ return;
+ emittedTableEntries.add(str);
tableWriter.print(" public long ");
tableWriter.print(PROCADDRESS_VAR_PREFIX);
tableWriter.print(str);