diff options
author | Bernard Normier <bernard@zeroc.com> | 2016-10-20 21:03:44 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2016-10-20 21:03:44 -0400 |
commit | 3cb9c15995b828c52dba34d0a222f572d5bbc41b (patch) | |
tree | 87bad249c2ee04972be5f3c7635880cb0c556128 /python/modules | |
parent | updating IceBT to BlueZ 5 (diff) | |
download | ice-3cb9c15995b828c52dba34d0a222f572d5bbc41b.tar.bz2 ice-3cb9c15995b828c52dba34d0a222f572d5bbc41b.tar.xz ice-3cb9c15995b828c52dba34d0a222f572d5bbc41b.zip |
Added support for non-ASCII characters and universal character names
to stringified identities and proxies.
This includes a new Ice.ToStringMode property.
Diffstat (limited to 'python/modules')
-rw-r--r-- | python/modules/IcePy/Communicator.cpp | 21 | ||||
-rw-r--r-- | python/modules/IcePy/Init.cpp | 4 | ||||
-rw-r--r-- | python/modules/IcePy/Operation.cpp | 4 |
3 files changed, 22 insertions, 7 deletions
diff --git a/python/modules/IcePy/Communicator.cpp b/python/modules/IcePy/Communicator.cpp index 1549cd1043c..eb223c85853 100644 --- a/python/modules/IcePy/Communicator.cpp +++ b/python/modules/IcePy/Communicator.cpp @@ -1740,19 +1740,34 @@ IcePy::getCommunicatorWrapper(const Ice::CommunicatorPtr& communicator) extern "C" PyObject* -IcePy_identityToString(PyObject* /*self*/, PyObject* obj) +IcePy_identityToString(PyObject* /*self*/, PyObject* args) { + PyObject* identityType = lookupType("Ice.Identity"); + PyObject* obj; + PyObject* mode = 0; + if(!PyArg_ParseTuple(args, STRCAST("O!O"), identityType, &obj, &mode)) + { + return 0; + } + Ice::Identity id; if(!getIdentity(obj, id)) { return 0; } - + + Ice::ToStringMode toStringMode = Ice::Unicode; + if(mode != Py_None && PyObject_HasAttrString(mode, STRCAST("value"))) + { + PyObjectHandle modeValue = PyObject_GetAttrString(mode, STRCAST("value")); + toStringMode = static_cast<Ice::ToStringMode>(PyLong_AsLong(modeValue.get())); + } + string str; try { - str = Ice::identityToString(id); + str = identityToString(id, toStringMode); } catch(const Ice::Exception& ex) { diff --git a/python/modules/IcePy/Init.cpp b/python/modules/IcePy/Init.cpp index 88205ebc571..581e4f649c5 100644 --- a/python/modules/IcePy/Init.cpp +++ b/python/modules/IcePy/Init.cpp @@ -60,8 +60,8 @@ static PyMethodDef methods[] = PyDoc_STR(STRCAST("createProperties([args]) -> Ice.Properties")) }, { STRCAST("stringToIdentity"), reinterpret_cast<PyCFunction>(IcePy_stringToIdentity), METH_O, PyDoc_STR(STRCAST("stringToIdentity(string) -> Ice.Identity")) }, - { STRCAST("identityToString"), reinterpret_cast<PyCFunction>(IcePy_identityToString), METH_O, - PyDoc_STR(STRCAST("identityToString(Ice.Identity) -> string")) }, + { STRCAST("identityToString"), reinterpret_cast<PyCFunction>(IcePy_identityToString), METH_VARARGS, + PyDoc_STR(STRCAST("identityToString(Ice.Identity, Ice.ToStringMode) -> string")) }, { STRCAST("getProcessLogger"), reinterpret_cast<PyCFunction>(IcePy_getProcessLogger), METH_NOARGS, PyDoc_STR(STRCAST("getProcessLogger() -> Ice.Logger")) }, { STRCAST("setProcessLogger"), reinterpret_cast<PyCFunction>(IcePy_setProcessLogger), METH_VARARGS, diff --git a/python/modules/IcePy/Operation.cpp b/python/modules/IcePy/Operation.cpp index 3b59074a8e5..c8dad9a0c96 100644 --- a/python/modules/IcePy/Operation.cpp +++ b/python/modules/IcePy/Operation.cpp @@ -3349,7 +3349,7 @@ IcePy::TypedUpcall::dispatch(PyObject* servant, const pair<const Ice::Byte*, con if(!method.get()) { ostringstream ostr; - ostr << "servant for identity " << identityToString(current.id) + ostr << "servant for identity " << _communicator->identityToString(current.id) << " does not define operation `" << _op->dispatchName << "'"; string str = ostr.str(); PyErr_Warn(PyExc_RuntimeWarning, const_cast<char*>(str.c_str())); @@ -3712,7 +3712,7 @@ IcePy::BlobjectUpcall::dispatch(PyObject* servant, const pair<const Ice::Byte*, if(!method.get()) { ostringstream ostr; - ostr << "servant for identity " << identityToString(current.id) + ostr << "servant for identity " << communicator->identityToString(current.id) << " does not define operation `" << dispatchName << "'"; string str = ostr.str(); PyErr_Warn(PyExc_RuntimeWarning, const_cast<char*>(str.c_str())); |