# HG changeset patch # User cslag # Date 1459298456 -7200 # Node ID 77ca609422f118e74195e642ab49b8183d5f4a3e # Parent 5b51738793c65b75b4f27cf760d2ed8165860e1c - first working build of new java binding diff -r 5b51738793c6 -r 77ca609422f1 java/jdc/Makefile --- a/java/jdc/Makefile Wed Mar 30 02:06:16 2016 +0200 +++ b/java/jdc/Makefile Wed Mar 30 02:40:56 2016 +0200 @@ -1,4 +1,21 @@ -all: - cd org/dyncall/ && javac DC.java +# should be .jnilib on os x, .dll on windows, etc. @@@ +SO=libjdc.so + +build: $(SO) + +clean: + rm org_dyncall_DC.h || true + rm org/dyncall/DC.class || true + rm $(SO) || true + +$(SO): org_dyncall_DC.h org_dyncall_DC.c + # @@@ support different compilers @@@ esp. on windows + $(CC) -shared -fPIC -o $@ org_dyncall_DC.c + +org_dyncall_DC.h: org/dyncall/DC.class javah org.dyncall.DC +org/dyncall/DC.class: + cd org/dyncall/ && javac DC.java + +.PHONY: build clean diff -r 5b51738793c6 -r 77ca609422f1 java/jdc/README.txt --- a/java/jdc/README.txt Wed Mar 30 02:06:16 2016 +0200 +++ b/java/jdc/README.txt Wed Mar 30 02:40:56 2016 +0200 @@ -1,4 +1,10 @@ BUILD ===== -@@@ +1) make sure dyncall is built and libraries/headers are in include paths or + CFLAGS points to them, etc. + +2) Build with: + + make + diff -r 5b51738793c6 -r 77ca609422f1 java/jdc/org/dyncall/DC.java --- a/java/jdc/org/dyncall/DC.java Wed Mar 30 02:06:16 2016 +0200 +++ b/java/jdc/org/dyncall/DC.java Wed Mar 30 02:40:56 2016 +0200 @@ -50,7 +50,7 @@ , ERROR_UNSUPPORTED_MODE = -1 ; - public static native long newCallVM(int type, int size); + public static native long newCallVM(int size); public static native long load(String libname); public static native long find(long libhandle, String symbol); diff -r 5b51738793c6 -r 77ca609422f1 java/jdc/org_dyncall_DC.c --- a/java/jdc/org_dyncall_DC.c Wed Mar 30 02:06:16 2016 +0200 +++ b/java/jdc/org_dyncall_DC.c Wed Mar 30 02:40:56 2016 +0200 @@ -1,155 +1,156 @@ #include "org_dyncall_DC.h" #include "dyncall.h" +#include "dynload.h" -jlong JNICALL Java_org_dyncall_DC_newCallVM(JNIEnv *pEnv, jclass clazz, jint mode, jint size) +jlong JNICALL Java_org_dyncall_DC_newCallVM(JNIEnv *pEnv, jclass clazz, jint size) { - return (jlong)dcNewCallVM(mode, size); + return (jlong)dcNewCallVM(size); //@@@ free } -jlong JNICALL Java_org_dyncall_DC_load(JNIEnv *, jclass, jstring s) +jlong JNICALL Java_org_dyncall_DC_load(JNIEnv *pEnv, jclass clazz, jstring s) { - return dlLoadLibrary((const char*)s); + return (jlong)dlLoadLibrary((const char*)s); //@@@ free } -jlong JNICALL Java_org_dyncall_DC_find(JNIEnv *, jclass, jlong libhandle, jstring s) +jlong JNICALL Java_org_dyncall_DC_find(JNIEnv *pEnv, jclass clazz, jlong libhandle, jstring s) { - return dlFindSymbol((DLLib*)libhandle, (const char*)s); + return (jlong)dlFindSymbol((DLLib*)libhandle, (const char*)s); } -//jint JNICALL Java_org_dyncall_DC_symsCount(JNIEnv *, jclass, jlong symshandle) +//jint JNICALL Java_org_dyncall_DC_symsCount(JNIEnv *pEnv, jclass clazz, jlong symshandle) //{ // return dlSymsCount((DLSyms*)symshandle); //} -//jstring JNICALL Java_org_dyncall_DC_symsName(JNIEnv *, jclass, jlong symshandle, jint i) +//jstring JNICALL Java_org_dyncall_DC_symsName(JNIEnv *pEnv, jclass clazz, jlong symshandle, jint i) //{ // return dlSymsName((DLSyms*)symshandle, i); //} -void JNICALL Java_org_dyncall_DC_mode(JNIEnv *, jclass, jlong in_vm, jint i) +void JNICALL Java_org_dyncall_DC_mode(JNIEnv *pEnv, jclass clazz, jlong vm, jint i) { - dcMode((DCCallVM*)in_vm, i); + dcMode((DCCallVM*)vm, i); } -void JNICALL Java_org_dyncall_DC_reset(JNIEnv *, jclass, jlong in_vm) +void JNICALL Java_org_dyncall_DC_reset(JNIEnv *pEnv, jclass clazz, jlong vm) { - dcReset((DCCallVM*)in_vm); + dcReset((DCCallVM*)vm); } -void JNICALL Java_org_dyncall_DC_argBool(JNIEnv *, jclass, jlong in_vm, jboolean b) +void JNICALL Java_org_dyncall_DC_argBool(JNIEnv *pEnv, jclass clazz, jlong vm, jboolean b) { - dcPushBool((DCCallVM*)in_vm, b); + dcArgBool((DCCallVM*)vm, b); } -void JNICALL Java_org_dyncall_DC_argChar(JNIEnv *, jclass, jlong in_vm, jbyte b) +void JNICALL Java_org_dyncall_DC_argChar(JNIEnv *pEnv, jclass clazz, jlong vm, jbyte b) { - dcPushChar((DCCallVM*)in_vm, b); + dcArgChar((DCCallVM*)vm, b); } -void JNICALL Java_org_dyncall_DC_argShort(JNIEnv *, jclass, jlong in_vm, jshort s) +void JNICALL Java_org_dyncall_DC_argShort(JNIEnv *pEnv, jclass clazz, jlong vm, jshort s) { - dcPushShort((DCCallVM*)in_vm, s); + dcArgShort((DCCallVM*)vm, s); } -void JNICALL Java_org_dyncall_DC_argInt(JNIEnv *, jclass, jlong in_vm, jint i) +void JNICALL Java_org_dyncall_DC_argInt(JNIEnv *pEnv, jclass clazz, jlong vm, jint i) { - dcPushInt((DCCallVM*)in_vm, i); + dcArgInt((DCCallVM*)vm, i); } -void JNICALL Java_org_dyncall_DC_argLong(JNIEnv *, jclass, jlong in_vm, jlong l) +void JNICALL Java_org_dyncall_DC_argLong(JNIEnv *pEnv, jclass clazz, jlong vm, jlong l) { - dcPushLong((DCCallVM*)in_vm, l); + dcArgLong((DCCallVM*)vm, l); } -void JNICALL Java_org_dyncall_DC_argLongLong(JNIEnv *, jclass, jlong in_vm, jlong l) +void JNICALL Java_org_dyncall_DC_argLongLong(JNIEnv *pEnv, jclass clazz, jlong vm, jlong l) { - dcPushLongLong((DCCallVM*)in_vm, l); + dcArgLongLong((DCCallVM*)vm, l); } -void JNICALL Java_org_dyncall_DC_argFloat(JNIEnv *, jclass, jlong in_vm, jfloat f) +void JNICALL Java_org_dyncall_DC_argFloat(JNIEnv *pEnv, jclass clazz, jlong vm, jfloat f) { - dcPushFloat((DCCallVM*)in_vm, f); + dcArgFloat((DCCallVM*)vm, f); } -void JNICALL Java_org_dyncall_DC_argDouble(JNIEnv *, jclass, jlong in_vm, jdouble d) +void JNICALL Java_org_dyncall_DC_argDouble(JNIEnv *pEnv, jclass clazz, jlong vm, jdouble d) { - dcPushDouble((DCCallVM*)in_vm, d); + dcArgDouble((DCCallVM*)vm, d); } -void JNICALL Java_org_dyncall_DC_argPointer__JJ(JNIEnv *, jclass, jlong in_vm, jlong l) +void JNICALL Java_org_dyncall_DC_argPointer__JJ(JNIEnv *pEnv, jclass clazz, jlong vm, jlong l) { - dcPushPointer((DCCallVM*)in_vm, (DCpointer)l); + dcArgPointer((DCCallVM*)vm, (DCpointer)l); } -void JNICALL Java_org_dyncall_DC_argPointer__JLjava_lang_Object_2(JNIEnv *, jclass, jlong in_vm, jobject o) +void JNICALL Java_org_dyncall_DC_argPointer__JLjava_lang_Object_2(JNIEnv *pEnv, jclass clazz, jlong vm, jobject o) { - dcPushPointer((DCCallVM*)in_vm, (DCpointer)o); + dcArgPointer((DCCallVM*)vm, (DCpointer)o); } -void JNICALL Java_org_dyncall_DC_argString(JNIEnv *, jclass, jlong in_vm, jstring s) +void JNICALL Java_org_dyncall_DC_argString(JNIEnv *pEnv, jclass clazz, jlong vm, jstring s) { - dcPushPointer((DCCallVM*)in_vm, (DCpointer)s); + dcArgPointer((DCCallVM*)vm, (DCpointer)s); } -void JNICALL Java_org_dyncall_DC_callVoid (JNIEnv *, jclass, jlong in_vm, jlong in_target) +void JNICALL Java_org_dyncall_DC_callVoid (JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - dcCallVoid((DCCallVM*)in_vm, (DCpointer)target) + dcCallVoid((DCCallVM*)vm, (DCpointer)target); } -jboolean JNICALL Java_org_dyncall_DC_callBool(JNIEnv *, jclass, jlong in_vm, jlong target) +jboolean JNICALL Java_org_dyncall_DC_callBool(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallBool((DCCallVM*)in_vm, (DCpointer)target) + return dcCallBool((DCCallVM*)vm, (DCpointer)target); } -jbyte JNICALL Java_org_dyncall_DC_callChar(JNIEnv *, jclass, jlong in_vm, jlong target) +jbyte JNICALL Java_org_dyncall_DC_callChar(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallChar((DCCallVM*)in_vm, (DCpointer)target) + return dcCallChar((DCCallVM*)vm, (DCpointer)target); } -jshort JNICALL Java_org_dyncall_DC_callShort(JNIEnv *, jclass, jlong in_vm, jlong target) +jshort JNICALL Java_org_dyncall_DC_callShort(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallShort((DCCallVM*)in_vm, (DCpointer)target) + return dcCallShort((DCCallVM*)vm, (DCpointer)target); } -jint JNICALL Java_org_dyncall_DC_callInt(JNIEnv *, jclass, jlong in_vm, jlong target) +jint JNICALL Java_org_dyncall_DC_callInt(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallInt((DCCallVM*)in_vm, (DCpointer)target) + return dcCallInt((DCCallVM*)vm, (DCpointer)target); } -jlong JNICALL Java_org_dyncall_DC_callLong(JNIEnv *, jclass, jlong in_vm, jlong target) +jlong JNICALL Java_org_dyncall_DC_callLong(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallLong((DCCallVM*)in_vm, (DCpointer)target) + return dcCallLong((DCCallVM*)vm, (DCpointer)target); } -jlong JNICALL Java_org_dyncall_DC_callLongLong(JNIEnv *, jclass, jlong in_vm, jlong target) +jlong JNICALL Java_org_dyncall_DC_callLongLong(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallLongLong((DCCallVM*)in_vm, (DCpointer)target) + return dcCallLongLong((DCCallVM*)vm, (DCpointer)target); } -jfloat JNICALL Java_org_dyncall_DC_callFloat(JNIEnv *, jclass, jlong in_vm, jlong target) +jfloat JNICALL Java_org_dyncall_DC_callFloat(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallFloat((DCCallVM*)in_vm, (DCpointer)target) + return dcCallFloat((DCCallVM*)vm, (DCpointer)target); } -jdouble JNICALL Java_org_dyncall_DC_callDouble(JNIEnv *, jclass, jlong in_vm, jlong target) +jdouble JNICALL Java_org_dyncall_DC_callDouble(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallDouble((DCCallVM*)in_vm, (DCpointer)target) + return dcCallDouble((DCCallVM*)vm, (DCpointer)target); } -jlong JNICALL Java_org_dyncall_DC_callPointer(JNIEnv *, jclass, jlong in_vm, jlong target) +jlong JNICALL Java_org_dyncall_DC_callPointer(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallPointer((DCCallVM*)in_vm, (DCpointer)target) + return (jlong)dcCallPointer((DCCallVM*)vm, (DCpointer)target); } -jstring JNICALL Java_org_dyncall_DC_callString(JNIEnv *, jclass, jlong in_vm, jlong target) +jstring JNICALL Java_org_dyncall_DC_callString(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) { - return dcCallPointer((DCCallVM*)in_vm, (DCpointer)target) + return dcCallPointer((DCCallVM*)vm, (DCpointer)target); } -jint JNICALL Java_org_dyncall_DC_getError(JNIEnv *, jclass, jlong in_vm) +jint JNICALL Java_org_dyncall_DC_getError(JNIEnv *pEnv, jclass clazz, jlong vm) { - return dcGetError((DCCallVM*)in_vm); + return dcGetError((DCCallVM*)vm); }