Path: Use PyObject_IsTrue in combination with conditional ternary operator

This commit is contained in:
marioalexis
2022-05-17 12:52:35 -03:00
committed by Chris Hennes
parent 51f3727d3c
commit d298a7101c
2 changed files with 12 additions and 11 deletions

View File

@@ -322,8 +322,8 @@ private:
static char* kwd_list[] = {"shapes", "start", "return_end",
PARAM_FIELD_STRINGS(ARG,AREA_PARAMS_PATH), nullptr};
if (!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(),
"O|O!O" PARAM_PY_KWDS(AREA_PARAMS_PATH),
kwd_list, &pShapes, &(Base::VectorPy::Type), &start, &return_end,
"O|O!O!" PARAM_PY_KWDS(AREA_PARAMS_PATH),
kwd_list, &pShapes, &(Base::VectorPy::Type), &start, &PyBool_Type, &return_end,
PARAM_REF(PARAM_FARG,AREA_PARAMS_PATH)))
throw Py::Exception();
@@ -355,7 +355,7 @@ private:
std::unique_ptr<Toolpath> path(new Toolpath);
Area::toPath(*path,shapes,start?&pstart:nullptr, &pend,
PARAM_PY_FIELDS(PARAM_FARG,AREA_PARAMS_PATH));
if(!PyObject_IsTrue(return_end))
if (PyObject_IsTrue(return_end) ? false : true)
return Py::asObject(new PathPy(path.release()));
Py::Tuple tuple(2);
tuple.setItem(0, Py::asObject(new PathPy(path.release())));