diff options
author | Mark Spruiell <mes@zeroc.com> | 2016-01-19 16:46:11 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2016-01-19 16:46:11 -0800 |
commit | d5dd7c866e9e1dc59dc7e127eb39f641530bf823 (patch) | |
tree | 61771e4f322a7138b643d5325a6d10acea30fb84 /python/modules/IcePy/Communicator.cpp | |
parent | Deprecate ice_name and add ice_id (diff) | |
download | ice-d5dd7c866e9e1dc59dc7e127eb39f641530bf823.tar.bz2 ice-d5dd7c866e9e1dc59dc7e127eb39f641530bf823.tar.xz ice-d5dd7c866e9e1dc59dc7e127eb39f641530bf823.zip |
ICE-6861 - removing public stream API
Diffstat (limited to 'python/modules/IcePy/Communicator.cpp')
-rw-r--r-- | python/modules/IcePy/Communicator.cpp | 144 |
1 files changed, 42 insertions, 102 deletions
diff --git a/python/modules/IcePy/Communicator.cpp b/python/modules/IcePy/Communicator.cpp index 1492c24c1ee..3f2d56e4c32 100644 --- a/python/modules/IcePy/Communicator.cpp +++ b/python/modules/IcePy/Communicator.cpp @@ -16,7 +16,6 @@ #include <ImplicitContext.h> #include <Logger.h> #include <ObjectAdapter.h> -#include <ObjectFactory.h> #include <Operation.h> #include <Properties.h> #include <PropertiesAdmin.h> @@ -24,6 +23,7 @@ #include <Thread.h> #include <Types.h> #include <Util.h> +#include <ValueFactoryManager.h> #include <Ice/ValueFactory.h> #include <Ice/Initialize.h> #include <Ice/CommunicatorAsync.h> @@ -142,12 +142,14 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) bool hasArgs = argList != 0; Ice::InitializationData data; + if(initData) { PyObjectHandle properties = PyObject_GetAttrString(initData, STRCAST("properties")); PyObjectHandle logger = PyObject_GetAttrString(initData, STRCAST("logger")); PyObjectHandle threadHook = PyObject_GetAttrString(initData, STRCAST("threadHook")); PyObjectHandle batchRequestInterceptor = PyObject_GetAttrString(initData, STRCAST("batchRequestInterceptor")); + PyErr_Clear(); // PyObject_GetAttrString sets an error on failure. if(properties.get() && properties.get() != Py_None) @@ -176,6 +178,11 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) } } + // + // We always supply our own implementation of ValueFactoryManager. + // + data.valueFactoryManager = new ValueFactoryManager; + try { if(argList) @@ -254,8 +261,6 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) delete[] argv; self->communicator = new Ice::CommunicatorPtr(communicator); - ObjectFactoryPtr factory = new ObjectFactory; - (*self->communicator)->addObjectFactory(factory, ""); CommunicatorMap::iterator p = _communicatorMap.find(communicator); if(p != _communicatorMap.end()) @@ -302,6 +307,10 @@ static PyObject* communicatorDestroy(CommunicatorObject* self) { assert(self->communicator); + + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast((*self->communicator)->getValueFactoryManager()); + assert(vfm); + try { AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. @@ -310,17 +319,25 @@ communicatorDestroy(CommunicatorObject* self) catch(const Ice::Exception& ex) { setPythonException(ex); - return 0; } + vfm->destroy(); + // // Break cyclic reference between this object and its Python wrapper. // Py_XDECREF(self->wrapper); self->wrapper = 0; - Py_INCREF(Py_None); - return Py_None; + if(PyErr_Occurred()) + { + return 0; + } + else + { + Py_INCREF(Py_None); + return Py_None; + } } #ifdef WIN32 @@ -1169,12 +1186,16 @@ extern "C" static PyObject* communicatorAddObjectFactory(CommunicatorObject* self, PyObject* args) { - PyObject* factoryType = lookupType("Ice.ObjectFactory"); - assert(factoryType); + PyObject* objectFactoryType = lookupType("Ice.ObjectFactory"); + assert(objectFactoryType); + PyObject* valueFactoryType = lookupType("types.FunctionType"); + assert(valueFactoryType); - PyObject* factory; + PyObject* objectFactory; PyObject* strObj; - if(!PyArg_ParseTuple(args, STRCAST("O!O"), factoryType, &factory, &strObj)) + PyObject* valueFactory; + if(!PyArg_ParseTuple(args, STRCAST("O!OO!"), objectFactoryType, &objectFactory, &strObj, valueFactoryType, + &valueFactory)) { return 0; } @@ -1185,55 +1206,12 @@ communicatorAddObjectFactory(CommunicatorObject* self, PyObject* args) return 0; } - ObjectFactoryPtr pof; - try - { - pof = ObjectFactoryPtr::dynamicCast((*self->communicator)->findObjectFactory("")); - assert(pof); - } - catch(const Ice::Exception& ex) - { - setPythonException(ex); - return 0; - - } - - if(!pof->addObjectFactory(factory, id)) - { - return 0; - } - - Py_INCREF(Py_None); - return Py_None; -} - -#ifdef WIN32 -extern "C" -#endif -static PyObject* -communicatorAddValueFactory(CommunicatorObject* self, PyObject* args) -{ - PyObject* factoryType = lookupType("types.FunctionType"); - assert(factoryType); - - PyObject* factory; - PyObject* strObj; - if(!PyArg_ParseTuple(args, STRCAST("O!O"), factoryType, &factory, &strObj)) - { - return 0; - } - - string id; - if(!getStringArg(strObj, "id", id)) - { - return 0; - } + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast((*self->communicator)->getValueFactoryManager()); + assert(vfm); - ObjectFactoryPtr pof; try { - pof = ObjectFactoryPtr::dynamicCast((*self->communicator)->findObjectFactory("")); - assert(pof); + vfm->add(valueFactory, objectFactory, id); } catch(const Ice::Exception& ex) { @@ -1242,11 +1220,6 @@ communicatorAddValueFactory(CommunicatorObject* self, PyObject* args) } - if(!pof->addValueFactory(factory, id)) - { - return 0; - } - Py_INCREF(Py_None); return Py_None; } @@ -1269,52 +1242,21 @@ communicatorFindObjectFactory(CommunicatorObject* self, PyObject* args) return 0; } - ObjectFactoryPtr pof; - try - { - pof = ObjectFactoryPtr::dynamicCast((*self->communicator)->findObjectFactory("")); - assert(pof); - } - catch(const Ice::Exception& ex) - { - setPythonException(ex); - return 0; - } + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast((*self->communicator)->getValueFactoryManager()); + assert(vfm); - return pof->findObjectFactory(id); + return vfm->findObjectFactory(id); } #ifdef WIN32 extern "C" #endif static PyObject* -communicatorFindValueFactory(CommunicatorObject* self, PyObject* args) +communicatorGetValueFactoryManager(CommunicatorObject* self) { - PyObject* strObj; - if(!PyArg_ParseTuple(args, STRCAST("O"), &strObj)) - { - return 0; - } - - string id; - if(!getStringArg(strObj, "id", id)) - { - return 0; - } - - ObjectFactoryPtr pof; - try - { - pof = ObjectFactoryPtr::dynamicCast((*self->communicator)->findObjectFactory("")); - assert(pof); - } - catch(const Ice::Exception& ex) - { - setPythonException(ex); - return 0; - } + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast((*self->communicator)->getValueFactoryManager()); - return pof->findValueFactory(id); + return vfm->getObject(); } #ifdef WIN32 @@ -1648,10 +1590,8 @@ static PyMethodDef CommunicatorMethods[] = PyDoc_STR(STRCAST("addObjectFactory(factory, id) -> None")) }, { STRCAST("findObjectFactory"), reinterpret_cast<PyCFunction>(communicatorFindObjectFactory), METH_VARARGS, PyDoc_STR(STRCAST("findObjectFactory(id) -> Ice.ObjectFactory")) }, - { STRCAST("addValueFactory"), reinterpret_cast<PyCFunction>(communicatorAddValueFactory), METH_VARARGS, - PyDoc_STR(STRCAST("addValueFactory(factory, id) -> None")) }, - { STRCAST("findValueFactory"), reinterpret_cast<PyCFunction>(communicatorFindValueFactory), METH_VARARGS, - PyDoc_STR(STRCAST("findValueFactory(id) -> Ice.ValueFactory")) }, + { STRCAST("getValueFactoryManager"), reinterpret_cast<PyCFunction>(communicatorGetValueFactoryManager), METH_NOARGS, + PyDoc_STR(STRCAST("getValueFactoryManager() -> Ice.ValueFactoryManager")) }, { STRCAST("getImplicitContext"), reinterpret_cast<PyCFunction>(communicatorGetImplicitContext), METH_NOARGS, PyDoc_STR(STRCAST("getImplicitContext() -> Ice.ImplicitContext")) }, { STRCAST("getProperties"), reinterpret_cast<PyCFunction>(communicatorGetProperties), METH_NOARGS, |