aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games/gluegen/opengl
diff options
context:
space:
mode:
authorTravis Bryson <[email protected]>2005-06-24 20:28:37 +0000
committerTravis Bryson <[email protected]>2005-06-24 20:28:37 +0000
commit0969a98f2007d76e38f8819eedfead5b840f6364 (patch)
tree82aff6a7fb922f45fc7853e5c5442af0d978768f /src/net/java/games/gluegen/opengl
parented85f53f73d69a44c6b98b3824354be3fbb7bf58 (diff)
This putback adds array offsets to the public JOGL API. The offsets are
respected and used properly in all of the public and private functions. The changes are in gluegen, so that the code is generated properly. And also throughout the parts of the jogl code that are not gluegen-generated. For the internally generated implementation methods, a "1" is added to the method names. So as to not overload the public API. This is similar to what is already done with Buffer APIs, which have a "0" added internally. I used a "1" instead of a "0" to avoid any collisions of the signatures, which could happen if a null object was sent down for the Array (e.g., the wrong method would get called). This should be a suitable foundation for the implementation to add the ability to wrap arrays in Buffers, which we plan to add to the implementation soon. These changes will cause all existing JOGL programs to break, although adapting them is pretty easy. We will later be putting back changed examples and utilities that incorporate these new APIs. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@313 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/gluegen/opengl')
-rw-r--r--src/net/java/games/gluegen/opengl/CGLPAWrapperEmitter.java68
-rw-r--r--src/net/java/games/gluegen/opengl/JavaGLPAWrapperEmitter.java10
2 files changed, 70 insertions, 8 deletions
diff --git a/src/net/java/games/gluegen/opengl/CGLPAWrapperEmitter.java b/src/net/java/games/gluegen/opengl/CGLPAWrapperEmitter.java
index bb80190d3..82ba9f0f9 100644
--- a/src/net/java/games/gluegen/opengl/CGLPAWrapperEmitter.java
+++ b/src/net/java/games/gluegen/opengl/CGLPAWrapperEmitter.java
@@ -54,8 +54,10 @@ public class CGLPAWrapperEmitter extends CMethodBindingEmitter
private static String procAddressJavaTypeName =
JavaType.createForClass(Long.TYPE).jniTypeName();
+ protected boolean arrayImplRoutine = false;
+
public CGLPAWrapperEmitter(CMethodBindingEmitter methodToWrap)
- {
+ {
super(
new MethodBinding(methodToWrap.getBinding()) {
public String getName() {
@@ -69,6 +71,9 @@ public class CGLPAWrapperEmitter extends CMethodBindingEmitter
methodToWrap.getDefaultOutput()
);
+// if(binding.signatureUsesPrimitiveArrays())
+// arrayImplRoutine = true;
+
if (methodToWrap.getReturnValueCapacityExpression() != null) {
setReturnValueCapacityExpression(methodToWrap.getReturnValueCapacityExpression());
}
@@ -194,10 +199,31 @@ public class CGLPAWrapperEmitter extends CMethodBindingEmitter
writer.print("(intptr_t) ");
}
if (javaType.isArray() || javaType.isNIOBuffer()) {
- writer.print(pointerConversionArgumentName(i));
- if (javaArgTypeNeedsDataCopy(javaType)) {
- writer.print("_copy");
- }
+
+ Type cArgType = binding.getCSymbol().getArgumentType(i);
+ boolean containsVoid = false;
+ // Add special code for accounting for array offsets
+ //
+ // For mapping from byte primitive array type to type* case produces code:
+ // (GLtype*)((char*)_ptr0 + varName_offset)
+ // where varName_offset is the number of bytes offset as calculated in Java code
+
+ if(javaType.isArray() && !javaType.isNIOBufferArray() && !javaType.isStringArray()) {
+ writer.print("( (char*)");
+ }
+ /* End of special code section for accounting for array offsets */
+
+ writer.print(pointerConversionArgumentName(i));
+ if (javaArgTypeNeedsDataCopy(javaType)) {
+ writer.print("_copy");
+ }
+
+ /* Add special code for accounting for array offsets */
+ if(javaType.isArray() && !javaType.isNIOBufferArray() && !javaType.isStringArray()) {
+ writer.print(" + " + binding.getArgumentName(i) + "_offset)");
+ }
+ /* End of special code section for accounting for array offsets */
+
} else {
if (javaType.isString()) { writer.print("_UTF8"); }
writer.print(binding.getArgumentName(i));
@@ -209,8 +235,36 @@ public class CGLPAWrapperEmitter extends CMethodBindingEmitter
protected String jniMangle(MethodBinding binding) {
StringBuffer buf = new StringBuffer();
- buf.append(super.jniMangle(binding));
- jniMangle(Long.TYPE, buf);
+ buf.append(jniMangle(binding.getName()));
+
+ if(binding.signatureUsesPrimitiveArrays())
+ buf.append("1");
+
+ buf.append("__");
+ for (int i = 0; i < binding.getNumArguments(); i++) {
+ JavaType type = binding.getJavaArgumentType(i);
+ Class c = type.getJavaClass();
+ if (c != null) {
+ jniMangle(c, buf);
+ // If Buffer offset arguments were added, we need to mangle the JNI for the
+ // extra arguments
+ if(type.isNIOBuffer()) {
+ jniMangle(Integer.TYPE, buf);
+ } else if (type.isNIOBufferArray()) {
+ int[] intArrayType = new int[0];
+ c = intArrayType.getClass();
+ jniMangle(c , buf);
+ }
+ if(type.isArray() && !type.isNIOBufferArray() && !type.isStringArray()) {
+ jniMangle(Integer.TYPE, buf);
+ }
+ } else {
+ // FIXME: add support for char* -> String conversion
+ throw new RuntimeException("Unknown kind of JavaType: name="+type.getName());
+ }
+ }
+
+ jniMangle(Long.TYPE, buf); // to account for the additional _addr_ parameter
return buf.toString();
}
diff --git a/src/net/java/games/gluegen/opengl/JavaGLPAWrapperEmitter.java b/src/net/java/games/gluegen/opengl/JavaGLPAWrapperEmitter.java
index c0bfef081..f45fcd3c7 100644
--- a/src/net/java/games/gluegen/opengl/JavaGLPAWrapperEmitter.java
+++ b/src/net/java/games/gluegen/opengl/JavaGLPAWrapperEmitter.java
@@ -75,10 +75,15 @@ public class JavaGLPAWrapperEmitter extends JavaMethodBindingImplEmitter
methodToWrap.getDefaultOutput(),
methodToWrap.getRuntimeExceptionType())
{
+
protected void emitName(PrintWriter writer)
{
writer.print(GLEmitter.WRAP_PREFIX);
super.emitName(writer);
+
+ if(getBinding().signatureUsesPrimitiveArrays())
+ writer.print("1");
+
}
protected int emitArguments(PrintWriter writer)
{
@@ -135,7 +140,10 @@ public class JavaGLPAWrapperEmitter extends JavaMethodBindingImplEmitter
}
protected String getImplMethodName() {
- return GLEmitter.WRAP_PREFIX + getBinding().getName();
+ if(getBinding().signatureUsesPrimitiveArrays())
+ return GLEmitter.WRAP_PREFIX + getBinding().getName() + "1";
+ else
+ return GLEmitter.WRAP_PREFIX + getBinding().getName();
}
public void emit(PrintWriter writer)