From 7c25ae9ae71346357208fb714250ac75aae9fb61 Mon Sep 17 00:00:00 2001 From: J Robert Ray jrray{_at_}imageworks{_dot_}com Date: Mon, 20 Aug 2012 14:54:22 -0700 Subject: [PATCH] Support custom Ice::Dispatchers in Python (sort of). This is a very thin shim to expose the InitializationData::dispatcher member, but not a way to implement an Ice::Dispatcher in Python. Extend the wrapped Ice.InitializationData to check for a 'dispatcher' attribute. In Python, the user is to pass in a PyCObject-wrapped Ice::Dispatcher*. The custom Ice::Dispatcher must still be implemented in C++, and also exposed to Python in some way. diff -ru ../Ice-3.4.2.orig/py/modules/IcePy/Communicator.cpp ./py/modules/IcePy/Communicator.cpp --- ../Ice-3.4.2.orig/py/modules/IcePy/Communicator.cpp 2011-06-15 12:44:00.000000000 -0700 +++ ./py/modules/IcePy/Communicator.cpp 2013-04-01 08:39:31.000000000 -0700 @@ -142,6 +142,7 @@ PyObjectHandle properties = PyObject_GetAttrString(initData, STRCAST("properties")); PyObjectHandle logger = PyObject_GetAttrString(initData, STRCAST("logger")); PyObjectHandle threadHook = PyObject_GetAttrString(initData, STRCAST("threadHook")); + PyObjectHandle dispatcher = PyObject_GetAttrString(initData, STRCAST("dispatcher")); PyErr_Clear(); // PyObject_GetAttrString sets an error on failure. if(properties.get() && properties.get() != Py_None) @@ -163,6 +164,16 @@ { data.threadHook = new ThreadNotificationWrapper(threadHook.get()); } + + if(dispatcher.get() && dispatcher.get() != Py_None) + { + if (!PyCObject_Check(dispatcher.get())) { + PyErr_Format(PyExc_ValueError, STRCAST("Ice.InitializationData dispatcher must be a PyCObject-wrapped Ice::Dispatcher*")); + return -1; + } + + data.dispatcher = reinterpret_cast(PyCObject_AsVoidPtr(dispatcher.get())); + } } try