summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/Operation.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2014-09-18 09:51:22 -0230
committerDwayne Boone <dwayne@zeroc.com>2014-09-18 09:51:22 -0230
commit4723f7bbd3ea2ffb241df26e5736fa5c04589e7b (patch)
tree1fb506dbb4f76a5e6ce7e9eada7489e19a0560e4 /py/modules/IcePy/Operation.cpp
parentICE-4891 some minor improvements (diff)
downloadice-4723f7bbd3ea2ffb241df26e5736fa5c04589e7b.tar.bz2
ice-4723f7bbd3ea2ffb241df26e5736fa5c04589e7b.tar.xz
ice-4723f7bbd3ea2ffb241df26e5736fa5c04589e7b.zip
ICE-5661 add proxy->begin_ice_getConnection
Diffstat (limited to 'py/modules/IcePy/Operation.cpp')
-rw-r--r--py/modules/IcePy/Operation.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp
index 327be1c130c..ac5221029fd 100644
--- a/py/modules/IcePy/Operation.cpp
+++ b/py/modules/IcePy/Operation.cpp
@@ -16,6 +16,7 @@
#include <Proxy.h>
#include <Thread.h>
#include <Types.h>
+#include <Connection.h>
#include <Util.h>
#include <Ice/Communicator.h>
#include <Ice/IncomingAsync.h>
@@ -2549,7 +2550,7 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */)
memcpy(buf, &out[0], sz);
}
#endif
-
+
if(PyTuple_SET_ITEM(result.get(), 1, op.get()) < 0)
{
throwPythonException();
@@ -3618,7 +3619,7 @@ IcePy::BlobjectUpcall::dispatch(PyObject* servant, const pair<const Ice::Byte*,
{
throwPythonException();
}
-
+
PyObjectHandle ip;
#if PY_VERSION_HEX >= 0x03000000
@@ -4010,6 +4011,45 @@ IcePy::FlushCallback::sent(bool sentSynchronously)
}
}
+IcePy::GetConnectionCallback::GetConnectionCallback(const Ice::CommunicatorPtr& communicator,
+ PyObject* response, PyObject* ex, const string& op) :
+ _communicator(communicator), _response(response), _ex(ex), _op(op)
+{
+ assert(_response);
+ Py_INCREF(_response);
+ Py_XINCREF(_ex);
+}
+
+IcePy::GetConnectionCallback::~GetConnectionCallback()
+{
+ AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
+
+ Py_DECREF(_response);
+ Py_XDECREF(_ex);
+}
+
+void
+IcePy::GetConnectionCallback::response(const Ice::ConnectionPtr& conn)
+{
+ AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
+
+ PyObjectHandle pyConn = createConnection(conn, _communicator);
+ PyObjectHandle args = Py_BuildValue(STRCAST("(O)"), pyConn.get());
+ PyObjectHandle tmp = PyObject_Call(_response, args.get(), 0);
+ if(PyErr_Occurred())
+ {
+ handleException(); // Callback raised an exception.
+ }
+}
+
+void
+IcePy::GetConnectionCallback::exception(const Ice::Exception& ex)
+{
+ AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
+
+ callException(_ex, ex);
+}
+
//
// ServantWrapper implementation.
//