diff options
author | Kenneth Russel <[email protected]> | 2005-11-09 00:32:37 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-11-09 00:32:37 +0000 |
commit | cf7b8b87f78687b8e4a867d3b18bd7f072a955ee (patch) | |
tree | 739fe8eec21acfe26cf7a684232f1219dbdd43b8 /src/classes/com/sun/gluegen/JavaMethodBindingEmitter.java | |
parent | e42abe5e45c693abc4c06ac5c1928ee2c3fe8d27 (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/JavaMethodBindingEmitter.java')
-rw-r--r-- | src/classes/com/sun/gluegen/JavaMethodBindingEmitter.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/classes/com/sun/gluegen/JavaMethodBindingEmitter.java b/src/classes/com/sun/gluegen/JavaMethodBindingEmitter.java index 8dbb20d28..64d349ca9 100644 --- a/src/classes/com/sun/gluegen/JavaMethodBindingEmitter.java +++ b/src/classes/com/sun/gluegen/JavaMethodBindingEmitter.java @@ -89,6 +89,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter public JavaMethodBindingEmitter(MethodBinding binding, PrintWriter output, + MachineDescription defaultMachDesc, String runtimeExceptionType, boolean emitBody, boolean eraseBufferAndArrayTypes, @@ -98,7 +99,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter boolean forIndirectBufferAndArrayImplementation, boolean isUnimplemented) { - super(output); + super(output, defaultMachDesc); this.binding = binding; this.runtimeExceptionType = runtimeExceptionType; this.emitBody = emitBody; @@ -333,7 +334,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter return getArgumentName(i) + "_offset"; } - protected void emitBody(PrintWriter writer) + protected void emitBody(PrintWriter writer, MachineDescription machDesc) { if (!emitBody) { writer.println(';'); @@ -347,7 +348,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter emitPrologueOrEpilogue(prologue, writer); emitPreCallSetup(binding, writer); //emitReturnVariableSetup(binding, writer); - emitReturnVariableSetupAndCall(binding, writer); + emitReturnVariableSetupAndCall(binding, writer, machDesc); emitPrologueOrEpilogue(epilogue, writer); } writer.println(" }"); @@ -435,7 +436,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter } - protected void emitReturnVariableSetupAndCall(MethodBinding binding, PrintWriter writer) { + protected void emitReturnVariableSetupAndCall(MethodBinding binding, PrintWriter writer, MachineDescription machDesc) { writer.print(" "); JavaType returnType = binding.getJavaReturnType(); boolean needsResultAssignment = false; @@ -502,7 +503,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter writer.println(); } if (needsResultAssignment) { - emitCallResultReturn(binding, writer); + emitCallResultReturn(binding, writer, machDesc); } } @@ -587,14 +588,14 @@ public class JavaMethodBindingEmitter extends FunctionEmitter return numArgsEmitted; } - protected void emitCallResultReturn(MethodBinding binding, PrintWriter writer) { + protected void emitCallResultReturn(MethodBinding binding, PrintWriter writer, MachineDescription machDesc) { JavaType returnType = binding.getJavaReturnType(); if (returnType.isCompoundTypeWrapper()) { String fmt = getReturnedArrayLengthExpression(); writer.println(" if (_res == null) return null;"); if (fmt == null) { - writer.print(" return new " + returnType.getName() + "(_res.order(ByteOrder.nativeOrder()))"); + writer.print(" return " + returnType.getName() + ".create(_res.order(ByteOrder.nativeOrder()))"); } else { writer.println(" _res.order(ByteOrder.nativeOrder());"); String[] argumentNames = new String[binding.getNumArguments()]; @@ -616,13 +617,13 @@ public class JavaMethodBindingEmitter extends FunctionEmitter // Create temporary ByteBuffer slice // FIXME: probably need Type.getAlignedSize() for arrays of // compound types (rounding up to machine-dependent alignment) - writer.println(" _res.position(_count * " + cReturnType.getSize() + ");"); - writer.println(" _res.limit ((1 + _count) * " + cReturnType.getSize() + ");"); + writer.println(" _res.position(_count * " + cReturnType.getSize(machDesc) + ");"); + writer.println(" _res.limit ((1 + _count) * " + cReturnType.getSize(machDesc) + ");"); writer.println(" ByteBuffer _tmp = _res.slice();"); writer.println(" _tmp.order(ByteOrder.nativeOrder());"); writer.println(" _res.position(0);"); writer.println(" _res.limit(_res.capacity());"); - writer.println(" _retarray[_count] = new " + getReturnTypeString(true) + "(_tmp);"); + writer.println(" _retarray[_count] = " + getReturnTypeString(true) + ".create(_tmp);"); writer.println(" }"); writer.print (" return _retarray"); } @@ -634,7 +635,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter writer.println(" if (_res == null) return null;"); writer.println(" " + getReturnTypeString(false) + " _retarray = new " + getReturnTypeString(true) + "[_res.length];"); writer.println(" for (int _count = 0; _count < _res.length; _count++) {"); - writer.println(" _retarray[_count] = new " + getReturnTypeString(true) + "(_res[_count]);"); + writer.println(" _retarray[_count] = " + getReturnTypeString(true) + ".create(_res[_count]);"); writer.println(" }"); writer.println(" return _retarray;"); } |