summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-03-01 14:33:27 +0100
committerJose <jose@zeroc.com>2016-03-01 14:33:27 +0100
commite283494c906ffac2be14f38422934921ea6ae307 (patch)
treec4b9274845482abd89f84555675d8486a41a71e3 /python
parentRework previous fix for 3.6 compatibility (diff)
downloadice-e283494c906ffac2be14f38422934921ea6ae307.tar.bz2
ice-e283494c906ffac2be14f38422934921ea6ae307.tar.xz
ice-e283494c906ffac2be14f38422934921ea6ae307.zip
Ice::identityToString/Ice::stringToIdentity php/ruby/python implementations
Diffstat (limited to 'python')
-rw-r--r--python/modules/IcePy/Communicator.cpp49
-rw-r--r--python/modules/IcePy/Communicator.h3
-rw-r--r--python/modules/IcePy/Init.cpp4
-rw-r--r--python/python/Ice.py12
-rw-r--r--python/test/Ice/proxy/AllTests.py2
5 files changed, 70 insertions, 0 deletions
diff --git a/python/modules/IcePy/Communicator.cpp b/python/modules/IcePy/Communicator.cpp
index 919086d9ae8..550b0fef0ff 100644
--- a/python/modules/IcePy/Communicator.cpp
+++ b/python/modules/IcePy/Communicator.cpp
@@ -1715,3 +1715,52 @@ IcePy::getCommunicatorWrapper(const Ice::CommunicatorPtr& communicator)
Py_INCREF(obj->wrapper);
return obj->wrapper;
}
+
+extern "C"
+PyObject*
+IcePy_identityToString(PyObject* /*self*/, PyObject* obj)
+{
+ Ice::Identity id;
+ if(!getIdentity(obj, id))
+ {
+ return 0;
+ }
+
+ string str;
+
+ try
+ {
+ str = Ice::identityToString(id);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ return createString(str);
+}
+
+extern "C"
+PyObject*
+IcePy_stringToIdentity(PyObject* /*self*/, PyObject* obj)
+{
+ string str;
+ if(!getStringArg(obj, "str", str))
+ {
+ return 0;
+ }
+
+ Ice::Identity id;
+ try
+ {
+ id = Ice::stringToIdentity(str);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ return createIdentity(id);
+}
diff --git a/python/modules/IcePy/Communicator.h b/python/modules/IcePy/Communicator.h
index 3f2ac0452c3..c83c2898aae 100644
--- a/python/modules/IcePy/Communicator.h
+++ b/python/modules/IcePy/Communicator.h
@@ -32,4 +32,7 @@ extern "C" PyObject* IcePy_initializeWithProperties(PyObject*, PyObject*);
extern "C" PyObject* IcePy_initializeWithLogger(PyObject*, PyObject*);
extern "C" PyObject* IcePy_initializeWithPropertiesAndLogger(PyObject*, PyObject*);
+extern "C" PyObject* IcePy_identityToString(PyObject*, PyObject*);
+extern "C" PyObject* IcePy_stringToIdentity(PyObject*, PyObject*);
+
#endif
diff --git a/python/modules/IcePy/Init.cpp b/python/modules/IcePy/Init.cpp
index 0a594104b61..4494d7f11b8 100644
--- a/python/modules/IcePy/Init.cpp
+++ b/python/modules/IcePy/Init.cpp
@@ -57,6 +57,10 @@ static PyMethodDef methods[] =
PyDoc_STR(STRCAST("generateUUID() -> string")) },
{ STRCAST("createProperties"), reinterpret_cast<PyCFunction>(IcePy_createProperties), METH_VARARGS,
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("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/python/Ice.py b/python/python/Ice.py
index feb060efa54..88b5b90f220 100644
--- a/python/python/Ice.py
+++ b/python/python/Ice.py
@@ -706,6 +706,18 @@ the list that were recognized by the Ice run time.
return CommunicatorI(communicator)
#
+# Ice.identityToString
+#
+def identityToString(id):
+ return IcePy.identityToString(id)
+
+#
+# Ice.stringToIdentity
+#
+def stringToIdentity(str):
+ return IcePy.stringToIdentity(str)
+
+#
# ObjectAdapter wrapper.
#
class ObjectAdapterI(ObjectAdapter):
diff --git a/python/test/Ice/proxy/AllTests.py b/python/test/Ice/proxy/AllTests.py
index fb606824b30..170b0448fe1 100644
--- a/python/test/Ice/proxy/AllTests.py
+++ b/python/test/Ice/proxy/AllTests.py
@@ -360,6 +360,8 @@ def allTests(communicator, collocated):
sys.stdout.flush()
test(communicator.identityToString(base.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()) \
== "other")
+ test(Ice.identityToString(base.ice_identity(Ice.stringToIdentity("other")).ice_getIdentity()) == "other")
+
test(base.ice_facet("facet").ice_getFacet() == "facet")
test(base.ice_adapterId("id").ice_getAdapterId() == "id")
test(base.ice_twoway().ice_isTwoway())