java - JNI what types can I use instead of given (unsigned int, const char*, const wchar_t*, .... ) -
stackoverflow users !
i trying covert functions had written in c++ java. have .so library witch have written in c++ , must call functions android application. functions this:
unsignd int uninitialize(); --------------------------------------- unsignd int deviceopen( const wchar_t* deviceid, unsigned long* phdevice); --------------------------------------- typedef struct blobdata_s { unsigned long length; unsigned char data[1]; } dsmblobdata_t; unsignd int enroll( unsigned long hdevice, const char* userid, blobdata_s* pinputinfo, void* puserdata);
now how can see have functions , typedefs want write in java style, problem there no unsigned int
java type (link). knew instead of int
can use jint
, instead of char*
can use jchar*
must with
const wchar_t*
unsigned long
unsigned char
what can use instead of types.
i try in way
jint java_com_example_testapp_testapp_deviceopen( jchar* deviceid, int* phdevice) { return deviceopen((const wchar_t*)deviceid, (unsigned long*)phdevice); }
am right ?*
thanks in advance, vitobrothers.
for starters, you'll have map types java types. say, there no unsigned
in java, , no wchar_t
. once you've decided types use on java side (e.g. int
instead of unsigned
, or maybe long
; , java.lang.string
both char*
, wchar_t*
), you'll have declare native methods using them, , implement jni in way maps them internal values.
also, if c++ code uses exceptions, you'll have catch them , remap them in jni interface.
for starters, i'd see if existing tool, swig, job. if didn't, i'd still use example code, can copy/pasted , edited.
Comments
Post a Comment