summaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-03-10 13:32:26 +0100
committerSven Gothel <[email protected]>2014-03-10 13:32:26 +0100
commitd5d6f47dad574c6b28522649bdff746102280e68 (patch)
treea032b3b07e0237ff3e5925849eb1533737ba5f1e /src/java/com
parent2d94feea41d648fccaa96090e08e754a31aa1b14 (diff)
parent0b2b05c25b5072ccbce0f92e66f29b45bde762cd (diff)
Merge remote-tracking branch 'remotes/wwalker/bug_990_fix_gluegen_c_warnings'
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/jogamp/gluegen/CMethodBindingEmitter.java18
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/IntType.java5
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/PointerType.java7
3 files changed, 26 insertions, 4 deletions
diff --git a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
index d856767..d18ea3d 100644
--- a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
@@ -427,7 +427,8 @@ public class CMethodBindingEmitter extends FunctionEmitter {
writer.println(" jsize _tmpArrayLen;");
// Pointer to the data in the Buffer, taking the offset into account
- writer.println(" int * _offsetHandle = NULL;");
+ if(type.isNIOBufferArray())
+ writer.println(" int * _offsetHandle = NULL;");
emittedDataCopyTemps = true;
}
@@ -925,6 +926,15 @@ public class CMethodBindingEmitter extends FunctionEmitter {
if (isConstPtrPtr(cArgType)) {
writer.print("const ");
}
+
+ // if this is a pointer to an unsigned type, add unsigned to the name to avoid compiler warnings
+ if(cArgType.isPointer()) {
+ Type typeLast = ((PointerType)cArgType).getLastTargetType();
+ if(typeLast.isInt() && (((IntType)typeLast).isPrimitiveUnsigned())) {
+ writer.print("unsigned ");
+ }
+ }
+
writer.print(cArgType.getName());
writer.print(") ");
if (binding.getCArgumentType(i).isPointer() && javaArgType.isPrimitive()) {
@@ -1048,11 +1058,11 @@ public class CMethodBindingEmitter extends FunctionEmitter {
writer.println(" " + arrayRes + " = (*env)->NewObjectArray(env, " + arrayResLength + ", (*env)->FindClass(env, \"java/nio/ByteBuffer\"), NULL);");
writer.println(" for (" + arrayIdx + " = 0; " + arrayIdx + " < " + arrayResLength + "; " + arrayIdx + "++) {");
Type retType = binding.getCSymbol().getReturnType();
- Type pointerType;
+ Type pointerType;
if (retType.isPointer()) {
- pointerType = retType.asPointer().getTargetType();
+ pointerType = retType.asPointer().getTargetType();
} else {
- pointerType = retType.asArray().getElementType();
+ pointerType = retType.asArray().getElementType();
}
writer.println(" (*env)->SetObjectArrayElement(env, " + arrayRes + ", " + arrayIdx +
", (*env)->NewDirectByteBuffer(env, _res[" + arrayIdx + "], sizeof(" + pointerType.getName() + ")));");
diff --git a/src/java/com/jogamp/gluegen/cgram/types/IntType.java b/src/java/com/jogamp/gluegen/cgram/types/IntType.java
index ffc5696..6eeb997 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/IntType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/IntType.java
@@ -82,6 +82,11 @@ public class IntType extends PrimitiveType implements Cloneable {
return unsigned;
}
+ /** Indicates whether this type is an unsigned primitive type, as opposed to a typedef type that's unsigned. */
+ public boolean isPrimitiveUnsigned() {
+ return unsigned && !typedefedUnsigned;
+ }
+
@Override
public String toString() {
return getCVAttributesString() + ((isUnsigned() & (!typedefedUnsigned)) ? "unsigned " : "") + getName();
diff --git a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
index 4922d28..af33f41 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
@@ -120,6 +120,13 @@ public class PointerType extends Type implements Cloneable {
return targetType;
}
+ public Type getLastTargetType() {
+ if(targetType.isPointer())
+ return ((PointerType)targetType).getLastTargetType();
+ else
+ return targetType;
+ }
+
@Override
public boolean isFunctionPointer() {
return targetType.isFunction();