summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--make/build.xml2
-rw-r--r--make/jogamp-archivetasks.xml2
-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
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java26
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.c12
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h3
9 files changed, 71 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 378eac2..f29c6a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
build
+make/GnuCTreeParserTokenTypes.txt
+make/STDCTokenTypes.txt
diff --git a/make/build.xml b/make/build.xml
index 1fb5987..d835f8b 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -72,7 +72,7 @@
</exec>
<exec dir="." executable="sed" logError="true" failonerror="false" failifexecutionfails="false"
outputproperty="gluegen.build.branch">
- <arg line="-e '/^[^*]/d' -e 's/* \(.*\)/\1/' ${build}/localbranch.raw"/>
+ <arg line="-e '/^[^*]/d' -e 's/* \(.*\)/\1/' '${build}/localbranch.raw'"/>
</exec>
<property name="gluegen.build.branch" value="manual"/> <!-- fallback -->
<exec dir="${project.root}" executable="git" logError="true" failonerror="false" failifexecutionfails="false"
diff --git a/make/jogamp-archivetasks.xml b/make/jogamp-archivetasks.xml
index 24309d8..0734f90 100644
--- a/make/jogamp-archivetasks.xml
+++ b/make/jogamp-archivetasks.xml
@@ -21,7 +21,7 @@
spawn="false"
failifexecutionfails="true"
failonerror="true">
- <arg line="a -r ${destfile.path} @{includes}"/>
+ <arg line="a -r '${destfile.path}' @{includes}"/>
</exec>
</sequential>
</macrodef>
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();
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
index f22b1df..a97430a 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -155,6 +155,8 @@ public class BaseClass extends JunitTracer {
i = binding.stringArrayRead(strings, i);
+ i = binding.binaryArrayRead(pb, pb, 0);
+
i = binding.intArrayRead(ib, i);
i = binding.intArrayRead(iarray, iarray_offset, i);
@@ -557,6 +559,30 @@ public class BaseClass extends JunitTracer {
i = binding.stringArrayRead(null, 0);
Assert.assertTrue("Wrong result: "+i, 0==i);
+ {
+ // one 0xff in each byte array
+ // the referenced buffer must be direct, non direct is not supported
+ ByteBuffer bbB = Buffers.newDirectByteBuffer(new byte [] {(byte)0xaa, (byte)0xff, (byte)0xba, (byte)0xbe});
+ bbB.rewind();
+ PointerBuffer pbB = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct);
+ PointerBuffer pbL = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct);
+ for(int j=0; j<Bindingtest1.ARRAY_SIZE; j++) {
+ pbB.referenceBuffer(bbB);
+ pbL.put(bbB.capacity());
+ }
+ pbB.rewind();
+ pbL.rewind();
+ validatePointerBuffer(pbB, Bindingtest1.ARRAY_SIZE);
+ Assert.assertNotNull(pbB.getReferencedBuffer(0));
+ Assert.assertTrue("Wrong result: "+pbB.getReferencedBuffer(0)+" != "+bbB, pbB.getReferencedBuffer(0).equals(bbB));
+ validatePointerBuffer(pbL, Bindingtest1.ARRAY_SIZE);
+ long temp = pbL.get();
+ Assert.assertTrue("Wrong result: "+temp, temp==bbB.capacity());
+ pbL.rewind();
+ i = binding.binaryArrayRead(pbL, pbB, Bindingtest1.ARRAY_SIZE);
+ Assert.assertTrue("Wrong result: "+i, Bindingtest1.ARRAY_SIZE==i);
+ }
+
IntBuffer ib = newIntBuffer(3, direct);
ib.put(0, 1);
ib.put(1, 2);
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
index 31307a9..fda37f7 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -236,6 +236,18 @@ MYAPI int MYAPIENTRY stringArrayRead(const char * * strings, int num) {
return l;
}
+MYAPI int MYAPIENTRY binaryArrayRead(const size_t * lengths, const unsigned char * * binaries, int num) {
+ int i, j, n=0;
+ for(i=0; i<num; i++) {
+ for(j=0; j<lengths[i]; j++) {
+ if(0xff==binaries[i][j]) {
+ ++n;
+ }
+ }
+ }
+ return n;
+}
+
MYAPI int MYAPIENTRY intArrayRead(const int * ints, int num) {
int i=0, s=0;
if(NULL!=ints) {
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
index 555a113..b6b6fd3 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -119,6 +119,9 @@ MYAPI const char * MYAPIENTRY intToStr(int i);
/** Returns the length of all strings, strings maybe NULL. */
MYAPI int MYAPIENTRY stringArrayRead(const char * * strings, int num);
+/** Returns the number of 0xff bytes found in all binaries. */
+MYAPI int MYAPIENTRY binaryArrayRead(const size_t * lengths, const unsigned char * * binaries, int num);
+
/** Returns the sum of all integers, ints maybe NULL. */
MYAPI int MYAPIENTRY intArrayRead(const int * ints, int num);