diff options
author | Wade Walker <[email protected]> | 2014-03-04 15:21:35 -0600 |
---|---|---|
committer | Wade Walker <[email protected]> | 2014-03-04 15:21:35 -0600 |
commit | 86c868fcb78b53f02ad2bae1770e4db61b892678 (patch) | |
tree | b1cc5d86954338f5449b39412f74115552495db5 /src/junit/com/jogamp/gluegen/test | |
parent | 15ea21ea190a79a3740b66698103ef5b4f145e94 (diff) |
Remove warnings in emitted C code.
Fix 1: Only emit "int * _offsetHandle = NULL" if it will be used, to
avoid unused variable warning. Fix 2: Add "unsigned" to typecasts in C
function calls when needed to avoid implicit typecast warning. This
commit also adds a unit test for a method that uses an "unsigned char
**" parameter, to mimic the JOCL clCreateProgramWithBinary() function
that caused the typecast warnings.
Diffstat (limited to 'src/junit/com/jogamp/gluegen/test')
3 files changed, 41 insertions, 0 deletions
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..f0db24b 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..c1fe41e 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); |