diff options
author | Mark Spruiell <mes@zeroc.com> | 2004-09-10 17:25:27 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2004-09-10 17:25:27 +0000 |
commit | 1f520976b4442f1dda2c055acc3eb24f2157c012 (patch) | |
tree | 7941162405d16cc451187dedd9700ec6737e0709 /py/modules/IcePy/Proxy.cpp | |
parent | Updated CHANGES for keyword changes and --impl fix in slice2cpp. (diff) | |
download | ice-1f520976b4442f1dda2c055acc3eb24f2157c012.tar.bz2 ice-1f520976b4442f1dda2c055acc3eb24f2157c012.tar.xz ice-1f520976b4442f1dda2c055acc3eb24f2157c012.zip |
implement ice_router, ice_locator
Diffstat (limited to 'py/modules/IcePy/Proxy.cpp')
-rw-r--r-- | py/modules/IcePy/Proxy.cpp | 89 |
1 files changed, 87 insertions, 2 deletions
diff --git a/py/modules/IcePy/Proxy.cpp b/py/modules/IcePy/Proxy.cpp index b3b18ef3955..e1c00f286bb 100644 --- a/py/modules/IcePy/Proxy.cpp +++ b/py/modules/IcePy/Proxy.cpp @@ -9,10 +9,11 @@ #include <Proxy.h> #include <structmember.h> -//#include <Operation.h> #include <Util.h> #include <Ice/LocalException.h> +#include <Ice/Locator.h> #include <Ice/Proxy.h> +#include <Ice/Router.h> using namespace std; using namespace IcePy; @@ -724,7 +725,87 @@ proxyIceTimeout(ProxyObject* self, PyObject* args) return createProxy(newProxy, *self->communicator); } -// TODO: ice_router, ice_locator +#ifdef WIN32 +extern "C" +#endif +static PyObject* +proxyIceRouter(ProxyObject* self, PyObject* args) +{ + PyObject* p; + if(!PyArg_ParseTuple(args, "O", &p)) + { + return NULL; + } + + PyObject* routerProxyType = lookupType("Ice.RouterPrx"); + assert(routerProxyType != NULL); + Ice::RouterPrx routerProxy; + if(PyObject_IsInstance(p, routerProxyType)) + { + routerProxy = Ice::RouterPrx::uncheckedCast(getProxy(p)); + } + else if(p != Py_None) + { + PyErr_Format(PyExc_ValueError, "ice_router requires None or Ice.RouterPrx"); + return NULL; + } + + assert(self->proxy); + + Ice::ObjectPrx newProxy; + try + { + newProxy = (*self->proxy)->ice_router(routerProxy); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return NULL; + } + + return createProxy(newProxy, *self->communicator); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +proxyIceLocator(ProxyObject* self, PyObject* args) +{ + PyObject* p; + if(!PyArg_ParseTuple(args, "O", &p)) + { + return NULL; + } + + PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); + assert(locatorProxyType != NULL); + Ice::LocatorPrx locatorProxy; + if(PyObject_IsInstance(p, locatorProxyType)) + { + locatorProxy = Ice::LocatorPrx::uncheckedCast(getProxy(p)); + } + else if(p != Py_None) + { + PyErr_Format(PyExc_ValueError, "ice_locator requires None or Ice.LocatorPrx"); + return NULL; + } + + assert(self->proxy); + + Ice::ObjectPrx newProxy; + try + { + newProxy = (*self->proxy)->ice_locator(locatorProxy); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return NULL; + } + + return createProxy(newProxy, *self->communicator); +} // NOTE: ice_collocationOptimization is not currently supported. @@ -963,6 +1044,10 @@ static PyMethodDef ProxyMethods[] = PyDoc_STR("ice_compress(bool) -> Ice.ObjectPrx") }, { "ice_timeout", (PyCFunction)proxyIceTimeout, METH_VARARGS, PyDoc_STR("ice_timeout(int) -> Ice.ObjectPrx") }, + { "ice_router", (PyCFunction)proxyIceRouter, METH_VARARGS, + PyDoc_STR("ice_router(Ice.RouterPrx) -> Ice.ObjectPrx") }, + { "ice_locator", (PyCFunction)proxyIceLocator, METH_VARARGS, + PyDoc_STR("ice_locator(Ice.LocatorPrx) -> Ice.ObjectPrx") }, { "ice_default", (PyCFunction)proxyIceDefault, METH_NOARGS, PyDoc_STR("ice_default() -> Ice.ObjectPrx") }, { "ice_checkedCast", (PyCFunction)proxyIceCheckedCast, METH_VARARGS | METH_CLASS, |