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

Method set

src/App/ObjectIdentifier.cpp:635–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635void ObjectIdentifier::Component::set(Py::Object& pyobj, const Py::Object& value) const
636{
637 if (isSimple()) {
638 if (PyObject_SetAttrString(*pyobj, getName().c_str(), *value) == -1) {
639 Base::PyException::throwException();
640 }
641 }
642 else if (isArray()) {
643 if (pyobj.isMapping()) {
644 Py::Mapping(pyobj).setItem(Py::Long(begin), value);
645 }
646 else {
647 Py::Sequence(pyobj).setItem(begin, value);
648 }
649 }
650 else if (isMap()) {
651 Py::Mapping(pyobj).setItem(getName(), value);
652 }
653 else {
654 assert(isRange());
655 constexpr int max = std::numeric_limits<int>::max();
656 Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
657 end != max ? Py::Long(end).ptr() : nullptr,
658 step != 1 ? Py::Long(step).ptr() : nullptr),
659 true);
660 if (PyObject_SetItem(pyobj.ptr(), slice.ptr(), value.ptr()) < 0) {
661 Base::PyException::throwException();
662 }
663 }
664}
665
666void ObjectIdentifier::Component::del(Py::Object& pyobj) const
667{

Callers 3

getDocumentObjectMethod · 0.45
resolveMethod · 0.45
accessMethod · 0.45

Calls 10

isSimpleFunction · 0.85
PyObject_SetAttrStringFunction · 0.85
isArrayFunction · 0.85
SequenceClass · 0.85
isMapFunction · 0.85
isRangeFunction · 0.85
maxFunction · 0.85
getNameFunction · 0.70
c_strMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected