Mstdlib-1.24.0
|
Functions | |
M_bool | M_io_jni_init (JavaVM *Jvm) |
M_bool | M_io_jni_android_init (jobject app_context) |
JNIEnv * | M_io_jni_getenv (void) |
jobject | M_io_jni_get_android_app_context (void) |
void | M_io_jni_debug (const char *fmt,...) |
jclass | M_io_jni_find_class (JNIEnv *env, const char *path) |
M_hash_dict_t * | M_io_jni_jhashmap_to_mhashdict (JNIEnv *env, jobject map) |
jobject | M_io_jni_mhashdict_to_jhashmap (JNIEnv *env, M_hash_dict_t *dict) |
void | M_io_jni_deletelocalref (JNIEnv *env, jobject *ref) |
jobject | M_io_jni_create_globalref (JNIEnv *env, jobject ref) |
void | M_io_jni_delete_globalref (JNIEnv *env, jobject *ref) |
size_t | M_io_jni_array_length (JNIEnv *env, jobject arr) |
jobject | M_io_jni_array_element (JNIEnv *env, jobject arr, size_t idx) |
char * | M_io_jni_jstring_to_pchar (JNIEnv *env, jstring str) |
jstring | M_io_jni_pchar_to_jstring (JNIEnv *env, const char *str) |
unsigned char * | M_io_jni_jbyteArray_to_puchar (JNIEnv *env, jbyteArray in, size_t max_len, size_t *size_out) |
jbyteArray | M_io_jni_puchar_to_jbyteArray (JNIEnv *env, const unsigned char *data, size_t data_size) |
void | M_io_jni_jbyteArray_zeroize (JNIEnv *env, jbyteArray arr) |
size_t | M_io_jni_jbyteArray_to_buf (JNIEnv *env, jbyteArray in, size_t max_len, M_buf_t *out) |
M_bool | M_io_jni_new_object (jobject *rv, char *error, size_t error_len, JNIEnv *env, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jvoid (char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jobject (jobject *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jbyte (jbyte *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jboolean (jboolean *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jchar (jchar *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jint (jint *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jlong (jlong *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jfloat (jfloat *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jdouble (jdouble *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jobjectArray (jobjectArray *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jbyteArray (jbyteArray *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jbooleanArray (jbooleanArray *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jcharArray (jcharArray *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jintArray (jintArray *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jlongArray (jlongArray *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jfloatArray (jfloatArray *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jdoubleArray (jdoubleArray *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *method, size_t argc,...) |
M_bool | M_io_jni_call_jobjectField (jobject *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *field) |
M_bool | M_io_jni_call_jbyteField (jbyte *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *field) |
M_bool | M_io_jni_call_jbooleanField (jboolean *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *field) |
M_bool | M_io_jni_call_jcharField (jchar *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *field) |
M_bool | M_io_jni_call_jintField (jint *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *field) |
M_bool | M_io_jni_call_jlongField (jlong *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *field) |
M_bool | M_io_jni_call_jfloatField (jfloat *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *field) |
M_bool | M_io_jni_call_jdoubleField (jdouble *rv, char *error, size_t error_len, JNIEnv *env, jobject classobj, const char *field) |
Included using the semi-public header of <mstdlib/io/m_io_jni.h> This is not included by default because it is considered a stable API.
Java JNI Helper Functions. Primarily used for Android integration where Bluetooth support requires it. However, nothing here is Android specific and will never be. This is purely JNI and does not use anything outside of what's provided by Java itself.
M_bool M_io_jni_init | ( | JavaVM * | Jvm | ) |
Initialization function to initialize the Java JNI environment.
This routine must be called once at startup before any of the M_io_jni helper functions can be used.
This implementation only supports a single Java VM instance, globally.
[in] | Jvm | Initialized JavaVM to use. Must be specified. |
M_bool M_io_jni_android_init | ( | jobject | app_context | ) |
Initialization function to initialize the io system for use on Android.
M_io_jni_init must be called before this function. This should only be called when building for Android.
This function must be called in order to use USB-HID devices.
This function must be called before DNS resolution will work on Android 8 (Oreo) or newer when built targeting SDK 26. Also, the ACCESS_NETWORK_STATE permission must be present in the Android application.
[in] | app_context | Android application context. Can be accessed in Java from like so: getApplicationContext(). |
JNIEnv * M_io_jni_getenv | ( | void | ) |
Retrieve JNI Environment Handle for current thread.
If thread is not currently assigned a handle, a new one will be created, otherwise the existing handle will be returned.
jobject M_io_jni_get_android_app_context | ( | void | ) |
Retrieve Android Applilcation Contect.
M_io_jni_android_init must be called to set the context.
void M_io_jni_debug | ( | const char * | fmt, |
... | |||
) |
Output debug text relevant to JNI execution.
If not using a debug build, this is a no-op, and no information will be output. This is mostly used internally by the implementation, but people wishing to implement additional JNI methods might find this useful for debug purposes.
On Android, this uses the android logging functions, on other systems this simply outputs the message to stderr.
[in] | fmt | Standard printf-style format string. A new line will be automatically added to the output. |
[in] | ... | Arguments as referenced in the format string |
jclass M_io_jni_find_class | ( | JNIEnv * | env, |
const char * | path | ||
) |
Look up a class based on its path.
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | path | The path for the class, such as java/util/HashMap |
M_hash_dict_t * M_io_jni_jhashmap_to_mhashdict | ( | JNIEnv * | env, |
jobject | map | ||
) |
Convert a Java HashMap into an M_hash_dict_t *.
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | map | Java Hash Map object to convert. |
jobject M_io_jni_mhashdict_to_jhashmap | ( | JNIEnv * | env, |
M_hash_dict_t * | dict | ||
) |
Convert an M_hash_dict_t * into a Java HashMap object.
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | dict | M_hash_dict_t to convert. |
void M_io_jni_deletelocalref | ( | JNIEnv * | env, |
jobject * | ref | ||
) |
Delete reference to object so garbage collector can destroy it.
This isn't absolutely necessary to call, but is recommended for long-running routines, or if using many objects in a loop so you don't run out of descriptors. When control returns from JNI back to Java, any used JNI objects not manually deleted will be released if they were not returned into java scope. Once an object is deleted it can no longer be used, nor can it be returned to Java.
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in,out] | ref | Object reference to be deleted, passed by reference. Will be set pointer will be set to NULL when dereferenced to ensure it won't be used again. |
jobject M_io_jni_create_globalref | ( | JNIEnv * | env, |
jobject | ref | ||
) |
Create a global JNI reference to prevent garbage collection of a Java object that may need to persist past the point where execution is returned to Java.
If a Java object is held within a C object that needs to persist, and integrator must mark it as a global reference, then delete the global reference when no longer needed, otherwise the object will be cleaned up by Java.
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | ref | Java object to create a global reference to. |
void M_io_jni_delete_globalref | ( | JNIEnv * | env, |
jobject * | ref | ||
) |
Delete the global JNI reference created with M_io_jni_create_globalref()
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in,out] | ref | Object reference to be deleted, passed by reference. Will be set pointer will be set to NULL when dereferenced to ensure it won't be used again. |
size_t M_io_jni_array_length | ( | JNIEnv * | env, |
jobject | arr | ||
) |
Retrieve length of Array.
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | arr | Array object to get count. |
jobject M_io_jni_array_element | ( | JNIEnv * | env, |
jobject | arr, | ||
size_t | idx | ||
) |
Retrieve an element from an Array.
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | arr | Array to retrieve element from. |
[in] | idx | Array index. |
char * M_io_jni_jstring_to_pchar | ( | JNIEnv * | env, |
jstring | str | ||
) |
Convert jstring into C String (allocated, null terminated).
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | str | jstring to convert into C String |
jstring M_io_jni_pchar_to_jstring | ( | JNIEnv * | env, |
const char * | str | ||
) |
Convert a C String into a jstring
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | str | C String to convert into a jstring. |
unsigned char * M_io_jni_jbyteArray_to_puchar | ( | JNIEnv * | env, |
jbyteArray | in, | ||
size_t | max_len, | ||
size_t * | size_out | ||
) |
Convert a byte array into an unsigned character pointer
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | in | Byte array to convert to unsigned character data. |
[in] | max_len | Maximum length to use, or 0 for full Byte Array. |
[out] | size_out | Size of returned buffer. |
jbyteArray M_io_jni_puchar_to_jbyteArray | ( | JNIEnv * | env, |
const unsigned char * | data, | ||
size_t | data_size | ||
) |
Convert an unsigned character buffer into a jbyteArray
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | data | Unsigned character data. |
[in] | data_size | Size of character data buffer. |
void M_io_jni_jbyteArray_zeroize | ( | JNIEnv * | env, |
jbyteArray | arr | ||
) |
Zeroize a Byte Array. Typically used for memory security reasons.
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | arr | Byte Array to zeroize |
size_t M_io_jni_jbyteArray_to_buf | ( | JNIEnv * | env, |
jbyteArray | in, | ||
size_t | max_len, | ||
M_buf_t * | out | ||
) |
Copy the contents of a Byte Array to an M_buf_t up to the given size.
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | in | Byte Array to copy |
[in] | max_len | Maximum length of byte array to copy, or 0 for full array. |
[out] | out | Initialized M_buf_t to copy data into |
M_bool M_io_jni_new_object | ( | jobject * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Create a new object using the specified method.
[out] | rv | Returned object, passed by reference. Returned object should be released using M_io_jni_deletelocalref() when no longer needed. |
[out] | error | Optional. Buffer to hold error message. |
[in] | error_len | Error buffer size. |
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | method | The class initializer method. The method specified should be in the form of "path/to/class.<init>", and must have been one of the classes in the global initialization. |
[in] | argc | Count of arguments to follow. |
[in] | ... | Variable argument list depending on method being called. |
M_bool M_io_jni_call_jvoid | ( | char * | error, |
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns jvoid (no result).
[out] | error | Optional. Buffer to hold error message. |
[in] | error_len | Error buffer size. |
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | classobj | Class object to call method on. If the method being called is static, this parameter will be ignored, so should be passed as NULL. |
[in] | method | The method to be called. The method should be in the form of "path/to/class.method", and must have been one of the methods in the global initialization. |
[in] | argc | Count of argument to follow. |
[in] | ... | Variable argument list depending on method being called. |
M_bool M_io_jni_call_jobject | ( | jobject * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns jobject.
[out] | rv | Returned object, passed by reference. Returned object should be released using M_io_jni_deletelocalref() when no longer needed. |
[out] | error | Optional. Buffer to hold error message. |
[in] | error_len | Error buffer size. |
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | classobj | Class object to call method on. If the method being called is static, this parameter will be ignored, so should be passed as NULL. |
[in] | method | The method to be called. The method should be in the form of "path/to/class.method", and must have been one of the methods in the global initialization. |
[in] | argc | Count of arguments to follow. |
[in] | ... | Variable argument list depending on method being called. |
M_bool M_io_jni_call_jbyte | ( | jbyte * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jbyte.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jboolean | ( | jboolean * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jboolean.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jchar | ( | jchar * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jchar.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jint | ( | jint * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jint.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jlong | ( | jlong * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jlong.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jfloat | ( | jfloat * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jfloat.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jdouble | ( | jdouble * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jdouble.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jobjectArray | ( | jobjectArray * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jobjectArray.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jbyteArray | ( | jbyteArray * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jbyteArray.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jbooleanArray | ( | jbooleanArray * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jbooleanArray.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jcharArray | ( | jcharArray * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jcharArray.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jintArray | ( | jintArray * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jintArray.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jlongArray | ( | jlongArray * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jlongArray.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jfloatArray | ( | jfloatArray * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jfloatArray.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jdoubleArray | ( | jdoubleArray * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | method, | ||
size_t | argc, | ||
... | |||
) |
Call an object method that returns a jdoubleArray.
See M_io_jni_call_jobject() for usage information.
M_bool M_io_jni_call_jobjectField | ( | jobject * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | field | ||
) |
Call an object field that returns a jobject.
[out] | rv | Returned value, passed by reference. Returned object should be released using M_io_jni_deletelocalref() when no longer needed. |
[out] | error | Optional. Buffer to hold error message. |
[in] | error_len | Error buffer size. |
[in] | env | Optional. Java JNI Environment. If not passed will request it from the JVM. Passing it is an optimization. |
[in] | classobj | Class object to call method on. If the method being called is static, this parameter will be ignored, so should be passed as NULL. |
[in] | field | The field to be called. The field should be in the form of "path/to/class.field", and must have been one of the fields in the global initialization. |
M_bool M_io_jni_call_jbyteField | ( | jbyte * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | field | ||
) |
Call an object field that returns a jbyte.
See M_io_jni_call_jobjectField() for usage information.
M_bool M_io_jni_call_jbooleanField | ( | jboolean * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | field | ||
) |
Call an object field that returns a jboolean.
See M_io_jni_call_jobjectField() for usage information.
M_bool M_io_jni_call_jcharField | ( | jchar * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | field | ||
) |
Call an object field that returns a jchar.
See M_io_jni_call_jobjectField() for usage information.
M_bool M_io_jni_call_jintField | ( | jint * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | field | ||
) |
Call an object field that returns a jint.
See M_io_jni_call_jobjectField() for usage information.
M_bool M_io_jni_call_jlongField | ( | jlong * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | field | ||
) |
Call an object field that returns a jlong.
See M_io_jni_call_jobjectField() for usage information.
M_bool M_io_jni_call_jfloatField | ( | jfloat * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | field | ||
) |
Call an object field that returns a jfloat.
See M_io_jni_call_jobjectField() for usage information.
M_bool M_io_jni_call_jdoubleField | ( | jdouble * | rv, |
char * | error, | ||
size_t | error_len, | ||
JNIEnv * | env, | ||
jobject | classobj, | ||
const char * | field | ||
) |
Call an object field that returns a jdouble.
See M_io_jni_call_jobjectField() for usage information.