本文整理汇总了C++中JEnv::GetObjectClass方法的典型用法代码示例。如果您正苦于以下问题:C++ JEnv::GetObjectClass方法的具体用法?C++ JEnv::GetObjectClass怎么用?C++ JEnv::GetObjectClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JEnv
的用法示例。
在下文中一共展示了JEnv::GetObjectClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clazz
Local<Object> ObjectManager::CreateJSWrapper(jint javaObjectID, const string& typeName, jobject instance)
{
JEnv env;
JniLocalRef clazz(env.GetObjectClass(instance));
return CreateJSWrapperHelper(javaObjectID, typeName, clazz);
}
示例2: GetClassName
string ObjectManager::GetClassName(jobject javaObject)
{
JEnv env;
JniLocalRef objectClass(env.GetObjectClass(javaObject));
return GetClassName((jclass) objectClass);
}
示例3: AppInitCallback
void NativePlatform::AppInitCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
{
try {
auto isolate = Isolate::GetCurrent();
if (args.Length() != 1)
{
throw NativeScriptException(string("Application should be initialized with single parameter"));
}
if (!args[0]->IsObject())
{
throw NativeScriptException(string("Application should be initialized with single object parameter containing overridden methods"));
}
// TODO: find another way to get "com/tns/NativeScriptApplication" metadata (move it to more appropriate place)
auto node = MetadataNode::GetOrCreate("com/tns/NativeScriptApplication");
auto appInstance = node->CreateJSWrapper(isolate);
DEBUG_WRITE("Application object created id: %d", appInstance->GetIdentityHash());
auto implementationObject = args[0]->ToObject();
implementationObject->SetHiddenValue(V8StringConstants::GetClassImplementationObject(), External::New(isolate, node));
DEBUG_WRITE("Application object implementation object is with id: %d", implementationObject->GetIdentityHash());
implementationObject->SetPrototype(appInstance->GetPrototype());
bool appSuccess = appInstance->SetPrototype(implementationObject);
if (!appSuccess)
{
throw NativeScriptException(string("Application could not be initialized correctly"));
}
jweak applicationObject = g_objectManager->GetJavaObjectByID(AppJavaObjectID);
JEnv env;
jclass appClass = env.FindClass("com/tns/NativeScriptApplication");
g_objectManager->Link(appInstance, AppJavaObjectID, appClass);
JniLocalRef applicationClass(env.GetObjectClass(applicationObject));
jmethodID setNativeScriptOverridesMethodId = env.GetMethodID((jclass)applicationClass, "setNativeScriptOverrides", "([Ljava/lang/String;)V");
jobjectArray methodOverrides = NativeScriptRuntime::GetMethodOverrides(env, implementationObject);
env.CallVoidMethod(applicationObject, setNativeScriptOverridesMethodId, methodOverrides);
} catch (NativeScriptException& e) {
e.ReThrowToV8();
}
catch (exception e) {
DEBUG_WRITE("Error: c++ exception: %s", e.what());
}
catch (...) {
DEBUG_WRITE("Error: c++ exception!");
}
}