diff options
author | Bernard Normier <bernard@zeroc.com> | 2017-02-10 12:26:16 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2017-02-10 12:26:16 -0500 |
commit | b2923da71983b0ccac196ac2d0b22b1296a153ed (patch) | |
tree | 431de1f175ba93975308627c391ace28fcba7cab /python/modules/IcePy/Endpoint.cpp | |
parent | Fixed (ICE-7577) - IllegalStateException in the IceGridGUI (diff) | |
download | ice-b2923da71983b0ccac196ac2d0b22b1296a153ed.tar.bz2 ice-b2923da71983b0ccac196ac2d0b22b1296a153ed.tar.xz ice-b2923da71983b0ccac196ac2d0b22b1296a153ed.zip |
ICE-7342: add setPublishedEndpoints to ObjectAdapter
Diffstat (limited to 'python/modules/IcePy/Endpoint.cpp')
-rw-r--r-- | python/modules/IcePy/Endpoint.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/python/modules/IcePy/Endpoint.cpp b/python/modules/IcePy/Endpoint.cpp index 4482c759d47..f2285f381ba 100644 --- a/python/modules/IcePy/Endpoint.cpp +++ b/python/modules/IcePy/Endpoint.cpp @@ -252,3 +252,27 @@ IcePy::createEndpoint(const Ice::EndpointPtr& endpoint) obj->endpoint = new Ice::EndpointPtr(endpoint); return (PyObject*)obj; } + +bool +IcePy::toEndpointSeq(PyObject* endpoints, Ice::EndpointSeq& seq) +{ + Py_ssize_t sz = PySequence_Fast_GET_SIZE(endpoints); + for(Py_ssize_t i = 0; i < sz; ++i) + { + PyObject* p = PySequence_Fast_GET_ITEM(endpoints, i); + PyTypeObject* type = &EndpointType; // Necessary to prevent GCC's strict-alias warnings. + if(!PyObject_IsInstance(p, reinterpret_cast<PyObject*>(type))) + { + PyErr_Format(PyExc_ValueError, STRCAST("expected element of type Ice.Endpoint")); + return false; + } + Ice::EndpointPtr endp = getEndpoint(p); + if(!endp) + { + return false; + } + seq.push_back(endp); + } + + return true; +} |