void setup_value(JNIEnv* env) { if (!setup) { classreg(env, ENGINE_VALUE_CLASS, &value_type); classreg(env, "java/lang/reflect/Array", &class_array); // for generic array setting value_constructor = (*env)->GetMethodID(env, value_type, "<init>", "()V"); handle_null_const(value_constructor, ENGINE_VALUE_CLASS); id_newarray = (*env)->GetStaticMethodID(env, class_array, "newInstance", "(Ljava/lang/Class;I)Ljava/lang/Object;"); id_arrayset = (*env)->GetStaticMethodID(env, class_array, "set", "(Ljava/lang/Object;ILjava/lang/Object;)V"); pair_map_init(env, &m); setup = 1; } }
static void setup_classes(JNIEnv* env, jmp_buf handle) { // class registering classreg(env, "java/lang/Object", &class_object, handle); classreg(env, ENGINE_CLASS, &class_type, handle); classreg(env, ENGINE_LUA_CLASS, &class_lua, handle); classreg(env, ENGINE_ERR_CLASS, &exclass, handle); classreg(env, "java/lang/reflect/Method", &class_method, handle); classreg(env, "java/lang/Throwable", &class_ex, handle); // Object ids id_hashcode = method_resolve(env, class_object, "hashCode", "()I", handle); // Method ids id_methodcall = method_resolve(env, class_method, "invoke", "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", handle); id_methodcount = method_resolve(env, class_method, "getParameterCount", "()I", handle); id_methodtypes = method_resolve(env, class_method, "getParameterTypes", "()[Ljava/lang/Class;", handle); // Class ids id_comptype = method_resolve(env, class_type, "getComponentType", "()Ljava/lang/Class;", handle); id_classname = method_resolve(env, class_type, "getSimpleName", "()Ljava/lang/String;", handle); // Lua ids id_methodresolve = static_method_resolve(env, class_lua, "resolveMethod", "(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/reflect/Method;", handle); id_methodid = static_method_resolve(env, class_lua, "methodId", "(Ljava/lang/reflect/Method;)J", handle); id_exhandle = static_method_resolve(env, class_lua, "handleJavaException", "(Ljava/lang/Throwable;)V", handle); // Throwable ids id_getmessage = method_resolve(env, class_ex, "getMessage", "()Ljava/lang/String;", handle); char buf[128] = {0}; strcat(buf, "(Ljava/lang/Object;)L"); strcat(buf, ENGINE_VALUE_INTERFACE); strcat(buf, ";"); id_translatevalue = static_method_resolve(env, class_lua, "translateToScriptValue", buf, handle); memset(buf, 0, sizeof(buf)); strcat(buf, "(Ljava/lang/Class;L"); strcat(buf, ENGINE_VALUE_INTERFACE); strcat(buf, ";)Ljava/lang/Object;"); id_translate = static_method_resolve(env, class_lua, "translate", buf, handle); ASSERTEX(env); }