Mercurial > pub > dyncall > bindings
annotate java/jdc/org_dyncall_DC.c @ 21:40a2c4198016
- working jdc (but with memleaks, currently)
- added example
author | cslag |
---|---|
date | Wed, 30 Mar 2016 23:40:52 +0200 |
parents | 77ca609422f1 |
children | 4ee8d6aa7721 |
rev | line source |
---|---|
0 | 1 #include "org_dyncall_DC.h" |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
2 #include "dyncall.h" |
20 | 3 #include "dynload.h" |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
4 |
20 | 5 jlong JNICALL Java_org_dyncall_DC_newCallVM(JNIEnv *pEnv, jclass clazz, jint size) |
0 | 6 { |
20 | 7 return (jlong)dcNewCallVM(size); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
8 //@@@ free |
0 | 9 } |
10 | |
20 | 11 jlong JNICALL Java_org_dyncall_DC_load(JNIEnv *pEnv, jclass clazz, jstring s) |
0 | 12 { |
21 | 13 jlong l = 0; |
14 const char *sz = (*pEnv)->GetStringUTFChars(pEnv, s, NULL); | |
15 if(sz != NULL) { | |
16 l = (jlong)dlLoadLibrary(sz); | |
17 (*pEnv)->ReleaseStringUTFChars(pEnv, s, sz); | |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
18 //@@@ free |
21 | 19 } |
20 return l; | |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
21 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
22 |
20 | 23 jlong JNICALL Java_org_dyncall_DC_find(JNIEnv *pEnv, jclass clazz, jlong libhandle, jstring s) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
24 { |
21 | 25 jlong l = 0; |
26 const char *sz = (*pEnv)->GetStringUTFChars(pEnv, s, NULL); | |
27 if(sz != NULL) { | |
28 l = (jlong)dlFindSymbol((DLLib*)libhandle, sz); | |
29 (*pEnv)->ReleaseStringUTFChars(pEnv, s, sz); | |
30 } | |
31 return l; | |
0 | 32 } |
33 | |
20 | 34 //jint JNICALL Java_org_dyncall_DC_symsCount(JNIEnv *pEnv, jclass clazz, jlong symshandle) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
35 //{ |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
36 // return dlSymsCount((DLSyms*)symshandle); |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
37 //} |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
38 |
20 | 39 //jstring JNICALL Java_org_dyncall_DC_symsName(JNIEnv *pEnv, jclass clazz, jlong symshandle, jint i) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
40 //{ |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
41 // return dlSymsName((DLSyms*)symshandle, i); |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
42 //} |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
43 |
20 | 44 void JNICALL Java_org_dyncall_DC_mode(JNIEnv *pEnv, jclass clazz, jlong vm, jint i) |
0 | 45 { |
21 | 46 dcMode((DCCallVM*)vm, i);//@@@test |
0 | 47 } |
48 | |
20 | 49 void JNICALL Java_org_dyncall_DC_reset(JNIEnv *pEnv, jclass clazz, jlong vm) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
50 { |
20 | 51 dcReset((DCCallVM*)vm); |
21 | 52 //@@@add cleanup code here for temporary memory held by jni |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
53 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
54 |
20 | 55 void JNICALL Java_org_dyncall_DC_argBool(JNIEnv *pEnv, jclass clazz, jlong vm, jboolean b) |
0 | 56 { |
21 | 57 dcArgBool((DCCallVM*)vm, b);//@@@test |
0 | 58 } |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
59 |
20 | 60 void JNICALL Java_org_dyncall_DC_argChar(JNIEnv *pEnv, jclass clazz, jlong vm, jbyte b) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
61 { |
21 | 62 dcArgChar((DCCallVM*)vm, b);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
63 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
64 |
20 | 65 void JNICALL Java_org_dyncall_DC_argShort(JNIEnv *pEnv, jclass clazz, jlong vm, jshort s) |
0 | 66 { |
21 | 67 dcArgShort((DCCallVM*)vm, s);//@@@test |
0 | 68 } |
69 | |
20 | 70 void JNICALL Java_org_dyncall_DC_argInt(JNIEnv *pEnv, jclass clazz, jlong vm, jint i) |
0 | 71 { |
21 | 72 dcArgInt((DCCallVM*)vm, i);//@@@test |
0 | 73 } |
74 | |
20 | 75 void JNICALL Java_org_dyncall_DC_argLong(JNIEnv *pEnv, jclass clazz, jlong vm, jlong l) |
0 | 76 { |
21 | 77 dcArgLong((DCCallVM*)vm, l);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
78 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
79 |
20 | 80 void JNICALL Java_org_dyncall_DC_argLongLong(JNIEnv *pEnv, jclass clazz, jlong vm, jlong l) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
81 { |
21 | 82 dcArgLongLong((DCCallVM*)vm, l);//@@@test |
0 | 83 } |
84 | |
20 | 85 void JNICALL Java_org_dyncall_DC_argFloat(JNIEnv *pEnv, jclass clazz, jlong vm, jfloat f) |
0 | 86 { |
20 | 87 dcArgFloat((DCCallVM*)vm, f); |
0 | 88 } |
89 | |
20 | 90 void JNICALL Java_org_dyncall_DC_argDouble(JNIEnv *pEnv, jclass clazz, jlong vm, jdouble d) |
0 | 91 { |
21 | 92 dcArgDouble((DCCallVM*)vm, d); |
0 | 93 } |
94 | |
20 | 95 void JNICALL Java_org_dyncall_DC_argPointer__JJ(JNIEnv *pEnv, jclass clazz, jlong vm, jlong l) |
0 | 96 { |
21 | 97 dcArgPointer((DCCallVM*)vm, (DCpointer)l);//@@@test |
0 | 98 } |
99 | |
20 | 100 void JNICALL Java_org_dyncall_DC_argPointer__JLjava_lang_Object_2(JNIEnv *pEnv, jclass clazz, jlong vm, jobject o) |
0 | 101 { |
21 | 102 dcArgPointer((DCCallVM*)vm, (DCpointer)o);//@@@test |
0 | 103 } |
104 | |
20 | 105 void JNICALL Java_org_dyncall_DC_argString(JNIEnv *pEnv, jclass clazz, jlong vm, jstring s) |
0 | 106 { |
21 | 107 const char *sz = (*pEnv)->GetStringUTFChars(pEnv, s, NULL); |
108 if(sz != NULL) { | |
109 dcArgPointer((DCCallVM*)vm, (DCpointer)sz); | |
110 //(*pEnv)->ReleaseStringUTFChars(pEnv, s, sz); | |
111 //@@@ free this string when vm is destroyed, reset | |
112 } | |
0 | 113 } |
114 | |
20 | 115 void JNICALL Java_org_dyncall_DC_callVoid (JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
0 | 116 { |
21 | 117 dcCallVoid((DCCallVM*)vm, (DCpointer)target);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
118 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
119 |
20 | 120 jboolean JNICALL Java_org_dyncall_DC_callBool(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
121 { |
21 | 122 return dcCallBool((DCCallVM*)vm, (DCpointer)target);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
123 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
124 |
20 | 125 jbyte JNICALL Java_org_dyncall_DC_callChar(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
126 { |
21 | 127 return dcCallChar((DCCallVM*)vm, (DCpointer)target);//@@@test |
0 | 128 } |
129 | |
20 | 130 jshort JNICALL Java_org_dyncall_DC_callShort(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
131 { |
21 | 132 return dcCallShort((DCCallVM*)vm, (DCpointer)target);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
133 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
134 |
20 | 135 jint JNICALL Java_org_dyncall_DC_callInt(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
0 | 136 { |
21 | 137 return dcCallInt((DCCallVM*)vm, (DCpointer)target);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
138 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
139 |
20 | 140 jlong JNICALL Java_org_dyncall_DC_callLong(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
141 { |
21 | 142 return dcCallLong((DCCallVM*)vm, (DCpointer)target);//@@@test |
0 | 143 } |
144 | |
20 | 145 jlong JNICALL Java_org_dyncall_DC_callLongLong(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
146 { |
21 | 147 return dcCallLongLong((DCCallVM*)vm, (DCpointer)target);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
148 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
149 |
20 | 150 jfloat JNICALL Java_org_dyncall_DC_callFloat(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
151 { |
20 | 152 return dcCallFloat((DCCallVM*)vm, (DCpointer)target); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
153 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
154 |
20 | 155 jdouble JNICALL Java_org_dyncall_DC_callDouble(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
156 { |
20 | 157 return dcCallDouble((DCCallVM*)vm, (DCpointer)target); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
158 } |
0 | 159 |
20 | 160 jlong JNICALL Java_org_dyncall_DC_callPointer(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
161 { |
21 | 162 return (jlong)dcCallPointer((DCCallVM*)vm, (DCpointer)target);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
163 } |
0 | 164 |
20 | 165 jstring JNICALL Java_org_dyncall_DC_callString(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
166 { |
21 | 167 return (*pEnv)->NewStringUTF(pEnv, dcCallPointer((DCCallVM*)vm, (DCpointer)target));//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
168 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
169 |
20 | 170 jint JNICALL Java_org_dyncall_DC_getError(JNIEnv *pEnv, jclass clazz, jlong vm) |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
171 { |
21 | 172 return dcGetError((DCCallVM*)vm);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
173 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
174 |