diff options
author | Mark Spruiell <mes@zeroc.com> | 2012-05-23 15:02:14 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2012-05-23 15:02:14 -0700 |
commit | 0ce3ea49125e83ba758c66ab6c88142315d047d3 (patch) | |
tree | 1d8c549acf22d5abeaa30fae67a292970f294a34 /py | |
parent | Added implementation of optional data members encoding (not tested yet) (diff) | |
download | ice-0ce3ea49125e83ba758c66ab6c88142315d047d3.tar.bz2 ice-0ce3ea49125e83ba758c66ab6c88142315d047d3.tar.xz ice-0ce3ea49125e83ba758c66ab6c88142315d047d3.zip |
PHP port; misc. fixes
Diffstat (limited to 'py')
-rw-r--r-- | py/modules/IcePy/Operation.cpp | 2 | ||||
-rw-r--r-- | py/modules/IcePy/Types.cpp | 16 | ||||
-rw-r--r-- | py/modules/IcePy/Util.cpp | 14 |
3 files changed, 22 insertions, 10 deletions
diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp index 401109e84b9..2c5931ba9ab 100644 --- a/py/modules/IcePy/Operation.cpp +++ b/py/modules/IcePy/Operation.cpp @@ -1563,6 +1563,8 @@ IcePy::TypedInvocation::unmarshalException(const pair<const Ice::Byte*, const Ic } catch(const ExceptionReader& r) { + is->endEncapsulation(); + PyObject* ex = r.getException(); if(validateException(ex)) diff --git a/py/modules/IcePy/Types.cpp b/py/modules/IcePy/Types.cpp index 97dbf7f989f..526ca3aa63e 100644 --- a/py/modules/IcePy/Types.cpp +++ b/py/modules/IcePy/Types.cpp @@ -370,8 +370,13 @@ IcePy::SlicedDataUtil::setMember(PyObject* obj, const Ice::SlicedDataPtr& sliced // // bytes // +#if PY_VERSION_HEX >= 0x03000000 + PyObjectHandle bytes = + PyBytes_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size()); +#else PyObjectHandle bytes = PyString_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size()); +#endif if(!bytes.get() || PyObject_SetAttrString(slice.get(), STRCAST("bytes"), bytes.get()) < 0) { assert(PyErr_Occurred()); @@ -446,14 +451,19 @@ IcePy::SlicedDataUtil::getMember(PyObject* obj, ObjectMap* objectMap) PyObjectHandle typeId = PyObject_GetAttrString(s.get(), STRCAST("typeId")); assert(typeId.get()); - assert(PyString_Check(typeId.get())); info->typeId = getString(typeId.get()); PyObjectHandle bytes = PyObject_GetAttrString(s.get(), STRCAST("bytes")); assert(bytes.get()); + char* str; + Py_ssize_t strsz; +#if PY_VERSION_HEX >= 0x03000000 + assert(PyBytes_Check(bytes.get())); + PyBytes_AsStringAndSize(bytes.get(), &str, &strsz); +#else assert(PyString_Check(bytes.get())); - const char* str = PyString_AS_STRING(bytes.get()); - Py_ssize_t strsz = PyString_GET_SIZE(bytes.get()); + PyString_AsStringAndSize(bytes.get(), &str, &strsz); +#endif vector<Ice::Byte> vtmp(str, str + strsz); info->bytes.swap(vtmp); diff --git a/py/modules/IcePy/Util.cpp b/py/modules/IcePy/Util.cpp index 1aae7f471a6..e49bd332334 100644 --- a/py/modules/IcePy/Util.cpp +++ b/py/modules/IcePy/Util.cpp @@ -36,8 +36,8 @@ setVersion(PyObject* p, const T& version) { assert(checkIsInstance(p, PT)); - PyObjectHandle major = PyInt_FromLong(version.major); - PyObjectHandle minor = PyInt_FromLong(version.minor); + PyObjectHandle major = PyLong_FromLong(version.major); + PyObjectHandle minor = PyLong_FromLong(version.minor); if(!major.get() || !minor.get()) { return false; @@ -58,12 +58,12 @@ getVersion(PyObject* p, T& v) PyObjectHandle minor = PyObject_GetAttrString(p, STRCAST("minor")); if(major.get()) { - if(!PyInt_Check(major.get())) + if(!PyLong_Check(major.get())) { PyErr_Format(PyExc_ValueError, STRCAST("version major must be a numeric value")); return false; } - int m = PyInt_AsLong(major.get()); + long m = PyLong_AsLong(major.get()); if(m < 0 || m > 255) { PyErr_Format(PyExc_ValueError, STRCAST("version major must be a value between 0 and 255")); @@ -73,12 +73,12 @@ getVersion(PyObject* p, T& v) } if(minor.get()) { - if(!PyInt_Check(minor.get())) + if(!PyLong_Check(minor.get())) { PyErr_Format(PyExc_ValueError, STRCAST("version minor must be a numeric value")); return false; } - int m = PyInt_AsLong(minor.get()); + long m = PyLong_AsLong(minor.get()); if(m < 0 || m > 255) { PyErr_Format(PyExc_ValueError, STRCAST("version minor must be a value between 0 and 255")); @@ -134,7 +134,7 @@ versionToString(PyObject* args) IcePy::setPythonException(ex); return NULL; } - return PyString_FromString(const_cast<char*>(s.c_str())); + return createString(s); } template<typename T, const char* PT> PyObject* |