diff options
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; +} |