本文整理汇总了C++中JNIContext::getClassRef方法的典型用法代码示例。如果您正苦于以下问题:C++ JNIContext::getClassRef方法的具体用法?C++ JNIContext::getClassRef怎么用?C++ JNIContext::getClassRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JNIContext
的用法示例。
在下文中一共展示了JNIContext::getClassRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createProxiedComponent
jobject createProxiedComponent(long contextAddress, const char *externalClassName, jmethodID methodID, jvalue *args)
{
LOGV("createProxiedComponent contextAddress %ld proxiedClass %s using args %ld", contextAddress, externalClassName, (long) args);
JNIContext *jni = JNIContext::sharedInstance();
jclass clazz = jni->getClassRef(externalClassName);
jobject object = jni->createNewObject(clazz, methodID, args);
jni->deleteLocalRef(clazz);
return object;
}
示例2: createProxiedCallback
jobject CXXContext::createProxiedCallback(long contextAddress, long proxiedObjectID, const char *externalClassName)
{
LOGV("createProxiedCallback contextAddress %ld proxiedObjectID %d proxiedClass %s", contextAddress, proxiedObjectID, externalClassName);
JNIContext *jni = JNIContext::sharedInstance();
jclass clazz = jni->getClassRef(externalClassName);
jobject object = jni->callObjectMethod(ectx_object, ectx_method_createProxiedCallback, (jlong) contextAddress, (jlong) proxiedObjectID, clazz);
jni->deleteLocalRef(clazz);
return object;
}
示例3:
CXXContext::CXXContext(jobject applicationContext, jobject cxxJavaContext)
{
sm_sharedInstance = this;
JNIContext *jniContext = JNIContext::sharedInstance();
actx_object = jniContext->localToGlobalRef(applicationContext);
LOGV("loaded actx_object %d", actx_object);
ectx_object = jniContext->localToGlobalRef(cxxJavaContext);
LOGV("loaded ectx_object %d", ectx_object);
ectx_class = jniContext->getClassRef(JAVA_CLASS_NAME);
ectx_class = (jclass) jniContext->localToGlobalRef(ectx_class);
LOGV("loaded ectx_class %d", ectx_class);
ectx_method_createProxiedCallback = jniContext->getMethodID(ectx_class, JAVA_CREATE_PROXIED_METHOD_NAME, JAVA_CREATE_PROXIED_METHOD_SIGNATURE);
LOGV("loaded ectx_method_createProxiedCallback");
}
示例4: convert__object_array_type
void convert__object_array_type(long& java_value, long& cxx_value, const CXXTypeHierarchy cxx_type_hierarchy, const converter_t& converter_type, std::stack<long>& converter_stack)
{
JNIContext *jni = JNIContext::sharedInstance();
if (converter_type == CONVERT_TO_JAVA)
{
jni->pushLocalFrame();
cxx_converter item_converter = get_converter(converter_stack);
std::vector<long> *cxx_vector = (std::vector<long> *) cxx_value;
int count = cxx_vector->size();
std::string child_type = jni->getJNIName( std::string("java.lang.Object") );
CXXTypeHierarchy item_type;
item_type.type_name = child_type;
std::vector<CXXTypeHierarchy> child_types = cxx_type_hierarchy.child_types;
if (child_types.size() > 0)
{
item_type = child_types.at(0);
child_type = jni->getJNIName( item_type.type_name );
}
java_value = (long) jni->createObjectArray(count, jni->getClassRef( child_type.c_str() ));
for(std::vector<long>::iterator it = cxx_vector->begin(); it != cxx_vector->end(); ++it)
{
long cxx_item_ptr = (long) *it;
long java_item_ptr = 0;
int item_idx = it - cxx_vector->begin();
item_converter(java_item_ptr, cxx_item_ptr, item_type, converter_type, converter_stack);
jni->setObjectArrayElement((jobjectArray) java_value, item_idx, (jobject) java_item_ptr);
}
java_value = (long) jni->popLocalFrame((jobject) java_value);
}
else if (converter_type == CONVERT_TO_CXX)
{
jni->pushLocalFrame();
std::string child_type = jni->getJNIName( std::string("java.lang.Object") );
CXXTypeHierarchy item_type;
item_type.type_name = child_type;
std::vector<CXXTypeHierarchy> child_types = cxx_type_hierarchy.child_types;
if (child_types.size() > 0)
{
item_type = child_types.at(0);
child_type = jni->getJNIName( item_type.type_name );
}
cxx_converter item_converter = get_converter(converter_stack);
std::vector<long> *cxx_vector = (std::vector<long> *) cxx_value;
int size = (int) jni->getArrayLength((jobjectArray) java_value);
for (int idx = 0 ; idx < size; idx++)
{
long java_item_ptr = (long) jni->getObjectArrayElement((jobjectArray) java_value, idx);
long cxx_item_ptr = 0;
item_converter(java_item_ptr, cxx_item_ptr, item_type, converter_type, converter_stack);
cxx_vector->push_back(cxx_item_ptr);
}
jni->popLocalFrame();
}
}