From 749361d2f3d3d689bbee59516df15e5c6579cb21 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 23 Mar 2022 17:29:23 +0100 Subject: [PATCH] App: modernize C++11 * use nullptr --- src/App/Application.cpp | 46 +++---- src/App/Application.h | 14 +- src/App/ApplicationPy.cpp | 38 ++--- src/App/AutoTransaction.cpp | 5 +- src/App/AutoTransaction.h | 2 +- src/App/ComplexGeoData.cpp | 2 +- src/App/Document.cpp | 72 +++++----- src/App/Document.h | 14 +- src/App/DocumentObject.cpp | 44 +++--- src/App/DocumentObject.h | 24 ++-- src/App/DocumentObjectExtensionPyImp.cpp | 2 +- src/App/DocumentObjectFileIncluded.cpp | 2 +- src/App/DocumentObjectGroupPyImp.cpp | 2 +- src/App/DocumentObjectPyImp.cpp | 75 +++++----- src/App/DocumentObserver.cpp | 6 +- src/App/DocumentObserver.h | 2 +- src/App/DocumentObserverPython.cpp | 2 +- src/App/DocumentPyImp.cpp | 42 +++--- src/App/DynamicProperty.cpp | 16 +-- src/App/DynamicProperty.h | 8 +- src/App/Enumeration.cpp | 32 ++--- src/App/Expression.cpp | 50 +++---- src/App/Expression.h | 12 +- src/App/ExpressionParser.h | 30 ++-- src/App/ExpressionVisitors.h | 2 +- src/App/ExtensionContainer.cpp | 34 ++--- src/App/ExtensionContainerPyImp.cpp | 18 +-- src/App/ExtensionPyImp.cpp | 2 +- src/App/FeaturePython.cpp | 12 +- src/App/FeaturePython.h | 4 +- src/App/FeaturePythonPyImp.inl | 74 +++++----- src/App/FeatureTest.cpp | 20 +-- src/App/GeoFeature.cpp | 6 +- src/App/GeoFeature.h | 2 +- src/App/GeoFeatureGroupExtension.cpp | 4 +- src/App/GeoFeatureGroupExtensionPyImp.cpp | 2 +- src/App/GeoFeaturePyImp.cpp | 6 +- src/App/GroupExtension.cpp | 4 +- src/App/GroupExtensionPyImp.cpp | 6 +- src/App/Link.cpp | 72 +++++----- src/App/Link.h | 14 +- src/App/LinkBaseExtensionPyImp.cpp | 40 +++--- src/App/MaterialPyImp.cpp | 16 +-- src/App/MergeDocuments.cpp | 4 +- src/App/MetadataPyImp.cpp | 2 +- src/App/ObjectIdentifier.cpp | 98 ++++++------- src/App/ObjectIdentifier.h | 22 +-- src/App/Origin.cpp | 2 +- src/App/OriginFeature.cpp | 2 +- src/App/OriginGroupExtension.cpp | 2 +- src/App/OriginGroupExtensionPyImp.cpp | 2 +- src/App/Part.cpp | 2 +- src/App/PartPyImp.cpp | 2 +- src/App/Property.cpp | 4 +- src/App/PropertyContainer.cpp | 20 +-- src/App/PropertyContainer.h | 8 +- src/App/PropertyContainerPyImp.cpp | 6 +- src/App/PropertyExpressionEngine.cpp | 8 +- src/App/PropertyExpressionEngine.h | 2 +- src/App/PropertyGeo.cpp | 2 +- src/App/PropertyLinks.cpp | 160 +++++++++++----------- src/App/PropertyLinks.h | 50 +++---- src/App/PropertyPythonObject.cpp | 2 +- src/App/PropertyUnits.h | 2 +- src/App/Range.cpp | 2 +- src/App/Transactions.cpp | 4 +- src/App/VRMLObject.cpp | 2 +- 67 files changed, 647 insertions(+), 643 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 7f93db5775..7b7aee0f8b 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -207,7 +207,7 @@ init_freecad_base_module(void) static struct PyModuleDef BaseModuleDef = { PyModuleDef_HEAD_INIT, "__FreeCADBase__", Base_doc, -1, - NULL, NULL, NULL, NULL, NULL + nullptr, nullptr, nullptr, nullptr, nullptr }; return PyModule_Create(&BaseModuleDef); } @@ -222,13 +222,13 @@ init_freecad_module(void) PyModuleDef_HEAD_INIT, "FreeCAD", FreeCAD_doc, -1, __AppMethods, - NULL, NULL, NULL, NULL + nullptr, nullptr, nullptr, nullptr }; return PyModule_Create(&FreeCADModuleDef); } Application::Application(std::map &mConfig) - : _mConfig(mConfig), _pActiveDoc(0), _isRestoring(false),_allowPartial(false) + : _mConfig(mConfig), _pActiveDoc(nullptr), _isRestoring(false),_allowPartial(false) , _isClosingAll(false), _objCount(-1), _activeTransactionID(0) , _activeTransactionGuard(0), _activeTransactionTmpName(false) { @@ -531,7 +531,7 @@ bool Application::closeDocument(const char* name) // For exception-safety use a smart pointer if (_pActiveDoc == pos->second) - setActiveDocument((Document*)0); + setActiveDocument(static_cast(nullptr)); std::unique_ptr delDoc (pos->second); DocMap.erase( pos ); DocFileMap.erase(FileInfo(delDoc->FileName.getValue()).filePath()); @@ -559,7 +559,7 @@ App::Document* Application::getDocument(const char *Name) const pos = DocMap.find(Name); if (pos == DocMap.end()) - return 0; + return nullptr; return pos->second; } @@ -570,7 +570,7 @@ const char * Application::getDocumentName(const App::Document* doc) const if (it->second == doc) return it->first.c_str(); - return 0; + return nullptr; } std::vector Application::getDocuments() const @@ -667,10 +667,10 @@ public: Document* Application::openDocument(const char * FileName, bool createView) { std::vector filenames(1,FileName); - auto docs = openDocuments(filenames,0,0,0,createView); + auto docs = openDocuments(filenames, nullptr, nullptr, nullptr, createView); if(docs.size()) return docs.front(); - return 0; + return nullptr; } Document *Application::getDocumentByPath(const char *path, PathMatchMode checkCanonical) const { @@ -767,7 +767,7 @@ std::vector Application::openDocuments(const std::vector DocTiming timing; const char *path = name.c_str(); - const char *label = 0; + const char *label = nullptr; if (isMainDoc) { if (paths && paths->size()>count) path = (*paths)[count].c_str(); @@ -959,17 +959,17 @@ Document* Application::openDocumentPrivate(const char * FileName, } } if(!reopen) - return 0; + return nullptr; } if(doc) { _pendingDocsReopen.emplace_back(FileName); - return 0; + return nullptr; } } if(!isMainDoc) - return 0; + return nullptr; else if(doc) return doc; } @@ -1042,7 +1042,7 @@ void Application::setActiveDocument(const char *Name) { // If no active document is set, resort to a default. if (*Name == '\0') { - _pActiveDoc = 0; + _pActiveDoc = nullptr; return; } @@ -1215,7 +1215,7 @@ ParameterManager * Application::GetParameterSet(const char* sName) const if ( it != mpcPramManager.end() ) return it->second; else - return 0; + return nullptr; } const std::map & Application::GetParameterSetList(void) const @@ -1612,7 +1612,7 @@ void Application::slotChangePropertyEditor(const App::Document &doc, const App:: //************************************************************************** // Init, Destruct and singleton -Application * Application::_pcSingleton = 0; +Application * Application::_pcSingleton = nullptr; int Application::_argc; char ** Application::_argv; @@ -1662,8 +1662,8 @@ void Application::destruct(void) } paramMgr.clear(); - _pcSysParamMngr = 0; - _pcUserParamMngr = 0; + _pcSysParamMngr = nullptr; + _pcUserParamMngr = nullptr; #ifdef FC_DEBUG // Do this only in debug mode for memory leak checkers @@ -1690,12 +1690,12 @@ void Application::destructObserver(void) if ( _pConsoleObserverFile ) { Console().DetachObserver(_pConsoleObserverFile); delete _pConsoleObserverFile; - _pConsoleObserverFile = 0; + _pConsoleObserverFile = nullptr; } if ( _pConsoleObserverStd ) { Console().DetachObserver(_pConsoleObserverStd); delete _pConsoleObserverStd; - _pConsoleObserverStd = 0; + _pConsoleObserverStd = nullptr; } } @@ -1741,12 +1741,12 @@ void printBacktrace(size_t skip=0) char **symbols = backtrace_symbols(callstack, nFrames); for (size_t i = skip; i < nFrames; i++) { - char *demangled = NULL; + char *demangled = nullptr; int status = -1; Dl_info info; if (dladdr(callstack[i], &info) && info.dli_sname && info.dli_fname) { if (info.dli_sname[0] == '_') { - demangled = abi::__cxa_demangle(info.dli_sname, NULL, 0, &status); + demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status); } } @@ -2483,7 +2483,7 @@ void Application::initConfig(int argc, char ** argv) Console().AttachObserver(_pConsoleObserverFile); } else - _pConsoleObserverFile = 0; + _pConsoleObserverFile = nullptr; // Banner =========================================================== if (!(mConfig["RunMode"] == "Cmd")) { @@ -2629,7 +2629,7 @@ void Application::initApplication(void) } // seed randomizer - srand(time(0)); + srand(time(nullptr)); } std::list Application::getCmdLineFiles() diff --git a/src/App/Application.h b/src/App/Application.h index 27ea6dd37a..719961def1 100644 --- a/src/App/Application.h +++ b/src/App/Application.h @@ -88,14 +88,14 @@ public: * The second name is a UTF8 name of any kind. It's that name normally shown to * the user and stored in the App::Document::Name property. */ - App::Document* newDocument(const char * Name=0l, const char * UserName=0l, + App::Document* newDocument(const char * Name=nullptr, const char * UserName=nullptr, bool createView=true, bool tempDoc=false); /// Closes the document \a name and removes it from the application. bool closeDocument(const char* name); /// find a unique document name std::string getUniqueDocumentName(const char *Name, bool tempDoc=false) const; /// Open an existing document from a file - App::Document* openDocument(const char * FileName=0l, bool createView=true); + App::Document* openDocument(const char * FileName=nullptr, bool createView=true); /** Open multiple documents * * @param filenames: input file names @@ -114,9 +114,9 @@ public: * This function will also open any external referenced files. */ std::vector openDocuments(const std::vector &filenames, - const std::vector *paths=0, - const std::vector *labels=0, - std::vector *errs=0, + const std::vector *paths=nullptr, + const std::vector *labels=nullptr, + std::vector *errs=nullptr, bool createView = true); /// Retrieve the active document App::Document* getActiveDocument(void) const; @@ -186,7 +186,7 @@ public: */ int setActiveTransaction(const char *name, bool persist=false); /// Return the current active transaction name and ID - const char *getActiveTransaction(int *tid=0) const; + const char *getActiveTransaction(int *tid=nullptr) const; /** Commit/abort current active transactions * * @param abort: whether to abort or commit the transactions @@ -404,7 +404,7 @@ public: system's temporary directory but can be customized by the user. */ static std::string getTempPath(); - static std::string getTempFileName(const char* FileName=0); + static std::string getTempFileName(const char* FileName=nullptr); static std::string getUserCachePath(); static std::string getUserConfigPath(); static std::string getUserAppDataDir(); diff --git a/src/App/ApplicationPy.cpp b/src/App/ApplicationPy.cpp index 51a2877fa7..6d04d72405 100644 --- a/src/App/ApplicationPy.cpp +++ b/src/App/ApplicationPy.cpp @@ -181,7 +181,7 @@ PyMethodDef Application::Methods[] = { "There is an active sequencer during document restore and recomputation. User may\n" "abort the operation by pressing the ESC key. Once detected, this function will\n" "trigger a Base.FreeCADAbort exception."}, - {NULL, NULL, 0, NULL} /* Sentinel */ + {nullptr, nullptr, 0, nullptr} /* Sentinel */ }; @@ -232,7 +232,7 @@ PyObject* Application::sLoadFile(PyObject * /*self*/, PyObject *args) PyObject* Application::sIsRestoring(PyObject * /*self*/, PyObject *args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; return Py::new_reference_to(Py::Boolean(GetApplication().isRestoring())); } @@ -240,10 +240,10 @@ PyObject* Application::sOpenDocument(PyObject * /*self*/, PyObject *args, PyObje { char* Name; PyObject *hidden = Py_False; - static char *kwlist[] = {"name","hidden",0}; + static char *kwlist[] = {"name","hidden",nullptr}; if (!PyArg_ParseTupleAndKeywords(args, kwd, "et|O", kwlist, "utf-8", &Name, &hidden)) - return NULL; + return nullptr; std::string EncodedName = std::string(Name); PyMem_Free(Name); try { @@ -252,25 +252,25 @@ PyObject* Application::sOpenDocument(PyObject * /*self*/, PyObject *args, PyObje } catch (const Base::Exception& e) { PyErr_SetString(PyExc_IOError, e.what()); - return 0L; + return nullptr; } catch (const std::exception& e) { // might be subclass from zipios PyErr_Format(PyExc_IOError, "Invalid project file %s: %s\n", EncodedName.c_str(), e.what()); - return 0L; + return nullptr; } } PyObject* Application::sNewDocument(PyObject * /*self*/, PyObject *args, PyObject *kwd) { - char *docName = 0; - char *usrName = 0; + char *docName = nullptr; + char *usrName = nullptr; PyObject *hidden = Py_False; PyObject *temp = Py_False; - static char *kwlist[] = {"name","label","hidden","temp",0}; + static char *kwlist[] = {"name","label","hidden","temp",nullptr}; if (!PyArg_ParseTupleAndKeywords(args, kwd, "|etetOO", kwlist, "utf-8", &docName, "utf-8", &usrName, &hidden, &temp)) - return NULL; + return nullptr; PY_TRY { App::Document* doc = GetApplication().newDocument(docName, usrName, @@ -284,7 +284,7 @@ PyObject* Application::sNewDocument(PyObject * /*self*/, PyObject *args, PyObjec PyObject* Application::sSetActiveDocument(PyObject * /*self*/, PyObject *args) { - char *pstr = 0; + char *pstr = nullptr; if (!PyArg_ParseTuple(args, "s", &pstr)) return nullptr; @@ -301,7 +301,7 @@ PyObject* Application::sSetActiveDocument(PyObject * /*self*/, PyObject *args) PyObject* Application::sCloseDocument(PyObject * /*self*/, PyObject *args) { - char *pstr = 0; + char *pstr = nullptr; if (!PyArg_ParseTuple(args, "s", &pstr)) return nullptr; @@ -379,7 +379,7 @@ PyObject* Application::sActiveDocument(PyObject * /*self*/, PyObject *args) PyObject* Application::sGetDocument(PyObject * /*self*/, PyObject *args) { - char *pstr=0; + char *pstr=nullptr; if (!PyArg_ParseTuple(args, "s", &pstr)) return nullptr; @@ -394,7 +394,7 @@ PyObject* Application::sGetDocument(PyObject * /*self*/, PyObject *args) PyObject* Application::sGetParam(PyObject * /*self*/, PyObject *args) { - char *pstr=0; + char *pstr=nullptr; if (!PyArg_ParseTuple(args, "s", &pstr)) return nullptr; @@ -536,7 +536,7 @@ PyObject* Application::sChangeImportModule(PyObject * /*self*/, PyObject *args) PyObject* Application::sGetImportType(PyObject * /*self*/, PyObject *args) { - char* psKey=0; + char* psKey=nullptr; if (!PyArg_ParseTuple(args, "|s", &psKey)) return nullptr; @@ -600,7 +600,7 @@ PyObject* Application::sChangeExportModule(PyObject * /*self*/, PyObject *args) PyObject* Application::sGetExportType(PyObject * /*self*/, PyObject *args) { - char* psKey=0; + char* psKey=nullptr; if (!PyArg_ParseTuple(args, "|s", &psKey)) return nullptr; @@ -872,11 +872,11 @@ PyObject *Application::sGetLinksTo(PyObject * /*self*/, PyObject *args) return nullptr; PY_TRY { - DocumentObject *obj = 0; + DocumentObject *obj = nullptr; if(pyobj!=Py_None) { if(!PyObject_TypeCheck(pyobj,&DocumentObjectPy::Type)) { PyErr_SetString(PyExc_TypeError, "Expect the first argument of type document object"); - return 0; + return nullptr; } obj = static_cast(pyobj)->getDocumentObjectPtr(); } @@ -902,7 +902,7 @@ PyObject *Application::sGetDependentObjects(PyObject * /*self*/, PyObject *args) for (Py_ssize_t i=0;i(seq[i].ptr())->getDocumentObjectPtr()); } diff --git a/src/App/AutoTransaction.cpp b/src/App/AutoTransaction.cpp index 054b6e8f61..5803ebcb87 100644 --- a/src/App/AutoTransaction.cpp +++ b/src/App/AutoTransaction.cpp @@ -153,8 +153,9 @@ const char *Application::getActiveTransaction(int *id) const { int tid = 0; if(Transaction::getLastID() == _activeTransactionID) tid = _activeTransactionID; - if(id) *id = tid; - return tid?_activeTransactionName.c_str():0; + if (id) + *id = tid; + return tid ? _activeTransactionName.c_str() : nullptr; } void Application::closeActiveTransaction(bool abort, int id) { diff --git a/src/App/AutoTransaction.h b/src/App/AutoTransaction.h index 00a02d8729..42a52fb4b1 100644 --- a/src/App/AutoTransaction.h +++ b/src/App/AutoTransaction.h @@ -50,7 +50,7 @@ public: * current active transaction until it reaches zero. It does not have any * effect on aborting transaction, though. */ - AutoTransaction(const char *name=0, bool tmpName=false); + AutoTransaction(const char *name=nullptr, bool tmpName=false); /** Destructor * diff --git a/src/App/ComplexGeoData.cpp b/src/App/ComplexGeoData.cpp index 9ac8ebaaac..adab0b8a0a 100644 --- a/src/App/ComplexGeoData.cpp +++ b/src/App/ComplexGeoData.cpp @@ -168,7 +168,7 @@ const std::string &ComplexGeoData::elementMapPrefix() { const char *ComplexGeoData::isMappedElement(const char *name) { if(name && boost::starts_with(name,elementMapPrefix())) return name+elementMapPrefix().size(); - return 0; + return nullptr; } std::string ComplexGeoData::newElementName(const char *name) { diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 3294812caf..02fccbe555 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -194,8 +194,8 @@ struct DocumentP // copying shape from other document. It is probably better to randomize // on each object ID. lastObjectId = _RDIST(_RGEN); - activeObject = 0; - activeUndoTransaction = 0; + activeObject = nullptr; + activeUndoTransaction = nullptr; iTransactionMode = 0; rollback = false; undoing = false; @@ -226,7 +226,7 @@ struct DocumentP returnCode->Which->setStatus(ObjectStatus::Error,true); } - void clearRecomputeLog(const App::DocumentObject *obj=0) { + void clearRecomputeLog(const App::DocumentObject *obj=nullptr) { if(!obj) _RecomputeLog.clear(); else @@ -236,7 +236,7 @@ struct DocumentP const char *findRecomputeLog(const App::DocumentObject *obj) { auto range = _RecomputeLog.equal_range(obj); if(range.first == range.second) - return 0; + return nullptr; return (--range.second)->second->Why.c_str(); } @@ -967,7 +967,7 @@ bool Document::undo(int id) // save the redo mRedoMap[d->activeUndoTransaction->getID()] = d->activeUndoTransaction; mRedoTransactions.push_back(d->activeUndoTransaction); - d->activeUndoTransaction = 0; + d->activeUndoTransaction = nullptr; mUndoMap.erase(mUndoTransactions.back()->getID()); delete mUndoTransactions.back(); @@ -1017,7 +1017,7 @@ bool Document::redo(int id) mUndoMap[d->activeUndoTransaction->getID()] = d->activeUndoTransaction; mUndoTransactions.push_back(d->activeUndoTransaction); - d->activeUndoTransaction = 0; + d->activeUndoTransaction = nullptr; mRedoMap.erase(mRedoTransactions.back()->getID()); delete mRedoTransactions.back(); @@ -1226,7 +1226,7 @@ void Document::_commitTransaction(bool notify) Application::TransactionSignaller signaller(false,true); int id = d->activeUndoTransaction->getID(); mUndoTransactions.push_back(d->activeUndoTransaction); - d->activeUndoTransaction = 0; + d->activeUndoTransaction = nullptr; // check the stack for the limits if(mUndoTransactions.size() > d->UndoMaxStackSize){ mUndoMap.erase(mUndoTransactions.front()->getID()); @@ -1268,7 +1268,7 @@ void Document::_abortTransaction() // destroy the undo mUndoMap.erase(d->activeUndoTransaction->getID()); delete d->activeUndoTransaction; - d->activeUndoTransaction = 0; + d->activeUndoTransaction = nullptr; signalAbortTransaction(*this); } } @@ -1319,7 +1319,7 @@ bool Document::isTransactionEmpty() const void Document::clearDocument() { - this->d->activeObject = 0; + this->d->activeObject = nullptr; if(this->d->objectArray.size()) { GetApplication().signalDeleteDocument(*this); @@ -1503,7 +1503,7 @@ void Document::onBeforeChangeProperty(const TransactionalObject *Who, const Prop if(Who->isDerivedFrom(App::DocumentObject::getClassTypeId())) signalBeforeChangeObject(*static_cast(Who), *What); if(!d->rollback && !_IsRelabeling) { - _checkTransaction(0,What,__LINE__); + _checkTransaction(nullptr,What,__LINE__); if (d->activeUndoTransaction) d->activeUndoTransaction->addObjectChange(Who,What); } @@ -1619,7 +1619,7 @@ Document::Document(const char *name) // this creates and sets 'TransientDir' in onChanged() ADD_PROPERTY_TYPE(TransientDir,(""),0,PropertyType(Prop_Transient|Prop_ReadOnly), "Transient directory, where the files live while the document is open"); - ADD_PROPERTY_TYPE(Tip,(0),0,PropertyType(Prop_Transient), + ADD_PROPERTY_TYPE(Tip,(nullptr),0,PropertyType(Prop_Transient), "Link of the tip object of the document"); ADD_PROPERTY_TYPE(TipName,(""),0,PropertyType(Prop_Hidden|Prop_ReadOnly), "Link of the tip object of the document"); @@ -1872,13 +1872,13 @@ void Document::writeObjects(const std::vector& obj, // writing the features types writer.incInd(); // indentation for 'Objects count' writer.Stream() << writer.ind() << "" << endl; writer.incInd(); // indentation for 'Object type' - if(!isExporting(0)) { + if(!isExporting(nullptr)) { for(auto o : obj) { const auto &outList = o->getOutList(DocumentObject::OutListNoHidden | DocumentObject::OutListNoXLinked); @@ -2705,7 +2705,7 @@ void Document::restore (const char *filename, bool delaySignal, const std::vector &objNames) { clearUndos(); - d->activeObject = 0; + d->activeObject = nullptr; bool signal = false; Document *activeDoc = GetApplication().getActiveDocument(); @@ -2992,7 +2992,7 @@ void Document::getLinksTo(std::set &links, else { auto ext = o->getExtensionByType(true); if(ext) - linked = ext->getTrueLinkedObject(false,0,0,true); + linked = ext->getTrueLinkedObject(false,nullptr,0,true); else linked = o->getLinkedObject(false); } @@ -3077,7 +3077,7 @@ std::vector Document::getInList(const DocumentObject* me) static void _buildDependencyList(const std::vector &objectArray, int options, std::vector *depObjs, DependencyList *depList, std::map *objectMap, - bool *touchCheck = 0) + bool *touchCheck = nullptr) { std::map > outLists; std::deque objs; @@ -3130,7 +3130,7 @@ std::vector Document::getDependencyList( { std::vector ret; if(!(options & DepSort)) { - _buildDependencyList(objectArray,options,&ret,0,0); + _buildDependencyList(objectArray,options,&ret,nullptr,nullptr); return ret; } @@ -3138,7 +3138,7 @@ std::vector Document::getDependencyList( std::map objectMap; std::map vertexMap; - _buildDependencyList(objectArray,options,0,&depList,&objectMap); + _buildDependencyList(objectArray,options,nullptr,&depList,&objectMap); for(auto &v : objectMap) vertexMap[v.second] = v.first; @@ -3770,7 +3770,7 @@ int Document::_recomputeFeature(DocumentObject* Feat) { FC_LOG("Recomputing " << Feat->getFullName()); - DocumentObjectExecReturn *returnCode = 0; + DocumentObjectExecReturn *returnCode = nullptr; try { returnCode = Feat->ExpressionEngine.execute(PropertyExpressionEngine::ExecuteNonOutput); if (returnCode == DocumentObject::StdReturn) { @@ -3862,7 +3862,7 @@ DocumentObject * Document::addObject(const char* sType, const char* pObjectName, // do no transactions if we do a rollback! if (!d->rollback) { // Undo stuff - _checkTransaction(0,0,__LINE__); + _checkTransaction(nullptr,nullptr,__LINE__); if (d->activeUndoTransaction) d->activeUndoTransaction->addObjectDel(pcObject); } @@ -3958,7 +3958,7 @@ std::vector Document::addObjects(const char* sType, const std: // do no transactions if we do a rollback! if (!d->rollback) { // Undo stuff - _checkTransaction(0,0,__LINE__); + _checkTransaction(nullptr,nullptr,__LINE__); if (d->activeUndoTransaction) { d->activeUndoTransaction->addObjectDel(pcObject); } @@ -4034,7 +4034,7 @@ void Document::addObject(DocumentObject* pcObject, const char* pObjectName) // do no transactions if we do a rollback! if (!d->rollback) { // Undo stuff - _checkTransaction(0,0,__LINE__); + _checkTransaction(nullptr,nullptr,__LINE__); if (d->activeUndoTransaction) d->activeUndoTransaction->addObjectDel(pcObject); } @@ -4090,7 +4090,7 @@ void Document::_addObject(DocumentObject* pcObject, const char* pObjectName) // do no transactions if we do a rollback! if (!d->rollback) { // Undo stuff - _checkTransaction(0,0,__LINE__); + _checkTransaction(nullptr,nullptr,__LINE__); if (d->activeUndoTransaction) d->activeUndoTransaction->addObjectDel(pcObject); } @@ -4128,7 +4128,7 @@ void Document::removeObject(const char* sName) TransactionLocker tlock; - _checkTransaction(pos->second,0,__LINE__); + _checkTransaction(pos->second,nullptr,__LINE__); #if 0 if(!d->rollback && d->activeUndoTransaction && pos->second->hasChildElement()) { @@ -4152,7 +4152,7 @@ void Document::removeObject(const char* sName) #endif if (d->activeObject == pos->second) - d->activeObject = 0; + d->activeObject = nullptr; // Mark the object as about to be deleted pos->second->setStatus(ObjectStatus::Remove, true); @@ -4235,7 +4235,7 @@ void Document::_removeObject(DocumentObject* pcObject) TransactionLocker tlock; // TODO Refactoring: share code with Document::removeObject() (2015-09-01, Fat-Zer) - _checkTransaction(pcObject,0,__LINE__); + _checkTransaction(pcObject,nullptr,__LINE__); auto pos = d->objectMap.find(pcObject->getNameInDocument()); @@ -4254,7 +4254,7 @@ void Document::_removeObject(DocumentObject* pcObject) } if (d->activeObject == pcObject) - d->activeObject = 0; + d->activeObject = nullptr; // Mark the object as about to be removed pcObject->setStatus(ObjectStatus::Remove, true); @@ -4346,7 +4346,7 @@ std::vector Document::copyObject( exportObjects(deps, ostr); Base::ByteArrayIStreambuf ibuf(res); - std::istream istr(0); + std::istream istr(nullptr); istr.rdbuf(&ibuf); imported = md.importObjects(istr); } else { @@ -4377,7 +4377,7 @@ std::vector Document::importLinks(const std::vector &objArray) { std::set links; - getLinksTo(links,0,GetLinkExternal,0,objArray); + getLinksTo(links,nullptr,GetLinkExternal,0,objArray); std::vector objs; objs.insert(objs.end(),links.begin(),links.end()); @@ -4446,10 +4446,10 @@ Document::importLinks(const std::vector &objArray) DocumentObject* Document::moveObject(DocumentObject* obj, bool recursive) { if(!obj) - return 0; + return nullptr; Document* that = obj->getDocument(); if (that == this) - return 0; // nothing todo + return nullptr; // nothing todo // True object move without copy is only safe when undo is off on both // documents. @@ -4471,7 +4471,7 @@ DocumentObject* Document::moveObject(DocumentObject* obj, bool recursive) auto objs = copyObject(deps,false); if(objs.empty()) - return 0; + return nullptr; // Some object may delete its children if deleted, so we collect the IDs // or all depending objects for safety reason. std::vector ids; @@ -4504,7 +4504,7 @@ DocumentObject * Document::getObject(const char *Name) const if (pos != d->objectMap.end()) return pos->second; else - return 0; + return nullptr; } DocumentObject * Document::getObjectByID(long id) const @@ -4512,7 +4512,7 @@ DocumentObject * Document::getObjectByID(long id) const auto it = d->objectIdMap.find(id); if(it!=d->objectIdMap.end()) return it->second; - return 0; + return nullptr; } @@ -4534,7 +4534,7 @@ const char * Document::getObjectName(DocumentObject *pFeat) const return pos->first.c_str(); } - return 0; + return nullptr; } std::string Document::getUniqueObjectName(const char *Name) const @@ -4745,7 +4745,7 @@ bool Document::mustExecute() const { if(PropertyXLink::hasXLink(this)) { bool touched = false; - _buildDependencyList(d->objectArray,false,0,0,0,&touched); + _buildDependencyList(d->objectArray,false,nullptr,nullptr,nullptr,&touched); return touched; } diff --git a/src/App/Document.h b/src/App/Document.h index 52ebe2c802..5148c53889 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -187,7 +187,7 @@ public: bool saveAs(const char* file); bool saveCopy(const char* file) const; /// Restore the document from the file in Property Path - void restore (const char *filename=0, + void restore (const char *filename=nullptr, bool delaySignal=false, const std::vector &objNames={}); bool afterRestore(bool checkPartial=false); bool afterRestore(const std::vector &, bool checkPartial=false); @@ -246,8 +246,8 @@ public: * @param viewType override object's view provider name * @param isPartial indicate if this object is meant to be partially loaded */ - DocumentObject *addObject(const char* sType, const char* pObjectName=0, - bool isNew=true, const char *viewType=0, bool isPartial=false); + DocumentObject *addObject(const char* sType, const char* pObjectName=nullptr, + bool isNew=true, const char *viewType=nullptr, bool isPartial=false); /** Add an array of features of the given types and names. * Unicode names are set through the Label property. * @param sType The type of created object @@ -264,7 +264,7 @@ public: * \note The passed feature must not yet be added to a document, otherwise an exception * is raised. */ - void addObject(DocumentObject*, const char* pObjectName=0); + void addObject(DocumentObject*, const char* pObjectName=nullptr); /** Copy objects from another document to this document @@ -338,7 +338,7 @@ public: * all object in this document is checked for recompute */ int recompute(const std::vector &objs={}, - bool force=false,bool *hasError=0, int options=0); + bool force=false,bool *hasError=nullptr, int options=0); /// Recompute only one feature bool recomputeFeature(DocumentObject* Feat,bool recursive=false); /// get the text of the error of a specified object @@ -381,7 +381,7 @@ public: * to setup a potential transaction which will only be created if there is * actual changes. */ - void openTransaction(const char* name=0); + void openTransaction(const char* name=nullptr); /// Rename the current transaction if the id matches void renameTransaction(const char *name, int id); /// Commit the Command transaction. Do nothing If there is no Command transaction open. @@ -548,7 +548,7 @@ protected: * This function creates an actual transaction regardless of Application * AutoTransaction setting. */ - int _openTransaction(const char* name=0, int id=0); + int _openTransaction(const char* name=nullptr, int id=0); /// Internally called by App::Application to commit the Command transaction. void _commitTransaction(bool notify=false); /// Internally called by App::Application to abort the running transaction. diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 6daef96f81..5beefe7c3f 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -56,14 +56,14 @@ using namespace App; PROPERTY_SOURCE(App::DocumentObject, App::TransactionalObject) -DocumentObjectExecReturn *DocumentObject::StdReturn = 0; +DocumentObjectExecReturn *DocumentObject::StdReturn = nullptr; //=========================================================================== // DocumentObject //=========================================================================== DocumentObject::DocumentObject(void) - : ExpressionEngine(),_pDoc(0),pcNameInDocument(0),_Id(0) + : ExpressionEngine(),_pDoc(nullptr),pcNameInDocument(nullptr),_Id(0) { // define Label of type 'Output' to avoid being marked as touched after relabeling ADD_PROPERTY_TYPE(Label,("Unnamed"),"Base",Prop_Output,"User name of the object (UTF8)"); @@ -275,7 +275,7 @@ const char *DocumentObject::getNameInDocument() const // to an object that has been removed from the document. In this case we should rather // return 0. //assert(pcNameInDocument); - if (!pcNameInDocument) return 0; + if (!pcNameInDocument) return nullptr; return pcNameInDocument->c_str(); } @@ -301,14 +301,14 @@ std::string DocumentObject::getExportName(bool forced) const { bool DocumentObject::isAttachedToDocument() const { - return (pcNameInDocument != 0); + return (pcNameInDocument != nullptr); } const char* DocumentObject::detachFromDocument() { const std::string* name = pcNameInDocument; - pcNameInDocument = 0; - return name ? name->c_str() : 0; + pcNameInDocument = nullptr; + return name ? name->c_str() : nullptr; } const std::vector &DocumentObject::getOutList() const { @@ -812,7 +812,7 @@ PyObject *DocumentObject::getPyObject(void) DocumentObject *DocumentObject::getSubObject(const char *subname, PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const { - DocumentObject *ret = 0; + DocumentObject *ret = nullptr; auto exts = getExtensionsDerivedFromType(); for(auto ext : exts) { if(ext->extensionGetSubObject(ret,subname,pyObj,mat,transform, depth)) @@ -820,7 +820,7 @@ DocumentObject *DocumentObject::getSubObject(const char *subname, } std::string name; - const char *dot=0; + const char *dot=nullptr; if(!subname || !(dot=strchr(subname,'.'))) { ret = const_cast(this); }else if(subname[0]=='$') { @@ -917,7 +917,7 @@ std::vector > DocumentObject::getPa DocumentObject *DocumentObject::getLinkedObject( bool recursive, Base::Matrix4D *mat, bool transform, int depth) const { - DocumentObject *ret = 0; + DocumentObject *ret = nullptr; auto exts = getExtensionsDerivedFromType(); for(auto ext : exts) { if(ext->extensionGetLinkedObject(ret,recursive,mat,transform,depth)) @@ -1083,8 +1083,8 @@ DocumentObject *DocumentObject::resolve(const char *subname, PyObject **pyObj, Base::Matrix4D *pmat, bool transform, int depth) const { auto self = const_cast(this); - if(parent) *parent = 0; - if(subElement) *subElement = 0; + if(parent) *parent = nullptr; + if(subElement) *subElement = nullptr; auto obj = getSubObject(subname,pyObj,pmat,transform,depth); if(!obj || !subname || *subname==0) @@ -1097,7 +1097,7 @@ DocumentObject *DocumentObject::resolve(const char *subname, // '.' for each object name in SubName, even if there is no subelement // following it. So finding the last dot will give us the end of the last // object name. - const char *dot=0; + const char *dot=nullptr; if(Data::ComplexGeoData::isMappedElement(subname) || !(dot=strrchr(subname,'.')) || dot == subname) @@ -1169,7 +1169,7 @@ DocumentObject *DocumentObject::resolveRelativeLink(std::string &subname, DocumentObject *&link, std::string &linkSub) const { if(!link || !link->getNameInDocument() || !getNameInDocument()) - return 0; + return nullptr; auto ret = const_cast(this); if(link != ret) { auto sub = subname.c_str(); @@ -1181,7 +1181,7 @@ DocumentObject *DocumentObject::resolveRelativeLink(std::string &subname, if(getSubObject(subcheck.c_str())==link) { ret = getSubObject(std::string(sub,dot+1-sub).c_str()); if(!ret) - return 0; + return nullptr; subname = std::string(dot+1); break; } @@ -1194,14 +1194,14 @@ DocumentObject *DocumentObject::resolveRelativeLink(std::string &subname, do { linkPos = linkSub.find('.',linkPos); if(linkPos == std::string::npos) { - link = 0; - return 0; + link = nullptr; + return nullptr; } ++linkPos; pos = subname.find('.',pos); if(pos == std::string::npos) { subname.clear(); - ret = 0; + ret = nullptr; break; } ++pos; @@ -1210,15 +1210,15 @@ DocumentObject *DocumentObject::resolveRelativeLink(std::string &subname, if(pos != std::string::npos) { ret = getSubObject(subname.substr(0,pos).c_str()); if(!ret) { - link = 0; - return 0; + link = nullptr; + return nullptr; } subname = subname.substr(pos); } if(linkPos) { link = link->getSubObject(linkSub.substr(0,linkPos).c_str()); if(!link) - return 0; + return nullptr; linkSub = linkSub.substr(linkPos); } return ret; @@ -1256,13 +1256,13 @@ const std::string &DocumentObject::hiddenMarker() { } const char *DocumentObject::hasHiddenMarker(const char *subname) { - if(!subname) return 0; + if(!subname) return nullptr; const char *marker = strrchr(subname,'.'); if(!marker) marker = subname; else ++marker; - return hiddenMarker()==marker?marker:0; + return hiddenMarker()==marker?marker:nullptr; } bool DocumentObject::redirectSubName(std::ostringstream &, DocumentObject *, DocumentObject *) const { diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index e994db5249..f7f0772566 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -74,11 +74,11 @@ enum ObjectStatus { class AppExport DocumentObjectExecReturn { public: - DocumentObjectExecReturn(const std::string& sWhy, DocumentObject* WhichObject=0) + DocumentObjectExecReturn(const std::string& sWhy, DocumentObject* WhichObject=nullptr) : Why(sWhy), Which(WhichObject) { } - DocumentObjectExecReturn(const char* sWhy, DocumentObject* WhichObject=0) + DocumentObjectExecReturn(const char* sWhy, DocumentObject* WhichObject=nullptr) : Which(WhichObject) { if (sWhy) @@ -249,7 +249,7 @@ public: * objects, with the furthest linking object ordered last. */ void getInListEx(std::set &inSet, - bool recursive, std::vector *inList=0) const; + bool recursive, std::vector *inList=nullptr) const; /** Return a set of all objects linking to this object, including possible external parent objects * @param recursive [in]: whether to obtain recursive in list */ @@ -347,8 +347,8 @@ public: * then it shall return itself. If subname is invalid, then it shall return * zero. */ - virtual DocumentObject *getSubObject(const char *subname, PyObject **pyObj=0, - Base::Matrix4D *mat=0, bool transform=true, int depth=0) const; + virtual DocumentObject *getSubObject(const char *subname, PyObject **pyObj=nullptr, + Base::Matrix4D *mat=nullptr, bool transform=true, int depth=0) const; /// Return a list of objects referenced by a given subname including this object std::vector getSubObjectList(const char *subname) const; @@ -397,7 +397,7 @@ public: * it is not a link or the link is invalid. */ virtual DocumentObject *getLinkedObject(bool recurse=true, - Base::Matrix4D *mat=0, bool transform=false, int depth=0) const; + Base::Matrix4D *mat=nullptr, bool transform=false, int depth=0) const; /* Return true to cause PropertyView to show linked object's property */ virtual bool canLinkProperties() const {return true;} @@ -440,8 +440,8 @@ public: virtual bool removeDynamicProperty(const char* prop) override; virtual App::Property* addDynamicProperty( - const char* type, const char* name=0, - const char* group=0, const char* doc=0, + const char* type, const char* name=nullptr, + const char* group=nullptr, const char* doc=nullptr, short attr=0, bool ro=false, bool hidden=false) override; /** Resolve the last document object referenced in the subname @@ -456,9 +456,9 @@ public: * @return Returns the last referenced document object in the subname. If no * such object in subname, return pObject. */ - App::DocumentObject *resolve(const char *subname, App::DocumentObject **parent=0, - std::string *childName=0, const char **subElement=0, - PyObject **pyObj=0, Base::Matrix4D *mat=0, bool transform=true, int depth=0) const; + App::DocumentObject *resolve(const char *subname, App::DocumentObject **parent=nullptr, + std::string *childName=nullptr, const char **subElement=nullptr, + PyObject **pyObj=nullptr, Base::Matrix4D *mat=nullptr, bool transform=true, int depth=0) const; /** Resolve a link reference that is relative to this object reference * @@ -522,7 +522,7 @@ public: * future parent. */ virtual bool adjustRelativeLinks(const std::set &inList, - std::set *visited=0); + std::set *visited=nullptr); /** allow partial loading of dependent objects * diff --git a/src/App/DocumentObjectExtensionPyImp.cpp b/src/App/DocumentObjectExtensionPyImp.cpp index 468220deb9..c519707e67 100644 --- a/src/App/DocumentObjectExtensionPyImp.cpp +++ b/src/App/DocumentObjectExtensionPyImp.cpp @@ -37,7 +37,7 @@ std::string DocumentObjectExtensionPy::representation(void) const PyObject *DocumentObjectExtensionPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int DocumentObjectExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject * /*obj*/) diff --git a/src/App/DocumentObjectFileIncluded.cpp b/src/App/DocumentObjectFileIncluded.cpp index f4e9edaae5..b8bbae91c4 100644 --- a/src/App/DocumentObjectFileIncluded.cpp +++ b/src/App/DocumentObjectFileIncluded.cpp @@ -32,7 +32,7 @@ PROPERTY_SOURCE(App::DocumentObjectFileIncluded, App::DocumentObject) DocumentObjectFileIncluded::DocumentObjectFileIncluded() { - ADD_PROPERTY_TYPE(File,(0),"",(App::PropertyType)(Prop_None),"File to include into Project File"); + ADD_PROPERTY_TYPE(File,(nullptr),"",(App::PropertyType)(Prop_None),"File to include into Project File"); } DocumentObjectFileIncluded::~DocumentObjectFileIncluded() diff --git a/src/App/DocumentObjectGroupPyImp.cpp b/src/App/DocumentObjectGroupPyImp.cpp index a5d4ac9d46..c08da1dfc3 100644 --- a/src/App/DocumentObjectGroupPyImp.cpp +++ b/src/App/DocumentObjectGroupPyImp.cpp @@ -39,7 +39,7 @@ std::string DocumentObjectGroupPy::representation(void) const PyObject *DocumentObjectGroupPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int DocumentObjectGroupPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index cd2e01c9c0..99aae5b42f 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -77,7 +77,7 @@ Py::Object DocumentObjectPy::getDocument(void) const PyObject* DocumentObjectPy::addProperty(PyObject *args) { - char *sType,*sName=0,*sGroup=0,*sDoc=0; + char *sType,*sName=nullptr,*sGroup=nullptr,*sDoc=nullptr; short attr=0; std::string sDocStr; PyObject *ro = Py_False, *hd = Py_False; @@ -100,7 +100,7 @@ PyObject* DocumentObjectPy::removeProperty(PyObject *args) { char *sName; if (!PyArg_ParseTuple(args, "s", &sName)) - return NULL; + return nullptr; bool ok = getDocumentObjectPtr()->removeDynamicProperty(sName); return Py_BuildValue("O", (ok ? Py_True : Py_False)); @@ -126,7 +126,7 @@ PyObject* DocumentObjectPy::supportedProperties(PyObject *args) PyObject* DocumentObjectPy::touch(PyObject * args) { - char *propName = 0; + char *propName = nullptr; if (!PyArg_ParseTuple(args, "|s",&propName)) return nullptr; if(propName) { @@ -376,7 +376,7 @@ PyObject* DocumentObjectPy::recompute(PyObject *args) { PyObject *recursive=Py_False; if (!PyArg_ParseTuple(args, "|O",&recursive)) - return NULL; + return nullptr; try { bool ok = getDocumentObjectPtr()->recomputeFeature(PyObject_IsTrue(recursive)); @@ -415,42 +415,45 @@ PyObject* DocumentObjectPy::getStatusString(PyObject *args) } } -PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) +PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) { PyObject *obj; short retType = 0; PyObject *pyMat = Py_None; PyObject *doTransform = Py_True; short depth = 0; - static char *kwlist[] = {"subname","retType","matrix","transform","depth", NULL}; + static char *kwlist[] = {"subname","retType","matrix","transform","depth", nullptr}; if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|hOOh", kwlist, &obj,&retType,&pyMat,&doTransform,&depth)) - return 0; + return nullptr; - if(retType<0 || retType>6) { + if (retType<0 || retType>6) { PyErr_SetString(PyExc_TypeError, "invalid retType, can only be integer 0~6"); - return 0; + return nullptr; } std::vector subs; bool single=true; if (PyUnicode_Check(obj)) { subs.push_back(PyUnicode_AsUTF8(obj)); - } else if (PySequence_Check(obj)) { + } + else if (PySequence_Check(obj)) { single=false; Py::Sequence shapeSeq(obj); for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) { PyObject* item = (*it).ptr(); if (PyUnicode_Check(item)) { - subs.push_back(PyUnicode_AsUTF8(item)); - }else{ + subs.push_back(PyUnicode_AsUTF8(item)); + } + else { PyErr_SetString(PyExc_TypeError, "non-string object in sequence"); - return 0; + return nullptr; } } - }else{ + } + else { PyErr_SetString(PyExc_TypeError, "subname must be either a string or sequence of string"); - return 0; + return nullptr; } bool transform = PyObject_IsTrue(doTransform); @@ -467,7 +470,7 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) if(pyMat!=Py_None) { if(!PyObject_TypeCheck(pyMat,&Base::MatrixPy::Type)) { PyErr_SetString(PyExc_TypeError, "expect argument 'matrix' to be of type Base.Matrix"); - return 0; + return nullptr; } mat = *static_cast(pyMat)->getMatrixPtr(); } @@ -477,9 +480,9 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) for(const auto &sub : subs) { ret.emplace_back(mat); auto &info = ret.back(); - PyObject *pyObj = 0; + PyObject *pyObj = nullptr; info.sobj = getDocumentObjectPtr()->getSubObject( - sub.c_str(),retType!=0&&retType!=2?0:&pyObj,&info.mat,transform,depth); + sub.c_str(),retType!=0&&retType!=2?nullptr:&pyObj,&info.mat,transform,depth); if(pyObj) info.pyObj = Py::Object(pyObj,true); if(info.sobj) @@ -547,7 +550,7 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) PyObject* DocumentObjectPy::getSubObjectList(PyObject *args) { const char *subname; if (!PyArg_ParseTuple(args, "s", &subname)) - return NULL; + return nullptr; Py::List res; PY_TRY { for(auto o : getDocumentObjectPtr()->getSubObjectList(subname)) @@ -559,7 +562,7 @@ PyObject* DocumentObjectPy::getSubObjectList(PyObject *args) { PyObject* DocumentObjectPy::getSubObjects(PyObject *args) { int reason = 0; if (!PyArg_ParseTuple(args, "|i", &reason)) - return NULL; + return nullptr; PY_TRY { auto names = getDocumentObjectPtr()->getSubObjects(reason); @@ -576,17 +579,17 @@ PyObject* DocumentObjectPy::getLinkedObject(PyObject *args, PyObject *keywds) PyObject *pyMat = Py_None; PyObject *transform = Py_True; short depth = 0; - static char *kwlist[] = {"recursive","matrix","transform","depth", NULL}; + static char *kwlist[] = {"recursive","matrix","transform","depth", nullptr}; if (!PyArg_ParseTupleAndKeywords(args, keywds, "|OOOh", kwlist, &recursive,&pyMat,&transform,&depth)) - return NULL; + return nullptr; Base::Matrix4D _mat; - Base::Matrix4D *mat = 0; + Base::Matrix4D *mat = nullptr; if(pyMat!=Py_None) { if(!PyObject_TypeCheck(pyMat,&Base::MatrixPy::Type)) { PyErr_SetString(PyExc_TypeError, "expect argument 'matrix' to be of type Base.Matrix"); - return 0; + return nullptr; } _mat = *static_cast(pyMat)->getMatrixPtr(); mat = &_mat; @@ -610,9 +613,9 @@ PyObject* DocumentObjectPy::getLinkedObject(PyObject *args, PyObject *keywds) PyObject* DocumentObjectPy::isElementVisible(PyObject *args) { - char *element = 0; + char *element = nullptr; if (!PyArg_ParseTuple(args, "s", &element)) - return NULL; + return nullptr; PY_TRY { return Py_BuildValue("h", getDocumentObjectPtr()->isElementVisible(element)); } PY_CATCH; @@ -620,10 +623,10 @@ PyObject* DocumentObjectPy::isElementVisible(PyObject *args) PyObject* DocumentObjectPy::setElementVisible(PyObject *args) { - char *element = 0; + char *element = nullptr; PyObject *visible = Py_True; if (!PyArg_ParseTuple(args, "s|O", &element,&visible)) - return NULL; + return nullptr; PY_TRY { return Py_BuildValue("h", getDocumentObjectPtr()->setElementVisible(element,PyObject_IsTrue(visible))); } PY_CATCH; @@ -632,7 +635,7 @@ PyObject* DocumentObjectPy::setElementVisible(PyObject *args) PyObject* DocumentObjectPy::hasChildElement(PyObject *args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; PY_TRY { return Py_BuildValue("O", getDocumentObjectPtr()->hasChildElement()?Py_True:Py_False); } PY_CATCH; @@ -641,7 +644,7 @@ PyObject* DocumentObjectPy::hasChildElement(PyObject *args) PyObject* DocumentObjectPy::getParentGroup(PyObject *args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; try { auto grp = GroupExtension::getGroupOfObject(getDocumentObjectPtr()); @@ -659,7 +662,7 @@ PyObject* DocumentObjectPy::getParentGroup(PyObject *args) PyObject* DocumentObjectPy::getParentGeoFeatureGroup(PyObject *args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; try { auto grp = GeoFeatureGroupExtension::getGroupOfObject(getDocumentObjectPtr()); @@ -688,7 +691,7 @@ PyObject* DocumentObjectPy::getPathsByOutList(PyObject *args) { PyObject* o; if (!PyArg_ParseTuple(args, "O!", &DocumentObjectPy::Type, &o)) - return NULL; + return nullptr; try { DocumentObject* target = static_cast @@ -722,7 +725,7 @@ PyObject *DocumentObjectPy::getCustomAttributes(const char* attr) const return prop->getPyObject(); else #endif - return 0; + return nullptr; } int DocumentObjectPy::setCustomAttributes(const char* attr, PyObject *obj) @@ -809,8 +812,8 @@ PyObject *DocumentObjectPy::resolve(PyObject *args) PY_TRY { std::string elementName; - const char *subElement = 0; - App::DocumentObject *parent = 0; + const char *subElement = nullptr; + App::DocumentObject *parent = nullptr; auto obj = getDocumentObjectPtr()->resolve(subname,&parent,&elementName,&subElement); Py::Tuple ret(4); @@ -857,7 +860,7 @@ PyObject *DocumentObjectPy::adjustRelativeLinks(PyObject *args) { PyObject *pyobj; PyObject *recursive = Py_True; if (!PyArg_ParseTuple(args, "O!|O",&DocumentObjectPy::Type,&pyobj,&recursive)) - return NULL; + return nullptr; PY_TRY { auto obj = static_cast(pyobj)->getDocumentObjectPtr(); auto inList = obj->getInListEx(true); diff --git a/src/App/DocumentObserver.cpp b/src/App/DocumentObserver.cpp index 1349a524f4..7f3bdb1216 100644 --- a/src/App/DocumentObserver.cpp +++ b/src/App/DocumentObserver.cpp @@ -218,7 +218,7 @@ std::string DocumentObjectT::getDocumentPython() const DocumentObject* DocumentObjectT::getObject() const { - DocumentObject* obj = 0; + DocumentObject* obj = nullptr; Document* doc = getDocument(); if (doc) { obj = doc->getObject(object.c_str()); @@ -260,7 +260,7 @@ Property *DocumentObjectT::getProperty() const { auto obj = getObject(); if(obj) return obj->getPropertyByName(property.c_str()); - return 0; + return nullptr; } // ----------------------------------------------------------------------------- @@ -379,7 +379,7 @@ App::DocumentObject *SubObjectT::getSubObject() const { auto obj = getObject(); if(obj) return obj->getSubObject(subname.c_str()); - return 0; + return nullptr; } std::string SubObjectT::getSubObjectPython(bool force) const { diff --git a/src/App/DocumentObserver.h b/src/App/DocumentObserver.h index c1070d6894..38f36a78e2 100644 --- a/src/App/DocumentObserver.h +++ b/src/App/DocumentObserver.h @@ -206,7 +206,7 @@ public: /** Return the old style sub-element name * @param index: if given, then return the element type, and extract the index */ - std::string getOldElementName(int *index=0) const; + std::string getOldElementName(int *index=nullptr) const; /// Return the sub-object DocumentObject *getSubObject() const; diff --git a/src/App/DocumentObserverPython.cpp b/src/App/DocumentObserverPython.cpp index dbd197484f..bc8a01a51a 100644 --- a/src/App/DocumentObserverPython.cpp +++ b/src/App/DocumentObserverPython.cpp @@ -43,7 +43,7 @@ void DocumentObserverPython::addObserver(const Py::Object& obj) void DocumentObserverPython::removeObserver(const Py::Object& obj) { - DocumentObserverPython* obs=0; + DocumentObserverPython* obs=nullptr; for (std::vector::iterator it = _instances.begin(); it != _instances.end(); ++it) { if ((*it)->inst == obj) { diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 455b86dfe1..ec02a6b4b6 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -75,7 +75,7 @@ PyObject* DocumentPy::saveAs(PyObject * args) { char* fn; if (!PyArg_ParseTuple(args, "et", "utf-8", &fn)) - return NULL; + return nullptr; std::string utf8Name = fn; PyMem_Free(fn); @@ -100,25 +100,25 @@ PyObject* DocumentPy::saveCopy(PyObject * args) PyObject* DocumentPy::load(PyObject * args) { - char* filename=0; + char* filename=nullptr; if (!PyArg_ParseTuple(args, "s", &filename)) - return NULL; + return nullptr; if (!filename || *filename == '\0') { PyErr_Format(PyExc_ValueError, "Path is empty"); - return NULL; + return nullptr; } getDocumentPtr()->FileName.setValue(filename); Base::FileInfo fi(filename); if (!fi.isReadable()) { PyErr_Format(PyExc_IOError, "No such file or directory: '%s'", filename); - return NULL; + return nullptr; } try { getDocumentPtr()->restore(); } catch (...) { PyErr_Format(PyExc_IOError, "Reading from file '%s' failed", filename); - return NULL; + return nullptr; } Py_Return; } @@ -188,7 +188,7 @@ PyObject* DocumentPy::mergeProject(PyObject * args) PyObject* DocumentPy::exportGraphviz(PyObject * args) { - char* fn=0; + char* fn=nullptr; if (!PyArg_ParseTuple(args, "|s",&fn)) return nullptr; if (fn) { @@ -207,14 +207,14 @@ PyObject* DocumentPy::exportGraphviz(PyObject * args) PyObject* DocumentPy::addObject(PyObject *args, PyObject *kwd) { - char *sType,*sName=0,*sViewType=0; - PyObject* obj=0; - PyObject* view=0; + char *sType,*sName=nullptr,*sViewType=nullptr; + PyObject* obj=nullptr; + PyObject* view=nullptr; PyObject *attach=Py_False; - static char *kwlist[] = {"type","name","objProxy","viewProxy","attach","viewType",NULL}; + static char *kwlist[] = {"type","name","objProxy","viewProxy","attach","viewType",nullptr}; if (!PyArg_ParseTupleAndKeywords(args,kwd,"s|sOOOs", kwlist, &sType,&sName,&obj,&view,&attach,&sViewType)) - return NULL; + return nullptr; DocumentObject *pcFtr = nullptr; @@ -528,7 +528,7 @@ PyObject* DocumentPy::recompute(PyObject * args) if (PyObject_IsTrue(checkCycle)) options = Document::DepNoCycle; - int objectCount = getDocumentPtr()->recompute(objs, PyObject_IsTrue(force), 0, options); + int objectCount = getDocumentPtr()->recompute(objs, PyObject_IsTrue(force), nullptr, options); // Document::recompute() hides possibly raised Python exceptions by its features // So, check if an error is set and return null if yes @@ -632,7 +632,7 @@ PyObject* DocumentPy::findObjects(PyObject *args, PyObject *kwds) } catch (const boost::regex_error& e) { PyErr_SetString(PyExc_RuntimeError, e.what()); - return 0; + return nullptr; } Py_ssize_t index=0; @@ -791,7 +791,7 @@ PyObject* DocumentPy::getTempFileName(PyObject *args) // delete the created file, we need only the name... fileName.deleteFile(); - PyObject *p = PyUnicode_DecodeUTF8(fileName.filePath().c_str(),fileName.filePath().size(),0); + PyObject *p = PyUnicode_DecodeUTF8(fileName.filePath().c_str(),fileName.filePath().size(),nullptr); if (!p) { throw Base::UnicodeError("UTF8 conversion failure at PropertyString::getPyObject()"); } @@ -808,7 +808,7 @@ PyObject *DocumentPy::getCustomAttributes(const char* attr) const App::Property* prop = getPropertyContainerPtr()->getPropertyByName(attr); if (prop) return nullptr; - if (this->ob_type->tp_dict == NULL) { + if (this->ob_type->tp_dict == nullptr) { if (PyType_Ready(this->ob_type) < 0) return nullptr; } @@ -817,7 +817,7 @@ PyObject *DocumentPy::getCustomAttributes(const char* attr) const return nullptr; // search for an object with this name DocumentObject* obj = getDocumentPtr()->getObject(attr); - return (obj ? obj->getPyObject() : 0); + return (obj ? obj->getPyObject() : nullptr); } int DocumentPy::setCustomAttributes(const char* attr, PyObject *) @@ -830,7 +830,7 @@ int DocumentPy::setCustomAttributes(const char* attr, PyObject *) App::Property* prop = getPropertyContainerPtr()->getPropertyByName(attr); if (prop) return 0; - if (this->ob_type->tp_dict == NULL) { + if (this->ob_type->tp_dict == nullptr) { if (PyType_Ready(this->ob_type) < 0) return 0; } @@ -858,11 +858,11 @@ PyObject* DocumentPy::getLinksTo(PyObject *args) return nullptr; PY_TRY { - DocumentObject *obj = 0; + DocumentObject *obj = nullptr; if (pyobj!=Py_None) { if (!PyObject_TypeCheck(pyobj,&DocumentObjectPy::Type)) { PyErr_SetString(PyExc_TypeError, "Expect the first argument of type document object"); - return 0; + return nullptr; } obj = static_cast(pyobj)->getDocumentObjectPtr(); } @@ -901,7 +901,7 @@ Py::List DocumentPy::getOutList(void) const PyObject *DocumentPy::getDependentDocuments(PyObject *args) { PyObject *sort = Py_True; if (!PyArg_ParseTuple(args, "|O", &sort)) - return 0; + return nullptr; PY_TRY { auto docs = getDocumentPtr()->getDependentDocuments(PyObject_IsTrue(sort)); Py::List ret; diff --git a/src/App/DynamicProperty.cpp b/src/App/DynamicProperty.cpp index 208c1cd3ad..635f8e85de 100644 --- a/src/App/DynamicProperty.cpp +++ b/src/App/DynamicProperty.cpp @@ -79,7 +79,7 @@ Property *DynamicProperty::getDynamicPropertyByName(const char* name) const auto it = index.find(name); if (it != index.end()) return it->property; - return 0; + return nullptr; } std::vector DynamicProperty::getDynamicPropertyNames() const @@ -118,7 +118,7 @@ const char* DynamicProperty::getPropertyGroup(const Property* prop) const auto it = index.find(const_cast(prop)); if(it!=index.end()) return it->group.c_str(); - return 0; + return nullptr; } const char* DynamicProperty::getPropertyGroup(const char *name) const @@ -127,7 +127,7 @@ const char* DynamicProperty::getPropertyGroup(const char *name) const auto it = index.find(name); if (it != index.end()) return it->group.c_str(); - return 0; + return nullptr; } const char* DynamicProperty::getPropertyDocumentation(const Property* prop) const @@ -136,7 +136,7 @@ const char* DynamicProperty::getPropertyDocumentation(const Property* prop) cons auto it = index.find(const_cast(prop)); if(it!=index.end()) return it->doc.c_str(); - return 0; + return nullptr; } const char* DynamicProperty::getPropertyDocumentation(const char *name) const @@ -145,7 +145,7 @@ const char* DynamicProperty::getPropertyDocumentation(const char *name) const auto it = index.find(name); if (it != index.end()) return it->doc.c_str(); - return 0; + return nullptr; } Property* DynamicProperty::addDynamicProperty(PropertyContainer &pc, const char* type, @@ -293,11 +293,11 @@ Property *DynamicProperty::restore(PropertyContainer &pc, const char *PropName, const char *TypeName, Base::XMLReader &reader) { if (!reader.hasAttribute("group")) - return 0; + return nullptr; short attribute = 0; bool readonly = false, hidden = false; - const char *group=0, *doc=0, *attr=0, *ro=0, *hide=0; + const char *group=nullptr, *doc=nullptr, *attr=nullptr, *ro=nullptr, *hide=nullptr; group = reader.getAttribute("group"); if (reader.hasAttribute("doc")) doc = reader.getAttribute("doc"); @@ -343,5 +343,5 @@ const char *DynamicProperty::getPropertyName(const Property *prop) const auto it = index.find(const_cast(prop)); if(it != index.end()) return it->getName(); - return 0; + return nullptr; } diff --git a/src/App/DynamicProperty.h b/src/App/DynamicProperty.h index 8a49f9a136..a292f74c8e 100644 --- a/src/App/DynamicProperty.h +++ b/src/App/DynamicProperty.h @@ -97,8 +97,8 @@ public: addDynamicProperty(..., ..., "Base","blah", Prop_None, true, true); @endcode */ - Property* addDynamicProperty(PropertyContainer &pc, const char* type, const char* name=0, const char* group=0, - const char* doc=0, short attr=0, bool ro=false, bool hidden=false); + Property* addDynamicProperty(PropertyContainer &pc, const char* type, const char* name=nullptr, const char* group=nullptr, + const char* doc=nullptr, short attr=0, bool ro=false, bool hidden=false); /** Add a pre-existing property * * The property is not treated as dynamic, and will not trigger signal. @@ -156,8 +156,8 @@ public: bool readonly; bool hidden; - PropData(Property *prop=0, std::string &&n=std::string(), const char *pn=0, - const char *g=0, const char *d=0, short a=0, bool ro=false, bool h=false) + PropData(Property *prop=nullptr, std::string &&n=std::string(), const char *pn=nullptr, + const char *g=nullptr, const char *d=nullptr, short a=0, bool ro=false, bool h=false) :property(prop),name(std::move(n)),pName(pn) ,group(g?g:""),doc(d?d:""),attr(a),readonly(ro),hidden(h) {} diff --git a/src/App/Enumeration.cpp b/src/App/Enumeration.cpp index dc4a73bbda..265a457789 100644 --- a/src/App/Enumeration.cpp +++ b/src/App/Enumeration.cpp @@ -32,12 +32,12 @@ using namespace App; Enumeration::Enumeration() - : _EnumArray(NULL), _ownEnumArray(false), _index(0), _maxVal(-1) + : _EnumArray(nullptr), _ownEnumArray(false), _index(0), _maxVal(-1) { } Enumeration::Enumeration(const Enumeration &other) - : _EnumArray(NULL), _ownEnumArray(false), _index(0), _maxVal(-1) + : _EnumArray(nullptr), _ownEnumArray(false), _index(0), _maxVal(-1) { if (other._ownEnumArray) { setEnums(other.getEnumVector()); @@ -59,7 +59,7 @@ Enumeration::Enumeration(const char *valStr) #else _EnumArray[0] = strdup(valStr); #endif - _EnumArray[1] = NULL; + _EnumArray[1] = nullptr; } Enumeration::Enumeration(const char **list, const char *valStr) @@ -72,7 +72,7 @@ Enumeration::Enumeration(const char **list, const char *valStr) Enumeration::~Enumeration() { if (_ownEnumArray) { - if (_EnumArray != NULL) { + if (_EnumArray != nullptr) { tearDown(); } } @@ -81,14 +81,14 @@ Enumeration::~Enumeration() void Enumeration::tearDown(void) { // Ugly... - for(char **plEnums = (char **)_EnumArray; *plEnums != NULL; ++plEnums) { + for(char **plEnums = (char **)_EnumArray; *plEnums != nullptr; ++plEnums) { // Delete C Strings first free(*plEnums); } delete [] _EnumArray; - _EnumArray = NULL; + _EnumArray = nullptr; _ownEnumArray = false; _maxVal = -1; } @@ -99,7 +99,7 @@ void Enumeration::setEnums(const char **plEnums) return; std::string oldValue; - bool preserve = (isValid() && plEnums != NULL); + bool preserve = (isValid() && plEnums != nullptr); if (preserve) { const char* str = getCStr(); if (str) @@ -157,7 +157,7 @@ void Enumeration::setEnums(const std::vector &values) #endif } - _EnumArray[i] = 0; // null termination + _EnumArray[i] = nullptr; // null termination // Other state variables _maxVal = static_cast(values.size() - 1); @@ -188,7 +188,7 @@ void Enumeration::setValue(const char *value) // search for the right entry while (1) { // end of list? set zero - if (*plEnums == NULL) { + if (*plEnums == nullptr) { _index = 0; break; } @@ -242,7 +242,7 @@ bool Enumeration::contains(const char *value) const // search for the right entry while (1) { // end of list? - if (*plEnums == NULL) + if (*plEnums == nullptr) return false; if (strcmp(*plEnums, value) == 0) return true; @@ -256,7 +256,7 @@ const char * Enumeration::getCStr(void) const //assert(_EnumArray); if (!isValid() || _index < 0 || _index > _maxVal) { - return NULL; + return nullptr; } return _EnumArray[_index]; @@ -281,7 +281,7 @@ std::vector Enumeration::getEnumVector(void) const const char **plEnums = _EnumArray; // end of list? - while (*plEnums != NULL) { + while (*plEnums != nullptr) { result.push_back(*plEnums); ++plEnums; } @@ -296,7 +296,7 @@ const char ** Enumeration::getEnums(void) const bool Enumeration::isValid(void) const { - return (_EnumArray != NULL && _index >= 0 && _index <= _maxVal); + return (_EnumArray != nullptr && _index >= 0 && _index <= _maxVal); } Enumeration & Enumeration::operator=(const Enumeration &other) @@ -333,7 +333,7 @@ bool Enumeration::operator==(const Enumeration &other) const bool Enumeration::operator==(const char *other) const { - if (getCStr() == NULL) { + if (getCStr() == nullptr) { return false; } @@ -342,7 +342,7 @@ bool Enumeration::operator==(const char *other) const void Enumeration::findMaxVal(void) { - if (_EnumArray == NULL) { + if (_EnumArray == nullptr) { _maxVal = -1; return; } @@ -352,7 +352,7 @@ void Enumeration::findMaxVal(void) // the NULL terminator doesn't belong to the range of // valid values int i = -1; - while (*(plEnums++) != NULL) { + while (*(plEnums++) != nullptr) { ++i; // very unlikely to have enums with more then 5000 entries! assert(i < 5000); diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index 37e27aaf55..54836181e1 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -441,7 +441,7 @@ static Py::Object _pyObjectFromAny(const App::any &value, const Expression *e) { namespace App { Py::Object pyObjectFromAny(const App::any &value) { - return _pyObjectFromAny(value,0); + return _pyObjectFromAny(value,nullptr); } App::any pyObjectToAny(Py::Object value, bool check) { @@ -489,7 +489,7 @@ bool pyToQuantity(Quantity &q, const Py::Object &pyobj) { } static inline Quantity pyToQuantity(const Py::Object &pyobj, - const Expression *e, const char *msg=0) + const Expression *e, const char *msg=nullptr) { Quantity q; if(!pyToQuantity(q,pyobj)) { @@ -664,7 +664,7 @@ Expression* expressionFromPy(const DocumentObject *owner, const Py::Object &valu // Expression::Component::Component(const std::string &n) :comp(ObjectIdentifier::SimpleComponent(n)) - ,e1(0) ,e2(0) ,e3(0) + ,e1(nullptr) ,e2(nullptr) ,e3(nullptr) {} Expression::Component::Component(Expression *_e1, Expression *_e2, Expression *_e3, bool isRange) @@ -676,14 +676,14 @@ Expression::Component::Component(Expression *_e1, Expression *_e2, Expression *_ Expression::Component::Component(const ObjectIdentifier::Component &comp) :comp(comp) - ,e1(0) ,e2(0) ,e3(0) + ,e1(nullptr) ,e2(nullptr) ,e3(nullptr) {} Expression::Component::Component(const Component &other) :comp(other.comp) - ,e1(other.e1?other.e1->copy():0) - ,e2(other.e2?other.e2->copy():0) - ,e3(other.e3?other.e3->copy():0) + ,e1(other.e1?other.e1->copy():nullptr) + ,e2(other.e2?other.e2->copy():nullptr) + ,e3(other.e3?other.e3->copy():nullptr) {} Expression::Component::~Component() @@ -989,7 +989,7 @@ public: ExpressionPtr Expression::importSubNames(const std::map &nameMap) const { if(!owner || !owner->getDocument()) - return 0; + return nullptr; ObjectIdentifier::SubNameMap subNameMap; for(auto &dep : getDeps(DepAll)) { for(auto &info : dep.second) { @@ -1011,7 +1011,7 @@ ExpressionPtr Expression::importSubNames(const std::map } } if(subNameMap.empty()) - return 0; + return nullptr; ImportSubNamesExpressionVisitor v(subNameMap); auto res = copy(); res->visit(v); @@ -1200,7 +1200,7 @@ void UnitExpression::setQuantity(const Quantity &_quantity) if(cache) { Base::PyGILStateLocker lock; Py::_XDECREF(cache); - cache = 0; + cache = nullptr; } } @@ -1218,7 +1218,7 @@ void UnitExpression::setUnit(const Quantity &_quantity) if(cache) { Base::PyGILStateLocker lock; Py::_XDECREF(cache); - cache = 0; + cache = nullptr; } } @@ -1967,11 +1967,11 @@ Py::Object FunctionExpression::evalAggregate( if (!p) continue; - if ((qp = freecad_dynamic_cast(p)) != 0) + if ((qp = freecad_dynamic_cast(p)) != nullptr) c->collect(qp->getQuantityValue()); - else if ((fp = freecad_dynamic_cast(p)) != 0) + else if ((fp = freecad_dynamic_cast(p)) != nullptr) c->collect(Quantity(fp->getValue())); - else if ((ip = freecad_dynamic_cast(p)) != 0) + else if ((ip = freecad_dynamic_cast(p)) != nullptr) c->collect(Quantity(ip->getValue())); else _EXPR_THROW("Invalid property type for aggregate.", owner); @@ -2849,7 +2849,7 @@ Expression *ConditionalExpression::simplify() const std::unique_ptr e(condition->simplify()); NumberExpression * v = freecad_dynamic_cast(e.get()); - if (v == 0) + if (v == nullptr) return new ConditionalExpression(owner, condition->simplify(), trueExpr->simplify(), falseExpr->simplify()); else { if (fabs(v->getValue()) > 0.5) @@ -3110,7 +3110,7 @@ void RangeExpression::_offsetCells(int rowOffset, int colOffset, ExpressionVisit //////////////////////////////////////////////////////////////////////////////////// -static Base::XMLReader *_Reader = 0; +static Base::XMLReader *_Reader = nullptr; ExpressionParser::ExpressionImporter::ExpressionImporter(Base::XMLReader &reader) { assert(!_Reader); _Reader = &reader; @@ -3118,7 +3118,7 @@ ExpressionParser::ExpressionImporter::ExpressionImporter(Base::XMLReader &reader ExpressionParser::ExpressionImporter::~ExpressionImporter() { assert(_Reader); - _Reader = 0; + _Reader = nullptr; } Base::XMLReader *ExpressionParser::ExpressionImporter::reader() { @@ -3163,7 +3163,7 @@ double num_change(char* yytext,char dez_delim,char grp_delim) temp[i] = '\0'; errno = 0; - ret_val = strtod( temp, NULL ); + ret_val = strtod( temp, nullptr ); if (ret_val == 0 && errno == ERANGE) throw Base::UnderflowError("Number underflow."); if (ret_val == HUGE_VAL || ret_val == -HUGE_VAL) @@ -3172,8 +3172,8 @@ double num_change(char* yytext,char dez_delim,char grp_delim) return ret_val; } -static Expression * ScanResult = 0; /**< The resulting expression after a successful parsing */ -static const App::DocumentObject * DocumentObject = 0; /**< The DocumentObject that will own the expression */ +static Expression * ScanResult = nullptr; /**< The resulting expression after a successful parsing */ +static const App::DocumentObject * DocumentObject = nullptr; /**< The DocumentObject that will own the expression */ static bool unitExpression = false; /**< True if the parsed string is a unit only */ static bool valueExpression = false; /**< True if the parsed string is a full expression */ static std::stack labels; /**< Label string primitive */ @@ -3216,7 +3216,7 @@ static void initParser(const App::DocumentObject *owner) using namespace App::ExpressionParser; - ScanResult = 0; + ScanResult = nullptr; App::ExpressionParser::DocumentObject = owner; labels = std::stack(); column = 0; @@ -3317,7 +3317,7 @@ Expression * App::ExpressionParser::parse(const App::DocumentObject *owner, cons if (result != 0) throw ParserError("Failed to parse expression."); - if (ScanResult == 0) + if (ScanResult == nullptr) throw ParserError("Unknown error in expression"); if (valueExpression) @@ -3325,7 +3325,7 @@ Expression * App::ExpressionParser::parse(const App::DocumentObject *owner, cons else { delete ScanResult; throw Expression::Exception("Expression can not evaluate to a value."); - return 0; + return nullptr; } } @@ -3345,7 +3345,7 @@ UnitExpression * ExpressionParser::parseUnit(const App::DocumentObject *owner, c if (result != 0) throw ParserError("Failed to parse expression."); - if (ScanResult == 0) + if (ScanResult == nullptr) throw ParserError("Unknown error in expression"); // Simplify expression @@ -3377,7 +3377,7 @@ UnitExpression * ExpressionParser::parseUnit(const App::DocumentObject *owner, c else { delete simplified; throw Expression::Exception("Expression is not a unit."); - return 0; + return nullptr; } } diff --git a/src/App/Expression.h b/src/App/Expression.h index f27e8259b7..2e45116b63 100644 --- a/src/App/Expression.h +++ b/src/App/Expression.h @@ -48,7 +48,7 @@ class Document; typedef std::unique_ptr ExpressionPtr; AppExport bool isAnyEqual(const App::any &v1, const App::any &v2); -AppExport Base::Quantity anyToQuantity(const App::any &value, const char *errmsg = 0); +AppExport Base::Quantity anyToQuantity(const App::any &value, const char *errmsg = nullptr); // Map of depending objects to a map of depending property name to the full referencing object identifier typedef std::map > > ExpressionDeps; @@ -60,7 +60,7 @@ public: virtual void aboutToChange() {} virtual int changed() const { return 0;} virtual void reset() {} - virtual App::PropertyLinkBase* getPropertyLink() {return 0;} + virtual App::PropertyLinkBase* getPropertyLink() {return nullptr;} protected: void getIdentifiers(Expression &e, std::map &); @@ -145,8 +145,8 @@ public: void getDeps(ExpressionDeps &deps, int option=DepNormal) const; ExpressionDeps getDeps(int option=DepNormal) const; - std::map getDepObjects(std::vector *labels=0) const; - void getDepObjects(std::map &, std::vector *labels=0) const; + std::map getDepObjects(std::vector *labels=nullptr) const; + void getDepObjects(std::map &, std::vector *labels=nullptr) const; ExpressionPtr importSubNames(const std::map &nameMap) const; @@ -175,8 +175,8 @@ public: typedef std::vector ComponentList; static Component *createComponent(const std::string &n); - static Component *createComponent(Expression *e1, Expression *e2=0, - Expression *e3=0, bool isRange=false); + static Component *createComponent(Expression *e1, Expression *e2=nullptr, + Expression *e3=nullptr, bool isRange=false); bool hasComponent() const {return !components.empty();} diff --git a/src/App/ExpressionParser.h b/src/App/ExpressionParser.h index 292ed2172f..72f4254ae6 100644 --- a/src/App/ExpressionParser.h +++ b/src/App/ExpressionParser.h @@ -71,7 +71,7 @@ struct AppExport Expression::Component { class AppExport UnitExpression : public Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - UnitExpression(const App::DocumentObject *_owner = 0, const Base::Quantity & _quantity = Base::Quantity(), const std::string & _unitStr = std::string()); + UnitExpression(const App::DocumentObject *_owner = nullptr, const Base::Quantity & _quantity = Base::Quantity(), const std::string & _unitStr = std::string()); ~UnitExpression(); @@ -97,7 +97,7 @@ protected: virtual Py::Object _getPyValue() const override; protected: - mutable PyObject *cache = 0; + mutable PyObject *cache = nullptr; private: Base::Quantity quantity; @@ -111,13 +111,13 @@ private: class AppExport NumberExpression : public UnitExpression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - NumberExpression(const App::DocumentObject *_owner = 0, const Base::Quantity & quantity = Base::Quantity()); + NumberExpression(const App::DocumentObject *_owner = nullptr, const Base::Quantity & quantity = Base::Quantity()); virtual Expression * simplify() const override; void negate(); - bool isInteger(long *v=0) const; + bool isInteger(long *v=nullptr) const; protected: virtual Expression * _copy() const override; @@ -127,7 +127,7 @@ protected: class AppExport ConstantExpression : public NumberExpression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - ConstantExpression(const App::DocumentObject *_owner = 0, + ConstantExpression(const App::DocumentObject *_owner = nullptr, const char *_name = "", const Base::Quantity &_quantity = Base::Quantity()); @@ -170,7 +170,7 @@ public: NEG, POS }; - OperatorExpression(const App::DocumentObject *_owner = 0, Expression * _left = 0, Operator _op = NONE, Expression * _right = 0); + OperatorExpression(const App::DocumentObject *_owner = nullptr, Expression * _left = nullptr, Operator _op = NONE, Expression * _right = nullptr); virtual ~OperatorExpression(); @@ -209,7 +209,7 @@ protected: class AppExport ConditionalExpression : public Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - ConditionalExpression(const App::DocumentObject *_owner = 0, Expression * _condition = 0,Expression * _trueExpr = 0, Expression * _falseExpr = 0); + ConditionalExpression(const App::DocumentObject *_owner = nullptr, Expression * _condition = nullptr,Expression * _trueExpr = nullptr, Expression * _falseExpr = nullptr); virtual ~ConditionalExpression(); @@ -290,7 +290,7 @@ public: LAST, }; - FunctionExpression(const App::DocumentObject *_owner = 0, Function _f = NONE, + FunctionExpression(const App::DocumentObject *_owner = nullptr, Function _f = NONE, std::string &&name = std::string(), std::vector _args = std::vector()); virtual ~FunctionExpression(); @@ -327,7 +327,7 @@ protected: class AppExport VariableExpression : public UnitExpression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - VariableExpression(const App::DocumentObject *_owner = 0, const ObjectIdentifier& _var = ObjectIdentifier()); + VariableExpression(const App::DocumentObject *_owner = nullptr, const ObjectIdentifier& _var = ObjectIdentifier()); ~VariableExpression(); @@ -375,7 +375,7 @@ class AppExport PyObjectExpression : public Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - PyObjectExpression(const App::DocumentObject *_owner=0, PyObject *pyobj=0, bool owned=false) + PyObjectExpression(const App::DocumentObject *_owner=nullptr, PyObject *pyobj=nullptr, bool owned=false) :Expression(_owner) { setPyValue(pyobj,owned); @@ -393,7 +393,7 @@ protected: virtual Py::Object _getPyValue() const override; protected: - PyObject *pyObj = 0; + PyObject *pyObj = nullptr; }; /** @@ -404,7 +404,7 @@ protected: class AppExport StringExpression : public Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - StringExpression(const App::DocumentObject *_owner = 0, const std::string & _text = std::string()); + StringExpression(const App::DocumentObject *_owner = nullptr, const std::string & _text = std::string()); ~StringExpression(); virtual Expression * simplify() const override; @@ -418,13 +418,13 @@ protected: private: std::string text; /**< Text string */ - mutable PyObject *cache = 0; + mutable PyObject *cache = nullptr; }; class AppExport RangeExpression : public App::Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - RangeExpression(const App::DocumentObject * _owner = 0, const std::string & begin = std::string(), const std::string & end = std::string()); + RangeExpression(const App::DocumentObject * _owner = nullptr, const std::string & begin = std::string(), const std::string & end = std::string()); virtual ~RangeExpression() { } @@ -492,7 +492,7 @@ public: std::string string; std::pair func; ObjectIdentifier::String string_or_identifier; - semantic_type() : component(0), expr(0), ivalue(0), fvalue(0) + semantic_type() : component(nullptr), expr(nullptr), ivalue(0), fvalue(0) , func({FunctionExpression::NONE, std::string()}) {} }; diff --git a/src/App/ExpressionVisitors.h b/src/App/ExpressionVisitors.h index 6b9949ef92..af1ad9d2b2 100644 --- a/src/App/ExpressionVisitors.h +++ b/src/App/ExpressionVisitors.h @@ -55,7 +55,7 @@ private: template class UpdateElementReferenceExpressionVisitor : public ExpressionModifier

{ public: - UpdateElementReferenceExpressionVisitor(P & _prop, App::DocumentObject *feature=0, bool reverse=false) + UpdateElementReferenceExpressionVisitor(P & _prop, App::DocumentObject *feature=nullptr, bool reverse=false) : ExpressionModifier

(_prop),feature(feature),reverse(reverse) { } diff --git a/src/App/ExtensionContainer.cpp b/src/App/ExtensionContainer.cpp index d3e233b48f..db26f4b359 100644 --- a/src/App/ExtensionContainer.cpp +++ b/src/App/ExtensionContainer.cpp @@ -102,7 +102,7 @@ Extension* ExtensionContainer::getExtension(Base::Type t, bool derived, bool no_ if(entry.first.isDerivedFrom(t)) return entry.second; } - if(no_except) return 0; + if(no_except) return nullptr; //if we arrive here we don't have anything matching throw Base::TypeError("ExtensionContainer::getExtension: No extension of given type available"); } @@ -110,7 +110,7 @@ Extension* ExtensionContainer::getExtension(Base::Type t, bool derived, bool no_ return result->second; } else { - if(no_except) return 0; + if(no_except) return nullptr; //if we arrive here we don't have anything matching throw Base::TypeError("ExtensionContainer::getExtension: No extension of given type available"); } @@ -202,77 +202,77 @@ short int ExtensionContainer::getPropertyType(const char* name) const { const char* ExtensionContainer::getPropertyName(const Property* prop) const { const char* res = App::PropertyContainer::getPropertyName(prop); - if(res != 0) + if(res != nullptr) return res; for(auto entry : _extensions) { res = entry.second->extensionGetPropertyName(prop); - if(res != 0) + if(res != nullptr) return res; } - return 0; + return nullptr; } const char* ExtensionContainer::getPropertyGroup(const Property* prop) const { const char* res = App::PropertyContainer::getPropertyGroup(prop); - if(res != 0) + if(res != nullptr) return res; for(auto entry : _extensions) { res = entry.second->extensionGetPropertyGroup(prop); - if(res != 0) + if(res != nullptr) return res; } - return 0; + return nullptr; } const char* ExtensionContainer::getPropertyGroup(const char* name) const { const char* res = App::PropertyContainer::getPropertyGroup(name); - if(res != 0) + if(res != nullptr) return res; for(auto entry : _extensions) { res = entry.second->extensionGetPropertyGroup(name); - if(res != 0) + if(res != nullptr) return res; } - return 0; + return nullptr; } const char* ExtensionContainer::getPropertyDocumentation(const Property* prop) const { const char* res = App::PropertyContainer::getPropertyDocumentation(prop); - if(res != 0) + if(res != nullptr) return res; for(auto entry : _extensions) { res = entry.second->extensionGetPropertyDocumentation(prop); - if(res != 0) + if(res != nullptr) return res; } - return 0; + return nullptr; } const char* ExtensionContainer::getPropertyDocumentation(const char* name) const { const char* res = App::PropertyContainer::getPropertyDocumentation(name); - if(res != 0) + if(res != nullptr) return res; for(auto entry : _extensions) { res = entry.second->extensionGetPropertyDocumentation(name); - if(res != 0) + if(res != nullptr) return res; } - return 0; + return nullptr; } void ExtensionContainer::onChanged(const Property* prop) { diff --git a/src/App/ExtensionContainerPyImp.cpp b/src/App/ExtensionContainerPyImp.cpp index 77e8d174f7..a048731032 100644 --- a/src/App/ExtensionContainerPyImp.cpp +++ b/src/App/ExtensionContainerPyImp.cpp @@ -43,7 +43,7 @@ std::string ExtensionContainerPy::representation(void) const int ExtensionContainerPy::initialization() { - if (this->ob_type->tp_dict == NULL) { + if (this->ob_type->tp_dict == nullptr) { if (PyType_Ready(this->ob_type) < 0) return 0; } @@ -61,7 +61,7 @@ int ExtensionContainerPy::initialization() { // make sure to do the initialization only once if (meth->ml_name) { PyObject* item = PyDict_GetItemString(dict, meth->ml_name); - if (item == NULL) { + if (item == nullptr) { // Note: this adds the methods to the type object to make sure // it appears in the call tips. The function will not be bound // to an instance @@ -69,7 +69,7 @@ int ExtensionContainerPy::initialization() { while (meth->ml_name) { PyObject *func; func = PyCFunction_New(meth, 0); - if (func == NULL) + if (func == nullptr) break; if (PyDict_SetItemString(dict, meth->ml_name, func) < 0) break; @@ -100,7 +100,7 @@ int ExtensionContainerPy::finalization() { PyObject* ExtensionContainerPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper { // create a new instance of @self.export.Name@ and the Twin object - return 0; + return nullptr; } // constructor method @@ -139,7 +139,7 @@ PyObject *ExtensionContainerPy::getCustomAttributes(const char* attr) const // Py_FindMethod is successful then a PyCFunction_New instance is returned // with the PyObject pointer of the extension to make sure the method will // be called for the correct instance. - PyObject *func = 0; + PyObject *func = nullptr; ExtensionContainer::ExtensionIterator it = this->getExtensionContainerPtr()->extensionBegin(); for (; it != this->getExtensionContainerPtr()->extensionEnd(); ++it) { // The PyTypeObject is shared by all instances of this type and therefore @@ -157,7 +157,7 @@ PyObject *ExtensionContainerPy::getCustomAttributes(const char* attr) const break; // otherwise cleanup the result again Py_DECREF(func); - func = 0; + func = nullptr; } PyErr_Clear(); // clear the error set inside Py_FindMethod } @@ -199,7 +199,7 @@ PyObject* ExtensionContainerPy::addExtension(PyObject *args) { char *typeId; PyObject* proxy = nullptr; if (!PyArg_ParseTuple(args, "s|O", &typeId, &proxy)) - return NULL; + return nullptr; if (proxy) { PyErr_SetString(PyExc_DeprecationWarning, "Second argument is deprecated. It is ignored and will be removed in future versions. " @@ -238,7 +238,7 @@ PyObject* ExtensionContainerPy::addExtension(PyObject *args) { // make sure to do the initialization only once if (meth->ml_name) { PyObject* item = PyDict_GetItemString(dict, meth->ml_name); - if (item == NULL) { + if (item == nullptr) { // Note: this adds the methods to the type object to make sure // it appears in the call tips. The function will not be bound // to an instance @@ -246,7 +246,7 @@ PyObject* ExtensionContainerPy::addExtension(PyObject *args) { while (meth->ml_name) { PyObject *func; func = PyCFunction_New(meth, 0); - if (func == NULL) + if (func == nullptr) break; if (PyDict_SetItemString(dict, meth->ml_name, func) < 0) break; diff --git a/src/App/ExtensionPyImp.cpp b/src/App/ExtensionPyImp.cpp index 5ce2d58c8f..059e7ea2a1 100644 --- a/src/App/ExtensionPyImp.cpp +++ b/src/App/ExtensionPyImp.cpp @@ -39,7 +39,7 @@ std::string ExtensionPy::representation(void) const PyObject *ExtensionPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int ExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject * /*obj*/) diff --git a/src/App/FeaturePython.cpp b/src/App/FeaturePython.cpp index f479cced2f..0fd6c3a4d2 100644 --- a/src/App/FeaturePython.cpp +++ b/src/App/FeaturePython.cpp @@ -136,7 +136,7 @@ void FeaturePythonImp::onBeforeChange(const Property* prop) Base::PyGILStateLocker lock; try { const char *prop_name = object->getPropertyName(prop); - if(prop_name == 0) + if(prop_name == nullptr) return; if (has__object__) { Py::Tuple args(1); @@ -190,7 +190,7 @@ void FeaturePythonImp::onChanged(const Property* prop) Base::PyGILStateLocker lock; try { const char *prop_name = object->getPropertyName(prop); - if(prop_name == 0) + if(prop_name == nullptr) return; if (has__object__) { Py::Tuple args(1); @@ -251,7 +251,7 @@ bool FeaturePythonImp::getSubObject(DocumentObject *&ret, const char *subname, Py::Object res(Base::pyCall(py_getSubObject.ptr(),args.ptr())); if(res.isNone()) { - ret = 0; + ret = nullptr; return true; } if(!res.isTrue()) @@ -275,7 +275,7 @@ bool FeaturePythonImp::getSubObject(DocumentObject *&ret, const char *subname, *pyObj = Py::new_reference_to(Py::None()); } if(seq.getItem(0).isNone()) - ret = 0; + ret = nullptr; else ret = static_cast(seq.getItem(0).ptr())->getDocumentObjectPtr(); return true; @@ -287,7 +287,7 @@ bool FeaturePythonImp::getSubObject(DocumentObject *&ret, const char *subname, } Base::PyException e; // extract the Python error text e.ReportException(); - ret = 0; + ret = nullptr; return true; } } @@ -369,7 +369,7 @@ bool FeaturePythonImp::getLinkedObject(DocumentObject *&ret, bool recurse, } Base::PyException e; // extract the Python error text e.ReportException(); - ret = 0; + ret = nullptr; return true; } } diff --git a/src/App/FeaturePython.h b/src/App/FeaturePython.h index da21ba4418..59fa6db51f 100644 --- a/src/App/FeaturePython.h +++ b/src/App/FeaturePython.h @@ -213,7 +213,7 @@ public: virtual App::DocumentObject *getSubObject(const char *subname, PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const override { - App::DocumentObject *ret = 0; + App::DocumentObject *ret = nullptr; if(imp->getSubObject(ret,subname,pyObj,mat,transform,depth)) return ret; return FeatureT::getSubObject(subname,pyObj,mat,transform,depth); @@ -229,7 +229,7 @@ public: virtual App::DocumentObject *getLinkedObject(bool recurse, Base::Matrix4D *mat, bool transform, int depth) const override { - App::DocumentObject *ret = 0; + App::DocumentObject *ret = nullptr; if(imp->getLinkedObject(ret,recurse,mat,transform,depth)) return ret; return FeatureT::getLinkedObject(recurse,mat,transform,depth); diff --git a/src/App/FeaturePythonPyImp.inl b/src/App/FeaturePythonPyImp.inl index 2d518cb7d3..6a93fa98ea 100644 --- a/src/App/FeaturePythonPyImp.inl +++ b/src/App/FeaturePythonPyImp.inl @@ -33,51 +33,51 @@ PyTypeObject FeaturePythonPyT::Type = { 0, /*tp_itemsize*/ /* methods */ FeaturePyT::PyDestructor, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call */ - 0, /*tp_str */ + nullptr, /*tp_print*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ + nullptr, /*tp_repr*/ + nullptr, /*tp_as_number*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ + nullptr, /*tp_hash*/ + nullptr, /*tp_call */ + nullptr, /*tp_str */ FeaturePyT::__getattro, /*tp_getattro*/ __setattro, /*tp_setattro*/ /* --- Functions to access object as input/output buffer ---------*/ - 0, /* tp_as_buffer */ + nullptr, /* tp_as_buffer */ /* --- Flags to define presence of optional/expanded features */ Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT, /*tp_flags */ "This is the father of all Feature classes", /*tp_doc */ - 0, /*tp_traverse */ - 0, /*tp_clear */ - 0, /*tp_richcompare */ + nullptr, /*tp_traverse */ + nullptr, /*tp_clear */ + nullptr, /*tp_richcompare */ 0, /*tp_weaklistoffset */ - 0, /*tp_iter */ - 0, /*tp_iternext */ - 0, /*tp_methods */ - 0, /*tp_members */ - 0, /*tp_getset */ + nullptr, /*tp_iter */ + nullptr, /*tp_iternext */ + nullptr, /*tp_methods */ + nullptr, /*tp_members */ + nullptr, /*tp_getset */ &FeaturePyT::Type, /*tp_base */ - 0, /*tp_dict */ - 0, /*tp_descr_get */ - 0, /*tp_descr_set */ + nullptr, /*tp_dict */ + nullptr, /*tp_descr_get */ + nullptr, /*tp_descr_set */ 0, /*tp_dictoffset */ FeaturePyT::__PyInit, /*tp_init */ - 0, /*tp_alloc */ - 0, /*tp_new */ - 0, /*tp_free Low-level free-memory routine */ - 0, /*tp_is_gc For PyObject_IS_GC */ - 0, /*tp_bases */ - 0, /*tp_mro method resolution order */ - 0, /*tp_cache */ - 0, /*tp_subclasses */ - 0, /*tp_weaklist */ - 0, /*tp_del */ + nullptr, /*tp_alloc */ + nullptr, /*tp_new */ + nullptr, /*tp_free Low-level free-memory routine */ + nullptr, /*tp_is_gc For PyObject_IS_GC */ + nullptr, /*tp_bases */ + nullptr, /*tp_mro method resolution order */ + nullptr, /*tp_cache */ + nullptr, /*tp_subclasses */ + nullptr, /*tp_weaklist */ + nullptr, /*tp_del */ 0 /*tp_version_tag */ - ,0 /*tp_finalize */ + ,nullptr /*tp_finalize */ #if PY_VERSION_HEX >= 0x03080000 ,0 /*tp_vectorcall */ #endif @@ -164,9 +164,9 @@ PyObject *FeaturePythonPyT::_getattr(const char *attr) // Return the default dict PyTypeObject *tp = this->ob_type; // register type if needed - if (tp->tp_dict == NULL) { + if (tp->tp_dict == nullptr) { if (PyType_Ready(tp) < 0) - return 0; + return nullptr; } PyObject* dict = FeaturePyT::_getattr(attr); @@ -180,7 +180,7 @@ PyObject *FeaturePythonPyT::_getattr(const char *attr) } // find the attribute in the dict - PyObject *dict_item = NULL; + PyObject *dict_item = nullptr; dict_item = PyDict_GetItemString(dict_methods, attr); if (dict_item) { Py_INCREF(dict_item); diff --git a/src/App/FeatureTest.cpp b/src/App/FeatureTest.cpp index a7aba4e6bf..d8fb8631e0 100644 --- a/src/App/FeatureTest.cpp +++ b/src/App/FeatureTest.cpp @@ -39,7 +39,7 @@ using namespace App; PROPERTY_SOURCE(App::FeatureTest, App::DocumentObject) -const char* enums[]= {"Zero","One","Two","Three","Four",NULL}; +const char* enums[]= {"Zero","One","Two","Three","Four",nullptr}; const PropertyIntegerConstraint::Constraints intPercent = {0,100,1}; const PropertyFloatConstraint::Constraints floatPercent = {0.0,100.0,1.0}; @@ -74,10 +74,10 @@ FeatureTest::FeatureTest() ADD_PROPERTY(IntegerList,(4711) ); ADD_PROPERTY(FloatList ,(47.11f) ); - ADD_PROPERTY(Link ,(0)); - ADD_PROPERTY(LinkSub ,(0)); - ADD_PROPERTY(LinkList ,(0)); - ADD_PROPERTY(LinkSubList,(0)); + ADD_PROPERTY(Link ,(nullptr)); + ADD_PROPERTY(LinkSub ,(nullptr)); + ADD_PROPERTY(LinkList ,(nullptr)); + ADD_PROPERTY(LinkSubList,(nullptr)); ADD_PROPERTY(Vector ,(1.0,2.0,3.0)); ADD_PROPERTY(VectorList,(3.0,2.0,1.0)); @@ -86,9 +86,9 @@ FeatureTest::FeatureTest() // properties for recompute testing static const char* group = "Feature Test"; - ADD_PROPERTY_TYPE(Source1 ,(0),group,Prop_None,"Source for testing links"); - ADD_PROPERTY_TYPE(Source2 ,(0),group,Prop_None,"Source for testing links"); - ADD_PROPERTY_TYPE(SourceN ,(0),group,Prop_None,"Source for testing links"); + ADD_PROPERTY_TYPE(Source1 ,(nullptr),group,Prop_None,"Source for testing links"); + ADD_PROPERTY_TYPE(Source2 ,(nullptr),group,Prop_None,"Source for testing links"); + ADD_PROPERTY_TYPE(SourceN ,(nullptr),group,Prop_None,"Source for testing links"); ADD_PROPERTY_TYPE(ExecResult ,("empty"),group,Prop_None,"Result of the execution"); ADD_PROPERTY_TYPE(ExceptionType ,(0),group,Prop_None,"The type of exception the execution method throws"); ADD_PROPERTY_TYPE(ExecCount ,(0),group,Prop_None,"Number of executions"); @@ -150,7 +150,7 @@ doc.recompute() obj.ExceptionType=6 # float division by zero doc.recompute() */ - int *i=0,j; + int *i=nullptr,j; float f; void *s; std::string t; @@ -194,5 +194,5 @@ DocumentObjectExecReturn *FeatureTestException::execute(void) //ExceptionType; throw Base::RuntimeError("FeatureTestException::execute(): Testexception ;-)"); - return 0; + return nullptr; } diff --git a/src/App/GeoFeature.cpp b/src/App/GeoFeature.cpp index c5030a5ed4..51a46511ab 100644 --- a/src/App/GeoFeature.cpp +++ b/src/App/GeoFeature.cpp @@ -99,20 +99,20 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn const char **_element, GeoFeature **geoFeature) { if(!obj || !obj->getNameInDocument()) - return 0; + return nullptr; if(!subname) subname = ""; const char *element = Data::ComplexGeoData::findElementName(subname); if(_element) *_element = element; auto sobj = obj->getSubObject(subname); if(!sobj) - return 0; + return nullptr; obj = sobj->getLinkedObject(true); auto geo = dynamic_cast(obj); if(geoFeature) *geoFeature = geo; if(!obj || (filter && obj!=filter)) - return 0; + return nullptr; if(!element || !element[0]) { if(append) elementName.second = Data::ComplexGeoData::oldElementName(subname); diff --git a/src/App/GeoFeature.h b/src/App/GeoFeature.h index bbc35454dc..c9d79dda58 100644 --- a/src/App/GeoFeature.h +++ b/src/App/GeoFeature.h @@ -105,7 +105,7 @@ public: static DocumentObject *resolveElement(App::DocumentObject *obj, const char *subname, std::pair &elementName, bool append=false, ElementNameType type=Normal, - const DocumentObject *filter=0,const char **element=0, GeoFeature **geo=0); + const DocumentObject *filter=nullptr,const char **element=nullptr, GeoFeature **geo=nullptr); /** * @brief Calculates the placement in the global reference coordinate system diff --git a/src/App/GeoFeatureGroupExtension.cpp b/src/App/GeoFeatureGroupExtension.cpp index 1dfb23a971..22ec309c39 100644 --- a/src/App/GeoFeatureGroupExtension.cpp +++ b/src/App/GeoFeatureGroupExtension.cpp @@ -351,7 +351,7 @@ void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* ob bool GeoFeatureGroupExtension::extensionGetSubObject(DocumentObject *&ret, const char *subname, PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const { - ret = 0; + ret = nullptr; const char *dot; if(!subname || *subname==0) { auto obj = dynamic_cast(getExtendedContainer()); @@ -389,7 +389,7 @@ bool GeoFeatureGroupExtension::extensionGetSubObject(DocumentObject *&ret, const // const char *next = strchr(dot,'.'); if(next) { - App::DocumentObject *nret=0; + App::DocumentObject *nret=nullptr; extensionGetSubObject(nret,dot,pyObj,mat,transform,depth+1); if(nret) { ret = nret; diff --git a/src/App/GeoFeatureGroupExtensionPyImp.cpp b/src/App/GeoFeatureGroupExtensionPyImp.cpp index 9261bb550f..7d0dde7432 100644 --- a/src/App/GeoFeatureGroupExtensionPyImp.cpp +++ b/src/App/GeoFeatureGroupExtensionPyImp.cpp @@ -39,7 +39,7 @@ std::string GeoFeatureGroupExtensionPy::representation(void) const PyObject *GeoFeatureGroupExtensionPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int GeoFeatureGroupExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) diff --git a/src/App/GeoFeaturePyImp.cpp b/src/App/GeoFeaturePyImp.cpp index 70cff24361..8fe282131d 100644 --- a/src/App/GeoFeaturePyImp.cpp +++ b/src/App/GeoFeaturePyImp.cpp @@ -40,13 +40,13 @@ std::string GeoFeaturePy::representation(void) const PyObject* GeoFeaturePy::getPaths(PyObject * /*args*/) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } PyObject* GeoFeaturePy::getGlobalPlacement(PyObject * args) { if (!PyArg_ParseTuple(args, "")) - return 0; + return nullptr; try { Base::Placement p = static_cast(getDocumentObjectPtr())->globalPlacement(); @@ -86,7 +86,7 @@ PyObject* GeoFeaturePy::getPropertyOfGeometry(PyObject * args) PyObject *GeoFeaturePy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int GeoFeaturePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) diff --git a/src/App/GroupExtension.cpp b/src/App/GroupExtension.cpp index 551471c3d5..2b70446f0b 100644 --- a/src/App/GroupExtension.cpp +++ b/src/App/GroupExtension.cpp @@ -46,7 +46,7 @@ GroupExtension::GroupExtension() { initExtensionType(GroupExtension::getExtensionClassTypeId()); - EXTENSION_ADD_PROPERTY_TYPE(Group,(0),"Base",(App::PropertyType)(Prop_None),"List of referenced objects"); + EXTENSION_ADD_PROPERTY_TYPE(Group,(nullptr),"Base",(App::PropertyType)(Prop_None),"List of referenced objects"); EXTENSION_ADD_PROPERTY_TYPE(_GroupTouched, (false), "Base", PropertyType(Prop_Hidden|Prop_Transient),0); @@ -189,7 +189,7 @@ DocumentObject *GroupExtension::getObject(const char *Name) const DocumentObject* obj = getExtendedObject()->getDocument()->getObject(Name); if (obj && hasObject(obj)) return obj; - return 0; + return nullptr; } bool GroupExtension::hasObject(const DocumentObject* obj, bool recursive) const diff --git a/src/App/GroupExtensionPyImp.cpp b/src/App/GroupExtensionPyImp.cpp index f429ea683f..98e37b8ce0 100644 --- a/src/App/GroupExtensionPyImp.cpp +++ b/src/App/GroupExtensionPyImp.cpp @@ -41,7 +41,7 @@ std::string GroupExtensionPy::representation(void) const PyObject* GroupExtensionPy::newObject(PyObject *args) { - char *sType,*sName=0; + char *sType,*sName=nullptr; if (!PyArg_ParseTuple(args, "s|s", &sType,&sName)) return nullptr; @@ -256,7 +256,7 @@ PyObject* GroupExtensionPy::getObject(PyObject *args) PyObject* GroupExtensionPy::hasObject(PyObject *args) { PyObject *object; - PyObject *recursivePy = 0; + PyObject *recursivePy = nullptr; int recursive = 0; if (!PyArg_ParseTuple(args, "O!|O", &(DocumentObjectPy::Type), &object, &recursivePy)) return nullptr; @@ -285,7 +285,7 @@ PyObject* GroupExtensionPy::hasObject(PyObject *args) PyObject *GroupExtensionPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int GroupExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) diff --git a/src/App/Link.cpp b/src/App/Link.cpp index 48f1c96a1a..a7964f88c6 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -58,7 +58,7 @@ LinkBaseExtension::LinkBaseExtension(void) _ChildCache.setScope(LinkScope::Global); EXTENSION_ADD_PROPERTY_TYPE(_LinkOwner, (0), " Link", PropertyType(Prop_Hidden|Prop_Output),0); - props.resize(PropMax,0); + props.resize(PropMax,nullptr); } LinkBaseExtension::~LinkBaseExtension() @@ -94,14 +94,14 @@ const LinkBaseExtension::PropInfoMap &LinkBaseExtension::getPropertyInfoMap() co Property *LinkBaseExtension::getProperty(int idx) { if(idx>=0 && idx<(int)props.size()) return props[idx]; - return 0; + return nullptr; } Property *LinkBaseExtension::getProperty(const char *name) { const auto &info = getPropertyInfoMap(); auto it = info.find(name); if(it == info.end()) - return 0; + return nullptr; return getProperty(it->second.index); } @@ -112,7 +112,7 @@ void LinkBaseExtension::setProperty(int idx, Property *prop) { if(props[idx]) { props[idx]->setStatus(Property::LockDynamic,false); - props[idx] = 0; + props[idx] = nullptr; } if(!prop) return; @@ -129,14 +129,14 @@ void LinkBaseExtension::setProperty(int idx, Property *prop) { switch(idx) { case PropLinkMode: { - static const char *linkModeEnums[] = {"None","Auto Delete","Auto Link","Auto Unlink",0}; + static const char *linkModeEnums[] = {"None","Auto Delete","Auto Link","Auto Unlink",nullptr}; auto propLinkMode = freecad_dynamic_cast(prop); if(!propLinkMode->getEnums()) propLinkMode->setEnums(linkModeEnums); break; } case PropLinkCopyOnChange: { - static const char *enums[] = {"Disabled","Enabled","Owned",0}; + static const char *enums[] = {"Disabled","Enabled","Owned",nullptr}; auto propEnum = freecad_dynamic_cast(prop); if(!propEnum->getEnums()) propEnum->setEnums(enums); @@ -162,7 +162,7 @@ void LinkBaseExtension::setProperty(int idx, Property *prop) { // LinkedObject property), because it is for holding array elements. if(getElementListProperty()) getElementListProperty()->setStatus( - Property::Immutable,getLinkedObjectProperty()!=0); + Property::Immutable,getLinkedObjectProperty()!=nullptr); break; case PropVisibilityList: getVisibilityListProperty()->setStatus(Property::Immutable,true); @@ -216,7 +216,7 @@ App::DocumentObjectExecReturn *LinkBaseExtension::extensionExecute(void) { } } - PropertyPythonObject *proxy = 0; + PropertyPythonObject *proxy = nullptr; if(getLinkExecuteProperty() && !boost::iequals(getLinkExecuteValue(), "none") && (!_LinkOwner.getValue() @@ -327,7 +327,7 @@ bool LinkBaseExtension::setupCopyOnChange(DocumentObject *parent, DocumentObject auto p = parent->getPropertyByName(prop->getName()); if(p) { if(p->getContainer()!=parent) - p = 0; + p = nullptr; else { const char* otherGroupName = p->getGroup(); if(!otherGroupName || !boost::starts_with(otherGroupName, _GroupPrefix)) { @@ -337,7 +337,7 @@ bool LinkBaseExtension::setupCopyOnChange(DocumentObject *parent, DocumentObject } if(p->getTypeId() != prop->getTypeId() || groupName != otherGroupName) { parent->removeDynamicProperty(p->getName()); - p = 0; + p = nullptr; } } } @@ -437,10 +437,10 @@ void LinkBaseExtension::checkCopyOnChange( App::GroupExtension *LinkBaseExtension::linkedPlainGroup() const { if(mySubElements.size() && mySubElements[0].size()) - return 0; + return nullptr; auto linked = getTrueLinkedObject(false); if(!linked) - return 0; + return nullptr; return linked->getExtensionByType(true,false); } @@ -464,7 +464,7 @@ App::PropertyBool *LinkBaseExtension::_getShowElementProperty() const { auto prop = getShowElementProperty(); if(prop && !linkedPlainGroup()) return const_cast(prop); - return 0; + return nullptr; } bool LinkBaseExtension::_getShowElementValue() const { @@ -478,7 +478,7 @@ App::PropertyInteger *LinkBaseExtension::_getElementCountProperty() const { auto prop = getElementCountProperty(); if(prop && !linkedPlainGroup()) return const_cast(prop); - return 0; + return nullptr; } int LinkBaseExtension::_getElementCountValue() const { @@ -563,7 +563,7 @@ DocumentObject *LinkBaseExtension::getLink(int depth) const{ GetApplication().checkLinkDepth(depth,false); if(getLinkedObjectProperty()) return getLinkedObjectValue(); - return 0; + return nullptr; } int LinkBaseExtension::getArrayIndex(const char *subname, const char **psubname) { @@ -595,7 +595,7 @@ int LinkBaseExtension::getElementIndex(const char *subname, const char **psubnam if(isdigit(subname[0])) { // If the name start with digits, treat as index reference - idx = getArrayIndex(subname,0); + idx = getArrayIndex(subname,nullptr); if(idx<0) return -1; if(_getElementCountProperty()) { if(idx>=_getElementCountValue()) @@ -613,7 +613,7 @@ int LinkBaseExtension::getElementIndex(const char *subname, const char **psubnam if(boost::algorithm::starts_with(name,ownerName.c_str())) { for(const char *txt=dot-1;txt>=name+ownerName.size();--txt) { if(*txt == 'i') { - idx = getArrayIndex(txt+1,0); + idx = getArrayIndex(txt+1,nullptr); if(idx<0 || idx>=_getElementCountValue()) idx = -1; break; @@ -768,7 +768,7 @@ bool LinkBaseExtension::extensionGetSubObjects(std::vector &ret, in bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char *subname, PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const { - ret = 0; + ret = nullptr; auto obj = getContainer(); if(!subname || !subname[0]) { ret = const_cast(obj); @@ -802,9 +802,9 @@ bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char * } auto linked = getTrueLinkedObject(false,&_mat,depth); if(linked && linked!=obj) { - linked->getSubObject(mySubElements.empty()?0:mySubElements.front().c_str(), + linked->getSubObject(mySubElements.empty()?nullptr:mySubElements.front().c_str(), pyObj,&_mat,false,depth+1); - checkGeoElementMap(obj,linked,pyObj,0); + checkGeoElementMap(obj,linked,pyObj,nullptr); } } return true; @@ -850,7 +850,7 @@ bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char * Base::Matrix4D matNext; if(mat) matNext = *mat; - ret = linked->getSubObject(subname,pyObj,mat?&matNext:0,false,depth+1); + ret = linked->getSubObject(subname,pyObj,mat?&matNext:nullptr,false,depth+1); std::string postfix; if(ret) { // do not resolve the link if we are the last referenced object @@ -874,7 +874,7 @@ bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char * *mat = matNext; } } - checkGeoElementMap(obj,linked,pyObj,postfix.size()?postfix.c_str():0); + checkGeoElementMap(obj,linked,pyObj,postfix.size()?postfix.c_str():nullptr); return true; } @@ -904,21 +904,21 @@ DocumentObject *LinkBaseExtension::getTrueLinkedObject( if(noElement && extensionIsDerivedFrom(LinkElement::getExtensionClassTypeId()) && !static_cast(this)->canDelete()) { - return 0; + return nullptr; } auto ret = getLink(depth); - if(!ret) return 0; + if(!ret) return nullptr; bool transform = linkTransform(); const char *subname = getSubName(); if(subname || (mat && transform)) { - ret = ret->getSubObject(subname,0,mat,transform,depth+1); + ret = ret->getSubObject(subname,nullptr,mat,transform,depth+1); transform = false; } if(ret && recurse) ret = ret->getLinkedObject(recurse,mat,transform,depth+1); if(ret && !ret->getNameInDocument()) - return 0; + return nullptr; return ret; } @@ -927,7 +927,7 @@ bool LinkBaseExtension::extensionGetLinkedObject(DocumentObject *&ret, { if(mat) *mat *= getTransform(transform); - ret = 0; + ret = nullptr; if(!_getElementCountValue()) ret = getTrueLinkedObject(recurse,mat,depth); if(!ret) @@ -1100,7 +1100,7 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop getElementListProperty()->setValues(std::vector()); if(getPlacementListProperty()) { - getPlacementListProperty()->setStatus(Property::User3,getScaleListProperty()!=0); + getPlacementListProperty()->setStatus(Property::User3,getScaleListProperty()!=nullptr); getPlacementListProperty()->setValue(placements); getPlacementListProperty()->setStatus(Property::User3,false); } @@ -1343,13 +1343,13 @@ void LinkBaseExtension::syncElementList() { element->_LinkOwner.setValue(ownerID); - element->LinkTransform.setStatus(Property::Hidden,transform!=0); - element->LinkTransform.setStatus(Property::Immutable,transform!=0); + element->LinkTransform.setStatus(Property::Hidden,transform!=nullptr); + element->LinkTransform.setStatus(Property::Immutable,transform!=nullptr); if(transform && element->LinkTransform.getValue()!=transform->getValue()) element->LinkTransform.setValue(transform->getValue()); - element->LinkedObject.setStatus(Property::Hidden,link!=0); - element->LinkedObject.setStatus(Property::Immutable,link!=0); + element->LinkedObject.setStatus(Property::Hidden,link!=nullptr); + element->LinkedObject.setStatus(Property::Immutable,link!=nullptr); if(element->LinkCopyOnChange.getValue()==2) continue; if(xlink) { @@ -1457,7 +1457,7 @@ void LinkBaseExtension::setLink(int index, DocumentObject *obj, if(linkProp || !getElementListProperty()) LINK_THROW(Base::RuntimeError,"Cannot set link element"); - DocumentObject *old = 0; + DocumentObject *old = nullptr; const auto &elements = getElementListProperty()->getValues(); if(!obj) { if(index>=(int)elements.size()) @@ -1587,7 +1587,7 @@ const char *LinkBaseExtension::flattenSubname(const char *subname) const { const char *sub = subname; std::string s; for(const char* dot=strchr(sub,'.');dot;sub=dot+1,dot=strchr(sub,'.')) { - DocumentObject *obj = 0; + DocumentObject *obj = nullptr; s.clear(); s.append(sub,dot+1); extensionGetSubObject(obj,s.c_str()); @@ -1604,7 +1604,7 @@ void LinkBaseExtension::expandSubname(std::string &subname) const { if(!_ChildCache.getSize()) return; - const char *pos = 0; + const char *pos = nullptr; int index = getElementIndex(subname.c_str(),&pos); if(index<0) return; @@ -1639,7 +1639,7 @@ Property *LinkBaseExtension::extensionGetPropertyByName(const char* name) const return linked->getPropertyByName(name); } } - return 0; + return nullptr; } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/App/Link.h b/src/App/Link.h index bc427a3aab..4241097f16 100644 --- a/src/App/Link.h +++ b/src/App/Link.h @@ -187,7 +187,7 @@ public: : index(index), name(name), type(type), doc(doc) {} - PropInfo() : index(0), name(0), doc(0) {} + PropInfo() : index(0), name(nullptr), doc(nullptr) {} }; #define LINK_PROP_INFO(_1,_var,_param) \ @@ -244,7 +244,7 @@ public: const char *getSubName() const { parseSubName(); - return mySubName.size()?mySubName.c_str():0; + return mySubName.size()?mySubName.c_str():nullptr; } const std::vector &getSubElements() const { @@ -253,7 +253,7 @@ public: } bool extensionGetSubObject(DocumentObject *&ret, const char *subname, - PyObject **pyObj=0, Base::Matrix4D *mat=0, bool transform=false, int depth=0) const override; + PyObject **pyObj=nullptr, Base::Matrix4D *mat=nullptr, bool transform=false, int depth=0) const override; bool extensionGetSubObjects(std::vector&ret, int reason) const override; @@ -274,18 +274,18 @@ public: virtual Property *extensionGetPropertyByName(const char* name) const override; - static int getArrayIndex(const char *subname, const char **psubname=0); - int getElementIndex(const char *subname, const char **psubname=0) const; + static int getArrayIndex(const char *subname, const char **psubname=nullptr); + int getElementIndex(const char *subname, const char **psubname=nullptr) const; void elementNameFromIndex(int idx, std::ostream &ss) const; DocumentObject *getContainer(); const DocumentObject *getContainer() const; - void setLink(int index, DocumentObject *obj, const char *subname=0, + void setLink(int index, DocumentObject *obj, const char *subname=nullptr, const std::vector &subs = std::vector()); DocumentObject *getTrueLinkedObject(bool recurse, - Base::Matrix4D *mat=0,int depth=0, bool noElement=false) const; + Base::Matrix4D *mat=nullptr,int depth=0, bool noElement=false) const; typedef std::map > LinkPropMap; diff --git a/src/App/LinkBaseExtensionPyImp.cpp b/src/App/LinkBaseExtensionPyImp.cpp index e723e720c1..0fa3a5895b 100644 --- a/src/App/LinkBaseExtensionPyImp.cpp +++ b/src/App/LinkBaseExtensionPyImp.cpp @@ -60,7 +60,7 @@ static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap return false; } - const char *valStr = 0; + const char *valStr = nullptr; if(key == value) valStr = keyStr; else if (value!=Py_None) { @@ -71,7 +71,7 @@ static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap valStr = PyUnicode_AsUTF8(value); } - App::Property *prop = 0; + App::Property *prop = nullptr; auto &info = it->second; if(valStr) { auto pIt = propMap.find(valStr); @@ -105,7 +105,7 @@ PyObject* LinkBaseExtensionPy::configLinkProperty(PyObject *args, PyObject *keyw for(Py_ssize_t pos=0;posgetProperty(name); if(!prop) { PyErr_SetString(PyExc_AttributeError, "unknown property name"); - return 0; + return nullptr; } return prop->getPyObject(); } @@ -137,21 +137,21 @@ PyObject* LinkBaseExtensionPy::getLinkExtProperty(PyObject *args) PyObject* LinkBaseExtensionPy::getLinkExtPropertyName(PyObject *args) { const char *name; if(!PyArg_ParseTuple(args,"s",&name)) - return 0; + return nullptr; auto prop = getLinkBaseExtensionPtr()->getProperty(name); if(!prop) { PyErr_SetString(PyExc_AttributeError, "unknown property name"); - return 0; + return nullptr; } auto container = getLinkBaseExtensionPtr()->getExtendedContainer(); if(!container) { PyErr_SetString(PyExc_RuntimeError, "no extended container"); - return 0; + return nullptr; } name = container->getPropertyName(prop); if(!name) { PyErr_SetString(PyExc_RuntimeError, "cannot find property name"); - return 0; + return nullptr; } return Py::new_reference_to(Py::String(name)); } @@ -176,7 +176,7 @@ PyObject* LinkBaseExtensionPy::getLinkPropertyInfo(PyObject *args) if(PyArg_ParseTuple(args,"h",&index)) { if(index<0 || index>=(int)infos.size()) { PyErr_SetString(PyExc_ValueError, "index out of range"); - return 0; + return nullptr; } Py::TupleN ret(Py::String(infos[index].name), Py::String(infos[index].type.getName()),Py::String(infos[index].doc)); @@ -193,15 +193,15 @@ PyObject* LinkBaseExtensionPy::getLinkPropertyInfo(PyObject *args) } } PyErr_SetString(PyExc_ValueError, "unknown property name"); - return 0; + return nullptr; } PyErr_SetString(PyExc_ValueError, "invalid arguments"); - return 0; + return nullptr; } void parseLink(LinkBaseExtension *ext, int index, PyObject *value) { - App::DocumentObject *obj = 0; + App::DocumentObject *obj = nullptr; PropertyStringList subs; PropertyString sub; if(value!=Py_None) { @@ -233,14 +233,14 @@ PyObject* LinkBaseExtensionPy::setLink(PyObject *_args) auto ext = getLinkBaseExtensionPtr(); PyObject *pcObj = args.size()?args[0].ptr():Py_None; if(pcObj == Py_None) { - ext->setLink(-1,0); + ext->setLink(-1,nullptr); }else if(PyDict_Check(pcObj)) { PyObject *key, *value; Py_ssize_t pos = 0; while(PyDict_Next(pcObj, &pos, &key, &value)) parseLink(ext,Py::Int(key),value); }else if(PySequence_Check(pcObj)) { - ext->setLink(-1,0); + ext->setLink(-1,nullptr); Py::Sequence seq(pcObj); for(Py_ssize_t i=0;icacheChildLabel(PyObject_IsTrue(enable)?-1:0); Py_Return; @@ -264,7 +264,7 @@ PyObject* LinkBaseExtensionPy::cacheChildLabel(PyObject *args) { PyObject* LinkBaseExtensionPy::flattenSubname(PyObject *args) { const char *subname; if(!PyArg_ParseTuple(args,"s",&subname)) - return 0; + return nullptr; PY_TRY { return Py::new_reference_to(Py::String( getLinkBaseExtensionPtr()->flattenSubname(subname))); @@ -274,7 +274,7 @@ PyObject* LinkBaseExtensionPy::flattenSubname(PyObject *args) { PyObject* LinkBaseExtensionPy::expandSubname(PyObject *args) { const char *subname; if(!PyArg_ParseTuple(args,"s",&subname)) - return 0; + return nullptr; PY_TRY { std::string sub(subname); getLinkBaseExtensionPtr()->expandSubname(sub); @@ -291,7 +291,7 @@ Py::List LinkBaseExtensionPy::getLinkedChildren() const { PyObject *LinkBaseExtensionPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int LinkBaseExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject * /*obj*/) diff --git a/src/App/MaterialPyImp.cpp b/src/App/MaterialPyImp.cpp index ae65f8fb9e..a4a5a8c60f 100644 --- a/src/App/MaterialPyImp.cpp +++ b/src/App/MaterialPyImp.cpp @@ -38,13 +38,13 @@ PyObject *MaterialPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // P // constructor method int MaterialPy::PyInit(PyObject* args, PyObject* kwds) { - PyObject* diffuse = 0; - PyObject* ambient = 0; - PyObject* specular = 0; - PyObject* emissive = 0; - PyObject* shininess = 0; - PyObject* transparency = 0; - static char* kwds_colors[] = { "DiffuseColor", "AmbientColor", "SpecularColor", "EmissiveColor", "Shininess", "Transparency", NULL }; + PyObject* diffuse = nullptr; + PyObject* ambient = nullptr; + PyObject* specular = nullptr; + PyObject* emissive = nullptr; + PyObject* shininess = nullptr; + PyObject* transparency = nullptr; + static char* kwds_colors[] = { "DiffuseColor", "AmbientColor", "SpecularColor", "EmissiveColor", "Shininess", "Transparency", nullptr }; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOO", kwds_colors, &diffuse, &ambient, &specular, &emissive, &shininess, &transparency)) @@ -200,7 +200,7 @@ void MaterialPy::setTransparency(Py::Float arg) PyObject *MaterialPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int MaterialPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) diff --git a/src/App/MergeDocuments.cpp b/src/App/MergeDocuments.cpp index 8ba07372a7..4726a9e975 100644 --- a/src/App/MergeDocuments.cpp +++ b/src/App/MergeDocuments.cpp @@ -123,7 +123,7 @@ private: }; } -MergeDocuments::MergeDocuments(App::Document* doc) : guiup(false), verbose(true), stream(0), appdoc(doc) +MergeDocuments::MergeDocuments(App::Document* doc) : guiup(false), verbose(true), stream(nullptr), appdoc(doc) { connectExport = doc->signalExportObjects.connect (boost::bind(&MergeDocuments::exportObject, this, bp::_1, bp::_2)); @@ -157,7 +157,7 @@ MergeDocuments::importObjects(std::istream& input) std::vector objs = appdoc->importObjects(reader); delete this->stream; - this->stream = 0; + this->stream = nullptr; return objs; } diff --git a/src/App/MetadataPyImp.cpp b/src/App/MetadataPyImp.cpp index a042d0d46e..e04582fc9c 100644 --- a/src/App/MetadataPyImp.cpp +++ b/src/App/MetadataPyImp.cpp @@ -396,7 +396,7 @@ PyObject* MetadataPy::supportsCurrentFreeCAD(PyObject* p) PyObject* MetadataPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int MetadataPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index 9aab4afb81..ac3ac9a5b4 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -110,7 +110,7 @@ std::string App::quote(const std::string &input, bool toPython) ObjectIdentifier::ObjectIdentifier(const App::PropertyContainer * _owner, const std::string & property, int index) - : owner(0) + : owner(nullptr) , documentNameSet(false) , documentObjectNameSet(false) , localProperty(false) @@ -134,7 +134,7 @@ ObjectIdentifier::ObjectIdentifier(const App::PropertyContainer * _owner, } ObjectIdentifier::ObjectIdentifier(const App::PropertyContainer * _owner, bool localProperty) - : owner(0) + : owner(nullptr) , documentNameSet(false) , documentObjectNameSet(false) , localProperty(localProperty) @@ -154,7 +154,7 @@ ObjectIdentifier::ObjectIdentifier(const App::PropertyContainer * _owner, bool l */ ObjectIdentifier::ObjectIdentifier(const Property &prop, int index) - : owner(0) + : owner(nullptr) , documentNameSet(false) , documentObjectNameSet(false) , localProperty(false) @@ -631,8 +631,8 @@ Py::Object ObjectIdentifier::Component::get(const Py::Object &pyobj) const { else { assert(isRange()); Py::Object slice(PySlice_New(Py::Int(begin).ptr(), - end!=INT_MAX?Py::Int(end).ptr():0, - step!=1?Py::Int(step).ptr():0),true); + end!=INT_MAX?Py::Int(end).ptr():nullptr, + step!=1?Py::Int(step).ptr():nullptr),true); PyObject *r = PyObject_GetItem(pyobj.ptr(),slice.ptr()); if(!r) Base::PyException::ThrowException(); @@ -659,8 +659,8 @@ void ObjectIdentifier::Component::set(Py::Object &pyobj, const Py::Object &value else { assert(isRange()); Py::Object slice(PySlice_New(Py::Int(begin).ptr(), - end!=INT_MAX?Py::Int(end).ptr():0, - step!=1?Py::Int(step).ptr():0),true); + end!=INT_MAX?Py::Int(end).ptr():nullptr, + step!=1?Py::Int(step).ptr():nullptr),true); if(PyObject_SetItem(pyobj.ptr(),slice.ptr(),value.ptr())<0) Base::PyException::ThrowException(); } @@ -679,8 +679,8 @@ void ObjectIdentifier::Component::del(Py::Object &pyobj) const { else { assert(isRange()); Py::Object slice(PySlice_New(Py::Int(begin).ptr(), - end!=INT_MAX?Py::Int(end).ptr():0, - step!=1?Py::Int(step).ptr():0),true); + end!=INT_MAX?Py::Int(end).ptr():nullptr, + step!=1?Py::Int(step).ptr():nullptr),true); if(PyObject_DelItem(pyobj.ptr(),slice.ptr())<0) Base::PyException::ThrowException(); } @@ -833,8 +833,8 @@ enum ResolveFlags { App::DocumentObject * ObjectIdentifier::getDocumentObject(const App::Document * doc, const String & name, std::bitset<32> &flags) { - DocumentObject * objectById = 0; - DocumentObject * objectByLabel = 0; + DocumentObject * objectById = nullptr; + DocumentObject * objectByLabel = nullptr; if(!name.isRealString()) { // No object found with matching label, try using name directly @@ -845,28 +845,28 @@ App::DocumentObject * ObjectIdentifier::getDocumentObject(const App::Document * return objectById; } if(name.isForceIdentifier()) - return 0; + return nullptr; } std::vector docObjects = doc->getObjects(); for (std::vector::iterator j = docObjects.begin(); j != docObjects.end(); ++j) { if (strcmp((*j)->Label.getValue(), static_cast(name)) == 0) { // Found object with matching label - if (objectByLabel != 0) { + if (objectByLabel != nullptr) { FC_WARN("duplicate object label " << doc->getName() << '#' << name); - return 0; + return nullptr; } objectByLabel = *j; } } - if (objectByLabel == 0 && objectById == 0) // Not found at all - return 0; - else if (objectByLabel == 0) { // Found by name + if (objectByLabel == nullptr && objectById == nullptr) // Not found at all + return nullptr; + else if (objectByLabel == nullptr) { // Found by name flags.set(ResolveByIdentifier); return objectById; } - else if (objectById == 0) { // Found by label + else if (objectById == nullptr) { // Found by label flags.set(ResolveByLabel); return objectByLabel; } @@ -877,7 +877,7 @@ App::DocumentObject * ObjectIdentifier::getDocumentObject(const App::Document * } else { flags.set(ResolveAmbiguous); - return 0; // Found by both name and label, two different objects + return nullptr; // Found by both name and label, two different objects } } @@ -910,7 +910,7 @@ void ObjectIdentifier::resolve(ResolveResults &results) const results.propertyIndex = 0; // Assume document name and object name from owner if not found - if (results.resolvedDocument == 0) { + if (results.resolvedDocument == nullptr) { if (documentName.getString().size() > 0) { if(docAmbiguous) results.flags.set(ResolveAmbiguous); @@ -918,7 +918,7 @@ void ObjectIdentifier::resolve(ResolveResults &results) const } results.resolvedDocument = owner->getDocument(); - if (results.resolvedDocument == 0) + if (results.resolvedDocument == nullptr) return; } @@ -971,7 +971,7 @@ void ObjectIdentifier::resolve(ResolveResults &results) const if(!results.resolvedProperty) { // If the second component is not a property name, try to // interpret the first component as the property name. - DocumentObject *sobj = 0; + DocumentObject *sobj = nullptr; results.resolvedProperty = resolveProperty( owner,components[0].name,sobj,results.propertyType); if(results.resolvedProperty) { @@ -1012,7 +1012,7 @@ Document * ObjectIdentifier::getDocument(String name, bool *ambiguous) const if (name.getString().size() == 0) name = getDocumentName(); - App::Document * docById = 0; + App::Document * docById = nullptr; if(!name.isRealString()) { docById = App::GetApplication().getDocument(name); @@ -1020,33 +1020,33 @@ Document * ObjectIdentifier::getDocument(String name, bool *ambiguous) const return docById; } - App::Document * docByLabel = 0; + App::Document * docByLabel = nullptr; const std::vector docs = App::GetApplication().getDocuments(); for (std::vector::const_iterator i = docs.begin(); i != docs.end(); ++i) { if ((*i)->Label.getValue() == name.getString()) { /* Multiple hits for same label? */ - if (docByLabel != 0) { + if (docByLabel != nullptr) { if(ambiguous) *ambiguous = true; - return 0; + return nullptr; } docByLabel = *i; } } /* Not found on id? */ - if (docById == 0) + if (docById == nullptr) return docByLabel; // Either not found at all, or on label else { /* Not found on label? */ - if (docByLabel == 0) /* Then return doc by id */ + if (docByLabel == nullptr) /* Then return doc by id */ return docById; /* docByLabel and docById could be equal; that is ok */ if(docByLabel==docById) return docById; if(ambiguous) *ambiguous = true; - return 0; + return nullptr; } } @@ -1061,7 +1061,7 @@ DocumentObject *ObjectIdentifier::getDocumentObject() const std::bitset<32> dummy; if (!doc) - return 0; + return nullptr; ResolveResults result(*this); @@ -1267,7 +1267,7 @@ Property *ObjectIdentifier::resolveProperty(const App::DocumentObject *obj, obj = sobj; } if(!obj) - return 0; + return nullptr; static std::unordered_map _props = { {"_shape",PseudoShape}, @@ -1294,7 +1294,7 @@ Property *ObjectIdentifier::resolveProperty(const App::DocumentObject *obj, subObjectName.getString().size() && !boost::ends_with(subObjectName.getString(),".")) { - return 0; + return nullptr; } return &const_cast(obj)->Label; //fake the property } @@ -1336,7 +1336,7 @@ ObjectIdentifier::DocumentMapper::DocumentMapper(const std::mapgetSubObject(result.subObjectName.getString().c_str(),0,&mat); + obj->getSubObject(result.subObjectName.getString().c_str(),nullptr,&mat); break; default: break; @@ -1675,7 +1675,7 @@ Py::Object ObjectIdentifier::access(const ResolveResults &result, if(propOwner) obj = propOwner; else - propName = 0; + propName = nullptr; } } auto &propset = (*deps)[obj]; @@ -1695,14 +1695,14 @@ Py::Object ObjectIdentifier::access(const ResolveResults &result, App::DocumentObject *lastObj = result.resolvedDocumentObject; if(result.resolvedSubObject) { - setPropDep(lastObj,0,0); + setPropDep(lastObj,nullptr,nullptr); lastObj = result.resolvedSubObject; } if(ptype == PseudoNone) setPropDep(lastObj, result.resolvedProperty, result.resolvedProperty->getName()); else - setPropDep(lastObj,0,0); - lastObj = 0; + setPropDep(lastObj,nullptr,nullptr); + lastObj = nullptr; if(components.empty()) return pyobj; @@ -1718,9 +1718,9 @@ Py::Object ObjectIdentifier::access(const ResolveResults &result, const char *attr = components[idx].getName().c_str(); auto prop = lastObj->getPropertyByName(attr); if(!prop && pyobj.hasAttr(attr)) - attr = 0; + attr = nullptr; setPropDep(lastObj,prop,attr); - lastObj = 0; + lastObj = nullptr; } pyobj = components[idx].get(pyobj); } @@ -1961,12 +1961,12 @@ void ObjectIdentifier::resolveAmbiguity(ResolveResults &result) { ObjectIdentifier::ResolveResults::ResolveResults(const ObjectIdentifier &oi) : propertyIndex(0) - , resolvedDocument(0) + , resolvedDocument(nullptr) , resolvedDocumentName() - , resolvedDocumentObject(0) + , resolvedDocumentObject(nullptr) , resolvedDocumentObjectName() - , resolvedSubObject(0) - , resolvedProperty(0) + , resolvedSubObject(nullptr) + , resolvedProperty(nullptr) , propertyName() , propertyType(PseudoNone) { @@ -1976,23 +1976,23 @@ ObjectIdentifier::ResolveResults::ResolveResults(const ObjectIdentifier &oi) std::string ObjectIdentifier::ResolveResults::resolveErrorString() const { std::ostringstream ss; - if (resolvedDocument == 0) { + if (resolvedDocument == nullptr) { if(flags.test(ResolveAmbiguous)) ss << "Ambiguous document name/label '" << resolvedDocumentName.getString() << "'"; else ss << "Document '" << resolvedDocumentName.toString() << "' not found"; - } else if (resolvedDocumentObject == 0) { + } else if (resolvedDocumentObject == nullptr) { if(flags.test(ResolveAmbiguous)) ss << "Ambiguous document object name '" << resolvedDocumentObjectName.getString() << "'"; else ss << "Document object '" << resolvedDocumentObjectName.toString() << "' not found"; - } else if (subObjectName.getString().size() && resolvedSubObject == 0) { + } else if (subObjectName.getString().size() && resolvedSubObject == nullptr) { ss << "Sub-object '" << resolvedDocumentObjectName.getString() << '.' << subObjectName.toString() << "' not found"; - } else if (resolvedProperty == 0) { + } else if (resolvedProperty == nullptr) { if(propertyType != PseudoShape && subObjectName.getString().size() && !boost::ends_with(subObjectName.getString(),".")) diff --git a/src/App/ObjectIdentifier.h b/src/App/ObjectIdentifier.h index 5bec35df13..c1e6db6cc1 100644 --- a/src/App/ObjectIdentifier.h +++ b/src/App/ObjectIdentifier.h @@ -127,7 +127,7 @@ public: bool operator>(const String & other) const { return str > other.str; } void checkImport(const App::DocumentObject *owner, - const App::DocumentObject *obj=0, String *objName=0); + const App::DocumentObject *obj=nullptr, String *objName=nullptr); private: std::string str; @@ -246,7 +246,7 @@ public: static Component MapComponent(String &&_key) {return Component::MapComponent(_key);} - ObjectIdentifier(const App::PropertyContainer * _owner = 0, + ObjectIdentifier(const App::PropertyContainer * _owner = nullptr, const std::string & property = std::string(), int index=INT_MAX); ObjectIdentifier(const App::PropertyContainer * _owner, bool localProperty); @@ -289,7 +289,7 @@ public: template void addComponents(const C &cs) { components.insert(components.end(), cs.begin(), cs.end()); } - const Component & getPropertyComponent(int i, int *idx=0) const; + const Component & getPropertyComponent(int i, int *idx=nullptr) const; void setComponent(int idx, Component &&comp); void setComponent(int idx, const Component &comp); @@ -311,7 +311,7 @@ public: bool isTouched() const; - App::Property *getProperty(int *ptype=0) const; + App::Property *getProperty(int *ptype=nullptr) const; App::ObjectIdentifier canonicalPath() const; @@ -365,7 +365,7 @@ public: * first referred object dependency. Or else, all object and property * dependencies will be returned. */ - Dependencies getDep(bool needProps, std::vector *labels=0) const; + Dependencies getDep(bool needProps, std::vector *labels=nullptr) const; /** Get dependencies of this object identifier * @@ -378,12 +378,12 @@ public: * first referred object dependency. Or else, all object and property * dependencies will be returned. */ - void getDep(Dependencies &deps, bool needProps, std::vector *labels=0) const; + void getDep(Dependencies &deps, bool needProps, std::vector *labels=nullptr) const; /// Returns all label references void getDepLabels(std::vector &labels) const; - App::Document *getDocument(String name = String(), bool *ambiguous=0) const; + App::Document *getDocument(String name = String(), bool *ambiguous=nullptr) const; App::DocumentObject *getDocumentObject() const; @@ -407,9 +407,9 @@ public: // Getter - App::any getValue(bool pathValue=false, bool *isPseudoProperty=0) const; + App::any getValue(bool pathValue=false, bool *isPseudoProperty=nullptr) const; - Py::Object getPyValue(bool pathValue=false, bool *isPseudoProperty=0) const; + Py::Object getPyValue(bool pathValue=false, bool *isPseudoProperty=nullptr) const; // Setter: is const because it does not alter the object state, // but does have an aiding effect. @@ -424,7 +424,7 @@ public: bool adjustLinks(ExpressionVisitor &v, const std::set &inList); - bool updateElementReference(ExpressionVisitor &v, App::DocumentObject *feature=0, bool reverse=false); + bool updateElementReference(ExpressionVisitor &v, App::DocumentObject *feature=nullptr, bool reverse=false); void resolveAmbiguity(); @@ -462,7 +462,7 @@ protected: void getSubPathStr(std::ostream &ss, const ResolveResults &result, bool toPython=false) const; Py::Object access(const ResolveResults &rs, - Py::Object *value=0, Dependencies *deps=0) const; + Py::Object *value=nullptr, Dependencies *deps=nullptr) const; void resolve(ResolveResults & results) const; void resolveAmbiguity(ResolveResults &results); diff --git a/src/App/Origin.cpp b/src/App/Origin.cpp index 713e862af5..9285fcff8b 100644 --- a/src/App/Origin.cpp +++ b/src/App/Origin.cpp @@ -49,7 +49,7 @@ const char* Origin::AxisRoles[3] = {"X_Axis", "Y_Axis", "Z_Axis"}; const char* Origin::PlaneRoles[3] = {"XY_Plane", "XZ_Plane", "YZ_Plane"}; Origin::Origin(void) : extension(this) { - ADD_PROPERTY_TYPE ( OriginFeatures, (0), 0, App::Prop_Hidden, + ADD_PROPERTY_TYPE ( OriginFeatures, (nullptr), 0, App::Prop_Hidden, "Axis and baseplanes controlled by the origin" ); setStatus(App::NoAutoExpand,true); diff --git a/src/App/OriginFeature.cpp b/src/App/OriginFeature.cpp index 5f7f608b4b..35c2acd0bd 100644 --- a/src/App/OriginFeature.cpp +++ b/src/App/OriginFeature.cpp @@ -53,7 +53,7 @@ Origin * OriginFeature::getOrigin () { return static_cast (origin)->hasObject (this); } ); if (originIt == origins.end()) { - return 0; + return nullptr; } else { assert ( (*originIt)->isDerivedFrom ( App::Origin::getClassTypeId() ) ); return static_cast (*originIt); diff --git a/src/App/OriginGroupExtension.cpp b/src/App/OriginGroupExtension.cpp index db35c0263e..e8606c215d 100644 --- a/src/App/OriginGroupExtension.cpp +++ b/src/App/OriginGroupExtension.cpp @@ -42,7 +42,7 @@ OriginGroupExtension::OriginGroupExtension () { initExtensionType(OriginGroupExtension::getExtensionClassTypeId()); - EXTENSION_ADD_PROPERTY_TYPE ( Origin, (0), 0, App::Prop_Hidden, "Origin linked to the group" ); + EXTENSION_ADD_PROPERTY_TYPE ( Origin, (nullptr), 0, App::Prop_Hidden, "Origin linked to the group" ); Origin.setScope(LinkScope::Child); } diff --git a/src/App/OriginGroupExtensionPyImp.cpp b/src/App/OriginGroupExtensionPyImp.cpp index e13cb8db75..471e4d11ea 100644 --- a/src/App/OriginGroupExtensionPyImp.cpp +++ b/src/App/OriginGroupExtensionPyImp.cpp @@ -37,7 +37,7 @@ std::string OriginGroupExtensionPy::representation(void) const PyObject *OriginGroupExtensionPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int OriginGroupExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) diff --git a/src/App/Part.cpp b/src/App/Part.cpp index 51de7a766f..de50bcf561 100644 --- a/src/App/Part.cpp +++ b/src/App/Part.cpp @@ -43,7 +43,7 @@ PROPERTY_SOURCE_WITH_EXTENSIONS(App::Part, App::GeoFeature) Part::Part(void) { ADD_PROPERTY(Type,("")); - ADD_PROPERTY_TYPE(Material, (0), 0, App::Prop_None, "The Material for this Part"); + ADD_PROPERTY_TYPE(Material, (nullptr), 0, App::Prop_None, "The Material for this Part"); ADD_PROPERTY_TYPE(Meta, (), 0, App::Prop_None, "Map with additional meta information"); // create the uuid for the document diff --git a/src/App/PartPyImp.cpp b/src/App/PartPyImp.cpp index 0dfd61e350..88e566afca 100644 --- a/src/App/PartPyImp.cpp +++ b/src/App/PartPyImp.cpp @@ -37,7 +37,7 @@ std::string PartPy::representation(void) const PyObject *PartPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int PartPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) diff --git a/src/App/Property.cpp b/src/App/Property.cpp index 216f8506d8..a1fc917b8e 100644 --- a/src/App/Property.cpp +++ b/src/App/Property.cpp @@ -54,7 +54,7 @@ static std::atomic _PropID; // Here is the implementation! Description should take place in the header file! Property::Property() - :father(0), myName(0), _id(++_PropID) + :father(nullptr), myName(nullptr), _id(++_PropID) { } @@ -252,7 +252,7 @@ Property *Property::Copy(void) const { // have to be reimplemented by a subclass! assert(0); - return 0; + return nullptr; } void Property::Paste(const Property& /*from*/) diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index a5f8d63f47..8faea17b58 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -47,7 +47,7 @@ TYPESYSTEM_SOURCE(App::PropertyContainer,Base::Persistence) // Here's the implementation! Description should take place in the header file! PropertyContainer::PropertyContainer() { - propertyData.parentPropertyData = 0; + propertyData.parentPropertyData = nullptr; } PropertyContainer::~PropertyContainer() @@ -470,7 +470,7 @@ const PropertyData::PropertySpec *PropertyData::findProperty(OffsetBase offsetBa auto it = index.find(PropName); if(it != index.end()) return &(*it); - return 0; + return nullptr; } const PropertyData::PropertySpec *PropertyData::findProperty(OffsetBase offsetBase,const Property* prop) const @@ -478,14 +478,14 @@ const PropertyData::PropertySpec *PropertyData::findProperty(OffsetBase offsetBa merge(); int diff = offsetBase.getOffsetTo(prop); if(diff<0) - return 0; + return nullptr; auto &index = propertyData.get<2>(); auto it = index.find(diff); if(it!=index.end()) return &(*it); - return 0; + return nullptr; } const char* PropertyData::getName(OffsetBase offsetBase,const Property* prop) const @@ -495,7 +495,7 @@ const char* PropertyData::getName(OffsetBase offsetBase,const Property* prop) co if(Spec) return Spec->Name; else - return 0; + return nullptr; } short PropertyData::getType(OffsetBase offsetBase,const Property* prop) const @@ -525,7 +525,7 @@ const char* PropertyData::getGroup(OffsetBase offsetBase,const Property* prop) c if(Spec) return Spec->Group; else - return 0; + return nullptr; } const char* PropertyData::getGroup(OffsetBase offsetBase,const char* name) const @@ -535,7 +535,7 @@ const char* PropertyData::getGroup(OffsetBase offsetBase,const char* name) const if(Spec) return Spec->Group; else - return 0; + return nullptr; } const char* PropertyData::getDocumentation(OffsetBase offsetBase,const Property* prop) const @@ -545,7 +545,7 @@ const char* PropertyData::getDocumentation(OffsetBase offsetBase,const Property* if(Spec) return Spec->Docu; else - return 0; + return nullptr; } const char* PropertyData::getDocumentation(OffsetBase offsetBase,const char* name) const @@ -555,7 +555,7 @@ const char* PropertyData::getDocumentation(OffsetBase offsetBase,const char* nam if(Spec) return Spec->Docu; else - return 0; + return nullptr; } Property *PropertyData::getPropertyByName(OffsetBase offsetBase,const char* name) const @@ -565,7 +565,7 @@ Property *PropertyData::getPropertyByName(OffsetBase offsetBase,const char* name if(Spec) return (Property *) (Spec->Offset + offsetBase.getOffset()); else - return 0; + return nullptr; } void PropertyData::getPropertyMap(OffsetBase offsetBase,std::map &Map) const diff --git a/src/App/PropertyContainer.h b/src/App/PropertyContainer.h index 68346244d0..feddcfe5e5 100644 --- a/src/App/PropertyContainer.h +++ b/src/App/PropertyContainer.h @@ -113,7 +113,7 @@ struct AppExport PropertyData const PropertyData* parentPropertyData; - void addProperty(OffsetBase offsetBase,const char* PropName, Property *Prop, const char* PropertyGroup= 0, PropertyType = Prop_None, const char* PropertyDocu= 0 ); + void addProperty(OffsetBase offsetBase,const char* PropName, Property *Prop, const char* PropertyGroup= nullptr, PropertyType = Prop_None, const char* PropertyDocu= nullptr ); const PropertySpec *findProperty(OffsetBase offsetBase,const char* PropName) const; const PropertySpec *findProperty(OffsetBase offsetBase,const Property* prop) const; @@ -131,7 +131,7 @@ struct AppExport PropertyData void getPropertyList(OffsetBase offsetBase,std::vector &List) const; void getPropertyNamedList(OffsetBase offsetBase, std::vector > &List) const; - void merge(PropertyData *other=0) const; + void merge(PropertyData *other=nullptr) const; void split(PropertyData *other); }; @@ -194,8 +194,8 @@ public: /// check if the named property is hidden bool isHidden(const char *name) const; virtual App::Property* addDynamicProperty( - const char* type, const char* name=0, - const char* group=0, const char* doc=0, + const char* type, const char* name=nullptr, + const char* group=nullptr, const char* doc=nullptr, short attr=0, bool ro=false, bool hidden=false); DynamicProperty::PropData getDynamicPropertyData(const Property* prop) const { diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index 6d7e477609..84e8c0d5ba 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -353,7 +353,7 @@ PyObject* PropertyContainerPy::setGroupOfProperty(PyObject *args) PyErr_Format(PyExc_AttributeError, "Property container has no dynamic property '%s'", pstr); return nullptr; } - prop->getContainer()->changeDynamicProperty(prop,group,0); + prop->getContainer()->changeDynamicProperty(prop,group,nullptr); Py_Return; } PY_CATCH } @@ -391,7 +391,7 @@ PyObject* PropertyContainerPy::setDocumentationOfProperty(PyObject *args) PyErr_Format(PyExc_AttributeError, "Property container has no dynamic property '%s'", pstr); return nullptr; } - prop->getContainer()->changeDynamicProperty(prop,0,doc); + prop->getContainer()->changeDynamicProperty(prop,nullptr,doc); Py_Return; } PY_CATCH } @@ -567,7 +567,7 @@ PyObject *PropertyContainerPy::getCustomAttributes(const char* attr) const ///FIXME: For v0.20: Do not use stuff from Part module here! else if(Base::streq(attr,"Shape") && getPropertyContainerPtr()->isDerivedFrom(App::DocumentObject::getClassTypeId())) { // Special treatment of Shape property - static PyObject *_getShape = 0; + static PyObject *_getShape = nullptr; if(!_getShape) { _getShape = Py_None; PyObject *mod = PyImport_ImportModule("Part"); diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index 9cdd282b34..d7bec0a746 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -711,7 +711,7 @@ void PropertyExpressionEngine::getPathsToDocumentObject(DocumentObject* obj, { DocumentObject * owner = freecad_dynamic_cast(getContainer()); - if (owner == 0 || owner==obj) + if (owner == nullptr || owner==obj) return; for(auto &v : expressions) { @@ -965,7 +965,7 @@ Property *PropertyExpressionEngine::CopyOnImportExternal( engine->expressions[it->first] = ExpressionInfo(expr); } if(!engine) - return 0; + return nullptr; engine->validator = validator; return engine.release(); } @@ -995,7 +995,7 @@ Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj, engine->expressions[it->first] = ExpressionInfo(expr); } if(!engine) - return 0; + return nullptr; engine->validator = validator; return engine.release(); } @@ -1027,7 +1027,7 @@ Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject engine->expressions[it->first] = ExpressionInfo(expr); } if(!engine) - return 0; + return nullptr; engine->validator = validator; return engine.release(); } diff --git a/src/App/PropertyExpressionEngine.h b/src/App/PropertyExpressionEngine.h index c48549d7df..d582c8b723 100644 --- a/src/App/PropertyExpressionEngine.h +++ b/src/App/PropertyExpressionEngine.h @@ -142,7 +142,7 @@ public: * * @param option: execution option, see ExecuteOption. */ - DocumentObjectExecReturn * execute(ExecuteOption option=ExecuteAll, bool *touched=0); + DocumentObjectExecReturn * execute(ExecuteOption option=ExecuteAll, bool *touched=nullptr); void getPathsToDocumentObject(DocumentObject*, std::vector & paths) const; diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index dc109e744d..aa8ebe810c 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -911,7 +911,7 @@ App::Placement * PropertyPlacementLink::getPlacementObject(void) const if (_pcLink->getTypeId().isDerivedFrom(App::Placement::getClassTypeId())) return dynamic_cast(_pcLink); else - return 0; + return nullptr; } diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index d3afb3552d..b42f5b416a 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -116,7 +116,7 @@ void PropertyLinkBase::unregisterLabelReferences() void PropertyLinkBase::getLabelReferences(std::vector &subs,const char *subname) { const char *dot; - for(;(subname=strchr(subname,'$'))!=0; subname=dot+1) { + for(;(subname=strchr(subname,'$'))!=nullptr; subname=dot+1) { ++subname; dot = strchr(subname,'.'); if(!dot) break; @@ -155,7 +155,7 @@ std::string PropertyLinkBase::updateLabelReference(const App::DocumentObject *pa // hierarchies, we have to search for all occurrences, and make sure the // referenced sub-object at the found hierarchy is actually the given // object. - for(const char *pos=subname; ((pos=strstr(pos,ref.c_str()))!=0); pos+=ref.size()) { + for(const char *pos=subname; ((pos=strstr(pos,ref.c_str()))!=nullptr); pos+=ref.size()) { auto sub = std::string(subname,pos+ref.size()-subname); auto sobj = parent->getSubObject(sub.c_str()); if(sobj == obj) { @@ -402,7 +402,7 @@ TYPESYSTEM_SOURCE(App::PropertyLinkHidden , App::PropertyLink) PropertyLink::PropertyLink() -:_pcLink(0) +:_pcLink(nullptr) { } @@ -434,7 +434,7 @@ void PropertyLink::resetLink() { } } #endif - _pcLink = 0; + _pcLink = nullptr; } void PropertyLink::setValue(App::DocumentObject * lValue) @@ -468,7 +468,7 @@ App::DocumentObject * PropertyLink::getValue(void) const App::DocumentObject * PropertyLink::getValue(Base::Type t) const { - return (_pcLink && _pcLink->getTypeId().isDerivedFrom(t)) ? _pcLink : 0; + return (_pcLink && _pcLink->getTypeId().isDerivedFrom(t)) ? _pcLink : nullptr; } PyObject *PropertyLink::getPyObject(void) @@ -486,7 +486,7 @@ void PropertyLink::setPyObject(PyObject *value) setValue(pcObject->getDocumentObjectPtr()); } else if (Py_None == value) { - setValue(0); + setValue(nullptr); } else { std::string error = std::string("type must be 'DocumentObject' or 'NoneType', not "); @@ -514,7 +514,7 @@ void PropertyLink::Restore(Base::XMLReader &reader) DocumentObject* parent = static_cast(getContainer()); App::Document* document = parent->getDocument(); - DocumentObject* object = document ? document->getObject(name.c_str()) : 0; + DocumentObject* object = document ? document->getObject(name.c_str()) : nullptr; if (!object) { if (reader.isVerbose()) { Base::Console().Warning("Lost link to '%s' while loading, maybe " @@ -525,13 +525,13 @@ void PropertyLink::Restore(Base::XMLReader &reader) if (reader.isVerbose()) { Base::Console().Warning("Object '%s' links to itself, nullify it\n",name.c_str()); } - object = 0; + object = nullptr; } setValue(object); } else { - setValue(0); + setValue(nullptr); } } @@ -561,7 +561,7 @@ void PropertyLink::getLinks(std::vector &objs, void PropertyLink::breakLink(App::DocumentObject *obj, bool clear) { if(_pcLink == obj || (clear && getContainer()==obj)) - setValue(0); + setValue(nullptr); } bool PropertyLink::adjustLink(const std::set &inList) { @@ -578,7 +578,7 @@ Property *PropertyLink::CopyOnLinkReplace(const App::DocumentObject *parent, p->_pcLink = res.first; return p; } - return 0; + return nullptr; } //************************************************************************** @@ -646,7 +646,7 @@ void PropertyLinkList::setSize(int newSize, const_reference def) { } void PropertyLinkList::set1Value(int idx, DocumentObject* const &value) { - DocumentObject *obj = 0; + DocumentObject *obj = nullptr; if(idx>=0 && idx<(int)_lValueList.size()) { obj = _lValueList[idx]; if(obj == value) return; @@ -786,7 +786,7 @@ void PropertyLinkList::Restore(Base::XMLReader &reader) // Property not in an object! DocumentObject* father = static_cast(getContainer()); App::Document* document = father->getDocument(); - DocumentObject* child = document ? document->getObject(name.c_str()) : 0; + DocumentObject* child = document ? document->getObject(name.c_str()) : nullptr; if (child) values.push_back(child); else if (reader.isVerbose()) @@ -826,7 +826,7 @@ Property *PropertyLinkList::CopyOnLinkReplace(const App::DocumentObject *parent, links.push_back(*it); } if(!found) - return 0; + return nullptr; auto p= new PropertyLinkList(); p->_lValueList = std::move(links); return p; @@ -863,7 +863,7 @@ DocumentObject *PropertyLinkList::find(const std::string &name, int *pindex) con } auto it = _nameMap.find(name); if(it == _nameMap.end()) - return 0; + return nullptr; if(pindex) *pindex = it->second; return _lValueList[it->second]; } @@ -917,7 +917,7 @@ TYPESYSTEM_SOURCE(App::PropertyLinkSubHidden, App::PropertyLinkSub) PropertyLinkSub::PropertyLinkSub() - : _pcLinkSub(0), _restoreLabel(false) + : _pcLinkSub(nullptr), _restoreLabel(false) { } @@ -972,7 +972,7 @@ void PropertyLinkSub::setValue(App::DocumentObject * lValue, if(shadows.size()==_cSubList.size()) _ShadowSubList = std::move(shadows); else - updateElementReference(0); + updateElementReference(nullptr); checkLabelReferences(_cSubList); hasSetValue(); } @@ -1020,7 +1020,7 @@ std::vector PropertyLinkSub::getSubValuesStartsWith(const char* sta App::DocumentObject * PropertyLinkSub::getValue(Base::Type t) const { - return (_pcLinkSub && _pcLinkSub->getTypeId().isDerivedFrom(t)) ? _pcLinkSub : 0; + return (_pcLinkSub && _pcLinkSub->getTypeId().isDerivedFrom(t)) ? _pcLinkSub : nullptr; } PyObject *PropertyLinkSub::getPyObject(void) @@ -1049,7 +1049,7 @@ void PropertyLinkSub::setPyObject(PyObject *value) else if (PyTuple_Check(value) || PyList_Check(value)) { Py::Sequence seq(value); if(seq.size() == 0) - setValue(NULL); + setValue(nullptr); else if(seq.size()!=2) throw Base::ValueError("Expect input sequence of size 2"); else if (PyObject_TypeCheck(seq[0].ptr(), &(DocumentObjectPy::Type))) { @@ -1085,7 +1085,7 @@ void PropertyLinkSub::setPyObject(PyObject *value) } } else if(Py_None == value) { - setValue(0); + setValue(nullptr); } else { std::string error = std::string("type must be 'DocumentObject', 'NoneType' or ('DocumentObject',['String',]) not "); @@ -1192,11 +1192,11 @@ const char *PropertyLinkBase::exportSubName(std::string &output, return res; const char *hash; for(hash=sub;hashgetNameInDocument()) doc = obj->getDocument(); } @@ -1370,9 +1370,9 @@ void PropertyLinkSub::Restore(Base::XMLReader &reader) assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId()) ); App::Document* document = static_cast(getContainer())->getDocument(); - DocumentObject *pcObject = 0; + DocumentObject *pcObject = nullptr; if (!name.empty()) { - pcObject = document ? document->getObject(name.c_str()) : 0; + pcObject = document ? document->getObject(name.c_str()) : nullptr; if (!pcObject) { if (reader.isVerbose()) { FC_WARN("Lost link to " << name @@ -1409,7 +1409,7 @@ void PropertyLinkSub::Restore(Base::XMLReader &reader) _mapped = std::move(mapped); } else { - setValue(0); + setValue(nullptr); } } @@ -1441,15 +1441,15 @@ Property *PropertyLinkSub::CopyOnImportExternal( { auto owner = dynamic_cast(getContainer()); if(!owner || !owner->getDocument()) - return 0; + return nullptr; if(!_pcLinkSub || !_pcLinkSub->getNameInDocument()) - return 0; + return nullptr; auto subs = updateLinkSubs(_pcLinkSub,_cSubList, &tryImportSubName,owner->getDocument(),nameMap); auto linked = tryImport(owner->getDocument(),_pcLinkSub,nameMap); if(subs.empty() && linked==_pcLinkSub) - return 0; + return nullptr; PropertyLinkSub *p= new PropertyLinkSub(); p->_pcLinkSub = linked; @@ -1465,13 +1465,13 @@ Property *PropertyLinkSub::CopyOnLabelChange(App::DocumentObject *obj, { auto owner = dynamic_cast(getContainer()); if(!owner || !owner->getDocument()) - return 0; + return nullptr; if(!_pcLinkSub || !_pcLinkSub->getNameInDocument()) - return 0; + return nullptr; auto subs = updateLinkSubs(_pcLinkSub,_cSubList,&updateLabelReference,obj,ref,newLabel); if(subs.empty()) - return 0; + return nullptr; PropertyLinkSub *p= new PropertyLinkSub(); p->_pcLinkSub = _pcLinkSub; @@ -1489,7 +1489,7 @@ Property *PropertyLinkSub::CopyOnLinkReplace(const App::DocumentObject *parent, p->_cSubList = std::move(res.second); return p; } - return 0; + return nullptr; } Property *PropertyLinkSub::Copy(void) const @@ -1522,15 +1522,15 @@ void PropertyLinkSub::getLinks(std::vector &objs, void PropertyLinkSub::breakLink(App::DocumentObject *obj, bool clear) { if(obj == _pcLinkSub || (clear && getContainer()==obj)) - setValue(0); + setValue(nullptr); } static App::DocumentObject *adjustLinkSubs(App::PropertyLinkBase *prop, const std::set &inList, App::DocumentObject *link, std::vector &subs, - std::map > *links=0) + std::map > *links=nullptr) { - App::DocumentObject *newLink = 0; + App::DocumentObject *newLink = nullptr; for(auto &sub : subs) { size_t pos = sub.find('.'); for(;pos!=std::string::npos;pos=sub.find('.',pos+1)) { @@ -1557,7 +1557,7 @@ static App::DocumentObject *adjustLinkSubs(App::PropertyLinkBase *prop, break; } if(pos == std::string::npos) - return 0; + return nullptr; } return newLink; } @@ -1668,7 +1668,7 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue,const char* SubName) _lValueList.clear(); _lSubList.clear(); } - updateElementReference(0); + updateElementReference(nullptr); checkLabelReferences(_lSubList); hasSetValue(); } @@ -1714,7 +1714,7 @@ void PropertyLinkSubList::setValues(const std::vector& lValue,c if (*it != nullptr) _lSubList[i] = *it; } - updateElementReference(0); + updateElementReference(nullptr); checkLabelReferences(_lSubList); hasSetValue(); } @@ -1765,7 +1765,7 @@ void PropertyLinkSubList::setValues(std::vector&& lValue, if(ShadowSubList.size()==_lSubList.size()) _ShadowSubList = std::move(ShadowSubList); else - updateElementReference(0); + updateElementReference(nullptr); checkLabelReferences(_lSubList); hasSetValue(); } @@ -1810,7 +1810,7 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue, const std::vector_lSubList = SubList; this->_lValueList.insert(this->_lValueList.begin(), size, lValue); } - updateElementReference(0); + updateElementReference(nullptr); checkLabelReferences(_lSubList); hasSetValue(); } @@ -1910,13 +1910,13 @@ const string PropertyLinkSubList::getPyReprString() const DocumentObject *PropertyLinkSubList::getValue() const { - App::DocumentObject* ret = 0; + App::DocumentObject* ret = nullptr; //FIXME: cache this to avoid iterating each time, to improve speed for (std::size_t i = 0; i < this->_lValueList.size(); i++) { - if (ret == 0) + if (ret == nullptr) ret = this->_lValueList[i]; if (ret != this->_lValueList[i]) - return 0; + return nullptr; } return ret; } @@ -2216,7 +2216,7 @@ void PropertyLinkSubList::Restore(Base::XMLReader &reader) std::vector shadows; shadows.reserve(count); DocumentObject* father = dynamic_cast(getContainer()); - App::Document* document = father ? father->getDocument() : 0; + App::Document* document = father ? father->getDocument() : nullptr; std::vector mapped; bool restoreLabel=false; for (int i = 0; i < count; i++) { @@ -2226,7 +2226,7 @@ void PropertyLinkSubList::Restore(Base::XMLReader &reader) // referenced objects in XML which do not exist anymore in the new // document. Thus, we should silently ignore this. // Property not in an object! - DocumentObject* child = document ? document->getObject(name.c_str()) : 0; + DocumentObject* child = document ? document->getObject(name.c_str()) : nullptr; if (child) { values.push_back(child); shadows.emplace_back(); @@ -2290,7 +2290,7 @@ Property *PropertyLinkSubList::CopyOnImportExternal( { auto owner = dynamic_cast(getContainer()); if(!owner || !owner->getDocument() || _lValueList.size()!=_lSubList.size()) - return 0; + return nullptr; std::vector values; std::vector subs; auto itSub = _lSubList.begin(); @@ -2321,7 +2321,7 @@ Property *PropertyLinkSubList::CopyOnImportExternal( } } if(values.empty()) - return 0; + return nullptr; std::unique_ptr p(new PropertyLinkSubList); p->_lValueList = std::move(values); p->_lSubList = std::move(subs); @@ -2333,7 +2333,7 @@ Property *PropertyLinkSubList::CopyOnLabelChange(App::DocumentObject *obj, { auto owner = dynamic_cast(getContainer()); if(!owner || !owner->getDocument()) - return 0; + return nullptr; std::vector values; std::vector subs; auto itSub = _lSubList.begin(); @@ -2363,7 +2363,7 @@ Property *PropertyLinkSubList::CopyOnLabelChange(App::DocumentObject *obj, } } if(values.empty()) - return 0; + return nullptr; std::unique_ptr p(new PropertyLinkSubList); p->_lValueList = std::move(values); p->_lSubList = std::move(subs); @@ -2428,7 +2428,7 @@ Property *PropertyLinkSubList::CopyOnLinkReplace(const App::DocumentObject *pare } } if(values.empty()) - return 0; + return nullptr; std::unique_ptr p(new PropertyLinkSubList); p->_lValueList = std::move(values); p->_lSubList = std::move(subs); @@ -2574,7 +2574,7 @@ public: std::set links; static std::string getDocPath( - const char *filename, App::Document *pDoc, bool relative, QString *fullPath = 0) + const char *filename, App::Document *pDoc, bool relative, QString *fullPath = nullptr) { bool absolute; // The path could be an URI, in that case @@ -2685,7 +2685,7 @@ public: } DocInfo() - :pcDoc(0) + :pcDoc(nullptr) {} ~DocInfo() { @@ -2704,7 +2704,7 @@ public: _DocInfoMap.erase(myPos); myPos = _DocInfoMap.end(); myPath.clear(); - pcDoc = 0; + pcDoc = nullptr; } void init(DocInfoMap::iterator pos, const char *objName, PropertyXLink *l) { @@ -2886,7 +2886,7 @@ public: if(link->parentProp) parentLinks[link->parentProp].push_back(link); else - parentLinks[0].push_back(link); + parentLinks[nullptr].push_back(link); } for(auto &v : parentLinks) { if(v.first) { @@ -2900,7 +2900,7 @@ public: v.first->setFlag(PropertyLinkBase::LinkDetached,false); } } - pcDoc = 0; + pcDoc = nullptr; } bool hasXLink(const App::Document *doc) const{ @@ -2985,7 +2985,7 @@ void PropertyXLink::detach() { if(docInfo && _pcLink) { aboutToSetValue(); resetLink(); - updateElementReference(0); + updateElementReference(nullptr); hasSetValue(); } } @@ -3022,12 +3022,12 @@ void PropertyXLink::setSubValues(std::vector &&subs, if(shadows.size() == _SubList.size()) _ShadowSubList = std::move(shadows); else - updateElementReference(0); + updateElementReference(nullptr); checkLabelReferences(_SubList); } void PropertyXLink::setValue(App::DocumentObject * lValue) { - setValue(lValue,0); + setValue(lValue,nullptr); } void PropertyXLink::setValue(App::DocumentObject * lValue, const char *subname) @@ -3054,7 +3054,7 @@ void PropertyXLink::restoreLink(App::DocumentObject *lValue) { lValue->_addBackLink(owner); #endif _pcLink=lValue; - updateElementReference(0); + updateElementReference(nullptr); hasSetValue(); setFlag(LinkRestoring,false); @@ -3133,14 +3133,14 @@ void PropertyXLink::setValue(std::string &&filename, std::string &&name, std::vector &&subs, std::vector &&shadows) { if(name.empty()) { - setValue(0,std::move(subs),std::move(shadows)); + setValue(nullptr,std::move(subs),std::move(shadows)); return; } auto owner = dynamic_cast(getContainer()); if(!owner || !owner->getNameInDocument()) throw Base::RuntimeError("invalid container"); - DocumentObject *pObject=0; + DocumentObject *pObject=nullptr; DocInfoPtr info; if(filename.size()) { owner->getDocument()->signalLinkXsetValue(filename); @@ -3160,7 +3160,7 @@ void PropertyXLink::setValue(std::string &&filename, std::string &&name, if (_pcLink && !owner->testStatus(ObjectStatus::Destroy) && _pcScope!=LinkScope::Hidden) _pcLink->_removeBackLink(owner); #endif - _pcLink = 0; + _pcLink = nullptr; if(docInfo!=info) { unlink(); docInfo = info; @@ -3181,7 +3181,7 @@ void PropertyXLink::setValue(App::DocumentObject *link, } App::Document *PropertyXLink::getDocument() const { - return docInfo?docInfo->pcDoc:0; + return docInfo?docInfo->pcDoc:nullptr; } const char *PropertyXLink::getDocumentPath() const { @@ -3394,11 +3394,11 @@ void PropertyXLink::Restore(Base::XMLReader &reader) name = reader.getAttribute("name"); assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId())); - DocumentObject *object = 0; + DocumentObject *object = nullptr; if(name.size() && file.empty()) { DocumentObject* parent = static_cast(getContainer()); Document *document = parent->getDocument(); - object = document ? document->getObject(name.c_str()) : 0; + object = document ? document->getObject(name.c_str()) : nullptr; if(!object) { if(reader.isVerbose()) { FC_WARN("Lost link to '" << name << "' while loading, maybe " @@ -3449,7 +3449,7 @@ void PropertyXLink::Restore(Base::XMLReader &reader) setFlag(LinkRestoreLabel,restoreLabel); if (name.empty()) { - setValue(0); + setValue(nullptr); return; } @@ -3466,13 +3466,13 @@ Property *PropertyXLink::CopyOnImportExternal( { auto owner = Base::freecad_dynamic_cast(getContainer()); if(!owner || !owner->getDocument() || !_pcLink || !_pcLink->getNameInDocument()) - return 0; + return nullptr; auto subs = updateLinkSubs(_pcLink,_SubList, &tryImportSubName,owner->getDocument(),nameMap); auto linked = tryImport(owner->getDocument(),_pcLink,nameMap); if(subs.empty() && linked==_pcLink) - return 0; + return nullptr; std::unique_ptr p(new PropertyXLink); copyTo(*p,linked,&subs); @@ -3484,7 +3484,7 @@ Property *PropertyXLink::CopyOnLinkReplace(const App::DocumentObject *parent, { auto res = tryReplaceLinkSubs(getContainer(),_pcLink,parent,oldObj,newObj,_SubList); if(!res.first) - return 0; + return nullptr; std::unique_ptr p(new PropertyXLink); copyTo(*p,res.first,&res.second); return p.release(); @@ -3495,10 +3495,10 @@ Property *PropertyXLink::CopyOnLabelChange(App::DocumentObject *obj, { auto owner = dynamic_cast(getContainer()); if(!owner || !owner->getDocument() || !_pcLink || !_pcLink->getNameInDocument()) - return 0; + return nullptr; auto subs = updateLinkSubs(_pcLink,_SubList,&updateLabelReference,obj,ref,newLabel); if(subs.empty()) - return 0; + return nullptr; std::unique_ptr p(new PropertyXLink); copyTo(*p,_pcLink,&subs); return p.release(); @@ -3672,7 +3672,7 @@ void PropertyXLink::setPyObject(PyObject *value) { Py::Object pyObj(seq[0].ptr()); Py::Object pySub(seq[1].ptr()); if(pyObj.isNone()) { - setValue(0); + setValue(nullptr); return; } else if(!PyObject_TypeCheck(pyObj.ptr(), &DocumentObjectPy::Type)) throw Base::TypeError("Expect the first element to be of 'DocumentObject'"); @@ -3696,7 +3696,7 @@ void PropertyXLink::setPyObject(PyObject *value) { } else if(PyObject_TypeCheck(value, &(DocumentObjectPy::Type))) { setValue(static_cast(value)->getDocumentObjectPtr()); } else if (Py_None == value) { - setValue(0); + setValue(nullptr); } else { throw Base::TypeError("type must be 'DocumentObject', 'None', or '(DocumentObject, SubName)' or " "'DocumentObject, [SubName..])"); @@ -4030,7 +4030,7 @@ DocumentObject *PropertyXLinkSubList::getValue() const { if(_Links.size()) return _Links.begin()->getValue(); - return 0; + return nullptr; } int PropertyXLinkSubList::removeValue(App::DocumentObject *lValue) @@ -4167,7 +4167,7 @@ Property *PropertyXLinkSubList::CopyOnImportExternal( if(copy) break; } if(!copy) - return 0; + return nullptr; std::unique_ptr p(new PropertyXLinkSubList); for(auto iter=_Links.begin();iter!=it;++iter) { p->_Links.emplace_back(); @@ -4196,7 +4196,7 @@ Property *PropertyXLinkSubList::CopyOnLabelChange(App::DocumentObject *obj, if(copy) break; } if(!copy) - return 0; + return nullptr; std::unique_ptr p(new PropertyXLinkSubList); for(auto iter=_Links.begin();iter!=it;++iter) { p->_Links.emplace_back(); @@ -4219,7 +4219,7 @@ Property *PropertyXLinkSubList::CopyOnLinkReplace(const App::DocumentObject *par App::DocumentObject *oldObj, App::DocumentObject *newObj) const { std::unique_ptr copy; - PropertyXLinkSub *copied = 0; + PropertyXLinkSub *copied = nullptr; std::set subs; auto it = _Links.begin(); for(;it!=_Links.end();++it) { @@ -4234,7 +4234,7 @@ Property *PropertyXLinkSubList::CopyOnLinkReplace(const App::DocumentObject *par } } if(!copy) - return 0; + return nullptr; std::unique_ptr p(new PropertyXLinkSubList); for(auto iter=_Links.begin();iter!=it;++iter) { if(iter->getValue()==newObj && copied->getValue()==newObj) { @@ -4365,14 +4365,14 @@ void PropertyXLinkSubList::getLinks(std::vector &objs, void PropertyXLinkSubList::breakLink(App::DocumentObject *obj, bool clear) { if(clear && getContainer()==obj) { - setValue(0); + setValue(nullptr); return; } atomic_change guard(*this,false); for(auto &l : _Links) { if(l.getValue() == obj) { guard.aboutToChange(); - l.setValue(0); + l.setValue(nullptr); } } guard.tryInvoke(); diff --git a/src/App/PropertyLinks.h b/src/App/PropertyLinks.h index da9f9838ff..34de1fa14a 100644 --- a/src/App/PropertyLinks.h +++ b/src/App/PropertyLinks.h @@ -161,7 +161,7 @@ public: * @return For external linked object, return 2 in case the link is * missing, and 1 if the time stamp has changed. */ - virtual int checkRestore(std::string *msg=0) const { + virtual int checkRestore(std::string *msg=nullptr) const { (void)msg; return 0; } @@ -176,7 +176,7 @@ public: * @param newStyle: whether to return new or old style subname reference */ virtual void getLinks(std::vector &objs, - bool all=false, std::vector *subs=0, bool newStyle=true) const = 0; + bool all=false, std::vector *subs=nullptr, bool newStyle=true) const = 0; /** Called to reset this link property * @@ -224,7 +224,7 @@ public: */ virtual Property *CopyOnImportExternal(const std::map &nameMap) const { (void)nameMap; - return 0; + return nullptr; } /** Update object label reference in this property @@ -242,7 +242,7 @@ public: (void)obj; (void)ref; (void)newLabel; - return 0; + return nullptr; } /// Helper function to return all linked objects of this property @@ -319,7 +319,7 @@ public: static std::pair tryReplaceLink( const App::PropertyContainer *owner, App::DocumentObject *obj, const App::DocumentObject *parent, App::DocumentObject *oldObj, - App::DocumentObject *newObj, const char *sub=0); + App::DocumentObject *newObj, const char *sub=nullptr); /** Helper function to check and replace a link with multiple subname references * @@ -483,7 +483,7 @@ public: * afterRestore() function, which calls this function to do the string * parsing. */ - static void restoreLabelReference(const App::DocumentObject *obj, std::string &sub, ShadowSub *shadow=0); + static void restoreLabelReference(const App::DocumentObject *obj, std::string &sub, ShadowSub *shadow=nullptr); /** Helper function to extract labels from a subname reference * @@ -620,7 +620,7 @@ public: { return "Gui::PropertyEditor::PropertyLinkItem"; } virtual void getLinks(std::vector &objs, - bool all=false, std::vector *subs=0, bool newStyle=true) const override; + bool all=false, std::vector *subs=nullptr, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -710,7 +710,7 @@ public: { return "Gui::PropertyEditor::PropertyLinkListItem"; } virtual void getLinks(std::vector &objs, - bool all=false, std::vector *subs=0, bool newStyle=true) const override; + bool all=false, std::vector *subs=nullptr, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -719,9 +719,9 @@ public: virtual Property *CopyOnLinkReplace(const App::DocumentObject *parent, App::DocumentObject *oldObj, App::DocumentObject *newObj) const override; - DocumentObject *find(const std::string &, int *pindex=0) const; - DocumentObject *find(const char *sub, int *pindex=0) const { - if(!sub) return 0; + DocumentObject *find(const std::string &, int *pindex=nullptr) const; + DocumentObject *find(const char *sub, int *pindex=nullptr) const { + if(!sub) return nullptr; return find(std::string(sub),pindex); } @@ -851,7 +851,7 @@ public: virtual bool referenceChanged() const override; virtual void getLinks(std::vector &objs, - bool all=false, std::vector *subs=0, bool newStyle=true) const override; + bool all=false, std::vector *subs=nullptr, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -997,7 +997,7 @@ public: virtual bool referenceChanged() const override; virtual void getLinks(std::vector &objs, - bool all=false, std::vector *subs=0, bool newStyle=true) const override; + bool all=false, std::vector *subs=nullptr, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -1050,7 +1050,7 @@ class AppExport PropertyXLink : public PropertyLinkGlobal TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - PropertyXLink(bool allowPartial=false, PropertyLinkBase *parent=0); + PropertyXLink(bool allowPartial=false, PropertyLinkBase *parent=nullptr); virtual ~PropertyXLink(); @@ -1083,7 +1083,7 @@ public: const char *getDocumentPath() const; const char *getObjectName() const; - virtual int checkRestore(std::string *msg=0) const override; + virtual int checkRestore(std::string *msg=nullptr) const override; virtual void Save (Base::Writer &writer) const override; virtual void Restore(Base::XMLReader &reader) override; @@ -1107,9 +1107,9 @@ public: static bool supportXLink(const App::Property *prop); static bool hasXLink(const App::Document *doc); - static bool hasXLink(const std::vector &objs, std::vector *unsaved=0); - static std::map > getDocumentOutList(App::Document *doc=0); - static std::map > getDocumentInList(App::Document *doc=0); + static bool hasXLink(const std::vector &objs, std::vector *unsaved=nullptr); + static std::map > getDocumentOutList(App::Document *doc=nullptr); + static std::map > getDocumentInList(App::Document *doc=nullptr); static void restoreDocument(const App::Document &doc); virtual void updateElementReference( @@ -1118,7 +1118,7 @@ public: virtual bool referenceChanged() const override; virtual void getLinks(std::vector &objs, - bool all=false, std::vector *subs=0, bool newStyle=true) const override; + bool all=false, std::vector *subs=nullptr, bool newStyle=true) const override; virtual bool adjustLink(const std::set &inList) override; @@ -1145,7 +1145,7 @@ protected: void restoreLink(App::DocumentObject *); - void copyTo(PropertyXLink &other, App::DocumentObject *linked=0, std::vector *subs=0) const; + void copyTo(PropertyXLink &other, App::DocumentObject *linked=nullptr, std::vector *subs=nullptr) const; virtual void aboutToSetValue() override; @@ -1172,7 +1172,7 @@ class AppExport PropertyXLinkSub: public PropertyXLink { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - PropertyXLinkSub(bool allowPartial=false, PropertyLinkBase *parent=0); + PropertyXLinkSub(bool allowPartial=false, PropertyLinkBase *parent=nullptr); virtual ~PropertyXLinkSub(); @@ -1277,7 +1277,7 @@ public: virtual bool referenceChanged() const override; virtual void getLinks(std::vector &objs, - bool all=false, std::vector *subs=0, bool newStyle=true) const override; + bool all=false, std::vector *subs=nullptr, bool newStyle=true) const override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; @@ -1285,7 +1285,7 @@ public: bool upgrade(Base::XMLReader &reader, const char *typeName); - virtual int checkRestore(std::string *msg=0) const override; + virtual int checkRestore(std::string *msg=nullptr) const override; virtual void setAllowPartial(bool enable) override; @@ -1326,12 +1326,12 @@ public: ~PropertyXLinkContainer(); virtual void afterRestore() override; - virtual int checkRestore(std::string *msg=0) const override; + virtual int checkRestore(std::string *msg=nullptr) const override; virtual void Save (Base::Writer &writer) const override; virtual void Restore(Base::XMLReader &reader) override; virtual void breakLink(App::DocumentObject *obj, bool clear) override; virtual void getLinks(std::vector &objs, - bool all=false, std::vector *subs=0, bool newStyle=true) const override; + bool all=false, std::vector *subs=nullptr, bool newStyle=true) const override; bool isLinkedToDocument(const App::Document &doc) const; diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp index 895faf7b7f..810605ea05 100644 --- a/src/App/PropertyPythonObject.cpp +++ b/src/App/PropertyPythonObject.cpp @@ -354,7 +354,7 @@ void PropertyPythonObject::Restore(Base::XMLReader &reader) Py::Module mod(PyImport_ImportModule(nam.c_str()),true); if (mod.isNull()) throw Py::Exception(); - this->object = PyObject_CallObject(mod.getAttr(cls).ptr(), NULL); + this->object = PyObject_CallObject(mod.getAttr(cls).ptr(), nullptr); load_pickle = true; buffer = std::string(what[2].second, end); } diff --git a/src/App/PropertyUnits.h b/src/App/PropertyUnits.h index 1f6155e75f..9697642f58 100644 --- a/src/App/PropertyUnits.h +++ b/src/App/PropertyUnits.h @@ -85,7 +85,7 @@ class AppExport PropertyQuantityConstraint : public PropertyQuantity TYPESYSTEM_HEADER(); public: - PropertyQuantityConstraint(void):_ConstStruct(0){} + PropertyQuantityConstraint(void):_ConstStruct(nullptr){} virtual ~PropertyQuantityConstraint(){} /// Constraint methods diff --git a/src/App/Range.cpp b/src/App/Range.cpp index 7a0fb891e8..d9b19780a7 100644 --- a/src/App/Range.cpp +++ b/src/App/Range.cpp @@ -207,7 +207,7 @@ int App::validColumn(const std::string &colstr) App::CellAddress App::stringToAddress(const char * strAddress, bool silent) { - assert(strAddress != 0); + assert(strAddress != nullptr); static boost::regex e("(\\$?[A-Z]{1,2})(\\$?[0-9]{1,5})"); boost::cmatch cm; diff --git a/src/App/Transactions.cpp b/src/App/Transactions.cpp index 71c4e72b65..297942a79a 100644 --- a/src/App/Transactions.cpp +++ b/src/App/Transactions.cpp @@ -389,13 +389,13 @@ void TransactionObject::addOrRemoveProperty(const Property* pcProp, bool add) } if(data.property) { delete data.property; - data.property = 0; + data.property = nullptr; } data.propertyOrig = pcProp; static_cast(data) = pcProp->getContainer()->getDynamicPropertyData(pcProp); if(add) - data.property = 0; + data.property = nullptr; else { data.property = pcProp->Copy(); data.propertyType = pcProp->getTypeId(); diff --git a/src/App/VRMLObject.cpp b/src/App/VRMLObject.cpp index 1a994e5f51..5994741f7b 100644 --- a/src/App/VRMLObject.cpp +++ b/src/App/VRMLObject.cpp @@ -39,7 +39,7 @@ PROPERTY_SOURCE(App::VRMLObject, App::GeoFeature) VRMLObject::VRMLObject() : index(0) { - ADD_PROPERTY_TYPE(VrmlFile,(0),"",Prop_None,"Included file with the VRML definition"); + ADD_PROPERTY_TYPE(VrmlFile,(nullptr),"",Prop_None,"Included file with the VRML definition"); ADD_PROPERTY_TYPE(Urls,(""),"",static_cast(Prop_ReadOnly|Prop_Output|Prop_Transient), "Resource files loaded by the VRML file"); ADD_PROPERTY_TYPE(Resources,(""),"",static_cast(Prop_ReadOnly|Prop_Output),