diff options
Diffstat (limited to 'py/modules/IcePy/EndpointInfo.cpp')
-rw-r--r-- | py/modules/IcePy/EndpointInfo.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/py/modules/IcePy/EndpointInfo.cpp b/py/modules/IcePy/EndpointInfo.cpp index 46df1510902..c096ed77006 100644 --- a/py/modules/IcePy/EndpointInfo.cpp +++ b/py/modules/IcePy/EndpointInfo.cpp @@ -31,7 +31,7 @@ struct EndpointInfoObject extern "C" #endif static EndpointInfoObject* -endpointInfoNew(PyObject* /*arg*/) +endpointInfoNew(PyTypeObject* /*type*/, PyObject* /*args*/, PyObject* /*kwds*/) { PyErr_Format(PyExc_RuntimeError, STRCAST("An endpoint info cannot be created directly")); return 0; @@ -44,7 +44,7 @@ static void endpointInfoDealloc(EndpointInfoObject* self) { delete self->endpointInfo; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } // @@ -60,7 +60,7 @@ endpointInfoType(EndpointInfoObject* self) try { Ice::Short type = (*self->endpointInfo)->type(); - return PyInt_FromLong(type); + return PyLong_FromLong(type); } catch(const Ice::Exception& ex) { @@ -125,7 +125,7 @@ extern "C" static PyObject* endpointInfoGetTimeout(EndpointInfoObject* self) { - return PyInt_FromLong((*self->endpointInfo)->timeout); + return PyLong_FromLong((*self->endpointInfo)->timeout); } #ifdef WIN32 @@ -158,7 +158,7 @@ ipEndpointInfoGetPort(EndpointInfoObject* self) { Ice::IPEndpointInfoPtr info = Ice::IPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->port); + return PyLong_FromLong(info->port); } #ifdef WIN32 @@ -169,7 +169,7 @@ udpEndpointInfoGetProtocolMajor(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->protocolMajor); + return PyLong_FromLong(info->protocolMajor); } #ifdef WIN32 @@ -180,7 +180,7 @@ udpEndpointInfoGetProtocolMinor(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->protocolMinor); + return PyLong_FromLong(info->protocolMinor); } #ifdef WIN32 @@ -191,7 +191,7 @@ udpEndpointInfoGetEncodingMajor(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->encodingMajor); + return PyLong_FromLong(info->encodingMajor); } #ifdef WIN32 @@ -202,7 +202,7 @@ udpEndpointInfoGetEncodingMinor(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->encodingMinor); + return PyLong_FromLong(info->encodingMinor); } #ifdef WIN32 @@ -224,7 +224,7 @@ udpEndpointInfoGetMcastTtl(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->mcastTtl); + return PyLong_FromLong(info->mcastTtl); } #ifdef WIN32 @@ -235,8 +235,13 @@ opaqueEndpointInfoGetRawBytes(EndpointInfoObject* self) { Ice::OpaqueEndpointInfoPtr info = Ice::OpaqueEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); +#if PY_VERSION_HEX >= 0x03000000 + return PyBytes_FromStringAndSize(reinterpret_cast<const char*>(&info->rawBytes[0]), + static_cast<int>(info->rawBytes.size())); +#else return PyString_FromStringAndSize(reinterpret_cast<const char*>(&info->rawBytes[0]), static_cast<int>(info->rawBytes.size())); +#endif } static PyMethodDef EndpointInfoMethods[] = @@ -299,17 +304,16 @@ PyTypeObject EndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.EndpointInfo"), /* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -338,7 +342,7 @@ PyTypeObject EndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -347,17 +351,16 @@ PyTypeObject IPEndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.IPEndpointInfo"), /* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -386,7 +389,7 @@ PyTypeObject IPEndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -395,17 +398,16 @@ PyTypeObject TCPEndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.TCPEndpointInfo"),/* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -434,7 +436,7 @@ PyTypeObject TCPEndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -443,17 +445,16 @@ PyTypeObject UDPEndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.UDPEndpointInfo"),/* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -482,7 +483,7 @@ PyTypeObject UDPEndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -491,17 +492,16 @@ PyTypeObject OpaqueEndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.OpaqueEndpointInfo"),/* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -530,7 +530,7 @@ PyTypeObject OpaqueEndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -630,7 +630,7 @@ IcePy::createEndpointInfo(const Ice::EndpointInfoPtr& endpointInfo) type = &EndpointInfoType; } - EndpointInfoObject* obj = PyObject_New(EndpointInfoObject, type); + EndpointInfoObject* obj = reinterpret_cast<EndpointInfoObject*>(type->tp_alloc(type, 0)); if(!obj) { return 0; |