| 1453 | } |
| 1454 | |
| 1455 | Py::Object |
| 1456 | ObjectIdentifier::access(const ResolveResults& result, const Py::Object* value, Dependencies* deps) const |
| 1457 | { |
| 1458 | if (!result.resolvedDocumentObject) { |
| 1459 | FC_THROWM(Base::RuntimeError, result.resolveErrorString() |
| 1460 | << " in '" << result.resolvedDocumentName.getString() << "'"); |
| 1461 | } |
| 1462 | if (!result.resolvedProperty) { |
| 1463 | FC_THROWM(Base::RuntimeError, result.resolveErrorString() |
| 1464 | << " in '" << result.resolvedDocumentObjectName.getString() << "'"); |
| 1465 | } |
| 1466 | if (!subObjectName.getString().empty() && !result.resolvedSubObject) { |
| 1467 | FC_THROWM(Base::RuntimeError, result.resolveErrorString() << " in '" << toString() << "'"); |
| 1468 | } |
| 1469 | |
| 1470 | Py::Object pyobj; |
| 1471 | int ptype = result.propertyType; |
| 1472 | |
| 1473 | // NOTE! We do not keep reference of the imported module, assuming once |
| 1474 | // imported they'll live (because of sys.modules) till the application |
| 1475 | // dies. |
| 1476 | #define GET_MODULE(_name) \ |
| 1477 | do { \ |
| 1478 | static PyObject* pymod; \ |
| 1479 | if (!pymod) { \ |
| 1480 | pymod = PyImport_ImportModule(#_name); \ |
| 1481 | if (!pymod) \ |
| 1482 | Base::PyException::throwException(); \ |
| 1483 | else \ |
| 1484 | Py_DECREF(pymod); \ |
| 1485 | } \ |
| 1486 | pyobj = Py::Object(pymod); \ |
| 1487 | } while (0) |
| 1488 | |
| 1489 | size_t idx = result.propertyIndex + 1; |
| 1490 | switch (ptype) { |
| 1491 | case PseudoApp: |
| 1492 | GET_MODULE(FreeCAD); |
| 1493 | break; |
| 1494 | case PseudoGui: |
| 1495 | GET_MODULE(FreeCADGui); |
| 1496 | break; |
| 1497 | case PseudoPart: |
| 1498 | GET_MODULE(Part); |
| 1499 | break; |
| 1500 | case PseudoCadquery: |
| 1501 | GET_MODULE(freecad.fc_cadquery); |
| 1502 | break; |
| 1503 | case PseudoRegex: |
| 1504 | GET_MODULE(re); |
| 1505 | break; |
| 1506 | case PseudoBuiltins: |
| 1507 | GET_MODULE(builtins); |
| 1508 | break; |
| 1509 | case PseudoMath: |
| 1510 | GET_MODULE(math); |
| 1511 | break; |
| 1512 | case PseudoCollections: |
nothing calls this directly
no test coverage detected