diff options
author | Sven Gothel <[email protected]> | 2012-03-22 17:00:26 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-03-22 17:00:26 +0100 |
commit | 3d527ea538c9e9897f86a0f6bdae0cab44d239c3 (patch) | |
tree | 7500881a0bff25538e69d4a4f6c5fab3ee228d71 /src/junit/com/jogamp | |
parent | cda1f9f66528cd7e16dc807840d927fd452e1dd6 (diff) |
Fix 'NIOOnly' impl ; Use 'final' in gen. Java stubs ;
- Fix 'NIOOnly' impl
- Use 'final' in gen. Java stubs ;
- No null check for Buffers.isDirect(arrayArg) [required]
- Clarify Buffer arg API doc (NIOOnly or NIODirectOnly)
- cleaned up loop / branch (CMethodBindingEmitter)
- remove unsued vars/code
- Tests:
- covers normal/NIOOnly/NIODirectOnly
- covers passing null for array and NIO
Diffstat (limited to 'src/junit/com/jogamp')
4 files changed, 38 insertions, 17 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 8d9c73a..8dff4be 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -466,29 +466,30 @@ public class BaseClass extends JunitTracer { result = binding.bufferTest(lb); Assert.assertTrue("Wrong result: "+result, 10==result); + result = binding.bufferTestNioOnly(lb); + Assert.assertTrue("Wrong result: "+result, 10==result); + if(direct) { - result = binding.bufferTestNioOnly(lb); + result = binding.bufferTestNioDirectOnly(lb); Assert.assertTrue("Wrong result: "+result, 10==result); } else { Exception e = null; try { - binding.bufferTestNioOnly(lb); + binding.bufferTestNioDirectOnly(lb); } catch (RuntimeException re) { e = re; } Assert.assertNotNull(e); } - + result = binding.doubleTest(context, lb, lb1, bb2, lb2); Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); result = binding.doubleTest(context, lb, larray1, larray1_offset, bb2, larray2, larray2_offset); Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); - if(direct) { - result = binding.doubleTestNioOnly(context, lb, lb1, bb2, lb2); - Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); - } + result = binding.doubleTestNioOnly(context, lb, lb1, bb2, lb2); + Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); result = binding.mixedTest(context, lb, lb1); Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); @@ -496,10 +497,8 @@ public class BaseClass extends JunitTracer { result = binding.mixedTest(context, lb, larray1, larray1_offset); Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); - if(direct) { - result = binding.mixedTestNioOnly(context, lb, lb1); - Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); - } + result = binding.mixedTestNioOnly(context, lb, lb1); + Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); result = binding.nopTest(); Assert.assertTrue("Wrong result: "+result, 42==result); @@ -513,6 +512,9 @@ public class BaseClass extends JunitTracer { i = binding.stringArrayRead(new String[] { "1234", "5678", "9a" }, 3); Assert.assertTrue("Wrong result: "+i, 10==i); + i = binding.stringArrayRead(null, 0); + Assert.assertTrue("Wrong result: "+i, 0==i); + IntBuffer ib = newIntBuffer(3, direct); ib.put(0, 1); ib.put(1, 2); @@ -523,9 +525,15 @@ public class BaseClass extends JunitTracer { i = binding.intArrayRead(ib, 3); Assert.assertTrue("Wrong result: "+i, 6==i); + i = binding.intArrayRead(null, 0); + Assert.assertTrue("Wrong result: "+i, 0==i); + i = binding.intArrayRead(iarray, 0, 3); Assert.assertTrue("Wrong result: "+i, 6==i); + i = binding.intArrayRead(null, 0, 0); + Assert.assertTrue("Wrong result: "+i, 0==i); + { long cfg_base = 0xAABBCCDD11223344L; diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg index 17890eb..490bf2d 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg @@ -1,8 +1,9 @@ -NIODirectOnly arrayTestNioOnly -NIODirectOnly bufferTestNioOnly -NIODirectOnly mixedTestNioOnly -NIODirectOnly doubleTestNioOnly +NIOOnly arrayTestFooNioOnly +NIOOnly bufferTestNioOnly +NIODirectOnly bufferTestNioDirectOnly +NIOOnly mixedTestNioOnly +NIOOnly doubleTestNioOnly ReturnsString intToStr ArgumentIsString strToInt 0 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 ebb1e08..1adf824 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c @@ -59,6 +59,7 @@ MYAPI void MYAPIENTRY arrayTestFoo3( foo * array ) { MYAPI foo * * MYAPIENTRY arrayTestFoo3ArrayToPtrPtr(const foo * array) { int j; foo * * result = calloc(ARRAY_SIZE, sizeof(foo *)); + assert(NULL!=array); for(j=0; j<ARRAY_SIZE; j++) { result[j] = (foo *) ( array + ARRAY_SIZE * j ) ; } @@ -143,6 +144,10 @@ MYAPI foo MYAPIENTRY bufferTestNioOnly(void * object) { return bufferTest(object); } +MYAPI foo MYAPIENTRY bufferTestNioDirectOnly(void * object) { + return bufferTest(object); +} + MYAPI foo MYAPIENTRY mixedTestNioOnly(int64_t context, void * object, foo * array ) { return mixedTest(context, object, array); } @@ -286,12 +291,14 @@ MYAPI TK_Surface * MYAPIENTRY createSurface() { } MYAPI void MYAPIENTRY destroySurface(TK_Surface * surface) { + assert(NULL!=surface); free(surface->clips); // free(surface->engine); free(surface); } static void dumpTK_ComplicatedSuperSet(TK_ComplicatedSuperSet * s) { + assert(NULL!=s); fprintf(stderr, "TK_ComplicatedSuperSet [\n"); fprintf(stderr, " cs.b1 0x%X\n", s->bits1); @@ -382,6 +389,7 @@ MYAPI TK_ComplicatedSuperSet * MYAPIENTRY createComplicatedSuperSet() { } MYAPI Bool MYAPIENTRY hasInitValues(TK_ComplicatedSuperSet * s) { + assert(NULL!=s); Bool b = s->bits1 == 0xA0U && s->sub1.bits1 == 0xA1U && s->sub1.id == 0x12345678U && @@ -415,6 +423,7 @@ MYAPI Bool MYAPIENTRY hasInitValues(TK_ComplicatedSuperSet * s) { } MYAPI void MYAPIENTRY destroyComplicatedSuperSet(TK_ComplicatedSuperSet * s) { + assert(NULL!=s); free(s); } 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 76a15f2..de57b66 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h @@ -74,6 +74,9 @@ MYAPI foo MYAPIENTRY arrayTestFooNioOnly(int64_t context, foo * array ); /** Returns *((foo *)object) */ MYAPI foo MYAPIENTRY bufferTestNioOnly(void * object); +/** Returns *((foo *)object) */ +MYAPI foo MYAPIENTRY bufferTestNioDirectOnly(void * object); + /** Returns Sum(array) + context + *((foo *)object) */ MYAPI foo MYAPIENTRY mixedTestNioOnly(int64_t context, void * object, foo * array ); @@ -86,10 +89,10 @@ MYAPI int MYAPIENTRY strToInt(const char* str); /** Returns itoa(i) - not thread safe */ MYAPI const char * MYAPIENTRY intToStr(int i); -/** Returns the length of all strings */ +/** Returns the length of all strings, strings maybe NULL. */ MYAPI int MYAPIENTRY stringArrayRead(const char * * strings, int num); -/** Returns the sum of all integers */ +/** Returns the sum of all integers, ints maybe NULL. */ MYAPI int MYAPIENTRY intArrayRead(const int * ints, int num); /** Increases the elements by 1, and returns the sum |