本文整理汇总了C++中PyObjectHandle::release方法的典型用法代码示例。如果您正苦于以下问题:C++ PyObjectHandle::release方法的具体用法?C++ PyObjectHandle::release怎么用?C++ PyObjectHandle::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyObjectHandle
的用法示例。
在下文中一共展示了PyObjectHandle::release方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
static PyObject*
adapterGetPublishedEndpoints(ObjectAdapterObject* self)
{
assert(self->adapter);
Ice::EndpointSeq endpoints;
try
{
endpoints = (*self->adapter)->getPublishedEndpoints();
}
catch(const Ice::Exception& ex)
{
setPythonException(ex);
return 0;
}
int count = static_cast<int>(endpoints.size());
PyObjectHandle result = PyTuple_New(count);
int i = 0;
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p, ++i)
{
PyObjectHandle endp = createEndpoint(*p);
if(!endp.get())
{
return 0;
}
PyTuple_SET_ITEM(result.get(), i, endp.release()); // PyTuple_SET_ITEM steals a reference.
}
return result.release();
}
示例2: assert
static PyObject*
communicatorFindAllAdminFacets(CommunicatorObject* self)
{
assert(self->communicator);
Ice::FacetMap facetMap;
try
{
facetMap = (*self->communicator)->findAllAdminFacets();
}
catch(const Ice::Exception& ex)
{
setPythonException(ex);
return 0;
}
PyObjectHandle result = PyDict_New();
if(!result.get())
{
return 0;
}
PyTypeObject* objectType = reinterpret_cast<PyTypeObject*>(lookupType("Ice.Object"));
PyObjectHandle plainObject = objectType->tp_alloc(objectType, 0);
for(Ice::FacetMap::const_iterator p = facetMap.begin(); p != facetMap.end(); ++p)
{
PyObjectHandle obj = plainObject;
ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(p->second);
if(wrapper)
{
obj = wrapper->getObject();
}
else
{
Ice::NativePropertiesAdminPtr props = Ice::NativePropertiesAdminPtr::dynamicCast(p->second);
if(props)
{
obj = createNativePropertiesAdmin(props);
}
}
if(PyDict_SetItemString(result.get(), const_cast<char*>(p->first.c_str()), obj.get()) < 0)
{
return 0;
}
}
return result.release();
}
示例3: getProxy
static PyObject*
communicatorProxyToProperty(CommunicatorObject* self, PyObject* args)
{
//
// We don't want to accept None here, so we can specify ProxyType and force
// the caller to supply a proxy object.
//
PyObject* proxyObj;
PyObject* strObj;
if(!PyArg_ParseTuple(args, STRCAST("O!O"), &ProxyType, &proxyObj, &strObj))
{
return 0;
}
Ice::ObjectPrx proxy = getProxy(proxyObj);
string str;
if(!getStringArg(strObj, "property", str))
{
return 0;
}
assert(self->communicator);
Ice::PropertyDict dict;
try
{
dict = (*self->communicator)->proxyToProperty(proxy, str);
}
catch(const Ice::Exception& ex)
{
setPythonException(ex);
return 0;
}
PyObjectHandle result = PyDict_New();
if(result.get())
{
for(Ice::PropertyDict::iterator p = dict.begin(); p != dict.end(); ++p)
{
PyObjectHandle key = createString(p->first);
PyObjectHandle val = createString(p->second);
if(!val.get() || PyDict_SetItem(result.get(), key.get(), val.get()) < 0)
{
return 0;
}
}
}
return result.release();
}
示例4: lookupType
static PyObject*
adapterRemoveAllFacets(ObjectAdapterObject* self, PyObject* args)
{
PyObject* identityType = lookupType("Ice.Identity");
PyObject* id;
if(!PyArg_ParseTuple(args, STRCAST("O!"), identityType, &id))
{
return 0;
}
Ice::Identity ident;
if(!getIdentity(id, ident))
{
return 0;
}
assert(self->adapter);
Ice::FacetMap facetMap;
try
{
facetMap = (*self->adapter)->removeAllFacets(ident);
}
catch(const Ice::Exception& ex)
{
setPythonException(ex);
return 0;
}
PyObjectHandle result = PyDict_New();
if(!result.get())
{
return 0;
}
for(Ice::FacetMap::iterator p = facetMap.begin(); p != facetMap.end(); ++p)
{
ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(p->second);
assert(wrapper);
PyObjectHandle obj = wrapper->getObject();
if(PyDict_SetItemString(result.get(), const_cast<char*>(p->first.c_str()), obj.get()) < 0)
{
return 0;
}
}
return result.release();
}
示例5: lookupType
static PyObject*
communicatorFlushBatchRequestsAsync(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/)
{
PyObject* compressBatchType = lookupType("Ice.CompressBatch");
PyObject* compressBatch;
if(!PyArg_ParseTuple(args, STRCAST("O!"), compressBatchType, &compressBatch))
{
return 0;
}
PyObjectHandle v = getAttr(compressBatch, "_value", false);
assert(v.get());
Ice::CompressBatch cb = static_cast<Ice::CompressBatch>(PyLong_AsLong(v.get()));
assert(self->communicator);
const string op = "flushBatchRequests";
FlushAsyncCallbackPtr d = new FlushAsyncCallback(op);
Ice::Callback_Communicator_flushBatchRequestsPtr callback =
Ice::newCallback_Communicator_flushBatchRequests(d, &FlushAsyncCallback::exception, &FlushAsyncCallback::sent);
Ice::AsyncResultPtr result;
try
{
result = (*self->communicator)->begin_flushBatchRequests(cb, callback);
}
catch(const Ice::Exception& ex)
{
setPythonException(ex);
return 0;
}
PyObjectHandle asyncResultObj = createAsyncResult(result, 0, 0, self->wrapper);
if(!asyncResultObj.get())
{
return 0;
}
PyObjectHandle future = createFuture(op, asyncResultObj.get());
if(!future.get())
{
return 0;
}
d->setFuture(future.get());
return future.release();
}
示例6: lookupType
template<typename T> PyObject*
createVersion(const T& version, const char* type)
{
PyObject* versionType = lookupType(type);
PyObjectHandle obj = PyObject_CallObject(versionType, 0);
if(!obj.get())
{
return 0;
}
if(!setVersion<T>(obj.get(), version, type))
{
return 0;
}
return obj.release();
}
示例7:
static PyObject*
implicitContextGetContext(ImplicitContextObject* self)
{
Ice::Context ctx = (*self->implicitContext)->getContext();
PyObjectHandle dict = PyDict_New();
if(!dict.get())
{
return 0;
}
if(!contextToDictionary(ctx, dict.get()))
{
return 0;
}
return dict.release();
}
示例8: assert
static PyObject*
propertiesGetPropertiesForPrefix(PropertiesObject* self, PyObject* args)
{
PyObject* prefixObj;
if(!PyArg_ParseTuple(args, STRCAST("O"), &prefixObj))
{
return 0;
}
string prefix;
if(!getStringArg(prefixObj, "prefix", prefix))
{
return 0;
}
assert(self->properties);
Ice::PropertyDict dict;
try
{
dict = (*self->properties)->getPropertiesForPrefix(prefix);
}
catch(const Ice::Exception& ex)
{
setPythonException(ex);
return 0;
}
PyObjectHandle result = PyDict_New();
if(result.get())
{
for(Ice::PropertyDict::iterator p = dict.begin(); p != dict.end(); ++p)
{
PyObjectHandle key = createString(p->first);
PyObjectHandle val = createString(p->second);
if(!val.get() || PyDict_SetItem(result.get(), key.get(), val.get()) < 0)
{
return 0;
}
}
}
return result.release();
}
示例9: PyObject_Call
PyObject*
IcePy::wrapObjectAdapter(const Ice::ObjectAdapterPtr& adapter)
{
//
// Create an Ice.ObjectAdapter wrapper for IcePy.ObjectAdapter.
//
PyObjectHandle adapterI = createObjectAdapter(adapter);
if(!adapterI.get())
{
return 0;
}
PyObject* wrapperType = lookupType("Ice.ObjectAdapterI");
assert(wrapperType);
PyObjectHandle args = PyTuple_New(1);
if(!args.get())
{
return 0;
}
PyTuple_SET_ITEM(args.get(), 0, adapterI.release());
return PyObject_Call(wrapperType, args.get(), 0);
}
示例10: assert
static PyObject*
wssConnectionInfoGetHeaders(ConnectionInfoObject* self)
{
IceSSL::WSSConnectionInfoPtr info = IceSSL::WSSConnectionInfoPtr::dynamicCast(*self->connectionInfo);
assert(info);
PyObjectHandle result = PyDict_New();
if(result.get())
{
for(Ice::HeaderDict::iterator p = info->headers.begin(); p != info->headers.end(); ++p)
{
PyObjectHandle key = createString(p->first);
PyObjectHandle val = createString(p->second);
if(!val.get() || PyDict_SetItem(result.get(), key.get(), val.get()) < 0)
{
return 0;
}
}
}
return result.release();
}
示例11: assert
static PyObject*
connectionGetACM(ConnectionObject* self)
{
assert(self->connection);
PyObject* acmType = lookupType("Ice.ACM");
PyObject* acmCloseType = lookupType("Ice._t_ACMClose");
PyObject* acmHeartbeatType = lookupType("Ice._t_ACMHeartbeat");
Ice::ACM acm;
try
{
AllowThreads allowThreads; // Release Python's global interpreter lock during blocking invocations.
acm = (*self->connection)->getACM();
}
catch(const Ice::Exception& ex)
{
setPythonException(ex);
return 0;
}
PyObjectHandle r = StructInfo::instantiate(acmType);
if(!r.get())
{
return 0;
}
PyObjectHandle timeout = PyLong_FromLong(acm.timeout);
if(!timeout.get())
{
assert(PyErr_Occurred());
return 0;
}
if(PyObject_SetAttrString(r.get(), STRCAST("timeout"), timeout.get()) < 0)
{
assert(PyErr_Occurred());
return 0;
}
EnumInfoPtr acmCloseEnum = EnumInfoPtr::dynamicCast(getType(acmCloseType));
assert(acmCloseEnum);
PyObjectHandle close = acmCloseEnum->enumeratorForValue(static_cast<Ice::Int>(acm.close));
if(!close.get())
{
PyErr_Format(PyExc_ValueError, "unexpected value for 'close' member of Ice.ACM");
return 0;
}
if(PyObject_SetAttrString(r.get(), STRCAST("close"), close.get()) < 0)
{
assert(PyErr_Occurred());
return 0;
}
EnumInfoPtr acmHeartbeatEnum = EnumInfoPtr::dynamicCast(getType(acmHeartbeatType));
assert(acmHeartbeatEnum);
PyObjectHandle heartbeat = acmHeartbeatEnum->enumeratorForValue(static_cast<Ice::Int>(acm.heartbeat));
if(!heartbeat.get())
{
PyErr_Format(PyExc_ValueError, "unexpected value for 'heartbeat' member of Ice.ACM");
return 0;
}
if(PyObject_SetAttrString(r.get(), STRCAST("heartbeat"), heartbeat.get()) < 0)
{
assert(PyErr_Occurred());
return 0;
}
return r.release();
}
示例12: catch
PyObject*
IcePy::convertException(const Ice::Exception& ex)
{
PyObjectHandle p;
PyObject* type;
ostringstream ostr;
ostr << ex;
string str = ostr.str();
try
{
ex.ice_throw();
}
catch(const Ice::LocalException& e)
{
type = lookupType(scopedToName(e.ice_id()));
if(type)
{
p = createExceptionInstance(type);
if(p.get())
{
convertLocalException(e, p.get());
}
}
else
{
type = lookupType("Ice.UnknownLocalException");
assert(type);
p = createExceptionInstance(type);
if(p.get())
{
PyObjectHandle s = createString(str);
PyObject_SetAttrString(p.get(), STRCAST("unknown"), s.get());
}
}
}
catch(const Ice::UserException&)
{
type = lookupType("Ice.UnknownUserException");
assert(type);
p = createExceptionInstance(type);
if(p.get())
{
PyObjectHandle s = createString(str);
PyObject_SetAttrString(p.get(), STRCAST("unknown"), s.get());
}
}
catch(const Ice::Exception&)
{
type = lookupType("Ice.UnknownException");
assert(type);
p = createExceptionInstance(type);
if(p.get())
{
PyObjectHandle s = createString(str);
PyObject_SetAttrString(p.get(), STRCAST("unknown"), s.get());
}
}
return p.release();
}