py3: App: files D-Z ported to python3

issue 0000995
diff to py3-branch will remain in the following files in src/App:
- ExtensionContainer.cpp
- FeaturePythonPyImp.h +.inl
most likely these files depend on Tools and Base
This commit is contained in:
looooo
2017-05-11 09:55:40 +02:00
committed by wmayer
parent f9bfd77555
commit ca3e58e2f3
10 changed files with 389 additions and 20 deletions

View File

@@ -115,24 +115,39 @@ void PropertyVector::setPyObject(PyObject *value)
item = PyTuple_GetItem(value,0);
if (PyFloat_Check(item))
cVec.x = PyFloat_AsDouble(item);
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(item))
cVec.x = (double)PyInt_AsLong(item);
#else
else if (PyLong_Check(item))
cVec.x = (double)PyLong_AsLong(item);
#endif
else
throw Base::TypeError("Not allowed type used in tuple (float expected)...");
// y
item = PyTuple_GetItem(value,1);
if (PyFloat_Check(item))
cVec.y = PyFloat_AsDouble(item);
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(item))
cVec.y = (double)PyInt_AsLong(item);
#else
else if (PyLong_Check(item))
cVec.y = (double)PyLong_AsLong(item);
#endif
else
throw Base::TypeError("Not allowed type used in tuple (float expected)...");
// z
item = PyTuple_GetItem(value,2);
if (PyFloat_Check(item))
cVec.z = PyFloat_AsDouble(item);
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(item))
cVec.z = (double)PyInt_AsLong(item);
#else
else if (PyLong_Check(item))
cVec.z = (double)PyLong_AsLong(item);
#endif
else
throw Base::TypeError("Not allowed type used in tuple (float expected)...");
setValue( cVec );
@@ -433,8 +448,13 @@ void PropertyMatrix::setPyObject(PyObject *value)
item = PyTuple_GetItem(value,x+y*4);
if (PyFloat_Check(item))
cMatrix[x][y] = PyFloat_AsDouble(item);
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(item))
cMatrix[x][y] = (double)PyInt_AsLong(item);
#else
else if (PyLong_Check(item))
cMatrix[x][y] = (double)PyLong_AsLong(item);
#endif
else
throw Base::TypeError("Not allowed type used in matrix tuple (a number expected)...");
}