jvalue JPClassType::convertToJava(HostRef* obj) { JPCleaner cleaner; jvalue v; if (JPEnv::getHost()->isNone(obj)) { v.l = NULL; return v; } else if (JPEnv::getHost()->isWrapper(obj)) { v = JPEnv::getHost()->getWrapperValue(obj); } else { JPClass* w = JPEnv::getHost()->asClass(obj); jclass lr = w->getClass(); v.l = lr; } return v; }
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; }
jobject JPPrimitiveType::convertToJavaObject(HostRef* obj) { JPCleaner cleaner; JPTypeName tname = getObjectType(); JPClass* c = JPTypeManager::findClass(tname); jclass jc = c->getClass(); cleaner.addLocal(jc); vector<HostRef*> args(1); args[0] = obj; JPObject* o = c->newInstance(args); jobject res = o->getObject(); delete o; return res; }