MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / access

Method access

src/App/ObjectIdentifier.cpp:1455–1683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1453}
1454
1455Py::Object
1456ObjectIdentifier::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:

Callers

nothing calls this directly

Calls 15

MatrixClass · 0.85
resolveErrorStringMethod · 0.80
getTrueLinkedObjectMethod · 0.80
toStringFunction · 0.70
PlacementClass · 0.70
ObjectClass · 0.70
getStringMethod · 0.45
emptyMethod · 0.45
getPyObjectMethod · 0.45
getElementMethod · 0.45
getSubObjectMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected