本文整理汇总了C++中JPCleaner::removeLocal方法的典型用法代码示例。如果您正苦于以下问题:C++ JPCleaner::removeLocal方法的具体用法?C++ JPCleaner::removeLocal怎么用?C++ JPCleaner::removeLocal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JPCleaner
的用法示例。
在下文中一共展示了JPCleaner::removeLocal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertToJava
jvalue JPArrayClass::convertToJava(HostRef* obj)
{
JPCleaner cleaner;
jvalue res;
res.l = NULL;
if (JPEnv::getHost()->isArray(obj))
{
JPArray* a = JPEnv::getHost()->asArray(obj);
res = a->getValue();
}
else if (JPEnv::getHost()->isByteString(obj) && m_ComponentType->getName().getType() == JPTypeName::_byte && sizeof(char) == sizeof(jbyte))
{
char* rawData;
long size;
JPEnv::getHost()->getRawByteString(obj, &rawData, size);
jbyteArray array = JPEnv::getJava()->NewByteArray(size);
cleaner.addLocal(array);
res.l = array;
jboolean isCopy;
jbyte* contents = JPEnv::getJava()->GetByteArrayElements(array, &isCopy);
memcpy(contents, rawData, size*sizeof(jbyte));
JPEnv::getJava()->ReleaseByteArrayElements(array, contents, 0);
cleaner.removeLocal(array);
}
else if (JPEnv::getHost()->isUnicodeString(obj) && m_ComponentType->getName().getType() == JPTypeName::_char && JPEnv::getHost()->getUnicodeSize() == sizeof(jchar))
{
jchar* rawData;
long size;
JPEnv::getHost()->getRawUnicodeString(obj, &rawData, size);
jcharArray array = JPEnv::getJava()->NewCharArray(size);
cleaner.addLocal(array);
res.l = array;
jboolean isCopy;
jchar* contents = JPEnv::getJava()->GetCharArrayElements(array, &isCopy);
memcpy(contents, rawData, size*sizeof(jchar));
JPEnv::getJava()->ReleaseCharArrayElements(array, contents, 0);
cleaner.removeLocal(array);
}
else if (JPEnv::getHost()->isSequence(obj))
{
int length = JPEnv::getHost()->getSequenceLength(obj);
jarray array = m_ComponentType->newArrayInstance(length);
cleaner.addLocal(array);
res.l = array;
for (int i = 0; i < length ; i++)
{
HostRef* obj2 = JPEnv::getHost()->getSequenceItem(obj, i);
cleaner.add(obj2);
m_ComponentType->setArrayItem(array, i, obj2);
}
cleaner.removeLocal(array);
}
return res;
}