Use PyObject_IsTrue to check argument

This commit is contained in:
wmayer
2012-12-29 15:59:54 +01:00
parent ad8d4d3a5e
commit 1cdcbfa77a
15 changed files with 37 additions and 29 deletions

View File

@@ -187,7 +187,9 @@ PyObject* DocumentPy::copyObject(PyObject *args)
return NULL; // NULL triggers exception
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(obj);
DocumentObject* copy = getDocumentPtr()->copyObject(docObj->getDocumentObjectPtr(), rec==Py_True, keep==Py_True);
DocumentObject* copy = getDocumentPtr()->copyObject(docObj->getDocumentObjectPtr(),
PyObject_IsTrue(rec) ? true : false,
PyObject_IsTrue(keep)? true : false);
if (copy) {
return copy->getPyObject();
}
@@ -204,7 +206,7 @@ PyObject* DocumentPy::moveObject(PyObject *args)
return NULL; // NULL triggers exception
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(obj);
DocumentObject* move = getDocumentPtr()->moveObject(docObj->getDocumentObjectPtr(), rec==Py_True);
DocumentObject* move = getDocumentPtr()->moveObject(docObj->getDocumentObjectPtr(), PyObject_IsTrue(rec) ? true : false);
if (move) {
return move->getPyObject();
}

View File

@@ -51,7 +51,8 @@ PyObject* FeaturePythonPy::addProperty(PyObject *args)
return NULL; // NULL triggers exception
Property* prop=0;
prop = getFeaturePythonPtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr,ro==Py_True,hd==Py_True);
prop = getFeaturePythonPtr()->addDynamicProperty(sType,sName,sGroup,sDoc,attr,
PyObject_IsTrue(ro) ? true : false, PyObject_IsTrue(hd) ? true : false);
if (!prop) {
std::stringstream str;

View File

@@ -1347,7 +1347,7 @@ PyObject *PropertyBool::getPyObject(void)
void PropertyBool::setPyObject(PyObject *value)
{
if (PyBool_Check(value))
setValue(value == Py_True);
setValue(PyObject_IsTrue(value)!=0);
else if(PyInt_Check(value))
setValue(PyInt_AsLong(value)!=0);
else {