本文整理汇总了C++中JEnv::NewGlobalRef方法的典型用法代码示例。如果您正苦于以下问题:C++ JEnv::NewGlobalRef方法的具体用法?C++ JEnv::NewGlobalRef怎么用?C++ JEnv::NewGlobalRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JEnv
的用法示例。
在下文中一共展示了JEnv::NewGlobalRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResolveClass
jclass NativeScriptRuntime::ResolveClass(const std::string& fullClassname, const Local<Object>& implementationObject) {
auto itFound = s_classCache.find(fullClassname);
jclass globalRefToGeneratedClass;
if (itFound != s_classCache.end())
{
globalRefToGeneratedClass = itFound->second;
}
else
{
JEnv env;
//get needed arguments in order to load binding
JniLocalRef javaFullClassName(env.NewStringUTF(fullClassname.c_str()));
jobjectArray methodOverrides = GetMethodOverrides(env, implementationObject);
//create or load generated binding (java class)
JniLocalRef generatedClass(env.CallStaticObjectMethod(PlatformClass, RESOLVE_CLASS_METHOD_ID, (jstring)javaFullClassName, methodOverrides));
globalRefToGeneratedClass = reinterpret_cast<jclass>(env.NewGlobalRef(generatedClass));
s_classCache.insert(make_pair(fullClassname, globalRefToGeneratedClass));
}
return globalRefToGeneratedClass;
}
示例2: ResolveClass
jclass NativeScriptRuntime::ResolveClass(const std::string& fullClassname, const Handle<Object>& implementationObject) {
JEnv env;
//get needed arguments in order to load binding
JniLocalRef javaFullClassName(env.NewStringUTF(fullClassname.c_str()));
jobjectArray methodOverrides = GetMethodOverrides(env, implementationObject);
//create or load generated binding (java class)
JniLocalRef generatedClass(env.CallStaticObjectMethod(PlatformClass, RESOLVE_CLASS_METHOD_ID, (jstring)javaFullClassName, methodOverrides));
jclass globalRefToGeneratedClass = reinterpret_cast<jclass>(env.NewGlobalRef(generatedClass));
return globalRefToGeneratedClass;
}
示例3: Init
void JsDebugger::Init(v8::Isolate *isolate, const string& packageName, jobject jsDebugger)
{
s_isolate = isolate;
s_packageName = packageName;
JEnv env;
s_jsDebugger = env.NewGlobalRef(jsDebugger);
s_JsDebuggerClass = env.FindClass("com/tns/JsDebugger");
assert(s_JsDebuggerClass != nullptr);
s_EnqueueMessage = env.GetMethodID(s_JsDebuggerClass, "enqueueMessage", "(Ljava/lang/String;)V");
assert(s_EnqueueMessage != nullptr);
s_EnableAgent = env.GetMethodID(s_JsDebuggerClass, "enableAgent", "()V");
assert(s_EnableAgent != nullptr);
}
示例4: buff
DirectBuffer::DirectBuffer(uint32_t length)
{
m_length = length;
m_data = new int[m_length];
m_end = m_data + m_length;
Reset();
int capacity = m_length * sizeof(int);
JEnv env;
JniLocalRef buff(env.NewDirectByteBuffer(m_data, capacity));
m_buff = env.NewGlobalRef(buff);
}