diff options
author | Mark Spruiell <mes@zeroc.com> | 2006-04-05 21:20:13 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2006-04-05 21:20:13 +0000 |
commit | 71e143d6fa50cc32452b0c6712c794502f001e28 (patch) | |
tree | 419720816f0c722868b582ebfcdf9bec6d4cada4 /py/modules/IcePy/Operation.cpp | |
parent | adding support for read/write timeouts (diff) | |
download | ice-71e143d6fa50cc32452b0c6712c794502f001e28.tar.bz2 ice-71e143d6fa50cc32452b0c6712c794502f001e28.tar.xz ice-71e143d6fa50cc32452b0c6712c794502f001e28.zip |
adding support for deprecated operations
Diffstat (limited to 'py/modules/IcePy/Operation.cpp')
-rw-r--r-- | py/modules/IcePy/Operation.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp index b0767309f4d..28da7f97817 100644 --- a/py/modules/IcePy/Operation.cpp +++ b/py/modules/IcePy/Operation.cpp @@ -51,6 +51,7 @@ public: virtual PyObject* invoke(const Ice::ObjectPrx&, PyObject*, PyObject*); virtual PyObject* invokeAsync(const Ice::ObjectPrx&, PyObject*, PyObject*, PyObject*); + virtual void deprecate(const string&); virtual void dispatch(PyObject*, const Ice::AMD_Object_ice_invokePtr&, const vector<Ice::Byte>&, const Ice::Current&); @@ -73,6 +74,7 @@ private: string _dispatchName; bool _sendsClasses; bool _returnsClasses; + string _deprecateMessage; bool prepareRequest(const Ice::CommunicatorPtr&, PyObject*, bool, vector<Ice::Byte>&); PyObject* unmarshalResults(const vector<Ice::Byte>&, const Ice::CommunicatorPtr&); @@ -225,6 +227,25 @@ operationInvokeAsync(OperationObject* self, PyObject* args) #ifdef WIN32 extern "C" #endif +static PyObject* +operationDeprecate(OperationObject* self, PyObject* args) +{ + char* msg; + if(!PyArg_ParseTuple(args, STRCAST("s"), &msg)) + { + return NULL; + } + + assert(self->op); + (*self->op)->deprecate(msg); + + Py_INCREF(Py_None); + return Py_None; +} + +#ifdef WIN32 +extern "C" +#endif static AMDCallbackObject* amdCallbackNew(PyObject* /*arg*/) { @@ -461,6 +482,11 @@ IcePy::OperationI::invoke(const Ice::ObjectPrx& proxy, PyObject* args, PyObject* return NULL; } + if(!_deprecateMessage.empty()) + { + PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); + } + try { // @@ -569,6 +595,11 @@ IcePy::OperationI::invokeAsync(const Ice::ObjectPrx& proxy, PyObject* callback, return NULL; } + if(!_deprecateMessage.empty()) + { + PyErr_Warn(PyExc_DeprecationWarning, const_cast<char*>(_deprecateMessage.c_str())); + } + try { Ice::AMI_Object_ice_invokePtr cb = new AMICallback(this, communicator, callback); @@ -611,6 +642,19 @@ IcePy::OperationI::invokeAsync(const Ice::ObjectPrx& proxy, PyObject* callback, } void +IcePy::OperationI::deprecate(const string& msg) +{ + if(!msg.empty()) + { + _deprecateMessage = msg; + } + else + { + _deprecateMessage = "operation " + _name + " is deprecated"; + } +} + +void IcePy::OperationI::dispatch(PyObject* servant, const Ice::AMD_Object_ice_invokePtr& cb, const vector<Ice::Byte>& inBytes, const Ice::Current& current) { @@ -1130,6 +1174,8 @@ static PyMethodDef OperationMethods[] = PyDoc_STR(STRCAST("internal function")) }, { STRCAST("invokeAsync"), (PyCFunction)operationInvokeAsync, METH_VARARGS, PyDoc_STR(STRCAST("internal function")) }, + { STRCAST("deprecate"), (PyCFunction)operationDeprecate, METH_VARARGS, + PyDoc_STR(STRCAST("internal function")) }, { NULL, NULL} /* sentinel */ }; |