summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/ObjectAdapter.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2009-05-27 12:29:18 -0230
committerDwayne Boone <dwayne@zeroc.com>2009-05-27 12:29:18 -0230
commit781e357a2e4703af1d292d1169ad9f1249792330 (patch)
treeb49458392e6e3d99dc97e5f817d499276768a1d4 /py/modules/IcePy/ObjectAdapter.cpp
parentBug 3502: Improve javadoc support in Eclipse (diff)
downloadice-781e357a2e4703af1d292d1169ad9f1249792330.tar.bz2
ice-781e357a2e4703af1d292d1169ad9f1249792330.tar.xz
ice-781e357a2e4703af1d292d1169ad9f1249792330.zip
Bug 3964 - improve endpoint info
Diffstat (limited to 'py/modules/IcePy/ObjectAdapter.cpp')
-rw-r--r--py/modules/IcePy/ObjectAdapter.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/py/modules/IcePy/ObjectAdapter.cpp b/py/modules/IcePy/ObjectAdapter.cpp
index 8a27457b428..961f1e8e5f8 100644
--- a/py/modules/IcePy/ObjectAdapter.cpp
+++ b/py/modules/IcePy/ObjectAdapter.cpp
@@ -13,6 +13,7 @@
#include <ObjectAdapter.h>
#include <Communicator.h>
#include <Current.h>
+#include <Endpoint.h>
#include <Operation.h>
#include <Proxy.h>
#include <Types.h>
@@ -1464,6 +1465,76 @@ adapterRefreshPublishedEndpoints(ObjectAdapterObject* self)
return Py_None;
}
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+adapterGetEndpoints(ObjectAdapterObject* self)
+{
+ assert(self->adapter);
+
+ Ice::EndpointSeq endpoints;
+ try
+ {
+ endpoints = (*self->adapter)->getEndpoints();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ int count = static_cast<int>(endpoints.size());
+ PyObjectHandle result = PyTuple_New(count);
+ int i = 0;
+ for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p, ++i)
+ {
+ PyObjectHandle endp = createEndpoint(*p);
+ if(!endp.get())
+ {
+ return 0;
+ }
+ PyTuple_SET_ITEM(result.get(), i, endp.release()); // PyTuple_SET_ITEM steals a reference.
+ }
+
+ return result.release();
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+adapterGetPublishedEndpoints(ObjectAdapterObject* self)
+{
+ assert(self->adapter);
+
+ Ice::EndpointSeq endpoints;
+ try
+ {
+ endpoints = (*self->adapter)->getPublishedEndpoints();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return 0;
+ }
+
+ int count = static_cast<int>(endpoints.size());
+ PyObjectHandle result = PyTuple_New(count);
+ int i = 0;
+ for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p, ++i)
+ {
+ PyObjectHandle endp = createEndpoint(*p);
+ if(!endp.get())
+ {
+ return 0;
+ }
+ PyTuple_SET_ITEM(result.get(), i, endp.release()); // PyTuple_SET_ITEM steals a reference.
+ }
+
+ return result.release();
+}
+
static PyMethodDef AdapterMethods[] =
{
{ STRCAST("getName"), reinterpret_cast<PyCFunction>(adapterGetName), METH_NOARGS,
@@ -1526,6 +1597,10 @@ static PyMethodDef AdapterMethods[] =
PyDoc_STR(STRCAST("setLocator(proxy) -> None")) },
{ STRCAST("refreshPublishedEndpoints"), reinterpret_cast<PyCFunction>(adapterRefreshPublishedEndpoints), METH_NOARGS,
PyDoc_STR(STRCAST("refreshPublishedEndpoints() -> None")) },
+ { STRCAST("getEndpoints"), reinterpret_cast<PyCFunction>(adapterGetEndpoints), METH_NOARGS,
+ PyDoc_STR(STRCAST("getEndpoints() -> None")) },
+ { STRCAST("getPublishedEndpoints"), reinterpret_cast<PyCFunction>(adapterGetPublishedEndpoints), METH_NOARGS,
+ PyDoc_STR(STRCAST("getPublishedEndpoints() -> None")) },
{ 0, 0 } /* sentinel */
};