本文整理汇总了C++中JPCleaner::addGlobal方法的典型用法代码示例。如果您正苦于以下问题:C++ JPCleaner::addGlobal方法的具体用法?C++ JPCleaner::addGlobal怎么用?C++ JPCleaner::addGlobal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JPCleaner
的用法示例。
在下文中一共展示了JPCleaner::addGlobal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: invokeStatic
HostRef* JPMethodOverload::invokeStatic(vector<HostRef*>& arg)
{
TRACE_IN("JPMethodOverload::invokeStatic");
JPCleaner cleaner;
size_t len = arg.size();
JPMallocCleaner<jvalue> v(len);
JPMallocCleaner<JPType*> types(len);
for (unsigned int i = 0; i < len; i++)
{
HostRef* obj = arg[i];
types[i] = JPTypeManager::getType(m_Arguments[i]);
v[i] = types[i]->convertToJava(obj);
if (types[i]->isObjectType())
{
cleaner.addLocal(v[i].l);
}
}
jclass claz = m_Class->getClass();
cleaner.addGlobal(claz);
JPType* retType = JPTypeManager::getType(m_ReturnType);
return retType->invokeStatic(claz, m_MethodID, v.borrow());
TRACE_OUT;
}
示例2: invokeInstance
HostRef* JPMethodOverload::invokeInstance(vector<HostRef*>& args)
{
TRACE_IN("JPMethodOverload::invokeInstance");
HostRef* res;
{
JPCleaner cleaner;
// Arg 0 is "this"
HostRef* self = args[0];
JPObject* selfObj = JPEnv::getHost()->asObject(self);
size_t len = args.size();
JPMallocCleaner<jvalue> v(len-1);
for (unsigned int i = 1; i < len; i++)
{
HostRef* obj = args[i];
JPType* type = JPTypeManager::getType(m_Arguments[i]);
v[i-1] = type->convertToJava(obj);
// below seems not to be necessary, since jvalues are clean by jpmalloccleaner
// if (type->isObjectType())
// {
// //TODO : investigate: this is not valid for either local or global ref
// // add hostref to garbage collection
// cleaner.add(v[i-1].l);
// }
}
JPType* retType = JPTypeManager::getType(m_ReturnType);
jobject c = selfObj->getObject();
cleaner.addLocal(c);
jclass clazz = m_Class->getClass();
cleaner.addGlobal(clazz);
res = retType->invoke(c, clazz, m_MethodID, v.borrow());
TRACE1("Call finished");
}
TRACE1("Call successfull");
return res;
TRACE_OUT;
}
示例3: createProxy
PyObject* JPypeJavaProxy::createProxy(PyObject*, PyObject* arg)
{
try {
JPCleaner cleaner;
PyObject* self;
PyObject* intf;
//TODO: why is self not initialized?
JPyArg::parseTuple(arg, "OO", &self, &intf);
std::vector<jclass> interfaces;
Py_ssize_t len = JPyObject::length(intf);
for (Py_ssize_t i = 0; i < len; i++)
{
PyObject* subObj = JPySequence::getItem(intf, i);
cleaner.add(new HostRef(subObj, false));
PyObject* claz = JPyObject::getAttrString(subObj, "__javaclass__");
PyJPClass* c = (PyJPClass*)claz;
jclass jc = c->m_Class->getClass();
cleaner.addGlobal(jc);
interfaces.push_back(jc);
}
HostRef ref = HostRef(self);
JPProxy* proxy = new JPProxy(&ref, interfaces);
PyObject* res = JPyCObject::fromVoidAndDesc(proxy, (void*)"jproxy", PythonHostEnvironment::deleteJPProxyDestructor);
return res;
}
PY_STANDARD_CATCH
return NULL;
}