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/IcePy/Communicator.cpp | |
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/IcePy/Communicator.cpp')
-rw-r--r-- | python/modules/IcePy/Communicator.cpp | 21 |
1 files changed, 18 insertions, 3 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) { |