Mercurial > pub > dyncall > bindings
annotate java/jdc/org_dyncall_DC.c @ 57:80b11152c659
make pydc tests display failed ones
author | Tassilo Philipp |
---|---|
date | Mon, 08 Feb 2021 09:58:25 +0100 |
parents | 87fd9f34eaa0 |
children |
rev | line source |
---|---|
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
1 #include <stdlib.h> |
0 | 2 #include "org_dyncall_DC.h" |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
3 #include "dyncall.h" |
20 | 4 #include "dynload.h" |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
5 |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
6 // Bookkeping to clean up on reset. |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
7 static int gc_snum = 0; |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
8 static jobject* gc_jstr = NULL; |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
9 static const char** gc_cstr = NULL; |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
10 static void cleanupHeldStrings(JNIEnv *pEnv) |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
11 { |
23 | 12 int i; |
13 for(i=0; i<gc_snum; ++i) | |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
14 (*pEnv)->ReleaseStringUTFChars(pEnv, gc_jstr[i], gc_cstr[i]); |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
15 |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
16 free(gc_jstr); gc_jstr = NULL; |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
17 free(gc_cstr); gc_cstr = NULL; |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
18 gc_snum = 0; |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
19 |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
20 } |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
21 |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
22 |
20 | 23 jlong JNICALL Java_org_dyncall_DC_newCallVM(JNIEnv *pEnv, jclass clazz, jint size) |
0 | 24 { |
20 | 25 return (jlong)dcNewCallVM(size); |
0 | 26 } |
27 | |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
28 void JNICALL Java_org_dyncall_DC_freeCallVM(JNIEnv *pEnv, jclass clazz, jlong vm) |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
29 { |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
30 cleanupHeldStrings(pEnv); |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
31 dcFree((DCCallVM*)vm); |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
32 } |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
33 |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
34 jlong JNICALL Java_org_dyncall_DC_loadLibrary(JNIEnv *pEnv, jclass clazz, jstring s) |
0 | 35 { |
21 | 36 jlong l = 0; |
37 const char *sz = (*pEnv)->GetStringUTFChars(pEnv, s, NULL); | |
38 if(sz != NULL) { | |
39 l = (jlong)dlLoadLibrary(sz); | |
40 (*pEnv)->ReleaseStringUTFChars(pEnv, s, sz); | |
41 } | |
42 return l; | |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
43 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
44 |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
45 void JNICALL Java_org_dyncall_DC_freeLibrary(JNIEnv *pEnv, jclass clazz, jlong libhandle) |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
46 { |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
47 dlFreeLibrary((DLLib*)libhandle); |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
48 } |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
49 |
20 | 50 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
|
51 { |
21 | 52 jlong l = 0; |
53 const char *sz = (*pEnv)->GetStringUTFChars(pEnv, s, NULL); | |
54 if(sz != NULL) { | |
55 l = (jlong)dlFindSymbol((DLLib*)libhandle, sz); | |
56 (*pEnv)->ReleaseStringUTFChars(pEnv, s, sz); | |
57 } | |
58 return l; | |
0 | 59 } |
60 | |
20 | 61 //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
|
62 //{ |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
63 // return dlSymsCount((DLSyms*)symshandle); |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
64 //} |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
65 |
20 | 66 //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
|
67 //{ |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
68 // return dlSymsName((DLSyms*)symshandle, i); |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
69 //} |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
70 |
20 | 71 void JNICALL Java_org_dyncall_DC_mode(JNIEnv *pEnv, jclass clazz, jlong vm, jint i) |
0 | 72 { |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
73 dcMode((DCCallVM*)vm, i); |
0 | 74 } |
75 | |
20 | 76 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
|
77 { |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
78 cleanupHeldStrings(pEnv); |
20 | 79 dcReset((DCCallVM*)vm); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
80 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
81 |
20 | 82 void JNICALL Java_org_dyncall_DC_argBool(JNIEnv *pEnv, jclass clazz, jlong vm, jboolean b) |
0 | 83 { |
21 | 84 dcArgBool((DCCallVM*)vm, b);//@@@test |
0 | 85 } |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
86 |
20 | 87 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
|
88 { |
21 | 89 dcArgChar((DCCallVM*)vm, b);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
90 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
91 |
20 | 92 void JNICALL Java_org_dyncall_DC_argShort(JNIEnv *pEnv, jclass clazz, jlong vm, jshort s) |
0 | 93 { |
21 | 94 dcArgShort((DCCallVM*)vm, s);//@@@test |
0 | 95 } |
96 | |
20 | 97 void JNICALL Java_org_dyncall_DC_argInt(JNIEnv *pEnv, jclass clazz, jlong vm, jint i) |
0 | 98 { |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
99 dcArgInt((DCCallVM*)vm, i); |
0 | 100 } |
101 | |
20 | 102 void JNICALL Java_org_dyncall_DC_argLong(JNIEnv *pEnv, jclass clazz, jlong vm, jlong l) |
0 | 103 { |
21 | 104 dcArgLong((DCCallVM*)vm, l);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
105 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
106 |
20 | 107 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
|
108 { |
21 | 109 dcArgLongLong((DCCallVM*)vm, l);//@@@test |
0 | 110 } |
111 | |
20 | 112 void JNICALL Java_org_dyncall_DC_argFloat(JNIEnv *pEnv, jclass clazz, jlong vm, jfloat f) |
0 | 113 { |
20 | 114 dcArgFloat((DCCallVM*)vm, f); |
0 | 115 } |
116 | |
20 | 117 void JNICALL Java_org_dyncall_DC_argDouble(JNIEnv *pEnv, jclass clazz, jlong vm, jdouble d) |
0 | 118 { |
21 | 119 dcArgDouble((DCCallVM*)vm, d); |
0 | 120 } |
121 | |
20 | 122 void JNICALL Java_org_dyncall_DC_argPointer__JJ(JNIEnv *pEnv, jclass clazz, jlong vm, jlong l) |
0 | 123 { |
21 | 124 dcArgPointer((DCCallVM*)vm, (DCpointer)l);//@@@test |
0 | 125 } |
126 | |
20 | 127 void JNICALL Java_org_dyncall_DC_argPointer__JLjava_lang_Object_2(JNIEnv *pEnv, jclass clazz, jlong vm, jobject o) |
0 | 128 { |
21 | 129 dcArgPointer((DCCallVM*)vm, (DCpointer)o);//@@@test |
0 | 130 } |
131 | |
20 | 132 void JNICALL Java_org_dyncall_DC_argString(JNIEnv *pEnv, jclass clazz, jlong vm, jstring s) |
0 | 133 { |
21 | 134 const char *sz = (*pEnv)->GetStringUTFChars(pEnv, s, NULL); |
135 if(sz != NULL) { | |
136 dcArgPointer((DCCallVM*)vm, (DCpointer)sz); | |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
137 |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
138 // Bookkeeping, to later release on reset or destruction of vm. |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
139 gc_jstr = realloc(gc_jstr, (gc_snum+1)*sizeof(jobject)); |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
140 gc_cstr = realloc(gc_cstr, (gc_snum+1)*sizeof(const char*)); |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
141 gc_jstr[gc_snum] = s; |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
142 gc_cstr[gc_snum] = sz; |
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
143 ++gc_snum; |
21 | 144 } |
0 | 145 } |
146 | |
20 | 147 void JNICALL Java_org_dyncall_DC_callVoid (JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
0 | 148 { |
21 | 149 dcCallVoid((DCCallVM*)vm, (DCpointer)target);//@@@test |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
150 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
151 |
20 | 152 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
|
153 { |
21 | 154 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
|
155 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
156 |
20 | 157 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
|
158 { |
21 | 159 return dcCallChar((DCCallVM*)vm, (DCpointer)target);//@@@test |
0 | 160 } |
161 | |
20 | 162 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
|
163 { |
21 | 164 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
|
165 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
166 |
20 | 167 jint JNICALL Java_org_dyncall_DC_callInt(JNIEnv *pEnv, jclass clazz, jlong vm, jlong target) |
0 | 168 { |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
169 return dcCallInt((DCCallVM*)vm, (DCpointer)target); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
170 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
171 |
20 | 172 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
|
173 { |
21 | 174 return dcCallLong((DCCallVM*)vm, (DCpointer)target);//@@@test |
0 | 175 } |
176 | |
20 | 177 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
|
178 { |
21 | 179 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
|
180 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
181 |
20 | 182 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
|
183 { |
20 | 184 return dcCallFloat((DCCallVM*)vm, (DCpointer)target); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
185 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
186 |
20 | 187 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
|
188 { |
20 | 189 return dcCallDouble((DCCallVM*)vm, (DCpointer)target); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
190 } |
0 | 191 |
20 | 192 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
|
193 { |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
194 return (jlong)dcCallPointer((DCCallVM*)vm, (DCpointer)target); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
195 } |
0 | 196 |
20 | 197 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
|
198 { |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
199 return (*pEnv)->NewStringUTF(pEnv, dcCallPointer((DCCallVM*)vm, (DCpointer)target)); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
200 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
201 |
20 | 202 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
|
203 { |
22
4ee8d6aa7721
- java binding cleanup, exposed free functions (not very oo, this entire binding)
cslag
parents:
21
diff
changeset
|
204 return dcGetError((DCCallVM*)vm); |
18
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
205 } |
3bfef07b0cd9
- cleanup of non-working java binding, restart work, somewhat different interface
cslag
parents:
0
diff
changeset
|
206 |