aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/junit/com/jogamp')
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java250
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/Test1.java151
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/Test1p1JavaEmitter.java107
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/Test1p2ProcAddressEmitter.java126
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg18
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg30
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1.c98
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1.h43
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg14
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1p2-gluegen.cfg36
10 files changed, 680 insertions, 193 deletions
diff --git a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java
new file mode 100644
index 0000000..457d96f
--- /dev/null
+++ b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.gluegen.test.junit;
+
+import com.sun.gluegen.runtime.BufferFactory;
+import com.sun.gluegen.runtime.PointerBuffer;
+import java.nio.*;
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URISyntaxException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static java.lang.System.*;
+import static com.jogamp.gluegen.test.junit.BuildEnvironment.*;
+
+/**
+ * @author Michael Bien
+ * @author Sven Gothel
+ */
+public class BaseTest1 {
+
+ /**
+ * Verifies the existence and creation of the generated class.
+ */
+ public void testClassExist(String name) throws Exception {
+ String ifName = "com.jogamp.gluegen.test.junit.Binding"+name;
+ String implName = "com.jogamp.gluegen.test.junit.impl.Binding"+name+"Impl";
+
+ Class<?> clazzIf = Class.forName(ifName);
+ Class<?> clazzImpl = Class.forName(implName);
+
+ Assert.assertNotNull(ifName+" does not exist", clazzIf);
+ Assert.assertNotNull(implName+" does not exist", clazzImpl);
+
+ Assert.assertEquals((int)1, clazzIf.getDeclaredField("CONSTANT_ONE").get(null));
+
+ Object obj = clazzImpl.newInstance();
+ Assert.assertTrue("Not of type "+ifName, clazzIf.isAssignableFrom(obj.getClass()));
+ Assert.assertTrue("Not of type com.jogamp.gluegen.test.junit.BindingTest1", (obj instanceof com.jogamp.gluegen.test.junit.BindingTest1));
+ }
+
+ /**
+ * Verifies if all generated method signatures are completed,
+ * ie a compilation only coverage test without functional tests.
+ */
+ public void chapter__TestCoverageSignature(BindingTest1 binding) throws Exception {
+ int i;
+ long result;
+ long context = 0;
+ ByteBuffer bb=null;
+ PointerBuffer pb=null;
+ LongBuffer lb=null;
+ long[] larray = null;
+ int array_offset = 0;
+ String str=null;
+ String[] strings = null;
+ IntBuffer ib = null;
+ int[] iarray = null;
+ int iarray_offset = 0;
+
+ result = binding.arrayTest(context, pb);
+ result = binding.arrayTest(context, larray, array_offset);
+ result = binding.arrayTestNioOnly(context, pb);
+
+ result = binding.bufferTest(bb);
+ result = binding.bufferTestNioOnly(bb);
+
+ result = binding.doubleTest(context, bb, pb, bb, pb);
+ result = binding.doubleTest(context, bb, larray, array_offset, bb, larray, array_offset);
+ result = binding.doubleTestNioOnly(context, bb, pb, bb, pb);
+
+ result = binding.mixedTest(context, bb, pb);
+ result = binding.mixedTest(context, bb, larray, array_offset);
+ result = binding.mixedTestNioOnly(context, bb, pb);
+
+ result = binding.nopTest();
+
+ i = binding.strToInt(str);
+ str = binding.intToStr(i);
+
+ i = binding.stringArrayRead(strings, i);
+
+ i = binding.intArrayRead(ib, i);
+ i = binding.intArrayRead(iarray, iarray_offset, i);
+
+ }
+
+ /**
+ * Verifies if all methods / signatures are properly generated,
+ * can be invoked and functions.
+ * This is a compilation (coverage) and runtime time (semantic) test.
+ * This covers indirect primitive arrays and direct NIO buffers.
+ */
+ public void chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(BindingTest1 binding) throws Exception {
+ int i;
+ long result;
+
+ long context = 1;
+ ByteBuffer bb1 = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_LONG);
+ LongBuffer bb1L = bb1.asLongBuffer();
+ bb1L.put(0, 10);
+
+ ByteBuffer bb2 = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_LONG);
+ LongBuffer bb2L = bb2.asLongBuffer();
+ bb2L.put(0, 100);
+
+ PointerBuffer pb1 = PointerBuffer.allocateDirect(BindingTest1.ARRAY_SIZE);
+ for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
+ pb1.put(i, 1000);
+ }
+ PointerBuffer pb2 = PointerBuffer.allocateDirect(BindingTest1.ARRAY_SIZE);
+ for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
+ pb2.put(i, 10000);
+ }
+
+ long[] larray1 = new long[BindingTest1.ARRAY_SIZE];
+ int array1_offset = 0;
+ for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
+ larray1[i]= 1000;
+ }
+
+ long[] larray2 = new long[BindingTest1.ARRAY_SIZE];
+ int array2_offset = 0;
+ for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
+ larray2[i]= 10000;
+ }
+
+ result = binding.arrayTest(context, pb1);
+ Assert.assertTrue("Wrong result: "+result, 1+8000==result);
+
+ result = binding.arrayTest(context, larray1, array1_offset);
+ Assert.assertTrue("Wrong result: "+result, 1+8000==result);
+
+ result = binding.arrayTestNioOnly(context, pb1);
+ Assert.assertTrue("Wrong result: "+result, 1+8000==result);
+
+ result = binding.bufferTest(bb1);
+ Assert.assertTrue("Wrong result: "+result, 10==result);
+
+ result = binding.bufferTestNioOnly(bb1);
+ Assert.assertTrue("Wrong result: "+result, 10==result);
+
+ result = binding.doubleTest(context, bb1, pb1, bb2, pb2);
+ Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result);
+
+ result = binding.doubleTest(context, bb1, larray1, array1_offset, bb2, larray2, array2_offset);
+ Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result);
+
+ result = binding.doubleTestNioOnly(context, bb1, pb1, bb2, pb2);
+ Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result);
+
+ result = binding.mixedTest(context, bb1, pb1);
+ Assert.assertTrue("Wrong result: "+result, 1+10+8000==result);
+
+ result = binding.mixedTest(context, bb1, larray1, array1_offset);
+ Assert.assertTrue("Wrong result: "+result, 1+10+8000==result);
+
+ result = binding.mixedTestNioOnly(context, bb1, pb1);
+ Assert.assertTrue("Wrong result: "+result, 1+10+8000==result);
+
+ result = binding.nopTest();
+ Assert.assertTrue("Wrong result: "+result, 42==result);
+
+ i = binding.strToInt("42");
+ Assert.assertTrue("Wrong result: "+i, 42==i);
+
+ String str = binding.intToStr(42);
+ Assert.assertTrue("Wrong result: "+str, str.equals("42"));
+
+ i = binding.stringArrayRead(new String[] { "1234", "5678", "9a" }, 3);
+ Assert.assertTrue("Wrong result: "+i, 10==i);
+
+ ByteBuffer bb3 = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_INT * 3);
+ IntBuffer ib = bb3.asIntBuffer();
+ ib.put(0, 1);
+ ib.put(1, 2);
+ ib.put(2, 3);
+
+ int[] iarray = new int[] { 1, 2, 3 };
+ int iarray_offset = 0;
+
+ i = binding.intArrayRead(ib, 3);
+ Assert.assertTrue("Wrong result: "+i, 6==i);
+
+ i = binding.intArrayRead(iarray, 0, 3);
+ Assert.assertTrue("Wrong result: "+i, 6==i);
+ }
+
+ /**
+ * This covers indirect primitive arrays and indirect NIO buffers.
+ */
+ public void chapter04TestSomeFunctionsAllIndirect(BindingTest1 binding) throws Exception {
+ int i;
+ long result;
+
+ IntBuffer ib = IntBuffer.allocate(3);
+ ib.put(0, 1);
+ ib.put(1, 2);
+ ib.put(2, 3);
+
+ int[] iarray = new int[] { 1, 2, 3 };
+ int iarray_offset = 0;
+
+ i = binding.intArrayRead(ib, 3);
+ Assert.assertTrue("Wrong result: "+i, 6==i);
+
+ i = binding.intArrayRead(iarray, 0, 3);
+ Assert.assertTrue("Wrong result: "+i, 6==i);
+ }
+
+}
diff --git a/src/junit/com/jogamp/gluegen/test/junit/Test1.java b/src/junit/com/jogamp/gluegen/test/junit/Test1.java
deleted file mode 100644
index 03fbaee..0000000
--- a/src/junit/com/jogamp/gluegen/test/junit/Test1.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name Sven Gothel or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package com.jogamp.gluegen.test.junit;
-
-import com.jogamp.gluegen.test.junit.impl.BindingTest1Impl;
-
-import com.sun.gluegen.runtime.BufferFactory;
-import com.sun.gluegen.runtime.PointerBuffer;
-import java.nio.*;
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URISyntaxException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static java.lang.System.*;
-import static com.jogamp.gluegen.test.junit.BuildEnvironment.*;
-
-/**
- * @author Michael Bien
- * @author Sven Gothel
- */
-public class Test1 {
-
- /**
- * Verifies loading of the new library.
- */
- @Test
- public void chapter01TestLoadLibrary() throws Exception {
- String nativesPath = testOutput + "/build/natives";
- System.load(nativesPath + "/libtest1.so");
- }
-
- /**
- * Verifies the existence and creation of the generated class.
- */
- @Test
- public void chapter01TestClassExist() throws Exception {
- Class<?> clazzIf = Class.forName("com.jogamp.gluegen.test.junit.BindingTest1");
- Class<?> clazzImpl = Class.forName("com.jogamp.gluegen.test.junit.impl.BindingTest1Impl");
-
- Assert.assertNotNull("com.jogamp.gluegen.test.junit.BindingTest1 does not exist", clazzIf);
- Assert.assertNotNull("com.jogamp.gluegen.test.junit.impl.BindingTest1Impl does not exist", clazzImpl);
-
- Assert.assertEquals((int)1, clazzIf.getDeclaredField("CONSTANT_ONE").get(null));
-
- Object obj = clazzImpl.newInstance();
- Assert.assertTrue("Not of type com.jogamp.gluegen.test.junit.BindingTest1", (obj instanceof com.jogamp.gluegen.test.junit.BindingTest1));
-
- BindingTest1 bindingTest1 = (BindingTest1) obj;
- Assert.assertTrue("nopTest1 failed", 42==bindingTest1.nopTest());
- }
-
- /**
- * Verifies if all methods / signatures are properly generated,
- * and can be invoked.
- * Gluegen Coverage test.
- * This is a compilation and runtime time test.
- */
- @Test
- public void chapter01TestCoverage() throws Exception {
- int dummy;
-
- int array_size = 10;
- long context = 0;
- ByteBuffer bb1 = BufferFactory.newDirectByteBuffer(PointerBuffer.elementSize() * array_size);
- ByteBuffer bb2 = BufferFactory.newDirectByteBuffer(PointerBuffer.elementSize() * array_size);
-
- PointerBuffer pb1 = PointerBuffer.allocateDirect(array_size);
- PointerBuffer pb2 = PointerBuffer.allocateDirect(array_size);
-
- long[] larray1 = new long[array_size];
- int array1_offset = 0;
-
- long[] larray2 = new long[array_size];
- int array2_offset = 0;
-
- BindingTest1 binding = new BindingTest1Impl();
-
- /** Interface to C language function: <br> <code> int arrayTest(long context, foo * array); </code> */
- dummy = binding.arrayTest(context, pb1);
- Assert.assertTrue(42==dummy);
-
- /** Interface to C language function: <br> <code> int arrayTest(long context, foo * array); </code> */
- dummy = binding.arrayTest(context, larray1, array1_offset);
- Assert.assertTrue(42==dummy);
-
- /** Interface to C language function: <br> <code> int bufferTest(void * object); </code> */
- dummy = binding.bufferTest(bb1);
- Assert.assertTrue(42==dummy);
-
- /** Interface to C language function: <br> <code> int doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2); </code> */
- dummy = binding.doubleTest(context, bb1, pb1, bb2, pb2);
- Assert.assertTrue(42==dummy);
-
- /** Interface to C language function: <br> <code> int doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2); </code> */
- dummy = binding.doubleTest(context, bb1, larray1, array1_offset, bb2, larray2, array2_offset);
- Assert.assertTrue(42==dummy);
-
- /** Interface to C language function: <br> <code> int mixedTest(long context, void * object, foo * array); </code> */
- dummy = binding.mixedTest(context, bb1, pb1);
- Assert.assertTrue(42==dummy);
-
- /** Interface to C language function: <br> <code> int mixedTest(long context, void * object, foo * array); </code> */
- dummy = binding.mixedTest(context, bb1, larray1, array1_offset);
- Assert.assertTrue(42==dummy);
-
- /** Interface to C language function: <br> <code> int nopTest(); </code> */
- dummy = binding.nopTest();
- Assert.assertTrue(42==dummy);
- }
-
-}
diff --git a/src/junit/com/jogamp/gluegen/test/junit/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/Test1p1JavaEmitter.java
new file mode 100644
index 0000000..1edb70e
--- /dev/null
+++ b/src/junit/com/jogamp/gluegen/test/junit/Test1p1JavaEmitter.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.gluegen.test.junit;
+
+import com.jogamp.gluegen.test.junit.impl.BindingTest1p1Impl;
+
+import com.sun.gluegen.runtime.BufferFactory;
+import com.sun.gluegen.runtime.PointerBuffer;
+import java.nio.*;
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URISyntaxException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static java.lang.System.*;
+import static com.jogamp.gluegen.test.junit.BuildEnvironment.*;
+
+/**
+ * @author Michael Bien
+ * @author Sven Gothel
+ */
+public class Test1p1JavaEmitter extends BaseTest1 {
+
+ /**
+ * Verifies loading of the new library.
+ */
+ @Test
+ public void chapter01TestLoadLibrary() throws Exception {
+ String nativesPath = testOutput + "/build/natives";
+ System.load(nativesPath + "/libtest1p1.so");
+ }
+
+ /**
+ * Verifies the existence and creation of the generated class.
+ */
+ @Test
+ public void chapter02TestClassExist() throws Exception {
+ testClassExist("Test1p1");
+ }
+
+ /**
+ * Verifies if all generated method signatures are completed,
+ * ie a compilation only coverage test without functional tests.
+ */
+ public void chapter__TestCoverageSignature() throws Exception {
+ chapter__TestCoverageSignature(new BindingTest1p1Impl());
+ }
+
+ /**
+ * Verifies if all methods / signatures are properly generated,
+ * can be invoked and functions.
+ * This is a compilation (coverage) and runtime time (semantic) test.
+ * This covers indirect primitive arrays and direct NIO buffers.
+ */
+ @Test
+ public void chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception {
+ chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(new BindingTest1p1Impl());
+ }
+
+ /**
+ * This covers indirect primitive arrays and indirect NIO buffers.
+ */
+ @Test
+ public void chapter04TestSomeFunctionsAllIndirect() throws Exception {
+ chapter04TestSomeFunctionsAllIndirect(new BindingTest1p1Impl());
+ }
+
+}
diff --git a/src/junit/com/jogamp/gluegen/test/junit/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/Test1p2ProcAddressEmitter.java
new file mode 100644
index 0000000..63d41f3
--- /dev/null
+++ b/src/junit/com/jogamp/gluegen/test/junit/Test1p2ProcAddressEmitter.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.gluegen.test.junit;
+
+import com.jogamp.gluegen.test.junit.impl.BindingTest1p2Impl;
+
+import com.sun.gluegen.runtime.BufferFactory;
+import com.sun.gluegen.runtime.PointerBuffer;
+import com.sun.gluegen.runtime.NativeLibrary;
+import com.sun.gluegen.runtime.DynamicLookupHelper;
+import java.nio.*;
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URISyntaxException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static java.lang.System.*;
+import static com.jogamp.gluegen.test.junit.BuildEnvironment.*;
+
+/**
+ * @author Michael Bien
+ * @author Sven Gothel
+ */
+public class Test1p2ProcAddressEmitter extends BaseTest1 {
+
+ DynamicLookupHelper dynamicLookupHelper;
+
+ /**
+ * Verifies loading of the new library.
+ */
+ @Test
+ public void chapter01TestLoadLibrary() throws Exception {
+ System.loadLibrary("test1p2");
+ dynamicLookupHelper = NativeLibrary.open("test1p2", getClass().getClassLoader(), true);
+ Assert.assertNotNull("NativeLibrary.open(test1p2) failed", dynamicLookupHelper);
+
+ BindingTest1p2Impl.resetProcAddressTable(dynamicLookupHelper);
+ }
+
+ /**
+ * Verifies the existence and creation of the generated class.
+ */
+ @Test
+ public void chapter02TestClassExist() throws Exception {
+ testClassExist("Test1p2");
+ }
+
+ /**
+ * Verifies if all generated method signatures are completed,
+ * ie a compilation only coverage test without functional tests.
+ */
+ public void chapter__TestCoverageSignature() throws Exception {
+ chapter__TestCoverageSignature(new BindingTest1p2Impl());
+ }
+
+ /**
+ * Verifies if all methods / signatures are properly generated,
+ * can be invoked and functions.
+ * This is a compilation (coverage) and runtime time (semantic) test.
+ * This covers indirect primitive arrays and direct NIO buffers.
+ */
+ @Test
+ public void chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception {
+ chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(new BindingTest1p2Impl());
+ }
+
+ /**
+ * This covers indirect primitive arrays and indirect NIO buffers.
+ */
+ @Test
+ public void chapter04TestSomeFunctionsAllIndirect() throws Exception {
+ chapter04TestSomeFunctionsAllIndirect(new BindingTest1p2Impl());
+ }
+
+ public static void main(String[] args) {
+ Test1p2ProcAddressEmitter test = new Test1p2ProcAddressEmitter();
+ try {
+ test.chapter01TestLoadLibrary();
+ test.chapter02TestClassExist();
+ test.chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray();
+ test.chapter04TestSomeFunctionsAllIndirect();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg
new file mode 100644
index 0000000..d775424
--- /dev/null
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg
@@ -0,0 +1,18 @@
+
+NIODirectOnly arrayTestNioOnly
+NIODirectOnly bufferTestNioOnly
+NIODirectOnly mixedTestNioOnly
+NIODirectOnly doubleTestNioOnly
+
+ReturnsString intToStr
+ArgumentIsString strToInt 0
+ArgumentIsString stringArrayRead 0
+
+CustomCCode #include "test1.h"
+
+# Imports needed by all glue code
+Import java.nio.*
+Import java.util.*
+
+
+
diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg
index 291e6cc..9d0f856 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1-gluegen.cfg
@@ -1,35 +1,9 @@
Package com.jogamp.gluegen.test.junit
JavaClass BindingTest1
-Style InterfaceAndImpl
+Style InterfaceOnly
JavaOutputDir classes
-NativeOutputDir native
-# Use a ProcAddressTable so we dynamically look up the routines
-#ProcAddressNameExpr PFN $UPPERCASE({0}) PROC
-#EmitProcAddressTable true
-#ProcAddressTableClassName BindingTest1ProcAddressTable
-#GetProcAddressTableExpr _table
+Include test1-common.cfg
-# Force all of the methods to be emitted using dynamic linking so we
-# don't need to link against any emulation library on the desktop or
-# depend on the presence of an import library for a particular device
-#ForceProcAddressGen __ALL__
-
-# Also force the calling conventions of the locally generated function
-# pointer typedefs for these routines to MYAPIENTRY
-#LocalProcAddressCallingConvention __ALL__ MYAPIENTRY
-
-#EmitProcAddressTable true
-#ProcAddressTableClassName CLProcAddressTable
-#GetProcAddressTableExpr addressTable
-#ProcAddressNameExpr $UpperCase(arg)
-#ForceProcAddressGen clGetGLContextInfoKHR
-
-CustomCCode #include "test1.h"
-
-# Imports needed by all glue code
-Import java.nio.*
-Import java.util.*
-Import com.jogamp.gluegen.test.junit.BindingTest1
diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.c b/src/junit/com/jogamp/gluegen/test/junit/test1.c
index 6b63f90..31c5f40 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1.c
@@ -1,21 +1,101 @@
#include "test1.h"
+#include <assert.h>
+#include <stdlib.h>
-int nopTest() {
+foo nopTest() {
return 42;
}
-int arrayTest(long context, foo * array) {
- return 42;
+foo arrayTest(long context, foo * array) {
+ foo r=0;
+ int i;
+ assert(NULL!=array);
+ // printf("array test - %p\n", array);
+ for(i=0; i<ARRAY_SIZE; i++) {
+ r+=array[i];
+ }
+ return r+context;
}
-int bufferTest(void * object) {
- return 42;
+foo bufferTest(void * object) {
+ assert(NULL!=object);
+ return *((foo *)object);
}
-int mixedTest(long context, void * object, foo * array){
- return 42;
+foo mixedTest(long context, void * object, foo * array){
+ assert(NULL!=object);
+ assert(NULL!=array);
+ return arrayTest(context, array) + bufferTest(object);
}
-int doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2) {
- return 42;
+foo doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2) {
+ assert(NULL!=object1);
+ assert(NULL!=array1);
+ assert(NULL!=object2);
+ assert(NULL!=array2);
+ return arrayTest(context, array1) +
+ arrayTest( 0, array2) +
+ bufferTest(object1) +
+ bufferTest(object2);
+}
+
+foo arrayTestNioOnly(long context, foo * array ) {
+ return arrayTest(context, array);
+}
+
+foo bufferTestNioOnly(void * object) {
+ return bufferTest(object);
+}
+
+foo mixedTestNioOnly(long context, void * object, foo * array ) {
+ return mixedTest(context, object, array);
+}
+
+foo doubleTestNioOnly(long context, void * object1, foo * array1, void * object2, foo * array2 ) {
+ return doubleTest(context, object1, array1, object2, array2);
+}
+
+int strToInt(const char * str) {
+ return atoi(str);
}
+
+const char * intToStr(int i) {
+ static char singleton[200];
+ snprintf(singleton, sizeof(singleton)-1, "%d", i);
+ return singleton;
+}
+
+int stringArrayRead(const char * * strings, int num) {
+ int i=0, l=0;
+ if(NULL!=strings) {
+ for(i=0; i<num; i++) {
+ if(NULL!=strings[i]) {
+ l+=strlen(strings[i]);
+ }
+ }
+ }
+ return l;
+}
+
+int intArrayRead(const int * ints, int num) {
+ int i=0, s=0;
+ if(NULL!=ints) {
+ for(i=0; i<num; i++) {
+ s+=ints[i];
+ }
+ }
+ return s;
+}
+
+/**
+int intArrayWrite(int * * ints, int num) {
+ int i=0, s=0;
+ if(NULL!=ints) {
+ for(i=0; i<num; i++) {
+ *(ints[i]) = *(ints[i]) + 1;
+ s+=*(ints[i]);
+ }
+ }
+ return s;
+} */
+
diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.h b/src/junit/com/jogamp/gluegen/test/junit/test1.h
index 776bc0a..38b4911 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1.h
@@ -9,16 +9,49 @@
#define MYAPI
#define CONSTANT_ONE 1
+#define ARRAY_SIZE 8
typedef unsigned long foo;
-MYAPI int MYAPIENTRY nopTest();
+/** Returns 42 */
+MYAPI foo MYAPIENTRY nopTest();
-MYAPI int MYAPIENTRY arrayTest(long context, foo * array );
+/** Returns Sum(array) + context */
+MYAPI foo MYAPIENTRY arrayTest(long context, foo * array );
-MYAPI int MYAPIENTRY bufferTest(void * object);
+/** Returns *((foo *)object) */
+MYAPI foo MYAPIENTRY bufferTest(void * object);
-MYAPI int MYAPIENTRY mixedTest(long context, void * object, foo * array );
+/** Returns Sum(array) + context + *((foo *)object) */
+MYAPI foo MYAPIENTRY mixedTest(long context, void * object, foo * array );
-MYAPI int MYAPIENTRY doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2 );
+/** Returns Sum(array1) + Sum(array2) + context + *((foo *)object1) + *((foo *)object2) */
+MYAPI foo MYAPIENTRY doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2 );
+
+/** Returns Sum(array) + context */
+MYAPI foo MYAPIENTRY arrayTestNioOnly(long context, foo * array );
+
+/** Returns *((foo *)object) */
+MYAPI foo MYAPIENTRY bufferTestNioOnly(void * object);
+
+/** Returns Sum(array) + context + *((foo *)object) */
+MYAPI foo MYAPIENTRY mixedTestNioOnly(long context, void * object, foo * array );
+
+/** Returns Sum(array1) + Sum(array2) + context + *((foo *)object1) + *((foo *)object2) */
+MYAPI foo MYAPIENTRY doubleTestNioOnly(long context, void * object1, foo * array1, void * object2, foo * array2 );
+
+/** Returns atoi(str) */
+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 */
+MYAPI int MYAPIENTRY stringArrayRead(const char * * strings, int num);
+
+/** Returns the sum of all integers */
+MYAPI int MYAPIENTRY intArrayRead(const int * ints, int num);
+
+/** Increases the elements by 1, and returns the sum
+MYAPI int MYAPIENTRY intArrayWrite(int * * ints, int num); */
diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg
new file mode 100644
index 0000000..78e4d8a
--- /dev/null
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1p1-gluegen.cfg
@@ -0,0 +1,14 @@
+Package com.jogamp.gluegen.test.junit
+JavaClass BindingTest1p1
+Style InterfaceAndImpl
+JavaOutputDir classes
+NativeOutputDir native
+
+Extends BindingTest1p1 BindingTest1
+
+Include test1-common.cfg
+
+Import com.jogamp.gluegen.test.junit.BindingTest1
+Import com.jogamp.gluegen.test.junit.BindingTest1p1
+
+
diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1p2-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1p2-gluegen.cfg
new file mode 100644
index 0000000..c0a63b4
--- /dev/null
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1p2-gluegen.cfg
@@ -0,0 +1,36 @@
+Package com.jogamp.gluegen.test.junit
+JavaClass BindingTest1p2
+Style InterfaceAndImpl
+JavaOutputDir classes
+NativeOutputDir native
+
+Extends BindingTest1p2 BindingTest1
+
+# Use a ProcAddressTable so we dynamically look up the routines
+EmitProcAddressTable true
+ProcAddressTableClassName BindingTest1p2ProcAddressTable
+GetProcAddressTableExpr _table
+ProcAddressNameExpr PFN $UPPERCASE({0}) PROC
+
+# Force all of the methods to be emitted using dynamic linking so we
+# don't need to link against any emulation library on the desktop or
+# depend on the presence of an import library for a particular device
+ForceProcAddressGen __ALL__
+
+# Also force the calling conventions of the locally generated function
+# pointer typedefs for these routines to MYAPIENTRY
+LocalProcAddressCallingConvention __ALL__ MYAPIENTRY
+
+Include test1-common.cfg
+Include ../../../../../../../make/config/intptr.cfg
+
+Import com.jogamp.gluegen.test.junit.BindingTest1
+Import com.jogamp.gluegen.test.junit.BindingTest1p2
+Import com.sun.gluegen.runtime.*
+
+CustomJavaCode BindingTest1p2Impl private static BindingTest1p2ProcAddressTable _table = new BindingTest1p2ProcAddressTable();
+CustomJavaCode BindingTest1p2Impl public static void resetProcAddressTable(DynamicLookupHelper lookup) {
+CustomJavaCode BindingTest1p2Impl ProcAddressHelper.resetProcAddressTable(_table, lookup);
+CustomJavaCode BindingTest1p2Impl }
+
+