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

Method getRange

src/App/Expression.cpp:3382–3418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3380}
3381
3382Range RangeExpression::getRange() const
3383{
3384 auto c1 = stringToAddress(begin.c_str(),true);
3385 auto c2 = stringToAddress(end.c_str(),true);
3386 if(c1.isValid() && c2.isValid())
3387 return Range(c1,c2);
3388
3389 Base::PyGILStateLocker lock;
3390 static const std::string attr("getCellFromAlias");
3391 Py::Object pyobj(owner->getPyObject(),true);
3392 if(!pyobj.hasAttr(attr))
3393 EXPR_THROW("Invalid cell range " << begin << ':' << end);
3394 Py::Callable callable(pyobj.getAttr(attr));
3395 if(!c1.isValid()) {
3396 try {
3397 Py::Tuple arg(1);
3398 arg.setItem(0,Py::String(begin));
3399 c1 = CellAddress(callable.apply(arg).as_string().c_str());
3400 } catch(Py::Exception &) {
3401 _EXPR_PY_THROW("Invalid cell address '" << begin << "': ",this);
3402 } catch(Base::Exception &e) {
3403 _EXPR_RETHROW(e,"Invalid cell address '" << begin << "': ",this);
3404 }
3405 }
3406 if(!c2.isValid()) {
3407 try {
3408 Py::Tuple arg(1);
3409 arg.setItem(0,Py::String(end));
3410 c2 = CellAddress(callable.apply(arg).as_string().c_str());
3411 } catch(Py::Exception &) {
3412 _EXPR_PY_THROW("Invalid cell address '" << end << "': ", this);
3413 } catch(Base::Exception &e) {
3414 _EXPR_RETHROW(e,"Invalid cell address '" << end << "': ", this);
3415 }
3416 }
3417 return Range(c1,c2);
3418}
3419
3420bool RangeExpression::_renameObjectIdentifier(
3421 const std::map<ObjectIdentifier,ObjectIdentifier> &paths,

Callers 1

evalAggregateMethod · 0.45

Calls 7

StringClass · 0.70
CellAddressFunction · 0.70
c_strMethod · 0.45
isValidMethod · 0.45
getPyObjectMethod · 0.45
as_stringMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected