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

Method resolveProperty

src/App/ObjectIdentifier.cpp:1221–1264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1219}
1220
1221Property* ObjectIdentifier::resolveProperty(const App::DocumentObject* obj,
1222 const char* propertyName,
1223 App::DocumentObject*& sobj,
1224 int& ptype) const
1225{
1226 if (obj && !subObjectName.getString().empty()) {
1227 sobj = obj->getSubObject(subObjectName.toString().c_str());
1228 obj = sobj;
1229 }
1230 if (!obj) {
1231 return nullptr;
1232 }
1233
1234 static std::unordered_map<const char*, int, CStringHasher, CStringHasher> _props = {
1235 {"_shape", PseudoShape},
1236 {"_pla", PseudoPlacement},
1237 {"_matrix", PseudoMatrix},
1238 {"__pla", PseudoLinkPlacement},
1239 {"__matrix", PseudoLinkMatrix},
1240 {"_self", PseudoSelf},
1241 {"_app", PseudoApp},
1242 {"_part", PseudoPart},
1243 {"_re", PseudoRegex},
1244 {"_py", PseudoBuiltins},
1245 {"_math", PseudoMath},
1246 {"_coll", PseudoCollections},
1247 {"_gui", PseudoGui},
1248 {"_cq", PseudoCadquery},
1249 };
1250 auto it = _props.find(propertyName);
1251 if (it == _props.end()) {
1252 ptype = PseudoNone;
1253 }
1254 else {
1255 ptype = it->second;
1256 if (ptype != PseudoShape && !subObjectName.getString().empty()
1257 && !boost::ends_with(subObjectName.getString(), ".")) {
1258 return nullptr;
1259 }
1260 return &const_cast<App::DocumentObject*>(obj)->Label; // fake the property
1261 }
1262
1263 return obj->getPropertyByName(propertyName);
1264}
1265
1266
1267ObjectIdentifier ObjectIdentifier::canonicalPath() const

Callers 1

getPropertyMethod · 0.80

Calls 8

emptyMethod · 0.45
getStringMethod · 0.45
getSubObjectMethod · 0.45
c_strMethod · 0.45
toStringMethod · 0.45
findMethod · 0.45
endMethod · 0.45
getPropertyByNameMethod · 0.45

Tested by

no test coverage detected