From 9e6fe284edfb29331a3dafb726bdc02039febf4e Mon Sep 17 00:00:00 2001 From: luz paz Date: Wed, 21 Apr 2021 22:12:07 -0400 Subject: [PATCH] Sketcher: remove Py2 code from Sketcher wb --- src/Mod/Sketcher/App/ConstraintPyImp.cpp | 50 ---------------------- src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 25 ----------- 2 files changed, 75 deletions(-) diff --git a/src/Mod/Sketcher/App/ConstraintPyImp.cpp b/src/Mod/Sketcher/App/ConstraintPyImp.cpp index cafa0019e0..6f4c0a79e9 100644 --- a/src/Mod/Sketcher/App/ConstraintPyImp.cpp +++ b/src/Mod/Sketcher/App/ConstraintPyImp.cpp @@ -86,13 +86,8 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "siO", &ConstraintType, &FirstIndex, &index_or_value)) { // ConstraintType, GeoIndex1, GeoIndex2 -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(index_or_value)) { SecondIndex = PyLong_AsLong(index_or_value); -#else - if (PyLong_Check(index_or_value) || PyInt_Check(index_or_value)) { - SecondIndex = PyInt_AsLong(index_or_value); -#endif bool valid = false; if (strcmp("Tangent",ConstraintType) == 0) { this->getConstraintPtr()->Type = Tangent; @@ -187,15 +182,9 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "siiO", &ConstraintType, &FirstIndex, &any_index, &index_or_value)) { // ConstraintType, GeoIndex1, PosIndex1, GeoIndex2 -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(index_or_value)) { FirstPos = any_index; SecondIndex = PyLong_AsLong(index_or_value); -#else - if (PyLong_Check(index_or_value) || PyInt_Check(index_or_value)) { - FirstPos = any_index; - SecondIndex = PyInt_AsLong(index_or_value); -#endif bool valid = false; if (strcmp("Perpendicular", ConstraintType) == 0) { this->getConstraintPtr()->Type = Perpendicular; @@ -279,13 +268,8 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "siiiO", &ConstraintType, &intArg1, &intArg2, &intArg3, &oNumArg4)) { // Value, ConstraintType, GeoIndex1, PosIndex1, GeoIndex2, PosIndex2 -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(oNumArg4)) { intArg4 = PyLong_AsLong(oNumArg4); -#else - if (PyInt_Check(oNumArg4)) { - intArg4 = PyInt_AsLong(oNumArg4); -#endif bool valid = false; if (strcmp("Coincident", ConstraintType) == 0) { this->getConstraintPtr()->Type = Coincident; @@ -376,13 +360,8 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "siiiiO", &ConstraintType, &intArg1, &intArg2, &intArg3, &intArg4, &oNumArg5)) { // ConstraintType, GeoIndex1, PosIndex1, GeoIndex2, PosIndex2, GeoIndex3 -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(oNumArg5)) { intArg5 = PyLong_AsLong(oNumArg5); -#else - if (PyInt_Check(oNumArg5)) { - intArg5 = PyInt_AsLong(oNumArg5); -#endif if (strcmp("Symmetric",ConstraintType) == 0 ) { this->getConstraintPtr()->Type = Symmetric; this->getConstraintPtr()->First = intArg1; @@ -448,13 +427,8 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) PyErr_Clear(); if (PyArg_ParseTuple(args, "siiiiiO", &ConstraintType, &FirstIndex, &FirstPos, &SecondIndex, &SecondPos, &ThirdIndex, &index_or_value)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(index_or_value)) { ThirdPos = PyLong_AsLong(index_or_value); -#else - if (PyInt_Check(index_or_value)) { - ThirdPos = PyInt_AsLong(index_or_value); -#endif // ConstraintType, GeoIndex1, PosIndex1, GeoIndex2, PosIndex2, GeoIndex3, PosIndex3 if (strcmp("Symmetric",ConstraintType) == 0 ) { this->getConstraintPtr()->Type = Symmetric; @@ -584,11 +558,7 @@ Py::Long ConstraintPy::getFirst(void) const void ConstraintPy::setFirst(Py::Long arg) { -#if PY_MAJOR_VERSION < 3 - this->getConstraintPtr()->First = Py::Int(arg); -#else this->getConstraintPtr()->First = arg; -#endif } Py::Long ConstraintPy::getFirstPos(void) const @@ -598,11 +568,7 @@ Py::Long ConstraintPy::getFirstPos(void) const void ConstraintPy::setFirstPos(Py::Long arg) { - #if PY_MAJOR_VERSION < 3 - int pos = Py::Int(arg); - #else int pos = arg; - #endif if(pos>=Sketcher::none && pos<=Sketcher::mid) { this->getConstraintPtr()->FirstPos = (Sketcher::PointPos)pos; @@ -622,11 +588,7 @@ Py::Long ConstraintPy::getSecond(void) const void ConstraintPy::setSecond(Py::Long arg) { -#if PY_MAJOR_VERSION < 3 - this->getConstraintPtr()->Second = Py::Int(arg); -#else this->getConstraintPtr()->Second = arg; -#endif } Py::Long ConstraintPy::getSecondPos(void) const @@ -636,11 +598,7 @@ Py::Long ConstraintPy::getSecondPos(void) const void ConstraintPy::setSecondPos(Py::Long arg) { - #if PY_MAJOR_VERSION < 3 - int pos = Py::Int(arg); - #else int pos = arg; - #endif if(pos>=Sketcher::none && pos<=Sketcher::mid) { this->getConstraintPtr()->SecondPos = (Sketcher::PointPos)pos; @@ -660,11 +618,7 @@ Py::Long ConstraintPy::getThird(void) const void ConstraintPy::setThird(Py::Long arg) { -#if PY_MAJOR_VERSION < 3 - this->getConstraintPtr()->Third = Py::Int(arg); -#else this->getConstraintPtr()->Third = arg; -#endif } Py::Long ConstraintPy::getThirdPos(void) const @@ -674,11 +628,7 @@ Py::Long ConstraintPy::getThirdPos(void) const void ConstraintPy::setThirdPos(Py::Long arg) { - #if PY_MAJOR_VERSION < 3 - int pos = Py::Int(arg); - #else int pos = arg; - #endif if(pos>=Sketcher::none && pos<=Sketcher::mid) { this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos)pos; diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 4a464b9a92..4600c9e248 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -227,13 +227,8 @@ PyObject* SketchObjectPy::delGeometries(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); -#else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); -#endif } if(this->getSketchObjectPtr()->delGeometries(geoIdList)) { @@ -1139,13 +1134,8 @@ PyObject* SketchObjectPy::addSymmetric(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); -#else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); -#endif } int ret = this->getSketchObjectPtr()->addSymmetric(geoIdList,refGeoId,(Sketcher::PointPos) refPosId) + 1; @@ -1183,13 +1173,8 @@ PyObject* SketchObjectPy::addCopy(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); -#else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); -#endif } try { @@ -1232,13 +1217,8 @@ PyObject* SketchObjectPy::addMove(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { - #if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); - #else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); - #endif } this->getSketchObjectPtr()->addCopy(geoIdList, vect, true); @@ -1270,13 +1250,8 @@ PyObject* SketchObjectPy::addRectangularArray(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); -#else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); -#endif } try {