diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
commit | abada90e3f84dc703b8ddc9efcbed8a946fadead (patch) | |
tree | 2c6f9dccd510ea97cb927a7bd635422efaae547a /py/modules | |
parent | removing trace message (diff) | |
download | ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2 ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip |
Expanded tabs into spaces
Diffstat (limited to 'py/modules')
-rw-r--r-- | py/modules/IcePy/Communicator.cpp | 194 | ||||
-rw-r--r-- | py/modules/IcePy/Connection.cpp | 14 | ||||
-rw-r--r-- | py/modules/IcePy/Current.cpp | 18 | ||||
-rw-r--r-- | py/modules/IcePy/ImplicitContext.cpp | 14 | ||||
-rw-r--r-- | py/modules/IcePy/Logger.cpp | 2 | ||||
-rw-r--r-- | py/modules/IcePy/ObjectAdapter.cpp | 62 | ||||
-rw-r--r-- | py/modules/IcePy/Operation.cpp | 142 | ||||
-rw-r--r-- | py/modules/IcePy/Properties.cpp | 48 | ||||
-rw-r--r-- | py/modules/IcePy/Proxy.cpp | 358 | ||||
-rw-r--r-- | py/modules/IcePy/Slice.cpp | 62 | ||||
-rw-r--r-- | py/modules/IcePy/Types.cpp | 1322 | ||||
-rw-r--r-- | py/modules/IcePy/Types.h | 34 | ||||
-rw-r--r-- | py/modules/IcePy/Util.cpp | 286 |
13 files changed, 1278 insertions, 1278 deletions
diff --git a/py/modules/IcePy/Communicator.cpp b/py/modules/IcePy/Communicator.cpp index 28e020669c9..29b3d80d0c7 100644 --- a/py/modules/IcePy/Communicator.cpp +++ b/py/modules/IcePy/Communicator.cpp @@ -105,29 +105,29 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) 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 properties = PyObject_GetAttrString(initData, STRCAST("properties")); + PyObjectHandle logger = PyObject_GetAttrString(initData, STRCAST("logger")); + PyObjectHandle threadHook = PyObject_GetAttrString(initData, STRCAST("threadHook")); - if(properties.get() && properties.get() != Py_None) - { - // - // Get the properties implementation. - // - PyObjectHandle impl = PyObject_GetAttrString(properties.get(), STRCAST("_impl")); - assert(impl.get() != NULL); - data.properties = getProperties(impl.get()); - } + if(properties.get() && properties.get() != Py_None) + { + // + // Get the properties implementation. + // + PyObjectHandle impl = PyObject_GetAttrString(properties.get(), STRCAST("_impl")); + assert(impl.get() != NULL); + data.properties = getProperties(impl.get()); + } - if(logger.get() && logger.get() != Py_None) - { - data.logger = new LoggerWrapper(logger.get()); - } + if(logger.get() && logger.get() != Py_None) + { + data.logger = new LoggerWrapper(logger.get()); + } - if(threadHook.get() && threadHook.get() != Py_None) - { - data.threadHook = new ThreadNotificationWrapper(threadHook.get()); - } + if(threadHook.get() && threadHook.get() != Py_None) + { + data.threadHook = new ThreadNotificationWrapper(threadHook.get()); + } } @@ -149,32 +149,32 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) int i = 0; for(Ice::StringSeq::const_iterator s = seq.begin(); s != seq.end(); ++s, ++i) { - argv[i] = strdup(s->c_str()); + argv[i] = strdup(s->c_str()); } argv[argc] = 0; Ice::CommunicatorPtr communicator; try { - if(hasArgs) - { - communicator = Ice::initialize(argc, argv, data); - } - else - { - communicator = Ice::initialize(data); - } + if(hasArgs) + { + communicator = Ice::initialize(argc, argv, data); + } + else + { + communicator = Ice::initialize(data); + } } catch(const Ice::Exception& ex) { - for(i = 0; i < argc + 1; ++i) - { - free(argv[i]); - } - delete[] argv; + for(i = 0; i < argc + 1; ++i) + { + free(argv[i]); + } + delete[] argv; - setPythonException(ex); - return -1; + setPythonException(ex); + return -1; } // @@ -182,18 +182,18 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) // if(arglist) { - PyList_SetSlice(arglist, 0, PyList_Size(arglist), NULL); // Clear the list. + PyList_SetSlice(arglist, 0, PyList_Size(arglist), NULL); // Clear the list. - for(i = 0; i < argc; ++i) - { - PyObjectHandle str = Py_BuildValue(STRCAST("s"), argv[i]); - PyList_Append(arglist, str.get()); - } + for(i = 0; i < argc; ++i) + { + PyObjectHandle str = Py_BuildValue(STRCAST("s"), argv[i]); + PyList_Append(arglist, str.get()); + } } for(i = 0; i < argc + 1; ++i) { - free(argv[i]); + free(argv[i]); } delete[] argv; @@ -204,7 +204,7 @@ communicatorInit(CommunicatorObject* self, PyObject* args, PyObject* /*kwds*/) CommunicatorMap::iterator p = _communicatorMap.find(communicator); if(p != _communicatorMap.end()) { - _communicatorMap.erase(p); + _communicatorMap.erase(p); } _communicatorMap.insert(CommunicatorMap::value_type(communicator, (PyObject*)self)); @@ -223,7 +223,7 @@ communicatorDealloc(CommunicatorObject* self) // if(p != _communicatorMap.end()) { - _communicatorMap.erase(p); + _communicatorMap.erase(p); } if(self->shutdownThread) @@ -246,7 +246,7 @@ communicatorDestroy(CommunicatorObject* self) assert(self->communicator); try { - AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. + AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. (*self->communicator)->destroy(); } catch(const Ice::Exception& ex) @@ -268,7 +268,7 @@ communicatorShutdown(CommunicatorObject* self) assert(self->communicator); try { - AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. + AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. (*self->communicator)->shutdown(); } catch(const Ice::Exception& ex) @@ -324,20 +324,20 @@ communicatorWaitForShutdown(CommunicatorObject* self, PyObject* args) t->start(); } - while(!self->shutdown) - { - bool done; - { - AllowThreads allowThreads; // Release Python's global interpreter lock during blocking calls. - done = (*self->shutdownMonitor).timedWait(IceUtil::Time::milliSeconds(timeout)); - } - - if(!done) - { - Py_INCREF(Py_False); - return Py_False; - } - } + while(!self->shutdown) + { + bool done; + { + AllowThreads allowThreads; // Release Python's global interpreter lock during blocking calls. + done = (*self->shutdownMonitor).timedWait(IceUtil::Time::milliSeconds(timeout)); + } + + if(!done) + { + Py_INCREF(Py_False); + return Py_False; + } + } } assert(self->shutdown); @@ -541,7 +541,7 @@ communicatorFlushBatchRequests(CommunicatorObject* self) assert(self->communicator); try { - AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. + AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. (*self->communicator)->flushBatchRequests(); } catch(const Ice::Exception& ex) @@ -634,9 +634,9 @@ communicatorGetLogger(CommunicatorObject* self) LoggerWrapperPtr wrapper = LoggerWrapperPtr::dynamicCast(logger); if(wrapper) { - PyObject* obj = wrapper->getObject(); - Py_INCREF(obj); - return obj; + PyObject* obj = wrapper->getObject(); + Py_INCREF(obj); + return obj; } return createLogger(logger); @@ -725,7 +725,7 @@ communicatorSetDefaultContext(CommunicatorObject* self, PyObject* args) Ice::Context ctx; if(!dictionaryToContext(dict, ctx)) { - return NULL; + return NULL; } try @@ -765,12 +765,12 @@ communicatorGetDefaultContext(CommunicatorObject* self) PyObjectHandle dict = PyDict_New(); if(dict.get() == NULL) { - return NULL; + return NULL; } if(!contextToDictionary(ctx, dict.get())) { - return NULL; + return NULL; } return dict.release(); @@ -786,7 +786,7 @@ communicatorGetImplicitContext(CommunicatorObject* self) if(implicitContext == 0) { - return 0; + return 0; } return createImplicitContext(implicitContext); @@ -882,7 +882,7 @@ communicatorCreateObjectAdapterWithRouter(CommunicatorObject* self, PyObject* ar PyObject* proxy; if(!PyArg_ParseTuple(args, STRCAST("sO"), &name, &proxy)) { - return NULL; + return NULL; } PyObject* routerProxyType = lookupType("Ice.RouterPrx"); @@ -890,12 +890,12 @@ communicatorCreateObjectAdapterWithRouter(CommunicatorObject* self, PyObject* ar Ice::RouterPrx router; if(PyObject_IsInstance(proxy, routerProxyType)) { - router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); + router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); } else if(proxy != Py_None) { - PyErr_Format(PyExc_ValueError, STRCAST("ice_createObjectAdapterWithRouter requires None or Ice.RouterPrx")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("ice_createObjectAdapterWithRouter requires None or Ice.RouterPrx")); + return NULL; } AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. @@ -947,8 +947,8 @@ communicatorGetDefaultRouter(CommunicatorObject* self) if(!router) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } PyObject* routerProxyType = lookupType("Ice.RouterPrx"); @@ -965,7 +965,7 @@ communicatorSetDefaultRouter(CommunicatorObject* self, PyObject* args) PyObject* proxy; if(!PyArg_ParseTuple(args, STRCAST("O"), &proxy)) { - return NULL; + return NULL; } PyObject* routerProxyType = lookupType("Ice.RouterPrx"); @@ -973,23 +973,23 @@ communicatorSetDefaultRouter(CommunicatorObject* self, PyObject* args) Ice::RouterPrx router; if(PyObject_IsInstance(proxy, routerProxyType)) { - router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); + router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); } else if(proxy != Py_None) { - PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultRouter requires None or Ice.RouterPrx")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultRouter requires None or Ice.RouterPrx")); + return NULL; } assert(self->communicator); try { - (*self->communicator)->setDefaultRouter(router); + (*self->communicator)->setDefaultRouter(router); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(Py_None); @@ -1016,8 +1016,8 @@ communicatorGetDefaultLocator(CommunicatorObject* self) if(!locator) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); @@ -1034,7 +1034,7 @@ communicatorSetDefaultLocator(CommunicatorObject* self, PyObject* args) PyObject* proxy; if(!PyArg_ParseTuple(args, STRCAST("O"), &proxy)) { - return NULL; + return NULL; } PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); @@ -1042,23 +1042,23 @@ communicatorSetDefaultLocator(CommunicatorObject* self, PyObject* args) Ice::LocatorPrx locator; if(PyObject_IsInstance(proxy, locatorProxyType)) { - locator = Ice::LocatorPrx::uncheckedCast(getProxy(proxy)); + locator = Ice::LocatorPrx::uncheckedCast(getProxy(proxy)); } else if(proxy != Py_None) { - PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultLocator requires None or Ice.LocatorPrx")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("ice_setDefaultLocator requires None or Ice.LocatorPrx")); + return NULL; } assert(self->communicator); try { - (*self->communicator)->setDefaultLocator(locator); + (*self->communicator)->setDefaultLocator(locator); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(Py_None); @@ -1088,11 +1088,11 @@ static PyMethodDef CommunicatorMethods[] = { STRCAST("createObjectAdapter"), (PyCFunction)communicatorCreateObjectAdapter, METH_VARARGS, PyDoc_STR(STRCAST("createObjectAdapter(name) -> Ice.ObjectAdapter")) }, { STRCAST("createObjectAdapterWithEndpoints"), (PyCFunction)communicatorCreateObjectAdapterWithEndpoints, - METH_VARARGS, - PyDoc_STR(STRCAST("createObjectAdapterWithEndpoints(name, endpoints) -> Ice.ObjectAdapter")) }, + METH_VARARGS, + PyDoc_STR(STRCAST("createObjectAdapterWithEndpoints(name, endpoints) -> Ice.ObjectAdapter")) }, { STRCAST("createObjectAdapterWithRouter"), (PyCFunction)communicatorCreateObjectAdapterWithRouter, - METH_VARARGS, - PyDoc_STR(STRCAST("createObjectAdapterWithRouter(name, router) -> Ice.ObjectAdapter")) }, + METH_VARARGS, + PyDoc_STR(STRCAST("createObjectAdapterWithRouter(name, router) -> Ice.ObjectAdapter")) }, { STRCAST("addObjectFactory"), (PyCFunction)communicatorAddObjectFactory, METH_VARARGS, PyDoc_STR(STRCAST("addObjectFactory(factory, id) -> None")) }, { STRCAST("findObjectFactory"), (PyCFunction)communicatorFindObjectFactory, METH_VARARGS, @@ -1208,8 +1208,8 @@ IcePy::createCommunicator(const Ice::CommunicatorPtr& communicator) CommunicatorMap::iterator p = _communicatorMap.find(communicator); if(p != _communicatorMap.end()) { - Py_INCREF(p->second); - return p->second; + Py_INCREF(p->second); + return p->second; } CommunicatorObject* obj = communicatorNew(NULL); diff --git a/py/modules/IcePy/Connection.cpp b/py/modules/IcePy/Connection.cpp index 335cd75929c..3ee67e29878 100644 --- a/py/modules/IcePy/Connection.cpp +++ b/py/modules/IcePy/Connection.cpp @@ -152,7 +152,7 @@ connectionSetAdapter(ConnectionObject* self, PyObject* args) PyObject* adapter; if(!PyArg_ParseTuple(args, STRCAST("O!"), adapterType, &adapter)) { - return NULL; + return NULL; } Ice::ObjectAdapterPtr oa = unwrapObjectAdapter(adapter); @@ -162,12 +162,12 @@ connectionSetAdapter(ConnectionObject* self, PyObject* args) assert(self->communicator); try { - (*self->connection)->setAdapter(oa); + (*self->connection)->setAdapter(oa); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(Py_None); @@ -186,12 +186,12 @@ connectionGetAdapter(ConnectionObject* self) assert(self->communicator); try { - adapter = (*self->connection)->getAdapter(); + adapter = (*self->connection)->getAdapter(); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return wrapObjectAdapter(adapter); diff --git a/py/modules/IcePy/Current.cpp b/py/modules/IcePy/Current.cpp index ed96092a761..8336c8147ea 100644 --- a/py/modules/IcePy/Current.cpp +++ b/py/modules/IcePy/Current.cpp @@ -112,7 +112,7 @@ currentGetter(CurrentObject* self, void* closure) { if(self->adapter == NULL) { - self->adapter = wrapObjectAdapter(self->current->adapter); + self->adapter = wrapObjectAdapter(self->current->adapter); if(self->adapter == NULL) { return NULL; @@ -124,14 +124,14 @@ currentGetter(CurrentObject* self, void* closure) } case CURRENT_CONNECTION: { - if(self->con == NULL) - { - self->con = createConnection(self->current->con, self->current->adapter->getCommunicator()); - if(self->con == NULL) - { - return NULL; - } - } + if(self->con == NULL) + { + self->con = createConnection(self->current->con, self->current->adapter->getCommunicator()); + if(self->con == NULL) + { + return NULL; + } + } Py_INCREF(self->con); result = self->con; break; diff --git a/py/modules/IcePy/ImplicitContext.cpp b/py/modules/IcePy/ImplicitContext.cpp index 4f1900eb9a1..598f88d5395 100644 --- a/py/modules/IcePy/ImplicitContext.cpp +++ b/py/modules/IcePy/ImplicitContext.cpp @@ -88,12 +88,12 @@ implicitContextGetContext(ImplicitContextObject* self) PyObjectHandle dict = PyDict_New(); if(dict.get() == NULL) { - return NULL; + return NULL; } if(!contextToDictionary(ctx, dict.get())) { - return NULL; + return NULL; } return dict.release(); @@ -115,7 +115,7 @@ implicitContextSetContext(ImplicitContextObject* self, PyObject* args) Ice::Context ctx; if(!dictionaryToContext(dict, ctx)) { - return NULL; + return NULL; } (*self->implicitContext)->setContext(ctx); @@ -139,11 +139,11 @@ implicitContextGet(ImplicitContextObject* self, PyObject* args) string val; try { - val = (*self->implicitContext)->get(key); + val = (*self->implicitContext)->get(key); } catch(const Ice::Exception& ex) { - setPythonException(ex); + setPythonException(ex); return NULL; } return PyString_FromString(const_cast<char*>(val.c_str())); @@ -200,11 +200,11 @@ implicitContextRemove(ImplicitContextObject* self, PyObject* args) try { - (*self->implicitContext)->remove(key); + (*self->implicitContext)->remove(key); } catch(const Ice::Exception& ex) { - setPythonException(ex); + setPythonException(ex); return NULL; } diff --git a/py/modules/IcePy/Logger.cpp b/py/modules/IcePy/Logger.cpp index c8da57220ea..2cde5545ac0 100644 --- a/py/modules/IcePy/Logger.cpp +++ b/py/modules/IcePy/Logger.cpp @@ -53,7 +53,7 @@ IcePy::LoggerWrapper::trace(const string& category, const string& message) AdoptThread adoptThread; // Ensure the current thread is able to call into Python. PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), STRCAST("trace"), STRCAST("ss"), category.c_str(), - message.c_str()); + message.c_str()); if(tmp.get() == NULL) { throwPythonException(); diff --git a/py/modules/IcePy/ObjectAdapter.cpp b/py/modules/IcePy/ObjectAdapter.cpp index be4d95d0abd..25def843246 100644 --- a/py/modules/IcePy/ObjectAdapter.cpp +++ b/py/modules/IcePy/ObjectAdapter.cpp @@ -175,7 +175,7 @@ IcePy::ServantWrapper::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& cb, } } - __checkMode(op->mode(), current.mode); + __checkMode(op->mode(), current.mode); op->dispatch(_servant, cb, inParams, current); } @@ -281,7 +281,7 @@ IcePy::ServantLocatorWrapper::finished(const Ice::Current&, const Ice::ObjectPtr PyObjectHandle servantObj = wrapper->getObject(); PyObjectHandle res = PyObject_CallMethod(_locator, STRCAST("finished"), STRCAST("OOO"), c->current, - servantObj.get(), c->cookie); + servantObj.get(), c->cookie); if(PyErr_Occurred()) { throwPythonException(); @@ -594,21 +594,21 @@ adapterWaitForDeactivate(ObjectAdapterObject* self, PyObject* args) self->deactivateThread = new AdapterInvokeThreadPtr(t); t->start(); } - - while(!self->deactivated) - { - bool done; - { - AllowThreads allowThreads; // Release Python's global interpreter lock during blocking calls. - done = (*self->deactivateMonitor).timedWait(IceUtil::Time::milliSeconds(timeout)); - } - - if(!done) - { - Py_INCREF(Py_False); - return Py_False; - } - } + + while(!self->deactivated) + { + bool done; + { + AllowThreads allowThreads; // Release Python's global interpreter lock during blocking calls. + done = (*self->deactivateMonitor).timedWait(IceUtil::Time::milliSeconds(timeout)); + } + + if(!done) + { + Py_INCREF(Py_False); + return Py_False; + } + } } assert(self->deactivated); @@ -868,8 +868,8 @@ adapterRemove(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -911,8 +911,8 @@ adapterRemoveFacet(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -1004,8 +1004,8 @@ adapterFind(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -1047,8 +1047,8 @@ adapterFindFacet(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -1136,8 +1136,8 @@ adapterFindByProxy(ObjectAdapterObject* self, PyObject* args) if(!obj) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); @@ -1202,8 +1202,8 @@ adapterFindServantLocator(ObjectAdapterObject* self, PyObject* args) if(!locator) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } ServantLocatorWrapperPtr wrapper = ServantLocatorWrapperPtr::dynamicCast(locator); @@ -1541,14 +1541,14 @@ IcePy::wrapObjectAdapter(const Ice::ObjectAdapterPtr& adapter) PyObjectHandle adapterI = createObjectAdapter(adapter); if(adapterI.get() == NULL) { - return NULL; + return NULL; } PyObject* wrapperType = lookupType("Ice.ObjectAdapterI"); assert(wrapperType != NULL); PyObjectHandle args = PyTuple_New(1); if(args.get() == NULL) { - return NULL; + return NULL; } PyTuple_SET_ITEM(args.get(), 0, adapterI.release()); return PyObject_Call(wrapperType, args.get(), NULL); diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp index 15e6d1cbb55..6404dac4e56 100644 --- a/py/modules/IcePy/Operation.cpp +++ b/py/modules/IcePy/Operation.cpp @@ -158,8 +158,8 @@ operationInit(OperationObject* self, PyObject* args, PyObject* /*kwds*/) PyObject* returnType; PyObject* exceptions; if(!PyArg_ParseTuple(args, STRCAST("sO!O!iO!O!O!OO!"), &name, modeType, &mode, modeType, &sendMode, &amd, - &PyTuple_Type, &meta, &PyTuple_Type, &inParams, &PyTuple_Type, &outParams, &returnType, - &PyTuple_Type, &exceptions)) + &PyTuple_Type, &meta, &PyTuple_Type, &inParams, &PyTuple_Type, &outParams, &returnType, + &PyTuple_Type, &exceptions)) { return -1; } @@ -323,8 +323,8 @@ amdCallbackIceException(AMDCallbackObject* self, PyObject* args) try { assert(self->op); - PyException pye(ex); // No traceback information available. - (*self->op)->sendException(*self->cb, pye, *self->communicator); + PyException pye(ex); // No traceback information available. + (*self->op)->sendException(*self->cb, pye, *self->communicator); } catch(const Ice::Exception& ex) { @@ -400,7 +400,7 @@ IcePy::AMICallback::ice_exception(const Ice::Exception& ex) // OperationI implementation. // IcePy::OperationI::OperationI(const char* name, PyObject* mode, PyObject* sendMode, int amd, PyObject* meta, - PyObject* inParams, PyObject* outParams, PyObject* returnType, PyObject* exceptions) + PyObject* inParams, PyObject* outParams, PyObject* returnType, PyObject* exceptions) { _name = name; @@ -491,13 +491,13 @@ IcePy::OperationI::invoke(const Ice::ObjectPrx& proxy, PyObject* args, PyObject* if(!_deprecateMessage.empty()) { - PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); - _deprecateMessage.clear(); // Only show the warning once. + PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); + _deprecateMessage.clear(); // Only show the warning once. } try { - checkTwowayOnly(proxy); + checkTwowayOnly(proxy); // // Invoke the operation. @@ -545,7 +545,7 @@ IcePy::OperationI::invoke(const Ice::ObjectPrx& proxy, PyObject* args, PyObject* // // Set the Python exception. // - setPythonException(ex.get()); + setPythonException(ex.get()); return NULL; } else if(_outParams.size() > 0 || _returnType) @@ -603,14 +603,14 @@ IcePy::OperationI::invokeAsync(const Ice::ObjectPrx& proxy, PyObject* callback, if(!_deprecateMessage.empty()) { - PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); - _deprecateMessage.clear(); // Only show the warning once. + PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); + _deprecateMessage.clear(); // Only show the warning once. } Ice::AMI_Object_ice_invokePtr cb = new AMICallback(this, communicator, callback); try { - checkTwowayOnly(proxy); + checkTwowayOnly(proxy); // // Invoke the operation asynchronously. @@ -641,7 +641,7 @@ IcePy::OperationI::invokeAsync(const Ice::ObjectPrx& proxy, PyObject* callback, } catch(const Ice::Exception& ex) { - cb->ice_exception(ex); + cb->ice_exception(ex); } Py_INCREF(Py_None); @@ -653,11 +653,11 @@ IcePy::OperationI::deprecate(const string& msg) { if(!msg.empty()) { - _deprecateMessage = msg; + _deprecateMessage = msg; } else { - _deprecateMessage = "operation " + _name + " is deprecated"; + _deprecateMessage = "operation " + _name + " is deprecated"; } } @@ -699,7 +699,7 @@ IcePy::OperationI::dispatch(PyObject* servant, const Ice::AMD_Object_ice_invokeP Py_ssize_t i = start; for(ParamInfoList::iterator p = _inParams.begin(); p != _inParams.end(); ++p, ++i) { - void* closure = reinterpret_cast<void*>(i); + void* closure = reinterpret_cast<void*>(i); (*p)->type->unmarshal(is, *p, args.get(), closure, &(*p)->metaData); } if(_sendsClasses) @@ -766,8 +766,8 @@ IcePy::OperationI::dispatch(PyObject* servant, const Ice::AMD_Object_ice_invokeP // if(PyErr_Occurred()) { - PyException ex; // Retrieve it before another Python API call clears it. - sendException(cb, ex, communicator); + PyException ex; // Retrieve it before another Python API call clears it. + sendException(cb, ex, communicator); return; } @@ -785,26 +785,26 @@ IcePy::OperationI::responseAsync(PyObject* callback, bool ok, const vector<Ice:: { if(ok) { - // - // Unmarshal the results. - // - PyObjectHandle args; - try - { - args = unmarshalResults(results, communicator); - if(args.get() == NULL) - { - assert(PyErr_Occurred()); - PyErr_Print(); - return; - } - } - catch(const Ice::Exception& ex) - { - PyObjectHandle h = convertException(ex); - responseAsyncException(callback, h.get()); - return; - } + // + // Unmarshal the results. + // + PyObjectHandle args; + try + { + args = unmarshalResults(results, communicator); + if(args.get() == NULL) + { + assert(PyErr_Occurred()); + PyErr_Print(); + return; + } + } + catch(const Ice::Exception& ex) + { + PyObjectHandle h = convertException(ex); + responseAsyncException(callback, h.get()); + return; + } PyObjectHandle method = PyObject_GetAttrString(callback, STRCAST("ice_response")); if(method.get() == NULL) @@ -968,14 +968,14 @@ IcePy::OperationI::sendException(const Ice::AMD_Object_ice_invokePtr& cb, PyExce // However, we have no way to pass this exception to the interpreter, // so we act on it directly. // - if(PyObject_IsInstance(ex.ex.get(), PyExc_SystemExit)) + if(PyObject_IsInstance(ex.ex.get(), PyExc_SystemExit)) { handleSystemExit(ex.ex.get()); // Does not return. } PyObject* userExceptionType = lookupType("Ice.UserException"); - if(PyObject_IsInstance(ex.ex.get(), userExceptionType)) + if(PyObject_IsInstance(ex.ex.get(), userExceptionType)) { // // Get the exception's type and verify that it is legal to be thrown from this operation. @@ -986,7 +986,7 @@ IcePy::OperationI::sendException(const Ice::AMD_Object_ice_invokePtr& cb, PyExce assert(info); if(!validateException(ex.ex.get())) { - ex.raise(); // Raises UnknownUserException. + ex.raise(); // Raises UnknownUserException. } else { @@ -1006,7 +1006,7 @@ IcePy::OperationI::sendException(const Ice::AMD_Object_ice_invokePtr& cb, PyExce } else { - ex.raise(); + ex.raise(); } } catch(const AbortMarshaling&) @@ -1030,7 +1030,7 @@ IcePy::OperationI::prepareRequest(const Ice::CommunicatorPtr& communicator, PyOb { string fixedName = fixIdent(_name); PyErr_Format(PyExc_RuntimeError, STRCAST("%s expects %d in parameters"), fixedName.c_str(), - static_cast<int>(paramCount)); + static_cast<int>(paramCount)); return false; } @@ -1103,7 +1103,7 @@ IcePy::OperationI::unmarshalResults(const vector<Ice::Byte>& bytes, const Ice::C Ice::InputStreamPtr is = Ice::createInputStream(communicator, bytes); for(ParamInfoList::iterator p = _outParams.begin(); p != _outParams.end(); ++p, ++i) { - void* closure = reinterpret_cast<void*>(i); + void* closure = reinterpret_cast<void*>(i); (*p)->type->unmarshal(is, *p, results.get(), closure, &(*p)->metaData); } @@ -1146,8 +1146,8 @@ IcePy::OperationI::unmarshalException(const vector<Ice::Byte>& bytes, const Ice: } else { - PyException pye(ex.get()); // No traceback information available. - pye.raise(); + PyException pye(ex.get()); // No traceback information available. + pye.raise(); } } else @@ -1185,9 +1185,9 @@ IcePy::OperationI::checkTwowayOnly(const Ice::ObjectPrx& proxy) const { if((_returnType != 0 || !_outParams.empty()) && !proxy->ice_isTwoway()) { - Ice::TwowayOnlyException ex(__FILE__, __LINE__); - ex.operation = _name; - throw ex; + Ice::TwowayOnlyException ex(__FILE__, __LINE__); + ex.operation = _name; + throw ex; } } @@ -1198,32 +1198,32 @@ IcePy::OperationI::convertParams(PyObject* p, ParamInfoList& params, bool& usesC int sz = PyTuple_GET_SIZE(p); for(int i = 0; i < sz; ++i) { - PyObject* item = PyTuple_GET_ITEM(p, i); - assert(PyTuple_Check(item)); - assert(PyTuple_GET_SIZE(item) == 2); + PyObject* item = PyTuple_GET_ITEM(p, i); + assert(PyTuple_Check(item)); + assert(PyTuple_GET_SIZE(item) == 2); - ParamInfoPtr param = new ParamInfo; + ParamInfoPtr param = new ParamInfo; - // - // metaData - // - PyObject* meta = PyTuple_GET_ITEM(item, 0); - assert(PyTuple_Check(meta)); + // + // metaData + // + PyObject* meta = PyTuple_GET_ITEM(item, 0); + assert(PyTuple_Check(meta)); #ifndef NDEBUG - bool b = + bool b = #endif - tupleToStringSeq(meta, param->metaData); - assert(b); - - // - // type - // - param->type = getType(PyTuple_GET_ITEM(item, 1)); - params.push_back(param); - if(!usesClasses) - { - usesClasses = param->type->usesClasses(); - } + tupleToStringSeq(meta, param->metaData); + assert(b); + + // + // type + // + param->type = getType(PyTuple_GET_ITEM(item, 1)); + params.push_back(param); + if(!usesClasses) + { + usesClasses = param->type->usesClasses(); + } } } diff --git a/py/modules/IcePy/Properties.cpp b/py/modules/IcePy/Properties.cpp index 040b6e77a43..b6097394264 100644 --- a/py/modules/IcePy/Properties.cpp +++ b/py/modules/IcePy/Properties.cpp @@ -61,35 +61,35 @@ propertiesInit(PropertiesObject* self, PyObject* args, PyObject* /*kwds*/) Ice::StringSeq seq; if(arglist) { - if(PyObject_IsInstance(arglist, (PyObject*)&PyList_Type)) - { - if(!listToStringSeq(arglist, seq)) - { - return -1; - } - } - else if(arglist != Py_None) - { - PyErr_Format(PyExc_ValueError, STRCAST("args must be None or a list")); - return -1; - } + if(PyObject_IsInstance(arglist, (PyObject*)&PyList_Type)) + { + if(!listToStringSeq(arglist, seq)) + { + return -1; + } + } + else if(arglist != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("args must be None or a list")); + return -1; + } } Ice::PropertiesPtr defaults; if(defaultsObj) { - PyObject* propType = lookupType("Ice.PropertiesI"); - assert(propType != NULL); - if(PyObject_IsInstance(defaultsObj, propType)) - { - PyObjectHandle impl = PyObject_GetAttrString(defaultsObj, STRCAST("_impl")); - defaults = getProperties(impl.get()); - } - else if(defaultsObj != Py_None) - { - PyErr_Format(PyExc_ValueError, STRCAST("defaults must be None or a Ice.Properties")); - return -1; - } + PyObject* propType = lookupType("Ice.PropertiesI"); + assert(propType != NULL); + if(PyObject_IsInstance(defaultsObj, propType)) + { + PyObjectHandle impl = PyObject_GetAttrString(defaultsObj, STRCAST("_impl")); + defaults = getProperties(impl.get()); + } + else if(defaultsObj != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("defaults must be None or a Ice.Properties")); + return -1; + } } diff --git a/py/modules/IcePy/Proxy.cpp b/py/modules/IcePy/Proxy.cpp index 2041e9cee9b..8b2263dbb33 100644 --- a/py/modules/IcePy/Proxy.cpp +++ b/py/modules/IcePy/Proxy.cpp @@ -222,19 +222,19 @@ proxyIceIsA(ProxyObject* self, PyObject* args) try { AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - if(ctx) - { - Ice::Context context; - if(!dictionaryToContext(ctx, context)) - { - return NULL; - } - b = (*self->proxy)->ice_isA(type, context); - } - else - { - b = (*self->proxy)->ice_isA(type); - } + if(ctx) + { + Ice::Context context; + if(!dictionaryToContext(ctx, context)) + { + return NULL; + } + b = (*self->proxy)->ice_isA(type, context); + } + else + { + b = (*self->proxy)->ice_isA(type); + } } catch(const Ice::Exception& ex) { @@ -264,19 +264,19 @@ proxyIcePing(ProxyObject* self, PyObject* args) try { AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - if(ctx) - { - Ice::Context context; - if(!dictionaryToContext(ctx, context)) - { - return NULL; - } - (*self->proxy)->ice_ping(context); - } - else - { - (*self->proxy)->ice_ping(); - } + if(ctx) + { + Ice::Context context; + if(!dictionaryToContext(ctx, context)) + { + return NULL; + } + (*self->proxy)->ice_ping(context); + } + else + { + (*self->proxy)->ice_ping(); + } } catch(const Ice::Exception& ex) { @@ -306,19 +306,19 @@ proxyIceIds(ProxyObject* self, PyObject* args) try { AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - if(ctx) - { - Ice::Context context; - if(!dictionaryToContext(ctx, context)) - { - return NULL; - } - ids = (*self->proxy)->ice_ids(context); - } - else - { - ids = (*self->proxy)->ice_ids(); - } + if(ctx) + { + Ice::Context context; + if(!dictionaryToContext(ctx, context)) + { + return NULL; + } + ids = (*self->proxy)->ice_ids(context); + } + else + { + ids = (*self->proxy)->ice_ids(); + } } catch(const Ice::Exception& ex) { @@ -353,19 +353,19 @@ proxyIceId(ProxyObject* self, PyObject* args) try { AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. - if(ctx) - { - Ice::Context context; - if(!dictionaryToContext(ctx, context)) - { - return NULL; - } - id = (*self->proxy)->ice_id(context); - } - else - { - id = (*self->proxy)->ice_id(); - } + if(ctx) + { + Ice::Context context; + if(!dictionaryToContext(ctx, context)) + { + return NULL; + } + id = (*self->proxy)->ice_id(context); + } + else + { + id = (*self->proxy)->ice_id(); + } } catch(const Ice::Exception& ex) { @@ -608,12 +608,12 @@ proxyIceGetAdapterId(ProxyObject* self) string id; try { - id = (*self->proxy)->ice_getAdapterId(); + id = (*self->proxy)->ice_getAdapterId(); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return PyString_FromString(const_cast<char*>(id.c_str())); @@ -668,12 +668,12 @@ proxyIceGetEndpoints(ProxyObject* self) Ice::EndpointSeq endpoints; try { - endpoints = (*self->proxy)->ice_getEndpoints(); + endpoints = (*self->proxy)->ice_getEndpoints(); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } int count = static_cast<int>(endpoints.size()); @@ -681,12 +681,12 @@ proxyIceGetEndpoints(ProxyObject* self) int i = 0; for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p, ++i) { - PyObjectHandle endp = (PyObject*)allocateEndpoint(*p); - if(endp.get() == NULL) - { - return NULL; - } - PyTuple_SET_ITEM(result.get(), i, endp.release()); // PyTuple_SET_ITEM steals a reference. + PyObjectHandle endp = (PyObject*)allocateEndpoint(*p); + if(endp.get() == NULL) + { + return NULL; + } + PyTuple_SET_ITEM(result.get(), i, endp.release()); // PyTuple_SET_ITEM steals a reference. } return result.release(); @@ -706,8 +706,8 @@ proxyIceEndpoints(ProxyObject* self, PyObject* args) if(!PyTuple_Check(endpoints) && !PyList_Check(endpoints)) { - PyErr_Format(PyExc_ValueError, STRCAST("argument must be a tuple or list")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("argument must be a tuple or list")); + return NULL; } assert(self->proxy); @@ -717,20 +717,20 @@ proxyIceEndpoints(ProxyObject* self, PyObject* args) for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* p = PySequence_Fast_GET_ITEM(endpoints, i); - if(!PyObject_IsInstance(p, (PyObject*)&EndpointType)) - { - PyErr_Format(PyExc_ValueError, STRCAST("expected element of type Ice.Endpoint")); - return NULL; - } - EndpointObject* o = (EndpointObject*)p; - assert(*o->endpoint); - seq.push_back(*o->endpoint); + if(!PyObject_IsInstance(p, (PyObject*)&EndpointType)) + { + PyErr_Format(PyExc_ValueError, STRCAST("expected element of type Ice.Endpoint")); + return NULL; + } + EndpointObject* o = (EndpointObject*)p; + assert(*o->endpoint); + seq.push_back(*o->endpoint); } Ice::ObjectPrx newProxy; try { - newProxy = (*self->proxy)->ice_endpoints(seq); + newProxy = (*self->proxy)->ice_endpoints(seq); } catch(const Ice::Exception& ex) { @@ -761,13 +761,13 @@ proxyIceGetLocatorCacheTimeout(ProxyObject* self) try { - Ice::Int timeout = (*self->proxy)->ice_getLocatorCacheTimeout(); - return PyInt_FromLong(timeout); + Ice::Int timeout = (*self->proxy)->ice_getLocatorCacheTimeout(); + return PyInt_FromLong(timeout); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } } @@ -780,7 +780,7 @@ proxyIceLocatorCacheTimeout(ProxyObject* self, PyObject* args) int timeout; if(!PyArg_ParseTuple(args, STRCAST("i"), &timeout)) { - return NULL; + return NULL; } assert(self->proxy); @@ -788,12 +788,12 @@ proxyIceLocatorCacheTimeout(ProxyObject* self, PyObject* args) Ice::ObjectPrx newProxy; try { - newProxy = (*self->proxy)->ice_locatorCacheTimeout(timeout); + newProxy = (*self->proxy)->ice_locatorCacheTimeout(timeout); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return createProxy(newProxy, *self->communicator); @@ -810,12 +810,12 @@ proxyIceIsConnectionCached(ProxyObject* self) PyObject* b; try { - b = (*self->proxy)->ice_isConnectionCached() ? Py_True : Py_False; + b = (*self->proxy)->ice_isConnectionCached() ? Py_True : Py_False; } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(b); @@ -845,12 +845,12 @@ proxyIceConnectionCached(ProxyObject* self, PyObject* args) Ice::ObjectPrx newProxy; try { - newProxy = (*self->proxy)->ice_connectionCached(n == 1); + newProxy = (*self->proxy)->ice_connectionCached(n == 1); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return createProxy(newProxy, *self->communicator); @@ -875,20 +875,20 @@ proxyIceGetEndpointSelection(ProxyObject* self) PyObject* type; try { - Ice::EndpointSelectionType val = (*self->proxy)->ice_getEndpointSelection(); - if(val == Ice::Random) - { - type = rnd.get(); - } - else - { - type = ord.get(); - } + Ice::EndpointSelectionType val = (*self->proxy)->ice_getEndpointSelection(); + if(val == Ice::Random) + { + type = rnd.get(); + } + else + { + type = ord.get(); + } } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } Py_INCREF(type); @@ -916,11 +916,11 @@ proxyIceEndpointSelection(ProxyObject* self, PyObject* args) assert(ord.get() != NULL); if(rnd.get() == type) { - val = Ice::Random; + val = Ice::Random; } else if(ord.get() == type) { - val = Ice::Ordered; + val = Ice::Ordered; } else { @@ -933,12 +933,12 @@ proxyIceEndpointSelection(ProxyObject* self, PyObject* args) Ice::ObjectPrx newProxy; try { - newProxy = (*self->proxy)->ice_endpointSelection(val); + newProxy = (*self->proxy)->ice_endpointSelection(val); } catch(const Ice::Exception& ex) { - setPythonException(ex); - return NULL; + setPythonException(ex); + return NULL; } return createProxy(newProxy, *self->communicator); @@ -1079,8 +1079,8 @@ proxyIceGetRouter(ProxyObject* self) if(!router) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } PyObject* routerProxyType = lookupType("Ice.RouterPrx"); @@ -1150,8 +1150,8 @@ proxyIceGetLocator(ProxyObject* self) if(!locator) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); @@ -1595,12 +1595,12 @@ proxyIceGetConnection(ProxyObject* self) if(con) { - return createConnection(con, *self->communicator); + return createConnection(con, *self->communicator); } else { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } } @@ -1625,12 +1625,12 @@ proxyIceGetCachedConnection(ProxyObject* self) if(con) { - return createConnection(con, *self->communicator); + return createConnection(con, *self->communicator); } else { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } } @@ -1747,42 +1747,42 @@ proxyIceCheckedCast(PyObject* type, PyObject* args) if(PyString_Check(facetOrCtx)) { - facet = PyString_AS_STRING(facetOrCtx); + facet = PyString_AS_STRING(facetOrCtx); } else if(PyDict_Check(facetOrCtx)) { - if(ctx != Py_None) - { - PyErr_Format(PyExc_ValueError, STRCAST("facet argument to checkedCast must be a string")); - return NULL; - } - ctx = facetOrCtx; + if(ctx != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("facet argument to checkedCast must be a string")); + return NULL; + } + ctx = facetOrCtx; } else if(facetOrCtx != Py_None) { - PyErr_Format(PyExc_ValueError, STRCAST("second argument to checkedCast must be a facet or context")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("second argument to checkedCast must be a facet or context")); + return NULL; } if(ctx != Py_None && !PyDict_Check(ctx)) { - PyErr_Format(PyExc_ValueError, STRCAST("context argument to checkedCast must be a dictionary")); - return NULL; + PyErr_Format(PyExc_ValueError, STRCAST("context argument to checkedCast must be a dictionary")); + return NULL; } if(ctx == Py_None) { - return checkedCastImpl((ProxyObject*)obj, id, facet, type); + return checkedCastImpl((ProxyObject*)obj, id, facet, type); } else { - Ice::Context c; - if(!dictionaryToContext(ctx, c)) - { - return NULL; - } + Ice::Context c; + if(!dictionaryToContext(ctx, c)) + { + return NULL; + } - return checkedCastImpl((ProxyObject*)obj, id, facet, c, type); + return checkedCastImpl((ProxyObject*)obj, id, facet, c, type); } } @@ -1854,63 +1854,63 @@ proxyCheckedCast(PyObject* /*self*/, PyObject* args) if(arg1 != 0 && arg2 != 0) { - if(arg1 == Py_None) - { - arg1 = 0; - } - - if(arg2 == Py_None) - { - arg2 = 0; - } - - if(arg1 != 0) - { - if(!PyString_Check(arg1)) - { - PyErr_Format(PyExc_ValueError, STRCAST("facet argument to checkedCast must be a string")); - return NULL; - } - facet = PyString_AS_STRING(arg1); - } - - if(arg2 != 0 && !PyDict_Check(arg2)) - { - PyErr_Format(PyExc_ValueError, STRCAST("context argument to checkedCast must be a dictionary")); - return NULL; - } - ctx = arg2; + if(arg1 == Py_None) + { + arg1 = 0; + } + + if(arg2 == Py_None) + { + arg2 = 0; + } + + if(arg1 != 0) + { + if(!PyString_Check(arg1)) + { + PyErr_Format(PyExc_ValueError, STRCAST("facet argument to checkedCast must be a string")); + return NULL; + } + facet = PyString_AS_STRING(arg1); + } + + if(arg2 != 0 && !PyDict_Check(arg2)) + { + PyErr_Format(PyExc_ValueError, STRCAST("context argument to checkedCast must be a dictionary")); + return NULL; + } + ctx = arg2; } else if(arg1 != 0 && arg1 != Py_None) { - if(PyString_Check(arg1)) - { - facet = PyString_AS_STRING(arg1); - } - else if(PyDict_Check(arg1)) - { - ctx = arg1; - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("second argument to checkedCast must be a facet or context")); - return NULL; - } + if(PyString_Check(arg1)) + { + facet = PyString_AS_STRING(arg1); + } + else if(PyDict_Check(arg1)) + { + ctx = arg1; + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("second argument to checkedCast must be a facet or context")); + return NULL; + } } if(ctx == 0) { - return checkedCastImpl((ProxyObject*)obj, "::Ice::Object", facet, NULL); + return checkedCastImpl((ProxyObject*)obj, "::Ice::Object", facet, NULL); } else { - Ice::Context c; - if(!dictionaryToContext(ctx, c)) - { - return NULL; - } + Ice::Context c; + if(!dictionaryToContext(ctx, c)) + { + return NULL; + } - return checkedCastImpl((ProxyObject*)obj, "::Ice::Object", facet, c, NULL); + return checkedCastImpl((ProxyObject*)obj, "::Ice::Object", facet, c, NULL); } } diff --git a/py/modules/IcePy/Slice.cpp b/py/modules/IcePy/Slice.cpp index 715d6f5fd55..a401aaf829c 100644 --- a/py/modules/IcePy/Slice.cpp +++ b/py/modules/IcePy/Slice.cpp @@ -41,17 +41,17 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) vector<string> argSeq; try { - argSeq = IceUtil::Options::split(cmd); + argSeq = IceUtil::Options::split(cmd); } catch(const IceUtil::BadOptException& ex) { - PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); - return NULL; + PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); + return NULL; } catch(const IceUtil::APIException& ex) { - PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); - return NULL; + PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); + return NULL; } if(list != NULL) @@ -72,23 +72,23 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) vector<string> files; try { - argSeq.insert(argSeq.begin(), ""); // dummy argv[0] - files = opts.parse(argSeq); - if(files.empty()) - { - PyErr_Format(PyExc_RuntimeError, "no Slice files specified in `%s'", cmd); - return NULL; - } + argSeq.insert(argSeq.begin(), ""); // dummy argv[0] + files = opts.parse(argSeq); + if(files.empty()) + { + PyErr_Format(PyExc_RuntimeError, "no Slice files specified in `%s'", cmd); + return NULL; + } } catch(const IceUtil::BadOptException& ex) { - PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); - return NULL; + PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); + return NULL; } catch(const IceUtil::APIException& ex) { - PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); - return NULL; + PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str()); + return NULL; } string cppArgs; @@ -100,27 +100,27 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) bool checksum = false; if(opts.isSet("D")) { - vector<string> optargs = opts.argVec("D"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs += " -D" + *i; - } + vector<string> optargs = opts.argVec("D"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs += " -D" + *i; + } } if(opts.isSet("U")) { - vector<string> optargs = opts.argVec("U"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs += " -U" + *i; - } + vector<string> optargs = opts.argVec("U"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs += " -U" + *i; + } } if(opts.isSet("I")) { - includePaths = opts.argVec("I"); - for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) - { - cppArgs += " -I" + *i; - } + includePaths = opts.argVec("I"); + for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) + { + cppArgs += " -I" + *i; + } } debug = opts.isSet("d") || opts.isSet("debug"); caseSensitive = opts.isSet("case-sensitive"); diff --git a/py/modules/IcePy/Types.cpp b/py/modules/IcePy/Types.cpp index 078763a49a0..2f496d117e5 100644 --- a/py/modules/IcePy/Types.cpp +++ b/py/modules/IcePy/Types.cpp @@ -141,7 +141,7 @@ addClassInfo(const string& id, const ClassInfoPtr& info) ClassInfoMap::iterator p = _classInfoMap.find(id); if(p != _classInfoMap.end()) { - _classInfoMap.erase(p); + _classInfoMap.erase(p); } _classInfoMap.insert(ClassInfoMap::value_type(id, info)); } @@ -161,7 +161,7 @@ addProxyInfo(const string& id, const ProxyInfoPtr& info) ProxyInfoMap::iterator p = _proxyInfoMap.find(id); if(p != _proxyInfoMap.end()) { - _proxyInfoMap.erase(p); + _proxyInfoMap.erase(p); } _proxyInfoMap.insert(ProxyInfoMap::value_type(id, info)); } @@ -593,13 +593,13 @@ IcePy::PrimitiveInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHi { if(!validate(value)) { - out << "<invalid value - expected " << getId() << ">"; - return; + out << "<invalid value - expected " << getId() << ">"; + return; } PyObjectHandle p = PyObject_Str(value); if(p.get() == NULL) { - return; + return; } assert(PyString_Check(p.get())); out << PyString_AS_STRING(p.get()); @@ -695,13 +695,13 @@ IcePy::EnumInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHistory { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } PyObjectHandle p = PyObject_Str(value); if(p.get() == NULL) { - return; + return; } assert(PyString_Check(p.get())); out << PyString_AS_STRING(p.get()); @@ -801,24 +801,24 @@ IcePy::StructInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHisto { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } out.sb(); for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - char* memberName = const_cast<char*>(member->name.c_str()); - PyObjectHandle attr = PyObject_GetAttrString(value, memberName); - out << nl << member->name << " = "; - if(attr.get() == NULL) - { - out << "<not defined>"; - } - else - { - member->type->print(attr.get(), out, history); - } + DataMemberPtr member = *q; + char* memberName = const_cast<char*>(member->name.c_str()); + PyObjectHandle attr = PyObject_GetAttrString(value, memberName); + out << nl << member->name << " = "; + if(attr.get() == NULL) + { + out << "<not defined>"; + } + else + { + member->type->print(attr.get(), out, history); + } } out.eb(); } @@ -856,7 +856,7 @@ IcePy::SequenceInfo::usesClasses() void IcePy::SequenceInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, - const Ice::StringSeq* metaData) + const Ice::StringSeq* metaData) { if(p == Py_None) { @@ -867,7 +867,7 @@ IcePy::SequenceInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Object PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType); if(pi) { - marshalPrimitiveSequence(pi, p, os); + marshalPrimitiveSequence(pi, p, os); return; } @@ -889,7 +889,7 @@ IcePy::SequenceInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Object if(!elementType->validate(item)) { PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of `%s'"), static_cast<int>(i), - const_cast<char*>(id.c_str())); + const_cast<char*>(id.c_str())); throw AbortMarshaling(); } elementType->marshal(item, os, objectMap); @@ -908,25 +908,25 @@ IcePy::SequenceInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCal SequenceMappingPtr sm; if(metaData) { - SequenceMapping::Type type; - if(!SequenceMapping::getType(*metaData, type) || type == mapping->type) - { - sm = mapping; - } - else - { - sm = new SequenceMapping(type); - } + SequenceMapping::Type type; + if(!SequenceMapping::getType(*metaData, type) || type == mapping->type) + { + sm = mapping; + } + else + { + sm = new SequenceMapping(type); + } } else { - sm = mapping; + sm = mapping; } PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType); if(pi) { - unmarshalPrimitiveSequence(pi, is, cb, target, closure, sm); + unmarshalPrimitiveSequence(pi, is, cb, target, closure, sm); return; } @@ -940,8 +940,8 @@ IcePy::SequenceInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCal for(Ice::Int i = 0; i < sz; ++i) { - void* cl = reinterpret_cast<void*>(i); - elementType->unmarshal(is, sm, result.get(), cl); + void* cl = reinterpret_cast<void*>(i); + elementType->unmarshal(is, sm, result.get(), cl); } cb->unmarshaled(result.get(), target, closure); @@ -952,36 +952,36 @@ IcePy::SequenceInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHis { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } if(value == Py_None) { - out << "{}"; + out << "{}"; } else { - PyObjectHandle fastSeq = PySequence_Fast(value, STRCAST("expected a sequence value")); - if(fastSeq.get() == NULL) - { - return; - } + PyObjectHandle fastSeq = PySequence_Fast(value, STRCAST("expected a sequence value")); + if(fastSeq.get() == NULL) + { + return; + } - Py_ssize_t sz = PySequence_Fast_GET_SIZE(fastSeq.get()); + Py_ssize_t sz = PySequence_Fast_GET_SIZE(fastSeq.get()); - out.sb(); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fastSeq.get(), i); - if(item == NULL) - { - break; - } - out << nl << '[' << static_cast<int>(i) << "] = "; - elementType->print(item, out, history); - } - out.eb(); + out.sb(); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fastSeq.get(), i); + if(item == NULL) + { + break; + } + out << nl << '[' << static_cast<int>(i) << "] = "; + elementType->print(item, out, history); + } + out.eb(); } } @@ -1006,52 +1006,52 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje Py_ssize_t sz; if(PyObject_AsReadBuffer(p, &buf, &sz) == 0) { - const Ice::Byte* b = reinterpret_cast<const Ice::Byte*>(buf); - switch(pi->kind) - { - case PrimitiveInfo::KindBool: - { - os->writeBoolSeq(reinterpret_cast<const bool*>(b), reinterpret_cast<const bool*>(b + sz)); - break; - } - case PrimitiveInfo::KindByte: - { - os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(b), reinterpret_cast<const Ice::Byte*>(b + sz)); - break; - } - case PrimitiveInfo::KindShort: - { - os->writeShortSeq(reinterpret_cast<const Ice::Short*>(b), reinterpret_cast<const Ice::Short*>(b + sz)); - break; - } - case PrimitiveInfo::KindInt: - { - os->writeIntSeq(reinterpret_cast<const Ice::Int*>(b), reinterpret_cast<const Ice::Int*>(b + sz)); - break; - } - case PrimitiveInfo::KindLong: - { - PyErr_Format(PyExc_ValueError, STRCAST("expected sequence value")); - throw AbortMarshaling(); - } - case PrimitiveInfo::KindFloat: - { - os->writeFloatSeq(reinterpret_cast<const Ice::Float*>(b), reinterpret_cast<const Ice::Float*>(b + sz)); - break; - } - case PrimitiveInfo::KindDouble: - { - os->writeDoubleSeq(reinterpret_cast<const Ice::Double*>(b), - reinterpret_cast<const Ice::Double*>(b + sz)); - break; - } - case PrimitiveInfo::KindString: - { - PyErr_Format(PyExc_ValueError, STRCAST("expected sequence value")); - throw AbortMarshaling(); - } - } - return; + const Ice::Byte* b = reinterpret_cast<const Ice::Byte*>(buf); + switch(pi->kind) + { + case PrimitiveInfo::KindBool: + { + os->writeBoolSeq(reinterpret_cast<const bool*>(b), reinterpret_cast<const bool*>(b + sz)); + break; + } + case PrimitiveInfo::KindByte: + { + os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(b), reinterpret_cast<const Ice::Byte*>(b + sz)); + break; + } + case PrimitiveInfo::KindShort: + { + os->writeShortSeq(reinterpret_cast<const Ice::Short*>(b), reinterpret_cast<const Ice::Short*>(b + sz)); + break; + } + case PrimitiveInfo::KindInt: + { + os->writeIntSeq(reinterpret_cast<const Ice::Int*>(b), reinterpret_cast<const Ice::Int*>(b + sz)); + break; + } + case PrimitiveInfo::KindLong: + { + PyErr_Format(PyExc_ValueError, STRCAST("expected sequence value")); + throw AbortMarshaling(); + } + case PrimitiveInfo::KindFloat: + { + os->writeFloatSeq(reinterpret_cast<const Ice::Float*>(b), reinterpret_cast<const Ice::Float*>(b + sz)); + break; + } + case PrimitiveInfo::KindDouble: + { + os->writeDoubleSeq(reinterpret_cast<const Ice::Double*>(b), + reinterpret_cast<const Ice::Double*>(b + sz)); + break; + } + case PrimitiveInfo::KindString: + { + PyErr_Format(PyExc_ValueError, STRCAST("expected sequence value")); + throw AbortMarshaling(); + } + } + return; } PyErr_Clear(); // PyObject_AsReadBuffer sets an exception on failure. @@ -1059,303 +1059,303 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje PyObjectHandle fs; if(!buf) { - if(pi->kind == PrimitiveInfo::KindByte) - { - // - // Accept a string or a sequence for sequence<byte>. - // - if(!PyString_Check(p)) - { - fs = PySequence_Fast(p, STRCAST("expected a string, sequence, or buffer value")); - if(fs.get() == NULL) - { - return; - } - } - } - else - { - fs = PySequence_Fast(p, STRCAST("expected a sequence or buffer value")); - if(fs.get() == NULL) - { - return; - } - } + if(pi->kind == PrimitiveInfo::KindByte) + { + // + // Accept a string or a sequence for sequence<byte>. + // + if(!PyString_Check(p)) + { + fs = PySequence_Fast(p, STRCAST("expected a string, sequence, or buffer value")); + if(fs.get() == NULL) + { + return; + } + } + } + else + { + fs = PySequence_Fast(p, STRCAST("expected a sequence or buffer value")); + if(fs.get() == NULL) + { + return; + } + } } switch(pi->kind) { case PrimitiveInfo::KindBool: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::BoolSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - int isTrue = PyObject_IsTrue(item); - if(isTrue < 0) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<bool>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = isTrue ? true : false; - } - os->writeBoolSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::BoolSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + int isTrue = PyObject_IsTrue(item); + if(isTrue < 0) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<bool>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = isTrue ? true : false; + } + os->writeBoolSeq(seq); + break; } case PrimitiveInfo::KindByte: { - if(fs.get() == NULL) - { - assert(PyString_Check(p)); - const char* str = PyString_AS_STRING(p); - sz = PyString_GET_SIZE(p); - os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(str), reinterpret_cast<const Ice::Byte*>(str + sz)); - } - else - { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::ByteSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - long val = -1; - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLong(item); - } - - if(PyErr_Occurred() || val < 0 || val > 255) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<byte>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = static_cast<Ice::Byte>(val); - } - os->writeByteSeq(seq); - } - break; + if(fs.get() == NULL) + { + assert(PyString_Check(p)); + const char* str = PyString_AS_STRING(p); + sz = PyString_GET_SIZE(p); + os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(str), reinterpret_cast<const Ice::Byte*>(str + sz)); + } + else + { + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::ByteSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + long val = -1; + if(PyInt_Check(item)) + { + val = PyInt_AS_LONG(item); + } + else if(PyLong_Check(item)) + { + val = PyLong_AsLong(item); + } + + if(PyErr_Occurred() || val < 0 || val > 255) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<byte>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = static_cast<Ice::Byte>(val); + } + os->writeByteSeq(seq); + } + break; } case PrimitiveInfo::KindShort: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::ShortSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - long val = SHRT_MIN - 1; - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLong(item); - } - - if(PyErr_Occurred() || val < SHRT_MIN || val > SHRT_MAX) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<short>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = static_cast<Ice::Short>(val); - } - os->writeShortSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::ShortSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + long val = SHRT_MIN - 1; + if(PyInt_Check(item)) + { + val = PyInt_AS_LONG(item); + } + else if(PyLong_Check(item)) + { + val = PyLong_AsLong(item); + } + + if(PyErr_Occurred() || val < SHRT_MIN || val > SHRT_MAX) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<short>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = static_cast<Ice::Short>(val); + } + os->writeShortSeq(seq); + break; } case PrimitiveInfo::KindInt: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::IntSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - long val; - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLong(item); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<int>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - - if(PyErr_Occurred() || val < INT_MIN || val > INT_MAX) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<int>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = static_cast<Ice::Int>(val); - } - os->writeIntSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::IntSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + long val; + if(PyInt_Check(item)) + { + val = PyInt_AS_LONG(item); + } + else if(PyLong_Check(item)) + { + val = PyLong_AsLong(item); + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<int>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + + if(PyErr_Occurred() || val < INT_MIN || val > INT_MAX) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<int>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = static_cast<Ice::Int>(val); + } + os->writeIntSeq(seq); + break; } case PrimitiveInfo::KindLong: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::LongSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - Ice::Long val; - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLongLong(item); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<long>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - - if(PyErr_Occurred()) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<long>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - seq[i] = val; - } - os->writeLongSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::LongSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + Ice::Long val; + if(PyInt_Check(item)) + { + val = PyInt_AS_LONG(item); + } + else if(PyLong_Check(item)) + { + val = PyLong_AsLongLong(item); + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<long>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + + if(PyErr_Occurred()) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<long>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + seq[i] = val; + } + os->writeLongSeq(seq); + break; } case PrimitiveInfo::KindFloat: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::FloatSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - float val; - if(PyFloat_Check(item)) - { - val = static_cast<float>(PyFloat_AS_DOUBLE(item)); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<float>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - - seq[i] = val; - } - os->writeFloatSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::FloatSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + float val; + if(PyFloat_Check(item)) + { + val = static_cast<float>(PyFloat_AS_DOUBLE(item)); + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<float>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + + seq[i] = val; + } + os->writeFloatSeq(seq); + break; } case PrimitiveInfo::KindDouble: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::DoubleSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } - - double val; - if(PyFloat_Check(item)) - { - val = PyFloat_AS_DOUBLE(item); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<double>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } - - seq[i] = val; - } - os->writeDoubleSeq(seq); - break; + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::DoubleSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } + + double val; + if(PyFloat_Check(item)) + { + val = PyFloat_AS_DOUBLE(item); + } + else + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<double>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } + + seq[i] = val; + } + os->writeDoubleSeq(seq); + break; } case PrimitiveInfo::KindString: { - sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::StringSeq seq(sz); - for(Py_ssize_t i = 0; i < sz; ++i) - { - PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); - if(item == NULL) - { - throw AbortMarshaling(); - } + sz = PySequence_Fast_GET_SIZE(fs.get()); + Ice::StringSeq seq(sz); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); + if(item == NULL) + { + throw AbortMarshaling(); + } - string val; - if(PyString_Check(item)) - { - val = string(PyString_AS_STRING(item), PyString_GET_SIZE(item)); - } - else if(p != Py_None) - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<string>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } + string val; + if(PyString_Check(item)) + { + val = string(PyString_AS_STRING(item), PyString_GET_SIZE(item)); + } + else if(p != Py_None) + { + PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<string>"), + static_cast<int>(i)); + throw AbortMarshaling(); + } - seq[i] = val; - } - os->writeStringSeq(seq); - break; + seq[i] = val; + } + os->writeStringSeq(seq); + break; } } } void IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, const Ice::InputStreamPtr& is, - const UnmarshalCallbackPtr& cb, PyObject* target, void* closure, - const SequenceMappingPtr& sm) + const UnmarshalCallbackPtr& cb, PyObject* target, void* closure, + const SequenceMappingPtr& sm) { PyObjectHandle result; @@ -1363,184 +1363,184 @@ IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, cons { case PrimitiveInfo::KindBool: { - pair<const bool*, const bool*> p; - IceUtil::ScopedArray<bool> arr(is->readBoolSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - sm->setItem(result.get(), i, p.first[i] ? Py_True : Py_False); - } - break; + pair<const bool*, const bool*> p; + IceUtil::ScopedArray<bool> arr(is->readBoolSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + sm->setItem(result.get(), i, p.first[i] ? Py_True : Py_False); + } + break; } case PrimitiveInfo::KindByte: { - pair<const Ice::Byte*, const Ice::Byte*> p; - is->readByteSeq(p); - int sz = static_cast<int>(p.second - p.first); - if(sm->type == SequenceMapping::SEQ_DEFAULT) - { - result = PyString_FromStringAndSize(reinterpret_cast<const char*>(p.first), sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - } - else - { - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyInt_FromLong(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - } - break; + pair<const Ice::Byte*, const Ice::Byte*> p; + is->readByteSeq(p); + int sz = static_cast<int>(p.second - p.first); + if(sm->type == SequenceMapping::SEQ_DEFAULT) + { + result = PyString_FromStringAndSize(reinterpret_cast<const char*>(p.first), sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + } + else + { + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyInt_FromLong(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + } + break; } case PrimitiveInfo::KindShort: { - pair<const Ice::Short*, const Ice::Short*> p; - IceUtil::ScopedArray<Ice::Short> arr(is->readShortSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyInt_FromLong(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Short*, const Ice::Short*> p; + IceUtil::ScopedArray<Ice::Short> arr(is->readShortSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyInt_FromLong(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindInt: { - pair<const Ice::Int*, const Ice::Int*> p; - IceUtil::ScopedArray<Ice::Int> arr(is->readIntSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyInt_FromLong(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Int*, const Ice::Int*> p; + IceUtil::ScopedArray<Ice::Int> arr(is->readIntSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyInt_FromLong(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindLong: { - pair<const Ice::Long*, const Ice::Long*> p; - IceUtil::ScopedArray<Ice::Long> arr(is->readLongSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyLong_FromLongLong(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Long*, const Ice::Long*> p; + IceUtil::ScopedArray<Ice::Long> arr(is->readLongSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyLong_FromLongLong(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindFloat: { - pair<const Ice::Float*, const Ice::Float*> p; - IceUtil::ScopedArray<Ice::Float> arr(is->readFloatSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyFloat_FromDouble(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Float*, const Ice::Float*> p; + IceUtil::ScopedArray<Ice::Float> arr(is->readFloatSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyFloat_FromDouble(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindDouble: { - pair<const Ice::Double*, const Ice::Double*> p; - IceUtil::ScopedArray<Ice::Double> arr(is->readDoubleSeq(p)); - int sz = static_cast<int>(p.second - p.first); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyFloat_FromDouble(p.first[i]); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + pair<const Ice::Double*, const Ice::Double*> p; + IceUtil::ScopedArray<Ice::Double> arr(is->readDoubleSeq(p)); + int sz = static_cast<int>(p.second - p.first); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyFloat_FromDouble(p.first[i]); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } case PrimitiveInfo::KindString: { - Ice::StringSeq seq = is->readStringSeq(); - int sz = static_cast<int>(seq.size()); - result = sm->createContainer(sz); - if(result.get() == NULL) - { - throw AbortMarshaling(); - } - - for(int i = 0; i < sz; ++i) - { - PyObjectHandle item = PyString_FromString(seq[i].c_str()); - if(item.get() == NULL) - { - throw AbortMarshaling(); - } - sm->setItem(result.get(), i, item.get()); - } - break; + Ice::StringSeq seq = is->readStringSeq(); + int sz = static_cast<int>(seq.size()); + result = sm->createContainer(sz); + if(result.get() == NULL) + { + throw AbortMarshaling(); + } + + for(int i = 0; i < sz; ++i) + { + PyObjectHandle item = PyString_FromString(seq[i].c_str()); + if(item.get() == NULL) + { + throw AbortMarshaling(); + } + sm->setItem(result.get(), i, item.get()); + } + break; } } cb->unmarshaled(result.get(), target, closure); @@ -1551,24 +1551,24 @@ IcePy::SequenceInfo::SequenceMapping::getType(const Ice::StringSeq& metaData, Ty { if(!metaData.empty()) { - for(Ice::StringSeq::const_iterator p = metaData.begin(); p != metaData.end(); ++p) - { - if((*p) == "python:seq:default") - { - t = SEQ_DEFAULT; - return true; - } - else if((*p) == "python:seq:tuple") - { - t = SEQ_TUPLE; - return true; - } - else if((*p) == "python:seq:list") - { - t = SEQ_LIST; - return true; - } - } + for(Ice::StringSeq::const_iterator p = metaData.begin(); p != metaData.end(); ++p) + { + if((*p) == "python:seq:default") + { + t = SEQ_DEFAULT; + return true; + } + else if((*p) == "python:seq:tuple") + { + t = SEQ_TUPLE; + return true; + } + else if((*p) == "python:seq:list") + { + t = SEQ_LIST; + return true; + } + } } return false; @@ -1583,7 +1583,7 @@ IcePy::SequenceInfo::SequenceMapping::SequenceMapping(const Ice::StringSeq& meta { if(!getType(meta, type)) { - type = SEQ_DEFAULT; + type = SEQ_DEFAULT; } } @@ -1593,14 +1593,14 @@ IcePy::SequenceInfo::SequenceMapping::unmarshaled(PyObject* val, PyObject* targe long i = reinterpret_cast<long>(closure); if(type == SEQ_DEFAULT || type == SEQ_LIST) { - PyList_SET_ITEM(target, i, val); - Py_INCREF(val); // PyList_SET_ITEM steals a reference. + PyList_SET_ITEM(target, i, val); + Py_INCREF(val); // PyList_SET_ITEM steals a reference. } else { - assert(type == SEQ_TUPLE); - PyTuple_SET_ITEM(target, i, val); - Py_INCREF(val); // PyTuple_SET_ITEM steals a reference. + assert(type == SEQ_TUPLE); + PyTuple_SET_ITEM(target, i, val); + Py_INCREF(val); // PyTuple_SET_ITEM steals a reference. } } @@ -1609,12 +1609,12 @@ IcePy::SequenceInfo::SequenceMapping::createContainer(int sz) const { if(type == SEQ_DEFAULT || type == SEQ_LIST) { - return PyList_New(sz); + return PyList_New(sz); } else { - assert(type == SEQ_TUPLE); - return PyTuple_New(sz); + assert(type == SEQ_TUPLE); + return PyTuple_New(sz); } } @@ -1623,14 +1623,14 @@ IcePy::SequenceInfo::SequenceMapping::setItem(PyObject* cont, int i, PyObject* v { if(type == SEQ_DEFAULT || type == SEQ_LIST) { - Py_INCREF(val); - PyList_SET_ITEM(cont, i, val); // PyList_SET_ITEM steals a reference. + Py_INCREF(val); + PyList_SET_ITEM(cont, i, val); // PyList_SET_ITEM steals a reference. } else { - assert(type == SEQ_TUPLE); - Py_INCREF(val); - PyTuple_SET_ITEM(cont, i, val); // PyTuple_SET_ITEM steals a reference. + assert(type == SEQ_TUPLE); + Py_INCREF(val); + PyTuple_SET_ITEM(cont, i, val); // PyTuple_SET_ITEM steals a reference. } } @@ -1657,7 +1657,7 @@ IcePy::DictionaryInfo::usesClasses() void IcePy::DictionaryInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, - const Ice::StringSeq*) + const Ice::StringSeq*) { if(p == Py_None) { @@ -1731,7 +1731,7 @@ IcePy::DictionaryInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalC // The callback will reset the dictionary entry with the unmarshaled value, // so we pass it the key. // - void* cl = reinterpret_cast<void*>(keyCB->key.get()); + void* cl = reinterpret_cast<void*>(keyCB->key.get()); valueType->unmarshal(is, this, p.get(), cl); } @@ -1753,37 +1753,37 @@ IcePy::DictionaryInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectH { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } if(value == Py_None) { - out << "{}"; + out << "{}"; } else { - Py_ssize_t pos = 0; - PyObject* elemKey; - PyObject* elemValue; - out.sb(); - bool first = true; - while(PyDict_Next(value, &pos, &elemKey, &elemValue)) - { - if(first) - { - first = false; - } - else - { - out << nl; - } - out << nl << "key = "; - keyType->print(elemKey, out, history); - out << nl << "value = "; - valueType->print(elemValue, out, history); - } - out.eb(); + Py_ssize_t pos = 0; + PyObject* elemKey; + PyObject* elemValue; + out.sb(); + bool first = true; + while(PyDict_Next(value, &pos, &elemKey, &elemValue)) + { + if(first) + { + first = false; + } + else + { + out << nl; + } + out << nl << "key = "; + keyType->print(elemKey, out, history); + out << nl << "value = "; + valueType->print(elemValue, out, history); + } + out.eb(); } } @@ -1832,7 +1832,7 @@ IcePy::ClassInfo::usesClasses() void IcePy::ClassInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, - const Ice::StringSeq*) + const Ice::StringSeq*) { if(pythonType.get() == NULL) { @@ -1902,34 +1902,34 @@ IcePy::ClassInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHistor { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } if(value == Py_None) { - out << "<nil>"; + out << "<nil>"; } else { - map<PyObject*, int>::iterator q = history->objects.find(value); - if(q != history->objects.end()) - { - out << "<object #" << q->second << ">"; - } - else - { - PyObjectHandle iceType = PyObject_GetAttrString(value, STRCAST("ice_type")); - assert(iceType.get() != NULL); - ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(iceType.get())); - assert(info); - out << "object #" << history->index << " (" << info->id << ')'; - history->objects.insert(map<PyObject*, int>::value_type(value, history->index)); - ++history->index; - out.sb(); - info->printMembers(value, out, history); - out.eb(); - } + map<PyObject*, int>::iterator q = history->objects.find(value); + if(q != history->objects.end()) + { + out << "<object #" << q->second << ">"; + } + else + { + PyObjectHandle iceType = PyObject_GetAttrString(value, STRCAST("ice_type")); + assert(iceType.get() != NULL); + ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(iceType.get())); + assert(info); + out << "object #" << history->index << " (" << info->id << ')'; + history->objects.insert(map<PyObject*, int>::value_type(value, history->index)); + ++history->index; + out.sb(); + info->printMembers(value, out, history); + out.eb(); + } } } @@ -1955,23 +1955,23 @@ IcePy::ClassInfo::printMembers(PyObject* value, IceUtil::Output& out, PrintObjec { if(base) { - base->printMembers(value, out, history); + base->printMembers(value, out, history); } for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - char* memberName = const_cast<char*>(member->name.c_str()); - PyObjectHandle attr = PyObject_GetAttrString(value, memberName); - out << nl << member->name << " = "; - if(attr.get() == NULL) - { - out << "<not defined>"; - } - else - { - member->type->print(attr.get(), out, history); - } + DataMemberPtr member = *q; + char* memberName = const_cast<char*>(member->name.c_str()); + PyObjectHandle attr = PyObject_GetAttrString(value, memberName); + out << nl << member->name << " = "; + if(attr.get() == NULL) + { + out << "<not defined>"; + } + else + { + member->type->print(attr.get(), out, history); + } } } @@ -2034,23 +2034,23 @@ IcePy::ProxyInfo::print(PyObject* value, IceUtil::Output& out, PrintObjectHistor { if(!validate(value)) { - out << "<invalid value - expected " << getId() << ">"; - return; + out << "<invalid value - expected " << getId() << ">"; + return; } if(value == Py_None) { - out << "<nil>"; + out << "<nil>"; } else { - PyObjectHandle p = PyObject_Str(value); - if(p.get() == NULL) - { - return; - } - assert(PyString_Check(p.get())); - out << PyString_AS_STRING(p.get()); + PyObjectHandle p = PyObject_Str(value); + if(p.get() == NULL) + { + return; + } + assert(PyString_Check(p.get())); + out << PyString_AS_STRING(p.get()); } } @@ -2270,9 +2270,9 @@ IcePy::ReadObjectCallback::invoke(const Ice::ObjectPtr& p) if(!PyObject_IsInstance(obj, _info->pythonType.get())) { Ice::UnexpectedObjectException ex(__FILE__, __LINE__); - ex.reason = "unmarshaled object is not an instance of " + _info->id; + ex.reason = "unmarshaled object is not an instance of " + _info->id; ex.type = reader->getInfo()->getId(); - ex.expectedType = _info->id; + ex.expectedType = _info->id; throw ex; } @@ -2321,7 +2321,7 @@ IcePy::ExceptionInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Objec if(!member->type->validate(val.get())) { PyErr_Format(PyExc_ValueError, STRCAST("invalid value for %s member `%s'"), - const_cast<char*>(id.c_str()), memberName); + const_cast<char*>(id.c_str()), memberName); throw AbortMarshaling(); } @@ -2367,8 +2367,8 @@ IcePy::ExceptionInfo::print(PyObject* value, IceUtil::Output& out) { if(!PyObject_IsInstance(value, pythonType.get())) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } PrintObjectHistory history; @@ -2385,23 +2385,23 @@ IcePy::ExceptionInfo::printMembers(PyObject* value, IceUtil::Output& out, PrintO { if(base) { - base->printMembers(value, out, history); + base->printMembers(value, out, history); } for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - char* memberName = const_cast<char*>(member->name.c_str()); - PyObjectHandle attr = PyObject_GetAttrString(value, memberName); - out << nl << member->name << " = "; - if(attr.get() == NULL) - { - out << "<not defined>"; - } - else - { - member->type->print(attr.get(), out, history); - } + DataMemberPtr member = *q; + char* memberName = const_cast<char*>(member->name.c_str()); + PyObjectHandle attr = PyObject_GetAttrString(value, memberName); + out << nl << member->name << " = "; + if(attr.get() == NULL) + { + out << "<not defined>"; + } + else + { + member->type->print(attr.get(), out, history); + } } } @@ -2708,25 +2708,25 @@ convertDataMembers(PyObject* members, DataMemberList& l) Py_ssize_t sz = PyTuple_GET_SIZE(members); for(Py_ssize_t i = 0; i < sz; ++i) { - PyObject* m = PyTuple_GET_ITEM(members, i); - assert(PyTuple_Check(m)); - assert(PyTuple_GET_SIZE(m) == 3); + PyObject* m = PyTuple_GET_ITEM(members, i); + assert(PyTuple_Check(m)); + assert(PyTuple_GET_SIZE(m) == 3); - PyObject* name = PyTuple_GET_ITEM(m, 0); // Member name. - assert(PyString_Check(name)); - PyObject* meta = PyTuple_GET_ITEM(m, 1); // Member metadata. - assert(PyTuple_Check(meta)); - PyObject* t = PyTuple_GET_ITEM(m, 2); // Member type. + PyObject* name = PyTuple_GET_ITEM(m, 0); // Member name. + assert(PyString_Check(name)); + PyObject* meta = PyTuple_GET_ITEM(m, 1); // Member metadata. + assert(PyTuple_Check(meta)); + PyObject* t = PyTuple_GET_ITEM(m, 2); // Member type. - DataMemberPtr member = new DataMember; - member->name = string(PyString_AS_STRING(name), PyString_GET_SIZE(name)); + DataMemberPtr member = new DataMember; + member->name = string(PyString_AS_STRING(name), PyString_GET_SIZE(name)); #ifndef NDEBUG - bool b = + bool b = #endif - tupleToStringSeq(meta, member->metaData); - assert(b); - member->type = getType(t); - l.push_back(member); + tupleToStringSeq(meta, member->metaData); + assert(b); + member->type = getType(t); + l.push_back(member); } } @@ -2883,7 +2883,7 @@ IcePy_declareClass(PyObject*, PyObject* args) info = new ClassInfo; info->id = id; info->typeObj = createType(info); - info->defined = false; + info->defined = false; addClassInfo(id, info); } diff --git a/py/modules/IcePy/Types.h b/py/modules/IcePy/Types.h index a1d91919746..4decb6741ef 100644 --- a/py/modules/IcePy/Types.h +++ b/py/modules/IcePy/Types.h @@ -93,7 +93,7 @@ public: // virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0) = 0; virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0) = 0; + const Ice::StringSeq* = 0) = 0; virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*) = 0; }; @@ -112,7 +112,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -147,7 +147,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -185,7 +185,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -212,7 +212,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -220,19 +220,19 @@ public: struct SequenceMapping : public UnmarshalCallback { - enum Type { SEQ_DEFAULT, SEQ_TUPLE, SEQ_LIST }; + enum Type { SEQ_DEFAULT, SEQ_TUPLE, SEQ_LIST }; - SequenceMapping(Type); - SequenceMapping(const Ice::StringSeq&); + SequenceMapping(Type); + SequenceMapping(const Ice::StringSeq&); - static bool getType(const Ice::StringSeq&, Type&); + static bool getType(const Ice::StringSeq&, Type&); - virtual void unmarshaled(PyObject*, PyObject*, void*); + virtual void unmarshaled(PyObject*, PyObject*, void*); - PyObject* createContainer(int) const; - void setItem(PyObject*, int, PyObject*) const; + PyObject* createContainer(int) const; + void setItem(PyObject*, int, PyObject*) const; - Type type; + Type type; }; typedef IceUtil::Handle<SequenceMapping> SequenceMappingPtr; @@ -244,7 +244,7 @@ private: void marshalPrimitiveSequence(const PrimitiveInfoPtr&, PyObject*, const Ice::OutputStreamPtr&); void unmarshalPrimitiveSequence(const PrimitiveInfoPtr&, const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, - PyObject*, void*, const SequenceMappingPtr&); + PyObject*, void*, const SequenceMappingPtr&); }; typedef IceUtil::Handle<SequenceInfo> SequenceInfoPtr; @@ -263,7 +263,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void unmarshaled(PyObject*, PyObject*, void*); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -300,7 +300,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); @@ -331,7 +331,7 @@ public: virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, - const Ice::StringSeq* = 0); + const Ice::StringSeq* = 0); virtual void print(PyObject*, IceUtil::Output&, PrintObjectHistory*); diff --git a/py/modules/IcePy/Util.cpp b/py/modules/IcePy/Util.cpp index fa313ffe5cf..32d587532d3 100644 --- a/py/modules/IcePy/Util.cpp +++ b/py/modules/IcePy/Util.cpp @@ -101,54 +101,54 @@ IcePy::PyException::raise() if(PyObject_IsInstance(ex.get(), userExceptionType)) { - Ice::UnknownUserException e(__FILE__, __LINE__); - string tb = getTraceback(); - if(!tb.empty()) - { - e.unknown = tb; - } - else - { - PyObjectHandle name = PyObject_CallMethod(ex.get(), STRCAST("ice_name"), NULL); - PyErr_Clear(); - if(name.get() == NULL) - { - e.unknown = getTypeName(); - } - else - { - e.unknown = PyString_AS_STRING(name.get()); - } - } - throw e; + Ice::UnknownUserException e(__FILE__, __LINE__); + string tb = getTraceback(); + if(!tb.empty()) + { + e.unknown = tb; + } + else + { + PyObjectHandle name = PyObject_CallMethod(ex.get(), STRCAST("ice_name"), NULL); + PyErr_Clear(); + if(name.get() == NULL) + { + e.unknown = getTypeName(); + } + else + { + e.unknown = PyString_AS_STRING(name.get()); + } + } + throw e; } else if(PyObject_IsInstance(ex.get(), localExceptionType)) { - raiseLocalException(); + raiseLocalException(); } else { - Ice::UnknownException e(__FILE__, __LINE__); - string tb = getTraceback(); - if(!tb.empty()) - { - e.unknown = tb; - } - else - { - ostringstream ostr; + Ice::UnknownException e(__FILE__, __LINE__); + string tb = getTraceback(); + if(!tb.empty()) + { + e.unknown = tb; + } + else + { + ostringstream ostr; - ostr << getTypeName(); + ostr << getTypeName(); - IcePy::PyObjectHandle msg = PyObject_Str(ex.get()); - if(msg.get() != NULL && strlen(PyString_AsString(msg.get())) > 0) - { - ostr << ": " << PyString_AsString(msg.get()); - } + IcePy::PyObjectHandle msg = PyObject_Str(ex.get()); + if(msg.get() != NULL && strlen(PyString_AsString(msg.get())) > 0) + { + ostr << ": " << PyString_AsString(msg.get()); + } - e.unknown = ostr.str(); - } - throw e; + e.unknown = ostr.str(); + } + throw e; } } @@ -159,67 +159,67 @@ IcePy::PyException::raiseLocalException() try { - if(typeName == "Ice.ObjectNotExistException") - { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); - } - else if(typeName == "Ice.OperationNotExistException") - { - throw Ice::OperationNotExistException(__FILE__, __LINE__); - } - else if(typeName == "Ice.FacetNotExistException") - { - throw Ice::FacetNotExistException(__FILE__, __LINE__); - } - else if(typeName == "Ice.RequestFailedException") - { - throw Ice::RequestFailedException(__FILE__, __LINE__); - } + if(typeName == "Ice.ObjectNotExistException") + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + else if(typeName == "Ice.OperationNotExistException") + { + throw Ice::OperationNotExistException(__FILE__, __LINE__); + } + else if(typeName == "Ice.FacetNotExistException") + { + throw Ice::FacetNotExistException(__FILE__, __LINE__); + } + else if(typeName == "Ice.RequestFailedException") + { + throw Ice::RequestFailedException(__FILE__, __LINE__); + } } catch(Ice::RequestFailedException& e) { - IcePy::PyObjectHandle member; - member = PyObject_GetAttrString(ex.get(), STRCAST("id")); - if(member.get() != NULL && IcePy::checkIdentity(member.get())) - { - IcePy::getIdentity(member.get(), e.id); - } - member = PyObject_GetAttrString(ex.get(), STRCAST("facet")); - if(member.get() != NULL && PyString_Check(member.get())) - { - e.facet = PyString_AS_STRING(member.get()); - } - member = PyObject_GetAttrString(ex.get(), STRCAST("operation")); - if(member.get() != NULL && PyString_Check(member.get())) - { - e.operation = PyString_AS_STRING(member.get()); - } - throw; + IcePy::PyObjectHandle member; + member = PyObject_GetAttrString(ex.get(), STRCAST("id")); + if(member.get() != NULL && IcePy::checkIdentity(member.get())) + { + IcePy::getIdentity(member.get(), e.id); + } + member = PyObject_GetAttrString(ex.get(), STRCAST("facet")); + if(member.get() != NULL && PyString_Check(member.get())) + { + e.facet = PyString_AS_STRING(member.get()); + } + member = PyObject_GetAttrString(ex.get(), STRCAST("operation")); + if(member.get() != NULL && PyString_Check(member.get())) + { + e.operation = PyString_AS_STRING(member.get()); + } + throw; } try { - if(typeName == "Ice.UnknownLocalException") - { - throw Ice::UnknownLocalException(__FILE__, __LINE__); - } - else if(typeName == "Ice.UnknownUserException") - { - throw Ice::UnknownUserException(__FILE__, __LINE__); - } - else if(typeName == "Ice.UnknownException") - { - throw Ice::UnknownException(__FILE__, __LINE__); - } + if(typeName == "Ice.UnknownLocalException") + { + throw Ice::UnknownLocalException(__FILE__, __LINE__); + } + else if(typeName == "Ice.UnknownUserException") + { + throw Ice::UnknownUserException(__FILE__, __LINE__); + } + else if(typeName == "Ice.UnknownException") + { + throw Ice::UnknownException(__FILE__, __LINE__); + } } catch(Ice::UnknownException& e) { - IcePy::PyObjectHandle member; - member = PyObject_GetAttrString(ex.get(), STRCAST("unknown")); - if(member.get() != NULL && PyString_Check(member.get()) && strlen(PyString_AS_STRING(member.get())) > 0) - { - e.unknown = PyString_AS_STRING(member.get()); - } + IcePy::PyObjectHandle member; + member = PyObject_GetAttrString(ex.get(), STRCAST("unknown")); + if(member.get() != NULL && PyString_Check(member.get()) && strlen(PyString_AS_STRING(member.get())) > 0) + { + e.unknown = PyString_AS_STRING(member.get()); + } throw; } @@ -227,11 +227,11 @@ IcePy::PyException::raiseLocalException() string tb = getTraceback(); if(!tb.empty()) { - e.unknown = tb; + e.unknown = tb; } else { - e.unknown = typeName; + e.unknown = typeName; } throw e; } @@ -241,7 +241,7 @@ IcePy::PyException::getTraceback() { if(_tb.get() == NULL) { - return string(); + return string(); } // @@ -262,7 +262,7 @@ IcePy::PyException::getTraceback() string result; for(Py_ssize_t i = 0; i < PyList_GET_SIZE(list.get()); ++i) { - result += PyString_AsString(PyList_GetItem(list.get(), i)); + result += PyString_AsString(PyList_GetItem(list.get(), i)); } return result; @@ -314,16 +314,16 @@ IcePy::listToStringSeq(PyObject* l, Ice::StringSeq& seq) Py_ssize_t sz = PyList_GET_SIZE(l); for(Py_ssize_t i = 0; i < sz; ++i) { - PyObject* item = PyList_GET_ITEM(l, i); - if(item == NULL) - { - return false; - } - if(!PyString_Check(item)) - { - return false; - } - seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item))); + PyObject* item = PyList_GET_ITEM(l, i); + if(item == NULL) + { + return false; + } + if(!PyString_Check(item)) + { + return false; + } + seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item))); } return true; @@ -362,16 +362,16 @@ IcePy::tupleToStringSeq(PyObject* t, Ice::StringSeq& seq) int sz = PyTuple_GET_SIZE(t); for(int i = 0; i < sz; ++i) { - PyObject* item = PyTuple_GET_ITEM(t, i); - if(item == NULL) - { - return false; - } - if(!PyString_Check(item)) - { - return false; - } - seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item))); + PyObject* item = PyTuple_GET_ITEM(t, i); + if(item == NULL) + { + return false; + } + if(!PyString_Check(item)) + { + return false; + } + seq.push_back(string(PyString_AS_STRING(item), PyString_GET_SIZE(item))); } return true; @@ -493,34 +493,34 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p) } catch(const Ice::InitializationException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); - PyObject_SetAttrString(p, STRCAST("reason"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); + PyObject_SetAttrString(p, STRCAST("reason"), m.get()); } catch(const Ice::PluginInitializationException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); - PyObject_SetAttrString(p, STRCAST("reason"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); + PyObject_SetAttrString(p, STRCAST("reason"), m.get()); } catch(const Ice::AlreadyRegisteredException& e) { - IcePy::PyObjectHandle m; - m = PyString_FromString(const_cast<char*>(e.kindOfObject.c_str())); - PyObject_SetAttrString(p, STRCAST("kindOfObject"), m.get()); - m = PyString_FromString(const_cast<char*>(e.id.c_str())); - PyObject_SetAttrString(p, STRCAST("id"), m.get()); + IcePy::PyObjectHandle m; + m = PyString_FromString(const_cast<char*>(e.kindOfObject.c_str())); + PyObject_SetAttrString(p, STRCAST("kindOfObject"), m.get()); + m = PyString_FromString(const_cast<char*>(e.id.c_str())); + PyObject_SetAttrString(p, STRCAST("id"), m.get()); } catch(const Ice::NotRegisteredException& e) { - IcePy::PyObjectHandle m; - m = PyString_FromString(const_cast<char*>(e.kindOfObject.c_str())); - PyObject_SetAttrString(p, STRCAST("kindOfObject"), m.get()); - m = PyString_FromString(const_cast<char*>(e.id.c_str())); - PyObject_SetAttrString(p, STRCAST("id"), m.get()); + IcePy::PyObjectHandle m; + m = PyString_FromString(const_cast<char*>(e.kindOfObject.c_str())); + PyObject_SetAttrString(p, STRCAST("kindOfObject"), m.get()); + m = PyString_FromString(const_cast<char*>(e.id.c_str())); + PyObject_SetAttrString(p, STRCAST("id"), m.get()); } catch(const Ice::TwowayOnlyException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.operation.c_str())); - PyObject_SetAttrString(p, STRCAST("operation"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.operation.c_str())); + PyObject_SetAttrString(p, STRCAST("operation"), m.get()); } catch(const Ice::UnknownException& e) { @@ -574,15 +574,15 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p) } catch(const Ice::FileException& e) { - IcePy::PyObjectHandle m = PyInt_FromLong(e.error); - PyObject_SetAttrString(p, STRCAST("error"), m.get()); - m = PyString_FromString(const_cast<char*>(e.path.c_str())); - PyObject_SetAttrString(p, STRCAST("path"), m.get()); + IcePy::PyObjectHandle m = PyInt_FromLong(e.error); + PyObject_SetAttrString(p, STRCAST("error"), m.get()); + m = PyString_FromString(const_cast<char*>(e.path.c_str())); + PyObject_SetAttrString(p, STRCAST("path"), m.get()); } catch(const Ice::SyscallException& e) // This must appear after all subclasses of SyscallException. { - IcePy::PyObjectHandle m = PyInt_FromLong(e.error); - PyObject_SetAttrString(p, STRCAST("error"), m.get()); + IcePy::PyObjectHandle m = PyInt_FromLong(e.error); + PyObject_SetAttrString(p, STRCAST("error"), m.get()); } catch(const Ice::DNSException& e) { @@ -641,18 +641,18 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p) } catch(const Ice::FeatureNotSupportedException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.unsupportedFeature.c_str())); - PyObject_SetAttrString(p, STRCAST("unsupportedFeature"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.unsupportedFeature.c_str())); + PyObject_SetAttrString(p, STRCAST("unsupportedFeature"), m.get()); } catch(const Ice::NotSetException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.key.c_str())); - PyObject_SetAttrString(p, STRCAST("key"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.key.c_str())); + PyObject_SetAttrString(p, STRCAST("key"), m.get()); } catch(const Ice::SecurityException& e) { - IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); - PyObject_SetAttrString(p, STRCAST("reason"), m.get()); + IcePy::PyObjectHandle m = PyString_FromString(const_cast<char*>(e.reason.c_str())); + PyObject_SetAttrString(p, STRCAST("reason"), m.get()); } catch(const Ice::LocalException&) { @@ -731,7 +731,7 @@ IcePy::setPythonException(const Ice::Exception& ex) PyObjectHandle p = convertException(ex); if(p.get() != NULL) { - setPythonException(p.get()); + setPythonException(p.get()); } } |