From c79a843b280cb8cc9559126b76e4f8b8ee3a651c Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Tue, 8 Feb 2005 22:10:01 +0000 Subject: updating Ice::Connection for bidir --- py/modules/IcePy/Connection.cpp | 94 +++++++++++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 17 deletions(-) (limited to 'py/modules/IcePy/Connection.cpp') diff --git a/py/modules/IcePy/Connection.cpp b/py/modules/IcePy/Connection.cpp index 17ba5672a9e..a6fc415b761 100644 --- a/py/modules/IcePy/Connection.cpp +++ b/py/modules/IcePy/Connection.cpp @@ -11,6 +11,7 @@ # include #endif #include +#include #include #include #include @@ -90,12 +91,27 @@ connectionClose(ConnectionObject* self, PyObject* args) extern "C" #endif static PyObject* -connectionFlushBatchRequests(ConnectionObject* self) +connectionCreateProxy(ConnectionObject* self, PyObject* args) { + PyObject* identityType = lookupType("Ice.Identity"); + PyObject* id; + if(!PyArg_ParseTuple(args, "O!", identityType, &id)) + { + return NULL; + } + + Ice::Identity ident; + if(!getIdentity(id, ident)) + { + return NULL; + } + assert(self->connection); + assert(self->communicator); + Ice::ObjectPrx proxy; try { - (*self->connection)->flushBatchRequests(); + proxy = (*self->connection)->createProxy(ident); } catch(const Ice::Exception& ex) { @@ -103,35 +119,74 @@ connectionFlushBatchRequests(ConnectionObject* self) return NULL; } - Py_INCREF(Py_None); - return Py_None; + return createProxy(proxy, (*self->communicator)); } #ifdef WIN32 extern "C" #endif static PyObject* -connectionCreateProxy(ConnectionObject* self, PyObject* args) +connectionSetAdapter(ConnectionObject* self, PyObject* args) { - PyObject* identityType = lookupType("Ice.Identity"); - PyObject* id; - if(!PyArg_ParseTuple(args, "O!", identityType, &id)) + PyObject* adapterType = lookupType("Ice.ObjectAdapter"); + PyObject* adapter; + if(!PyArg_ParseTuple(args, "O!", adapterType, &adapter)) { - return NULL; + return NULL; } - Ice::Identity ident; - if(!getIdentity(id, ident)) + Ice::ObjectAdapterPtr oa = unwrapObjectAdapter(adapter); + assert(oa); + + assert(self->connection); + assert(self->communicator); + try { - return NULL; + (*self->connection)->setAdapter(oa); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return NULL; } + Py_INCREF(Py_None); + return Py_None; +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +connectionGetAdapter(ConnectionObject* self) +{ + Ice::ObjectAdapterPtr adapter; + assert(self->connection); assert(self->communicator); - Ice::ObjectPrx proxy; try { - proxy = (*self->connection)->createProxy(ident); + adapter = (*self->connection)->getAdapter(); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return NULL; + } + + return wrapObjectAdapter(adapter); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +connectionFlushBatchRequests(ConnectionObject* self) +{ + assert(self->connection); + try + { + (*self->connection)->flushBatchRequests(); } catch(const Ice::Exception& ex) { @@ -139,7 +194,8 @@ connectionCreateProxy(ConnectionObject* self, PyObject* args) return NULL; } - return createProxy(proxy, (*self->communicator)); + Py_INCREF(Py_None); + return Py_None; } #ifdef WIN32 @@ -209,10 +265,14 @@ static PyMethodDef ConnectionMethods[] = { { "close", (PyCFunction)connectionClose, METH_VARARGS, PyDoc_STR("close(bool) -> None") }, - { "flushBatchRequests", (PyCFunction)connectionFlushBatchRequests, METH_NOARGS, - PyDoc_STR("flushBatchRequests() -> None") }, { "createProxy", (PyCFunction)connectionCreateProxy, METH_VARARGS, PyDoc_STR("createProxy(Ice.Identity) -> Ice.ObjectPrx") }, + { "setAdapter", (PyCFunction)connectionSetAdapter, METH_VARARGS, + PyDoc_STR("setAdapter(Ice.ObjectAdapter) -> None") }, + { "getAdapter", (PyCFunction)connectionGetAdapter, METH_NOARGS, + PyDoc_STR("getAdapter() -> Ice.ObjectAdapter") }, + { "flushBatchRequests", (PyCFunction)connectionFlushBatchRequests, METH_NOARGS, + PyDoc_STR("flushBatchRequests() -> None") }, { "type", (PyCFunction)connectionType, METH_NOARGS, PyDoc_STR("type() -> string") }, { "timeout", (PyCFunction)connectionTimeout, METH_NOARGS, -- cgit v1.2.3