Part: remove py2 code
This commit is contained in:
@@ -2023,13 +2023,8 @@ private:
|
||||
PyErr_Clear();
|
||||
PyObject* index_or_value;
|
||||
if (PyArg_ParseTuple(args.ptr(), "sO", &name, &index_or_value)) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if (PyLong_Check(index_or_value)) {
|
||||
int ival = (int)PyLong_AsLong(index_or_value);
|
||||
#else
|
||||
if (PyInt_Check(index_or_value)) {
|
||||
int ival = (int)PyInt_AsLong(index_or_value);
|
||||
#endif
|
||||
if (!Interface_Static::SetIVal(name, ival)) {
|
||||
std::stringstream str;
|
||||
str << "Failed to set '" << name << "'";
|
||||
|
||||
@@ -277,11 +277,7 @@ PyObject* AttachEnginePy::getModeInfo(PyObject* args)
|
||||
}
|
||||
Py::Dict ret;
|
||||
ret["ReferenceCombinations"] = pyListOfCombinations;
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
ret["ModeIndex"] = Py::Long(mmode);
|
||||
#else
|
||||
ret["ModeIndex"] = Py::Int(mmode);
|
||||
#endif
|
||||
try {
|
||||
Py::Module module(PyImport_ImportModule("PartGui"),true);
|
||||
if (module.isNull() || !module.hasAttr("AttachEngineResources")) {
|
||||
@@ -292,11 +288,7 @@ PyObject* AttachEnginePy::getModeInfo(PyObject* args)
|
||||
Py::Callable method(submod.getAttr("getModeStrings"));
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::String(this->getAttachEnginePtr()->getTypeId().getName()));
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
arg.setItem(1, Py::Long(mmode));
|
||||
#else
|
||||
arg.setItem(1, Py::Int(mmode));
|
||||
#endif
|
||||
Py::List strs = method.apply(arg);
|
||||
assert(strs.size() == 2);
|
||||
ret["UserFriendlyName"] = strs[0];
|
||||
@@ -369,13 +361,8 @@ PyObject* AttachEnginePy::getRefTypeInfo(PyObject* args)
|
||||
AttachEngine &attacher = *(this->getAttachEnginePtr());
|
||||
eRefType rt = attacher.getRefTypeByName(typeName);
|
||||
Py::Dict ret;
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
ret["TypeIndex"] = Py::Long(rt);
|
||||
ret["Rank"] = Py::Long(AttachEngine::getTypeRank(rt));
|
||||
#else
|
||||
ret["TypeIndex"] = Py::Int(rt);
|
||||
ret["Rank"] = Py::Int(AttachEngine::getTypeRank(rt));
|
||||
#endif
|
||||
|
||||
try {
|
||||
Py::Module module(PyImport_ImportModule("PartGui"),true);
|
||||
@@ -386,11 +373,7 @@ PyObject* AttachEnginePy::getRefTypeInfo(PyObject* args)
|
||||
Py::Object submod(module.getAttr("AttachEngineResources"));
|
||||
Py::Callable method(submod.getAttr("getRefTypeUserFriendlyName"));
|
||||
Py::Tuple arg(1);
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
arg.setItem(0, Py::Long(rt));
|
||||
#else
|
||||
arg.setItem(0, Py::Int(rt));
|
||||
#endif
|
||||
Py::String st = method.apply(arg);
|
||||
ret["UserFriendlyName"] = st;
|
||||
} catch (Py::Exception& e) {
|
||||
|
||||
@@ -250,11 +250,7 @@ PyObject* BSplineCurvePy::insertKnots(PyObject * args)
|
||||
TColStd_Array1OfInteger m(1,mults.size());
|
||||
index=1;
|
||||
for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long val(*it);
|
||||
#else
|
||||
Py::Int val(*it);
|
||||
#endif
|
||||
m(index++) = (int)val;
|
||||
}
|
||||
|
||||
@@ -1253,11 +1249,7 @@ PyObject* BSplineCurvePy::buildFromPolesMultsKnots(PyObject *args, PyObject *key
|
||||
Py::Sequence multssq(mults);
|
||||
Standard_Integer index = 1;
|
||||
for (Py::Sequence::iterator it = multssq.begin(); it != multssq.end() && index <= occmults.Length(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long mult(*it);
|
||||
#else
|
||||
Py::Int mult(*it);
|
||||
#endif
|
||||
if (index < occmults.Length() || PyObject_Not(periodic)) {
|
||||
sum_of_mults += static_cast<int>(mult); //sum up the mults to compare them against the number of poles later
|
||||
}
|
||||
|
||||
@@ -284,11 +284,7 @@ PyObject* BSplineSurfacePy::insertUKnots(PyObject *args)
|
||||
TColStd_Array1OfInteger m(1,mults.size());
|
||||
index=1;
|
||||
for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long val(*it);
|
||||
#else
|
||||
Py::Int val(*it);
|
||||
#endif
|
||||
m(index++) = (int)val;
|
||||
}
|
||||
|
||||
@@ -349,11 +345,7 @@ PyObject* BSplineSurfacePy::insertVKnots(PyObject *args)
|
||||
TColStd_Array1OfInteger m(1,mults.size());
|
||||
index=1;
|
||||
for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long val(*it);
|
||||
#else
|
||||
Py::Int val(*it);
|
||||
#endif
|
||||
m(index++) = (int)val;
|
||||
}
|
||||
|
||||
@@ -1423,11 +1415,7 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
|
||||
Py::Sequence umultssq(umults);
|
||||
Standard_Integer index = 1;
|
||||
for (Py::Sequence::iterator it = umultssq.begin(); it != umultssq.end() && index <= occumults.Length(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long mult(*it);
|
||||
#else
|
||||
Py::Int mult(*it);
|
||||
#endif
|
||||
if (index < occumults.Length() || PyObject_Not(uperiodic)) {
|
||||
sum_of_umults += static_cast<int>(mult); //sum up the mults to compare them against the number of poles later
|
||||
}
|
||||
@@ -1436,11 +1424,7 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
|
||||
Py::Sequence vmultssq(vmults);
|
||||
index = 1;
|
||||
for (Py::Sequence::iterator it = vmultssq.begin(); it != vmultssq.end() && index <= occvmults.Length(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long mult(*it);
|
||||
#else
|
||||
Py::Int mult(*it);
|
||||
#endif
|
||||
if (index < occvmults.Length() || PyObject_Not(vperiodic)) {
|
||||
sum_of_vmults += static_cast<int>(mult); //sum up the mults to compare them against the number of poles later
|
||||
}
|
||||
|
||||
@@ -214,11 +214,7 @@ PyObject* BSplineCurve2dPy::insertKnots(PyObject * args)
|
||||
TColStd_Array1OfInteger m(1,mults.size());
|
||||
index=1;
|
||||
for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long val(*it);
|
||||
#else
|
||||
Py::Int val(*it);
|
||||
#endif
|
||||
m(index++) = (int)val;
|
||||
}
|
||||
|
||||
@@ -649,11 +645,7 @@ PyObject* BSplineCurve2dPy::getMultiplicities(PyObject * args)
|
||||
curve->Multiplicities(m);
|
||||
Py::List mults;
|
||||
for (Standard_Integer i=m.Lower(); i<=m.Upper(); i++) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
mults.append(Py::Long(m(i)));
|
||||
#else
|
||||
mults.append(Py::Int(m(i)));
|
||||
#endif
|
||||
}
|
||||
return Py::new_reference_to(mults);
|
||||
}
|
||||
@@ -724,22 +716,14 @@ Py::Object BSplineCurve2dPy::getFirstUKnotIndex(void) const
|
||||
{
|
||||
Handle(Geom2d_BSplineCurve) curve = Handle(Geom2d_BSplineCurve)::DownCast
|
||||
(getGeometry2dPtr()->handle());
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return Py::Long(curve->FirstUKnotIndex());
|
||||
#else
|
||||
return Py::Int(curve->FirstUKnotIndex());
|
||||
#endif
|
||||
}
|
||||
|
||||
Py::Object BSplineCurve2dPy::getLastUKnotIndex(void) const
|
||||
{
|
||||
Handle(Geom2d_BSplineCurve) curve = Handle(Geom2d_BSplineCurve)::DownCast
|
||||
(getGeometry2dPtr()->handle());
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return Py::Long(curve->LastUKnotIndex());
|
||||
#else
|
||||
return Py::Int(curve->LastUKnotIndex());
|
||||
#endif
|
||||
}
|
||||
|
||||
Py::List BSplineCurve2dPy::getKnotSequence(void) const
|
||||
@@ -1224,11 +1208,7 @@ PyObject* BSplineCurve2dPy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
|
||||
Py::Sequence multssq(mults);
|
||||
Standard_Integer index = 1;
|
||||
for (Py::Sequence::iterator it = multssq.begin(); it != multssq.end() && index <= occmults.Length(); ++it) {
|
||||
#if PY_MAJOR_VERSION >=3
|
||||
Py::Long mult(*it);
|
||||
#else
|
||||
Py::Int mult(*it);
|
||||
#endif
|
||||
if (index < occmults.Length() || PyObject_Not(periodic)) {
|
||||
sum_of_mults += (int)mult; //sum up the mults to compare them against the number of poles later
|
||||
}
|
||||
|
||||
@@ -149,17 +149,10 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds)
|
||||
// use no kwds
|
||||
PyObject* dist_or_num;
|
||||
if (PyArg_ParseTuple(args, "O", &dist_or_num)) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if (PyLong_Check(dist_or_num)) {
|
||||
numPoints = PyLong_AsLong(dist_or_num);
|
||||
uniformAbscissaPoints = true;
|
||||
}
|
||||
#else
|
||||
if (PyInt_Check(dist_or_num)) {
|
||||
numPoints = PyInt_AsLong(dist_or_num);
|
||||
uniformAbscissaPoints = true;
|
||||
}
|
||||
#endif
|
||||
else if (PyFloat_Check(dist_or_num)) {
|
||||
distance = PyFloat_AsDouble(dist_or_num);
|
||||
uniformAbscissaDistance = true;
|
||||
|
||||
@@ -507,11 +507,7 @@ PyObject *PropertyFilletEdges::getPyObject(void)
|
||||
int index = 0;
|
||||
for (it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
Py::Tuple ent(3);
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
ent.setItem(0, Py::Long(it->edgeid));
|
||||
#else
|
||||
ent.setItem(0, Py::Int(it->edgeid));
|
||||
#endif
|
||||
ent.setItem(1, Py::Float(it->radius1));
|
||||
ent.setItem(2, Py::Float(it->radius2));
|
||||
list[index++] = ent;
|
||||
@@ -528,11 +524,7 @@ void PropertyFilletEdges::setPyObject(PyObject *value)
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
FilletElement fe;
|
||||
Py::Tuple ent(*it);
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
fe.edgeid = (int)Py::Long(ent.getItem(0));
|
||||
#else
|
||||
fe.edgeid = (int)Py::Int(ent.getItem(0));
|
||||
#endif
|
||||
fe.radius1 = (double)Py::Float(ent.getItem(1));
|
||||
fe.radius2 = (double)Py::Float(ent.getItem(2));
|
||||
values.push_back(fe);
|
||||
|
||||
@@ -491,17 +491,10 @@ PyObject* TopoShapeEdgePy::discretize(PyObject *args, PyObject *kwds)
|
||||
// use no kwds
|
||||
PyObject* dist_or_num;
|
||||
if (PyArg_ParseTuple(args, "O", &dist_or_num)) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if (PyLong_Check(dist_or_num)) {
|
||||
numPoints = PyLong_AsLong(dist_or_num);
|
||||
uniformAbscissaPoints = true;
|
||||
}
|
||||
#else
|
||||
if (PyInt_Check(dist_or_num)) {
|
||||
numPoints = PyInt_AsLong(dist_or_num);
|
||||
uniformAbscissaPoints = true;
|
||||
}
|
||||
#endif
|
||||
else if (PyFloat_Check(dist_or_num)) {
|
||||
distance = PyFloat_AsDouble(dist_or_num);
|
||||
uniformAbscissaDistance = true;
|
||||
|
||||
@@ -2150,15 +2150,9 @@ PyObject* TopoShapePy::makeShapeFromMesh(PyObject *args)
|
||||
for (Py::Sequence::iterator it = facets.begin(); it != facets.end(); ++it) {
|
||||
Data::ComplexGeoData::Facet face;
|
||||
Py::Tuple f(*it);
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
face.I1 = (int)Py::Long(f[0]);
|
||||
face.I2 = (int)Py::Long(f[1]);
|
||||
face.I3 = (int)Py::Long(f[2]);
|
||||
#else
|
||||
face.I1 = (int)Py::Int(f[0]);
|
||||
face.I2 = (int)Py::Int(f[1]);
|
||||
face.I3 = (int)Py::Int(f[2]);
|
||||
#endif
|
||||
Facets.push_back(face);
|
||||
}
|
||||
|
||||
@@ -2547,11 +2541,7 @@ PyObject* _getSupportIndex(const char* suppStr, TopoShape* ts, TopoDS_Shape supp
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return PyLong_FromLong(supportIndex);
|
||||
#else
|
||||
return PyInt_FromLong(supportIndex);
|
||||
#endif
|
||||
}
|
||||
|
||||
PyObject* TopoShapePy::proximity(PyObject *args)
|
||||
|
||||
@@ -376,17 +376,10 @@ PyObject* TopoShapeWirePy::discretize(PyObject *args, PyObject *kwds)
|
||||
// use no kwds
|
||||
PyObject* dist_or_num;
|
||||
if (PyArg_ParseTuple(args, "O", &dist_or_num)) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if (PyLong_Check(dist_or_num)) {
|
||||
numPoints = PyLong_AsLong(dist_or_num);
|
||||
uniformAbscissaPoints = true;
|
||||
}
|
||||
#else
|
||||
if (PyInt_Check(dist_or_num)) {
|
||||
numPoints = PyInt_AsLong(dist_or_num);
|
||||
uniformAbscissaPoints = true;
|
||||
}
|
||||
#endif
|
||||
else if (PyFloat_Check(dist_or_num)) {
|
||||
distance = PyFloat_AsDouble(dist_or_num);
|
||||
uniformAbscissaDistance = true;
|
||||
|
||||
@@ -132,7 +132,6 @@ PyMOD_INIT_FUNC(PartGui)
|
||||
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/parametric"));
|
||||
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/tools"));
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
static struct PyModuleDef pAttachEngineTextsModuleDef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"AttachEngineResources",
|
||||
@@ -141,10 +140,6 @@ PyMOD_INIT_FUNC(PartGui)
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
PyObject* pAttachEngineTextsModule = PyModule_Create(&pAttachEngineTextsModuleDef);
|
||||
#else
|
||||
PyObject* pAttachEngineTextsModule = Py_InitModule3("AttachEngineResources", AttacherGui::AttacherGuiPy::Methods,
|
||||
"AttachEngine Gui resources");
|
||||
#endif
|
||||
|
||||
Py_INCREF(pAttachEngineTextsModule);
|
||||
PyModule_AddObject(partGuiModule, "AttachEngineResources", pAttachEngineTextsModule);
|
||||
|
||||
Reference in New Issue
Block a user