##// END OF EJS Templates
improved strictness when enum values are used...
florianlink -
r52:947ce094f432
parent child
Show More
@@ -635,12 +635,15 int PythonQtConv::PyObjGetInt(PyObject* val, bool strict, bool &ok) {
635 qint64 PythonQtConv::PyObjGetLongLong(PyObject* val, bool strict, bool &ok) {
635 qint64 PythonQtConv::PyObjGetLongLong(PyObject* val, bool strict, bool &ok) {
636 qint64 d = 0;
636 qint64 d = 0;
637 ok = true;
637 ok = true;
638 if (PyObject_TypeCheck(val, &PyInt_Type)) {
638 if (val->ob_type == &PyInt_Type) {
639 d = PyInt_AS_LONG(val);
639 d = PyInt_AS_LONG(val);
640 } else if (val->ob_type == &PyLong_Type) {
640 } else if (val->ob_type == &PyLong_Type) {
641 d = PyLong_AsLongLong(val);
641 d = PyLong_AsLongLong(val);
642 } else if (!strict) {
642 } else if (!strict) {
643 if (val->ob_type == &PyFloat_Type) {
643 if (PyObject_TypeCheck(val, &PyInt_Type)) {
644 // support for derived int classes, e.g. for our enums
645 d = PyInt_AS_LONG(val);
646 } else if (val->ob_type == &PyFloat_Type) {
644 d = floor(PyFloat_AS_DOUBLE(val));
647 d = floor(PyFloat_AS_DOUBLE(val));
645 } else if (val == Py_False) {
648 } else if (val == Py_False) {
646 d = 0;
649 d = 0;
@@ -663,7 +666,10 quint64 PythonQtConv::PyObjGetULongLong(PyObject* val, bool strict, bool &ok) {
663 } else if (val->ob_type == &PyLong_Type) {
666 } else if (val->ob_type == &PyLong_Type) {
664 d = PyLong_AsLongLong(val);
667 d = PyLong_AsLongLong(val);
665 } else if (!strict) {
668 } else if (!strict) {
666 if (val->ob_type == &PyFloat_Type) {
669 if (PyObject_TypeCheck(val, &PyInt_Type)) {
670 // support for derived int classes, e.g. for our enums
671 d = PyInt_AS_LONG(val);
672 } else if (val->ob_type == &PyFloat_Type) {
667 d = floor(PyFloat_AS_DOUBLE(val));
673 d = floor(PyFloat_AS_DOUBLE(val));
668 } else if (val == Py_False) {
674 } else if (val == Py_False) {
669 d = 0;
675 d = 0;
General Comments 0
You need to be logged in to leave comments. Login now