summaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/gluegen/CMethodBindingEmitter.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-11-09 00:32:37 +0000
committerKenneth Russel <[email protected]>2005-11-09 00:32:37 +0000
commitcf7b8b87f78687b8e4a867d3b18bd7f072a955ee (patch)
tree739fe8eec21acfe26cf7a684232f1219dbdd43b8 /src/classes/com/sun/gluegen/CMethodBindingEmitter.java
parente42abe5e45c693abc4c06ac5c1928ee2c3fe8d27 (diff)
Refactored computations of sizes of data types and offsets of fields
in data structures in GlueGen to be performed lazily via SizeThunks. The concrete size of primitive data types is computed only by passing a MachineDescription into one of these thunks. Changed generated glue code for struct accessors to delegate their instantiation and field access to specialized 32- or 64-bit versions. This should allow one jar file to support both 32-bit and 64-bit CPUs; the native code is of course still specialized for the processor and data model. Changed default build to generate both 32-bit and 64-bit accessors for all generated data structures. Tested on Windows; more testing, including build testing, is needed on other platforms. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@426 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/gluegen/CMethodBindingEmitter.java')
-rw-r--r--src/classes/com/sun/gluegen/CMethodBindingEmitter.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/classes/com/sun/gluegen/CMethodBindingEmitter.java b/src/classes/com/sun/gluegen/CMethodBindingEmitter.java
index 70877ff5e..a1cae8d51 100644
--- a/src/classes/com/sun/gluegen/CMethodBindingEmitter.java
+++ b/src/classes/com/sun/gluegen/CMethodBindingEmitter.java
@@ -120,6 +120,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
*/
public CMethodBindingEmitter(MethodBinding binding,
PrintWriter output,
+ MachineDescription defaultMachDesc,
String javaPackageName,
String javaClassName,
boolean isOverloadedBinding,
@@ -127,7 +128,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
boolean forImplementingMethodCall,
boolean forIndirectBufferAndArrayImplementation)
{
- super(output);
+ super(output, defaultMachDesc);
assert(binding != null);
assert(javaClassName != null);
@@ -381,7 +382,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
}
- protected void emitBody(PrintWriter writer)
+ protected void emitBody(PrintWriter writer, MachineDescription machDesc)
{
writer.println(" {");
emitBodyVariableDeclarations(writer);
@@ -392,7 +393,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
emitBodyUserVariableAssignments(writer);
emitBodyVariablePostCallCleanup(writer, true);
emitBodyVariablePostCallCleanup(writer, false);
- emitBodyReturnResult(writer);
+ emitBodyReturnResult(writer, machDesc);
writer.println("}");
writer.println();
}
@@ -965,7 +966,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
}
}
- protected void emitBodyReturnResult(PrintWriter writer)
+ protected void emitBodyReturnResult(PrintWriter writer, MachineDescription machDesc)
{
// WARNING: this code assumes that the return type has already been
// typedef-resolved.
@@ -996,11 +997,11 @@ public class CMethodBindingEmitter extends FunctionEmitter
writer.print(
returnValueCapacityExpression.format(argumentNames));
} else {
- int sz = 0;
+ SizeThunk sz = null;
if (cReturnType.isPointer() &&
cReturnType.asPointer().getTargetType().isCompound()) {
sz = cReturnType.asPointer().getTargetType().getSize();
- if (sz == -1) {
+ if (sz == null) {
throw new RuntimeException(
"Error emitting code for compound return type "+
"for function \"" + binding + "\": " +
@@ -1012,7 +1013,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
} else {
sz = cReturnType.getSize();
}
- writer.print(sz);
+ writer.print(sz.compute(machDesc));
System.err.println(
"WARNING: No capacity specified for java.nio.Buffer return " +
"value for function \"" + binding + "\";" +
@@ -1043,11 +1044,11 @@ public class CMethodBindingEmitter extends FunctionEmitter
} else {
baseType = retType.asArray().getElementType().asPointer().getTargetType();
}
- int sz = baseType.getSize();
- if (sz < 0)
- sz = 0;
+ SizeThunk sz = baseType.getSize();
+ if (sz == null)
+ sz = SizeThunk.constant(0);
writer.println(" (*env)->SetObjectArrayElement(env, " + arrayRes + ", " + arrayIdx +
- ", (*env)->NewDirectByteBuffer(env, _res[" + arrayIdx + "], " + sz + "));");
+ ", (*env)->NewDirectByteBuffer(env, _res[" + arrayIdx + "], " + sz.compute(machDesc) + "));");
writer.println(" }");
writer.println(" return " + arrayRes + ";");
} else if (javaReturnType.isArray()) {