50 #define VPPJNI_CLASS_SYMBOL(name) vppjni_class_##name 51 #define VPPJNI_CLASS_INIT(name) vppjni_class_##name##_init 52 #define BIND_JAPI_CLASS(name, sig) \ 53 static vppjni_class_t VPPJNI_CLASS_SYMBOL(name); \ 54 static void VPPJNI_CLASS_INIT(name)(void) __attribute__((__constructor__)); \ 55 static void VPPJNI_CLASS_INIT(name)() \ 57 VPPJNI_CLASS_SYMBOL(name).fqcn = "org/openvpp/vppjapi/" #name; \ 58 VPPJNI_CLASS_SYMBOL(name).init_sig = sig; \ 59 vppjni_register_class(&VPPJNI_CLASS_SYMBOL(name)); \ 61 static __attribute__((unused)) jobject name##Array(JNIEnv *env, jsize length) \ 63 return (*env)->NewObjectArray(env, length, VPPJNI_CLASS_SYMBOL(name).jclass, NULL); \ 65 static jobject name##Object(JNIEnv *env, ...) \ 69 jobject obj = vppjni_new_object(env, &VPPJNI_CLASS_SYMBOL(name), ap); \ 74 #define VPPJNI_FIELD_SYMBOL(cls, name) vppjni_field_##cls##_##name 75 #define VPPJNI_FIELD_INIT(cls, name) vppjni_field_##cls##_##name##_init 76 #define BIND_JAPI_FIELD(cls, field, sig) \ 77 static vppjni_field_t VPPJNI_FIELD_SYMBOL(cls, field); \ 78 static void VPPJNI_FIELD_INIT(cls, field)(void) __attribute__((__constructor__)); \ 79 static void VPPJNI_FIELD_INIT(cls, field)() \ 81 VPPJNI_FIELD_SYMBOL(cls, field).name = #field; \ 82 VPPJNI_FIELD_SYMBOL(cls, field).type = sig; \ 83 VPPJNI_FIELD_SYMBOL(cls, field).clsref = &VPPJNI_CLASS_SYMBOL(cls); \ 84 vppjni_register_field(&VPPJNI_FIELD_SYMBOL(cls, field)); \ 86 #define BIND_JAPI_BOOL_FIELD(cls, field) \ 87 BIND_JAPI_FIELD(cls, field, "Z"); \ 88 static void set_##cls##_##field(JNIEnv *env, jobject obj, jboolean value) \ 90 (*env)->SetBooleanField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ 92 #define BIND_JAPI_BYTE_FIELD(cls, field) \ 93 BIND_JAPI_FIELD(cls, field, "B"); \ 94 static void set_##cls##_##field(JNIEnv *env, jobject obj, jbyte value) \ 96 (*env)->SetByteField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ 98 #define BIND_JAPI_INT_FIELD(cls, field) \ 99 BIND_JAPI_FIELD(cls, field, "I"); \ 100 static void set_##cls##_##field(JNIEnv *env, jobject obj, jint value) \ 102 (*env)->SetIntField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ 104 #define BIND_JAPI_OBJ_FIELD(cls, field, sig) \ 105 BIND_JAPI_FIELD(cls, field, sig); \ 106 static void set_##cls##_##field(JNIEnv *env, jobject obj, jobject value) \ 108 (*env)->SetObjectField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ 110 #define BIND_JAPI_STRING_FIELD(cls, field) \ 111 BIND_JAPI_OBJ_FIELD(cls, field, "Ljava/lang/String;") 116 int vppjni_init(JNIEnv *env) __attribute__ ((visibility (
"hidden")));
117 void vppjni_uninit(JNIEnv *env) __attribute__ ((visibility (
"hidden")));
jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap)
int vppjni_init(JNIEnv *env)
const vppjni_class_t * clsref
struct vppjni_class vppjni_class_t
struct jenv_field vppjni_field_t
void vppjni_register_class(vppjni_class_t *ptr)
struct vppjni_class * next
void vppjni_register_field(vppjni_field_t *ptr)
void vppjni_uninit(JNIEnv *env)