| 336 | } |
| 337 | |
| 338 | bool FeaturePythonImp::getSubObjects(std::vector<std::string>& ret, int reason) const |
| 339 | { |
| 340 | FC_PY_CALL_CHECK(getSubObjects); |
| 341 | Base::PyGILStateLocker lock; |
| 342 | try { |
| 343 | Py::Tuple args(2); |
| 344 | args.setItem(0, Py::Object(object->getPyObject(), true)); |
| 345 | args.setItem(1, Py::Long(reason)); |
| 346 | Py::Object res(Base::pyCall(py_getSubObjects.ptr(), args.ptr())); |
| 347 | if (!res.isTrue()) { |
| 348 | return true; |
| 349 | } |
| 350 | if (!res.isSequence()) { |
| 351 | throw Py::TypeError("getSubObjects expects return type of tuple"); |
| 352 | } |
| 353 | Py::Sequence seq(res); |
| 354 | for (Py_ssize_t i = 0; i < seq.length(); ++i) { |
| 355 | Py::Object name(seq[i].ptr()); |
| 356 | if (!name.isString()) { |
| 357 | throw Py::TypeError("getSubObjects expects string in returned sequence"); |
| 358 | } |
| 359 | ret.push_back(name.as_string()); |
| 360 | } |
| 361 | return true; |
| 362 | } |
| 363 | catch (Py::Exception&) { |
| 364 | if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) { |
| 365 | PyErr_Clear(); |
| 366 | return false; |
| 367 | } |
| 368 | Base::PyException e; // extract the Python error text |
| 369 | e.reportException(); |
| 370 | return true; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | bool FeaturePythonImp::getLinkedObject(DocumentObject*& ret, |
| 375 | bool recurse, |
no test coverage detected