diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-05-09 12:50:43 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-05-09 12:50:43 +0000 |
commit | 765822ab9caa9c8079792f17ca40a885bc8261ea (patch) | |
tree | 40ee66aaffe1813ba3e82f3133213e0e43c5cea4 /py/modules/IcePy/Communicator.cpp | |
parent | More minor fixes (diff) | |
download | ice-765822ab9caa9c8079792f17ca40a885bc8261ea.tar.bz2 ice-765822ab9caa9c8079792f17ca40a885bc8261ea.tar.xz ice-765822ab9caa9c8079792f17ca40a885bc8261ea.zip |
Added identityToString and stringToIdentity to Communicator
Diffstat (limited to 'py/modules/IcePy/Communicator.cpp')
-rw-r--r-- | py/modules/IcePy/Communicator.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/py/modules/IcePy/Communicator.cpp b/py/modules/IcePy/Communicator.cpp index 63953a661f0..19eb5440013 100644 --- a/py/modules/IcePy/Communicator.cpp +++ b/py/modules/IcePy/Communicator.cpp @@ -418,6 +418,67 @@ communicatorProxyToString(CommunicatorObject* self, PyObject* args) extern "C" #endif static PyObject* +communicatorStringToIdentity(CommunicatorObject* self, PyObject* args) +{ + char* str; + if(!PyArg_ParseTuple(args, STRCAST("s"), &str)) + { + return NULL; + } + + assert(self->communicator); + Ice::Identity id; + try + { + id = (*self->communicator)->stringToIdentity(str); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return NULL; + } + + return IcePy::createIdentity(id); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +communicatorIdentityToString(CommunicatorObject* self, PyObject* args) +{ + PyObject* identityType = IcePy::lookupType("Ice.Identity"); + PyObject* obj; + if(!PyArg_ParseTuple(args, STRCAST("O!"), identityType, &obj)) + { + return NULL; + } + + Ice::Identity id; + if(!IcePy::getIdentity(obj, id)) + { + return NULL; + } + string str; + + assert(self->communicator); + try + { + str = (*self->communicator)->identityToString(id); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return NULL; + } + + return PyString_FromString(const_cast<char*>(str.c_str())); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* communicatorFlushBatchRequests(CommunicatorObject* self) { assert(self->communicator); @@ -936,6 +997,10 @@ static PyMethodDef CommunicatorMethods[] = PyDoc_STR(STRCAST("stringToProxy(str) -> Ice.ObjectPrx")) }, { STRCAST("proxyToString"), (PyCFunction)communicatorProxyToString, METH_VARARGS, PyDoc_STR(STRCAST("proxyToString(Ice.ObjectPrx) -> string")) }, + { STRCAST("stringToIdentity"), (PyCFunction)communicatorStringToIdentity, METH_VARARGS, + PyDoc_STR(STRCAST("stringToIdentity(str) -> Ice.Identity")) }, + { STRCAST("identityToString"), (PyCFunction)communicatorIdentityToString, METH_VARARGS, + PyDoc_STR(STRCAST("identityToString(Ice.Identity) -> string")) }, { STRCAST("createObjectAdapter"), (PyCFunction)communicatorCreateObjectAdapter, METH_VARARGS, PyDoc_STR(STRCAST("createObjectAdapter(name) -> Ice.ObjectAdapter")) }, { STRCAST("createObjectAdapterWithEndpoints"), (PyCFunction)communicatorCreateObjectAdapterWithEndpoints, |