Core/Mod: modernize C++11

* use nullptr
This commit is contained in:
wmayer
2022-03-09 21:55:31 +01:00
parent f4a51f3788
commit 08b77bff08
16 changed files with 248 additions and 241 deletions

View File

@@ -80,8 +80,8 @@ PyObject *FemMeshPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Py
int FemMeshPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
PyObject *pcObj=0;
if (!PyArg_ParseTuple(args, "|O", &pcObj)) // convert args: Python->C
return -1; // NULL triggers exception
if (!PyArg_ParseTuple(args, "|O", &pcObj))
return -1;
try {
// if no mesh is given

View File

@@ -509,7 +509,7 @@ PyObject* AttachEnginePy::readParametersFromFeature(PyObject* args)
{
PyObject* obj;
if (!PyArg_ParseTuple(args, "O!",&(App::DocumentObjectPy::Type),&obj))
return NULL; // NULL triggers exception
return nullptr;
try{
App::DocumentObjectPy* dobjpy = static_cast<App::DocumentObjectPy*>(obj);
@@ -533,7 +533,7 @@ PyObject* AttachEnginePy::writeParametersToFeature(PyObject* args)
{
PyObject* obj;
if (!PyArg_ParseTuple(args, "O!",&(App::DocumentObjectPy::Type),&obj))
return NULL; // NULL triggers exception
return nullptr;
try{
App::DocumentObjectPy* dobjpy = static_cast<App::DocumentObjectPy*>(obj);

View File

@@ -43,21 +43,21 @@ std::string FeaturePathCompoundPy::representation(void) const
PyObject* FeaturePathCompoundPy::addObject(PyObject *args)
{
PyObject *object;
if (!PyArg_ParseTuple(args, "O!", &(DocumentObjectPy::Type), &object)) // convert args: Python->C
return NULL; // NULL triggers exception
if (!PyArg_ParseTuple(args, "O!", &(DocumentObjectPy::Type), &object))
return nullptr;
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add an invalid object");
return NULL;
return nullptr;
}
if (docObj->getDocumentObjectPtr()->getDocument() != getFeaturePathCompoundPtr()->getDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add an object from another document to this group");
return NULL;
return nullptr;
}
if (docObj->getDocumentObjectPtr() == this->getFeaturePathCompoundPtr()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add a group object to itself");
return NULL;
return nullptr;
}
FeatureCompound* comp = getFeaturePathCompoundPtr();
@@ -88,17 +88,17 @@ PyObject* FeaturePathCompoundPy::addObject(PyObject *args)
PyObject* FeaturePathCompoundPy::removeObject(PyObject *args)
{
PyObject *object;
if (!PyArg_ParseTuple(args, "O!", &(DocumentObjectPy::Type), &object)) // convert args: Python->C
return NULL; // NULL triggers exception
if (!PyArg_ParseTuple(args, "O!", &(DocumentObjectPy::Type), &object))
return nullptr;
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot remove an invalid object");
return NULL;
return nullptr;
}
if (docObj->getDocumentObjectPtr()->getDocument() != getFeaturePathCompoundPtr()->getDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot remove an object from another document from this group");
return NULL;
return nullptr;
}
FeatureCompound* comp = getFeaturePathCompoundPtr();

View File

@@ -51,8 +51,8 @@ PyObject *PointsPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Pyt
int PointsPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
PyObject *pcObj=nullptr;
if (!PyArg_ParseTuple(args, "|O", &pcObj)) // convert args: Python->C
return -1; // NULL triggers exception
if (!PyArg_ParseTuple(args, "|O", &pcObj))
return -1;
// if no mesh is given
if (!pcObj) return 0;