本文整理汇总了C++中JNISingleton类的典型用法代码示例。如果您正苦于以下问题:C++ JNISingleton类的具体用法?C++ JNISingleton怎么用?C++ JNISingleton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JNISingleton类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Java_org_godotengine_godot_GodotLib_singleton
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_singleton(JNIEnv *env, jobject obj, jstring name, jobject p_object) {
String singname = env->GetStringUTFChars(name, NULL);
JNISingleton *s = memnew(JNISingleton);
s->set_instance(env->NewGlobalRef(p_object));
jni_singletons[singname] = s;
GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton(singname, s));
GlobalConfig::get_singleton()->set(singname, s);
}
示例2: Java_com_android_godot_Godot_registerSingleton
JNIEXPORT void JNICALL Java_com_android_godot_Godot_registerSingleton(JNIEnv * env, jobject obj, jstring name,jobject p_object){
String singname = env->GetStringUTFChars( name, NULL );
JNISingleton *s = memnew( JNISingleton );
s->update_env(env);
s->set_instance(env->NewGlobalRef(p_object));
jni_singletons[singname]=s;
Globals::get_singleton()->add_singleton(Globals::Singleton(singname,s));
}
示例3: Java_com_android_godot_Godot_registerMethod
JNIEXPORT void JNICALL Java_com_android_godot_Godot_registerMethod(JNIEnv * env, jobject obj, jstring sname, jstring name, jstring ret, jobjectArray args){
String singname = env->GetStringUTFChars( sname, NULL );
ERR_FAIL_COND(!jni_singletons.has(singname));
JNISingleton *s = jni_singletons.get(singname);
String mname = env->GetStringUTFChars( name, NULL );
String retval = env->GetStringUTFChars( ret, NULL );
Vector<Variant::Type> types;
String cs="(";
int stringCount = env->GetArrayLength(args);
print_line("Singl: "+singname+" Method: "+mname+" RetVal: "+retval);
for (int i=0; i<stringCount; i++) {
jstring string = (jstring) env->GetObjectArrayElement(args, i);
const char *rawString = env->GetStringUTFChars(string, 0);
types.push_back(get_jni_type(String(rawString)));
cs+=get_jni_sig(String(rawString));
}
cs+=")";
cs+=get_jni_sig(retval);
jclass cls = env->GetObjectClass(s->get_instance());
print_line("METHOD: "+mname+" sig: "+cs);
jmethodID mid = env->GetMethodID(cls, mname.ascii().get_data(), cs.ascii().get_data());
if (!mid) {
print_line("FAILED GETTING METHOID "+mname);
}
s->add_method(mname,mid,types,get_jni_type(retval));
}