本文整理汇总了C++中JPCleaner::addLocal方法的典型用法代码示例。如果您正苦于以下问题:C++ JPCleaner::addLocal方法的具体用法?C++ JPCleaner::addLocal怎么用?C++ JPCleaner::addLocal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JPCleaner
的用法示例。
在下文中一共展示了JPCleaner::addLocal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getParameterTypes
vector<JPTypeName> getParameterTypes(jobject o, bool isConstructor)
{
JPCleaner cleaner;
vector<JPTypeName> args;
jobjectArray types ;
if (isConstructor)
{
types = (jobjectArray)JPEnv::getJava()->CallObjectMethod(o, getConstructorParameterTypesID);
}
else
{
types = (jobjectArray)JPEnv::getJava()->CallObjectMethod(o, getParameterTypesID);
}
cleaner.addLocal(types);
int len = JPEnv::getJava()->GetArrayLength(types);
for (int i = 0; i < len; i++)
{
jclass c = (jclass)JPEnv::getJava()->GetObjectArrayElement(types, i);
cleaner.addLocal(c);
JPTypeName name = getName(c);
args.push_back(name);
}
return args;
}
示例2: invokeConstructor
JPObject* JPMethodOverload::invokeConstructor(jclass claz, vector<HostRef*>& arg)
{
TRACE_IN("JPMethodOverload::invokeConstructor");
size_t len = arg.size();
JPCleaner cleaner;
JPMallocCleaner<jvalue> v(len);
for (unsigned int i = 0; i < len; i++)
{
HostRef* obj = arg[i];
// TODO the following can easily be optimized ... or at least cached
JPType* t = JPTypeManager::getType(m_Arguments[i]);
v[i] = t->convertToJava(obj);
if (t->isObjectType())
{
cleaner.addLocal(v[i].l);
}
}
jvalue val;
val.l = JPEnv::getJava()->NewObjectA(claz, m_MethodID, v.borrow());
cleaner.addLocal(val.l);
TRACE1("Object created");
JPTypeName name = JPJni::getName(claz);
return new JPObject(name, val.l);
TRACE_OUT;
}
示例3: errorOccurred
void JPypeJavaException::errorOccurred()
{
TRACE_IN("PyJavaException::errorOccurred");
JPCleaner cleaner;
jthrowable th = JPEnv::getJava()->ExceptionOccurred();
cleaner.addLocal(th);
JPEnv::getJava()->ExceptionClear();
jclass ec = JPJni::getClass(th);
JPTypeName tn = JPJni::getName(ec);
JPClass* jpclass = JPTypeManager::findClass(tn);
cleaner.addLocal(ec);
PyObject* jexclass = hostEnv->getJavaShadowClass(jpclass);
HostRef* pyth = hostEnv->newObject(new JPObject(tn, th));
cleaner.add(pyth);
PyObject* args = JPySequence::newTuple(2);
PyObject* arg2 = JPySequence::newTuple(1);
JPySequence::setItem(arg2, 0, args);
Py_DECREF(args);
JPySequence::setItem(args, 0, hostEnv->m_SpecialConstructorKey);
JPySequence::setItem(args, 1, (PyObject*)pyth->data());
PyObject* pyexclass = JPyObject::getAttrString(jexclass, "PYEXC");
Py_DECREF(jexclass);
JPyErr::setObject(pyexclass, arg2);
Py_DECREF(arg2);
Py_DECREF(pyexclass);
TRACE_OUT;
}
示例4: synchronized
PyObject* JPypeModule::synchronized(PyObject* obj, PyObject* args)
{
JPCleaner cleaner;
TRACE_IN("synchronized");
try {
PyObject* o;
JPyArg::parseTuple(args, "O!", &PyCObject_Type, &o);
string desc = (char*)JPyCObject::getDesc(o);
jobject obj;
if (desc == "JPObject")
{
JPObject* jpo = (JPObject*)JPyCObject::asVoidPtr(o);
obj = jpo->getObject();
cleaner.addLocal(obj);
}
else if (desc == "JPClass")
{
JPClass* jpo = (JPClass*)JPyCObject::asVoidPtr(o);
obj = jpo->getClass();
cleaner.addLocal(obj);
}
else if (desc == "JPArray")
{
JPArray* jpo = (JPArray*)JPyCObject::asVoidPtr(o);
obj = jpo->getObject();
cleaner.addLocal(obj);
}
else if (desc == "JPArrayClass")
{
JPArrayClass* jpo = (JPArrayClass*)JPyCObject::asVoidPtr(o);
obj = jpo->getClass();
cleaner.addLocal(obj);
}
else if (hostEnv->isWrapper(o) && hostEnv->getWrapperTypeName(o).isObjectType())
{
obj = hostEnv->getWrapperValue(o).l;
cleaner.addLocal(obj);
}
// TODO proxy
else
{
RAISE(JPypeException, "method only accepts object values.");
}
PyJPMonitor* c = PyJPMonitor::alloc(new JPMonitor(obj));
return (PyObject*)c;
}
PY_STANDARD_CATCH;
PyErr_Clear();
Py_INCREF(Py_None);
return Py_None;
TRACE_OUT;
}
示例5: getInstanceAttribute
PyObject* PyJPField::getInstanceAttribute(PyObject* o, PyObject* arg)
{
TRACE_IN("getInstanceAttribute");
JPCleaner cleaner;
try {
PyJPField* self = (PyJPField*)o;
PyObject* jo;
JPyArg::parseTuple(arg, "O!", &PyCapsule_Type, &jo);
JPObject* obj = (JPObject*)JPyCObject::asVoidPtr(jo);
jobject jobj = obj->getObject();
cleaner.addLocal(jobj);
HostRef* res = self->m_Field->getAttribute(jobj);
return detachRef(res);
}
PY_STANDARD_CATCH
return NULL;
TRACE_OUT;
}
示例6: setInstanceAttribute
PyObject* PyJPField::setInstanceAttribute(PyObject* o, PyObject* arg)
{
JPCleaner cleaner;
try {
PyJPField* self = (PyJPField*)o;
PyObject* jo;
PyObject* value;
JPyArg::parseTuple(arg, "O!O", &PyCapsule_Type, &jo, &value);
JPObject* obj = (JPObject*)JPyCObject::asVoidPtr(jo);
HostRef* ref = new HostRef(value);
cleaner.add(ref);
jobject jobj = obj->getObject();
cleaner.addLocal(jobj);
self->m_Field->setAttribute(jobj, ref);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
示例7: startJPypeReferenceQueue
void startJPypeReferenceQueue(bool useJavaThread)
{
JPCleaner cleaner;
JPypeReferenceQueueClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("jpype/ref/JPypeReferenceQueue"));
JPypeReferenceQueueConstructorMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "<init>", "()V");
JPypeReferenceQueueRegisterMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "registerRef", "(Ljpype/ref/JPypeReference;J)V");
JPypeReferenceQueueStartMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "startManaging", "()V");
JPypeReferenceQueueRunMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "run", "()V");
JPypeReferenceQueueStopMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "stop", "()V");
JPypeReferenceClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("jpype/ref/JPypeReference"));
JPypeReferenceConstructorMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceClass, "<init>", "(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V");
jobject obj = JPEnv::getJava()->NewObject(JPypeReferenceQueueClass, JPypeReferenceQueueConstructorMethod);
cleaner.addLocal(obj);
JPEnv::getJava()->setReferenceQueue(obj);
if (useJavaThread)
{
JPEnv::getJava()->CallVoidMethod(obj, JPypeReferenceQueueStartMethod);
}
else
{
JPEnv::getJava()->CallVoidMethod(obj, JPypeReferenceQueueRunMethod);
}
}
示例8: setStaticAttribute
void JPField::setStaticAttribute(HostRef* val)
{
TRACE_IN("JPField::setStaticAttribute");
if (m_IsFinal)
{
stringstream err;
err << "Field " << m_Name << " is read-only";
RAISE(JPypeException, err.str().c_str());
}
JPType* type = JPTypeManager::getType(m_Type);
if (type->canConvertToJava(val) <= _explicit)
{
stringstream err;
err << "unable to convert to " << type->getName().getSimpleName();
RAISE(JPypeException, err.str().c_str());
}
JPCleaner cleaner;
jclass claz = m_Class->getClass();
cleaner.addLocal(claz);
type->setStaticValue(claz, m_FieldID, val);
TRACE_OUT;
}
示例9: 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;
}
示例10: init
void JPProxy::init()
{
TRACE_IN("JPProxy::init");
// build the proxy class ...
jobject cl = JPJni::getSystemClassLoader();
JPCleaner cleaner;
jclass handler = JPEnv::getJava()->DefineClass("jpype/JPypeInvocationHandler", cl, JPypeInvocationHandler, getJPypeInvocationHandlerLength());
handlerClass = (jclass)JPEnv::getJava()->NewGlobalRef(handler);
cleaner.addLocal(handler);
JNINativeMethod method[1];
method[0].name = (char*) "hostInvoke";
method[0].signature =(char*) "(Ljava/lang/String;J[Ljava/lang/Object;[Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Object;";
method[0].fnPtr = (void*) &Java_jpype_JPypeInvocationHandler_hostInvoke;
hostObjectID = JPEnv::getJava()->GetFieldID(handler, "hostObject", "J");
invocationHandlerConstructorID = JPEnv::getJava()->GetMethodID(handler, "<init>", "()V");
JPEnv::getJava()->RegisterNatives(handlerClass, method, 1);
// Not quite the right area ... but I;m doing similar here already so let's register the other classes too
jclass reference = JPEnv::getJava()->DefineClass("jpype/ref/JPypeReference", cl, JPypeReference, getJPypeReferenceLength());
jclass referenceQueue = JPEnv::getJava()->DefineClass("jpype/ref/JPypeReferenceQueue", cl, JPypeReferenceQueue, getJPypeReferenceQueueLength());
referenceClass = (jclass)JPEnv::getJava()->NewGlobalRef(reference);
referenceQueueClass = (jclass)JPEnv::getJava()->NewGlobalRef(referenceQueue);
//Required due to bug in jvm
//See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6493522
jmethodID refQConstr = JPEnv::getJava()->GetMethodID(referenceQueue, "<init>", "()V");
cleaner.addLocal(reference);
cleaner.addLocal(referenceQueue);
JNINativeMethod method2[1];
method2[0].name = (char*) "removeHostReference";
method2[0].signature = (char*) "(J)V";
method2[0].fnPtr = (void*)&Java_jpype_ref_JPypeReferenceQueue_removeHostReference;
JPEnv::getJava()->RegisterNatives(referenceQueueClass, method2, 1);
TRACE_OUT;
}
示例11: getMessage
string getMessage(jthrowable th)
{
JPCleaner cleaner;
jstring jstr = (jstring)JPEnv::getJava()->CallObjectMethod(th, getMessageID);
cleaner.addLocal(jstr);
return asciiFromJava(jstr);
}
示例12: getReturnType
JPTypeName getReturnType(jobject o)
{
JPCleaner cleaner;
jclass c = (jclass)JPEnv::getJava()->CallObjectMethod(o, getReturnTypeID);
cleaner.addLocal(c);
return getName(c);
}
示例13: getMemberName
string getMemberName(jobject o)
{
JPCleaner cleaner;
jstring name = (jstring)JPEnv::getJava()->CallObjectMethod(o, getMemberNameID);
cleaner.addLocal(name);
string simpleName = asciiFromJava(name);
return simpleName;
}
示例14: newArrayInstance
jarray JPObjectType::newArrayInstance(int sz)
{
JPCleaner cleaner;
jclass c = getClass();
cleaner.addLocal(c);
return JPEnv::getJava()->NewObjectArray(sz, c, NULL);
}
示例15: setArrayItem
void JPObjectType::setArrayItem(jarray a, int ndx, HostRef* val)
{
jobjectArray array = (jobjectArray)a;
JPCleaner cleaner;
jvalue v = convertToJava(val);
cleaner.addLocal(v.l);
JPEnv::getJava()->SetObjectArrayElement(array, ndx, v.l);
}