diff options
author | Travis Bryson <[email protected]> | 2005-05-25 01:49:58 +0000 |
---|---|---|
committer | Travis Bryson <[email protected]> | 2005-05-25 01:49:58 +0000 |
commit | 48fda1ba14e025d9d6a984953219868c73318e5b (patch) | |
tree | b92757971b17ab08a9ba23158bb1e14a2cc090d7 /src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java | |
parent | 492f117fd3f76c7a5778ca2a07c6f5803242b8e0 (diff) |
Modified Files:
jogl/make/gl-common.cfg jogl/make/gl-glx-common.cfg
jogl/src/net/java/games/gluegen/opengl/JavaGLPAWrapperEmitter.java
jogl/src/net/java/games/gluegen/runtime/BufferFactory.java
jogl/src/net/java/games/gluegen/JavaEmitter.java
jogl/src/net/java/games/gluegen/JavaConfiguration.java
jogl/src/net/java/games/gluegen/CMethodBindingEmitter.java
jogl/src/net/java/games/gluegen/JavaMethodBindingEmitter.java
jogl/src/net/java/games/gluegen/CMethodBindingImplEmitter.java
jogl/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java
jogl/src/net/java/games/jogl/util/BufferUtils.java
Changes:
* Add NIODirectOnly grammar for description of methods that should have
only NIO Direct Buffer option (no expansion into other types, and also will
not be expanded to include indirect Buffer when we add that functionality)
* Make changes to respect Direct Buffer position value. This allows a setting
of an internal Buffer object parameter and JOGL will start reading data at
the point in the buffer to which this position is set
* The code is now generated to always respect this offset option. This has the
affect of changing the internal signatures of all methods that use Buffers. But
it does not affect the external API at all.
* Old JOGL programs will continue working the same as long as they had the
Buffer position set to zero before (the default value)
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@281 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java')
-rw-r--r-- | src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java b/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java index dc3dfa629..c1f05b564 100644 --- a/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java +++ b/src/net/java/games/gluegen/JavaMethodBindingImplEmitter.java @@ -106,7 +106,9 @@ public class JavaMethodBindingImplEmitter extends JavaMethodBindingEmitter emitArrayLengthAndNIOBufferChecks(binding, writer); } + protected void emitArrayLengthAndNIOBufferChecks(MethodBinding binding, PrintWriter writer) { + int numBufferOffsetArrayArgs = 0; // Check lengths of any incoming arrays if necessary for (int i = 0; i < binding.getNumArguments(); i++) { Type type = binding.getCArgumentType(i); @@ -122,14 +124,21 @@ public class JavaMethodBindingImplEmitter extends JavaMethodBindingEmitter writer.println(" throw new " + getRuntimeExceptionType() + "(\"Argument \\\"" + binding.getArgumentName(i) + "\\\" was not a direct buffer\");"); } else if (javaType.isNIOBufferArray()) { + numBufferOffsetArrayArgs++; String argName = binding.getArgumentName(i); + String arrayName = byteOffsetArrayConversionArgName(numBufferOffsetArrayArgs); + writer.println(" int[] " + arrayName + " = new int[" + argName + ".length];"); // Check direct buffer properties of all buffers within writer.println(" if (" + argName + " != null) {"); writer.println(" for (int _ctr = 0; _ctr < " + argName + ".length; _ctr++) {"); writer.println(" if (!BufferFactory.isDirect(" + argName + "[_ctr])) {"); - writer.println(" throw new " + getRuntimeExceptionType() + "(\"Element \" + _ctr + \" of argument \\\"" + + writer.println(" throw new " + getRuntimeExceptionType() + + "(\"Element \" + _ctr + \" of argument \\\"" + binding.getArgumentName(i) + "\\\" was not a direct buffer\");"); writer.println(" }"); + // get the Buffer Array offset values and save them into another array to send down to JNI + writer.print(" " + arrayName + "[_ctr] = BufferFactory.getPositionByteOffset("); + writer.println(argName + "[_ctr]);"); writer.println(" }"); writer.println(" }"); } @@ -165,12 +174,16 @@ public class JavaMethodBindingImplEmitter extends JavaMethodBindingEmitter protected int emitCallArguments(MethodBinding binding, PrintWriter writer) { boolean needComma = false; int numArgsEmitted = 0; + int numBufferOffsetArgs = 0, numBufferOffsetArrayArgs = 0; if (binding.hasContainingType()) { // Emit this pointer assert(binding.getContainingType().isCompoundTypeWrapper()); writer.print("getBuffer()"); needComma = true; ++numArgsEmitted; + numBufferOffsetArgs++; + //writer.print(", " + byteOffsetConversionArgName(numBufferOffsetArgs)); + writer.print(", BufferFactory.getPositionByteOffset(getBuffer())"); } for (int i = 0; i < binding.getNumArguments(); i++) { JavaType type = binding.getJavaArgumentType(i); @@ -198,9 +211,23 @@ public class JavaMethodBindingImplEmitter extends JavaMethodBindingEmitter writer.print(" == null) ? null : "); writer.print(binding.getArgumentName(i)); writer.print(".getBuffer())"); + numBufferOffsetArgs++; + //writer.print(", " + byteOffsetConversionArgName(numBufferOffsetArgs)); + writer.print(", BufferFactory.getPositionByteOffset(((" + binding.getArgumentName(i)); + writer.print(" == null) ? null : " + binding.getArgumentName(i) + ".getBuffer()))"); } needComma = true; ++numArgsEmitted; + if(type.isNIOBuffer() || type.isNIOBufferArray()) { + if(!type.isArray()) { + numBufferOffsetArgs++; + writer.print + (", BufferFactory.getPositionByteOffset(" + binding.getArgumentName(i) + ")"); + } else { + numBufferOffsetArrayArgs++; + writer.print(", " + byteOffsetArrayConversionArgName(numBufferOffsetArrayArgs)); + } + } } return numArgsEmitted; } |