aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/gluegen/CMethodBindingEmitter.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-01-01 22:51:07 +0000
committerKenneth Russel <[email protected]>2006-01-01 22:51:07 +0000
commit875a3de8f54704604d006badf0f0747347319025 (patch)
tree904c468f43c9c818c57bb0f7f17608066172cf29 /src/classes/com/sun/gluegen/CMethodBindingEmitter.java
parent0747964f0b88d0c9da9c38bf9eff96eb6561f0c1 (diff)
Fixed more problems related to recent restructuring of glue code
generation to support simultaneous 32- and 64-bit ports. Now uses size() (on Java side) and sizeof (on C side) when creating direct Buffers for struct accessors rather than passing MachineDescription down to JavaMethodBindingEmitter and CMethodBindingEmitter. Now uses 64-bit MachineDescription when sizing outgoing arguments and return types for bound methods. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@506 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/gluegen/CMethodBindingEmitter.java')
-rw-r--r--src/classes/com/sun/gluegen/CMethodBindingEmitter.java24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/classes/com/sun/gluegen/CMethodBindingEmitter.java b/src/classes/com/sun/gluegen/CMethodBindingEmitter.java
index a1cae8d51..550d8d739 100644
--- a/src/classes/com/sun/gluegen/CMethodBindingEmitter.java
+++ b/src/classes/com/sun/gluegen/CMethodBindingEmitter.java
@@ -120,7 +120,6 @@ public class CMethodBindingEmitter extends FunctionEmitter
*/
public CMethodBindingEmitter(MethodBinding binding,
PrintWriter output,
- MachineDescription defaultMachDesc,
String javaPackageName,
String javaClassName,
boolean isOverloadedBinding,
@@ -128,7 +127,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
boolean forImplementingMethodCall,
boolean forIndirectBufferAndArrayImplementation)
{
- super(output, defaultMachDesc);
+ super(output);
assert(binding != null);
assert(javaClassName != null);
@@ -382,7 +381,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
}
- protected void emitBody(PrintWriter writer, MachineDescription machDesc)
+ protected void emitBody(PrintWriter writer)
{
writer.println(" {");
emitBodyVariableDeclarations(writer);
@@ -393,7 +392,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
emitBodyUserVariableAssignments(writer);
emitBodyVariablePostCallCleanup(writer, true);
emitBodyVariablePostCallCleanup(writer, false);
- emitBodyReturnResult(writer, machDesc);
+ emitBodyReturnResult(writer);
writer.println("}");
writer.println();
}
@@ -966,7 +965,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
}
}
- protected void emitBodyReturnResult(PrintWriter writer, MachineDescription machDesc)
+ protected void emitBodyReturnResult(PrintWriter writer)
{
// WARNING: this code assumes that the return type has already been
// typedef-resolved.
@@ -997,11 +996,9 @@ public class CMethodBindingEmitter extends FunctionEmitter
writer.print(
returnValueCapacityExpression.format(argumentNames));
} else {
- SizeThunk sz = null;
if (cReturnType.isPointer() &&
cReturnType.asPointer().getTargetType().isCompound()) {
- sz = cReturnType.asPointer().getTargetType().getSize();
- if (sz == null) {
+ if (cReturnType.asPointer().getTargetType().getSize() == null) {
throw new RuntimeException(
"Error emitting code for compound return type "+
"for function \"" + binding + "\": " +
@@ -1010,14 +1007,12 @@ public class CMethodBindingEmitter extends FunctionEmitter
cReturnType.asPointer().getTargetType() + " was not)"
);
}
- } else {
- sz = cReturnType.getSize();
}
- writer.print(sz.compute(machDesc));
+ writer.print("sizeof(" + cReturnType.getName() + ")");
System.err.println(
"WARNING: No capacity specified for java.nio.Buffer return " +
"value for function \"" + binding + "\";" +
- " assuming size of equivalent C return type (" + sz + " bytes): " + binding);
+ " assuming size of equivalent C return type (sizeof(" + cReturnType.getName() + ")): " + binding);
}
writer.println(");");
} else if (javaReturnType.isString()) {
@@ -1044,11 +1039,8 @@ public class CMethodBindingEmitter extends FunctionEmitter
} else {
baseType = retType.asArray().getElementType().asPointer().getTargetType();
}
- SizeThunk sz = baseType.getSize();
- if (sz == null)
- sz = SizeThunk.constant(0);
writer.println(" (*env)->SetObjectArrayElement(env, " + arrayRes + ", " + arrayIdx +
- ", (*env)->NewDirectByteBuffer(env, _res[" + arrayIdx + "], " + sz.compute(machDesc) + "));");
+ ", (*env)->NewDirectByteBuffer(env, _res[" + arrayIdx + "], sizeof(" + baseType.getName() + ")));");
writer.println(" }");
writer.println(" return " + arrayRes + ";");
} else if (javaReturnType.isArray()) {