aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/junit/com')
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java21
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass4JavaCallback.java8
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java13
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java13
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java4
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg3
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.c11
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h3
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test2-CustomJavaImplCode.java.stub4
9 files changed, 57 insertions, 23 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 dc49475..a236e85 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2010-2023 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
@@ -48,10 +48,6 @@ import jogamp.common.os.MachineDataInfoRuntime;
import org.junit.Assert;
-/**
- * @author Michael Bien
- * @author Sven Gothel
- */
public class BaseClass extends SingletonJunitCase {
static {
@@ -214,6 +210,8 @@ public class BaseClass extends SingletonJunitCase {
l = binding.typeTestPtrDiffT(l, l);
l = binding.typeTestIntPtrT(l, l);
l = binding.typeTestUIntPtrT(l, l);
+
+ i = binding.addStrlenAndPascalStrLen("lala");
}
/**
@@ -2523,7 +2521,7 @@ public class BaseClass extends SingletonJunitCase {
binding.destroyTKFieldImmutable(model);
}
- public void chapter15TestTKMixed(final Bindingtest1 binding) throws Exception {
+ public void chapter14TestTKMixed(final Bindingtest1 binding) throws Exception {
Assert.assertEquals(false, TK_ModelMixed.usesNativeCode());
final TK_ModelMixed model = binding.createTKModelMixed();
@@ -2568,7 +2566,16 @@ public class BaseClass extends SingletonJunitCase {
assertAPTR(surfaceContext, model.getCtx());
}
- public void chapter14TestCustomJNICode(final Bindingtest1 binding) throws Exception {
+ public void chapter15TestCustomJNICode(final Bindingtest1 binding) throws Exception {
Assert.assertEquals(Bindingtest1.FOO_VALUE, binding.getFoo());
}
+
+ public void chapter16TestPascalString(final Bindingtest1 binding) throws Exception {
+ Assert.assertEquals(false, TK_ModelMixed.usesNativeCode());
+ Assert.assertEquals( 2, binding.addStrlenAndPascalStrLen("1"));
+ Assert.assertEquals( 8, binding.addStrlenAndPascalStrLen("1234"));
+ Assert.assertEquals(10, binding.addStrlenAndPascalStrLen("12345"));
+ Assert.assertEquals( 0, binding.addStrlenAndPascalStrLen(null));
+ }
+
}
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass4JavaCallback.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass4JavaCallback.java
index cab8a9c..0838e72 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass4JavaCallback.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass4JavaCallback.java
@@ -898,7 +898,7 @@ public class BaseClass4JavaCallback extends BaseClass {
final String[] msg_res = { null };
final ALEVENTPROCSOFT myCallback01 = new ALEVENTPROCSOFT() {
@Override
- public void callback(final int eventType, final int object, final int param, final int length, final String message, final ALCcontext context) {
+ public void callback(final int eventType, final int object, final int param, final String message, final ALCcontext context) {
id_res[0] = object;
msg_res[0] = message;
System.err.println("chapter05a.myCallback01: type "+eventType+", obj "+object+", param "+param+", '"+message+"', userParam 0x"+
@@ -907,7 +907,7 @@ public class BaseClass4JavaCallback extends BaseClass {
};
final ALEVENTPROCSOFT myCallback02 = new ALEVENTPROCSOFT() {
@Override
- public void callback(final int eventType, final int object, final int param, final int length, final String message, final ALCcontext context) {
+ public void callback(final int eventType, final int object, final int param, final String message, final ALCcontext context) {
id_res[0] = 1000 * object;
msg_res[0] = message;
System.err.println("chapter05a.myCallback02: type "+eventType+", obj "+object+", param "+param+", '"+message+"', userParam 0x"+
@@ -1018,7 +1018,7 @@ public class BaseClass4JavaCallback extends BaseClass {
final String[] msg_res = { null };
final ALEVENTPROCSOFT myCallback01 = new ALEVENTPROCSOFT() {
@Override
- public void callback(final int eventType, final int object, final int param, final int length, final String message, final ALCcontext context) {
+ public void callback(final int eventType, final int object, final int param, final String message, final ALCcontext context) {
id_res[0] = object;
msg_res[0] = message;
System.err.println("chapter05.myCallback01: type "+eventType+", obj "+object+", param "+param+", '"+message+"', userParam 0x"+
@@ -1027,7 +1027,7 @@ public class BaseClass4JavaCallback extends BaseClass {
};
final ALEVENTPROCSOFT myCallback02 = new ALEVENTPROCSOFT() {
@Override
- public void callback(final int eventType, final int object, final int param, final int length, final String message, final ALCcontext context) {
+ public void callback(final int eventType, final int object, final int param, final String message, final ALCcontext context) {
id_res[0] = 1000 * object;
msg_res[0] = message;
System.err.println("chapter05.myCallback02: type "+eventType+", obj "+object+", param "+param+", '"+message+"', userParam 0x"+
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
index c7c5644..f92aef3 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
@@ -161,16 +161,21 @@ public class Test1p1JavaEmitter extends BaseClass {
}
@Test
- public void chapter15TestTKMixed() throws Exception {
- chapter15TestTKMixed(new Bindingtest1p1Impl());
+ public void chapter14TestTKMixed() throws Exception {
+ chapter14TestTKMixed(new Bindingtest1p1Impl());
}
/**
* Test Custom JNI Code invocation
*/
@Test
- public void chapter14TestCustomJNICode() throws Exception {
- chapter14TestCustomJNICode(new Bindingtest1p1Impl());
+ public void chapter15TestCustomJNICode() throws Exception {
+ chapter15TestCustomJNICode(new Bindingtest1p1Impl());
+ }
+
+ @Test
+ public void chapter16TestPascalString() throws Exception {
+ chapter16TestPascalString(new Bindingtest1p1Impl());
}
public static void main(final String args[]) throws IOException {
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java
index fbf0ff0..4e5b268 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java
@@ -171,16 +171,21 @@ public class Test1p2DynamicLibraryBundle extends BaseClass {
}
@Test
- public void chapter15TestTKMixed() throws Exception {
- chapter15TestTKMixed(new Bindingtest1p2Impl());
+ public void chapter14TestTKMixed() throws Exception {
+ chapter14TestTKMixed(new Bindingtest1p2Impl());
}
/**
* Test Custom JNI Code invocation
*/
@Test
- public void chapter14TestCustomJNICode() throws Exception {
- chapter14TestCustomJNICode(new Bindingtest1p2Impl());
+ public void chapter15TestCustomJNICode() throws Exception {
+ chapter15TestCustomJNICode(new Bindingtest1p2Impl());
+ }
+
+ @Test
+ public void chapter16TestPascalString() throws Exception {
+ chapter16TestPascalString(new Bindingtest1p2Impl());
}
/**
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
index b2c1974..22db353 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
@@ -172,7 +172,7 @@ public class Test1p2ProcAddressEmitter extends BaseClass {
@Test
public void chapter15TestTKMixed() throws Exception {
- chapter15TestTKMixed(new Bindingtest1p2Impl());
+ chapter14TestTKMixed(new Bindingtest1p2Impl());
}
/**
@@ -180,7 +180,7 @@ public class Test1p2ProcAddressEmitter extends BaseClass {
*/
@Test
public void chapter14TestCustomJNICode() throws Exception {
- chapter14TestCustomJNICode(new Bindingtest1p2Impl());
+ chapter15TestCustomJNICode(new Bindingtest1p2Impl());
}
/**
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 05bed70..7111f77 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
@@ -369,6 +369,9 @@ ReturnValueCapacity createTKStructImmutable sizeof(TK_StructImmutable)
ReturnValueCapacity createTKField sizeof(TK_Field)
ReturnValueCapacity createTKModelMixed sizeof(TK_ModelMixed)
+# MYAPI int addStrlenAndPascalStrLen(int length, const char* val);
+ArgumentIsPascalString addStrlenAndPascalStrLen 0 1
+
# Imports needed by all glue code
Import java.nio.*
Import java.util.*
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 c5ea388..07763b9 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -1056,3 +1056,14 @@ MYAPI void MYAPIENTRY destroyTKModelMixed(TK_ModelMixed * s) {
free(s);
}
+MYAPI int addStrlenAndPascalStrLen(int length, const char* val) {
+ if( NULL == val ) {
+ fprintf(stderr, "addStrlenAndPascalStrLen: %d + %d of NULL\n", 0, length);
+ return length;
+ } else {
+ int len2 = (int)strlen(val);
+ fprintf(stderr, "addStrlenAndPascalStrLen: %d + %d of '%s'\n", len2, length, val);
+ return len2 + length;
+ }
+}
+
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 3b74040..021bca1 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -767,3 +767,6 @@ typedef struct {
MYAPI TK_ModelMixed* MYAPIENTRY createTKModelMixed();
MYAPI void MYAPIENTRY destroyTKModelMixed(TK_ModelMixed* s);
+// Pascal String test
+MYAPI int addStrlenAndPascalStrLen(int length, const char* val);
+
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2-CustomJavaImplCode.java.stub b/src/junit/com/jogamp/gluegen/test/junit/generation/test2-CustomJavaImplCode.java.stub
index 9d58e02..ab360a6 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test2-CustomJavaImplCode.java.stub
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2-CustomJavaImplCode.java.stub
@@ -18,7 +18,7 @@
if( null == value ) {
return;
}
- value.func.callback(eventType, object, param, message.length(), message, userParam2);
+ value.func.callback(eventType, object, param, message, userParam2);
}
public void alEventCallback1Inject(ALCcontext userParam, int eventType, int object, int param, String message) {
@@ -41,6 +41,6 @@
if( null == value ) {
return;
}
- value.func.callback(eventType, object, param, message.length(), message, userParam2);
+ value.func.callback(eventType, object, param, message, userParam2);
}