Skip to content

Commit

Permalink
Fix clang compiler warnings:
Browse files Browse the repository at this point in the history
+ fix -Winconsistent-missing-override
+ fix -Wunused-private-field
+ suppress -Woverloaded-virtual but fix later
  • Loading branch information
wwmayer committed Aug 17, 2019
1 parent 7e70438 commit 3e6ae0d
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 197 deletions.
14 changes: 7 additions & 7 deletions src/App/Document.h
Expand Up @@ -60,7 +60,7 @@ namespace App
/// The document class
class AppExport Document : public App::PropertyContainer
{
PROPERTY_HEADER(App::Document);
PROPERTY_HEADER_WITH_OVERRIDE(App::Document);

public:
enum Status {
Expand Down Expand Up @@ -222,11 +222,11 @@ class AppExport Document : public App::PropertyContainer
const char* getName() const;
//@}

virtual void Save (Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual void Save (Base::Writer &writer) const override;
virtual void Restore(Base::XMLReader &reader) override;

/// returns the complete document memory consumption, including all managed DocObjects and Undo Redo.
unsigned int getMemSize (void) const;
unsigned int getMemSize (void) const override;

/** @name Object handling */
//@{
Expand Down Expand Up @@ -478,7 +478,7 @@ class AppExport Document : public App::PropertyContainer
/// Function called to signal that an object identifier has been renamed
void renameObjectIdentifiers(const std::map<App::ObjectIdentifier, App::ObjectIdentifier> & paths, const std::function<bool(const App::DocumentObject*)> &selector = [](const App::DocumentObject *) { return true; });

virtual PyObject *getPyObject(void);
virtual PyObject *getPyObject(void) override;

virtual std::string getFullName() const override;

Expand Down Expand Up @@ -508,8 +508,8 @@ class AppExport Document : public App::PropertyContainer
void writeObjects(const std::vector<App::DocumentObject*>&, Base::Writer &writer) const;
bool saveToFile(const char* filename) const;

void onBeforeChange(const Property* prop);
void onChanged(const Property* prop);
void onBeforeChange(const Property* prop) override;
void onChanged(const Property* prop) override;
/// callback from the Document objects before property will be changed
void onBeforeChangeProperty(const TransactionalObject *Who, const Property *What);
/// callback from the Document objects after property was changed
Expand Down
14 changes: 7 additions & 7 deletions src/App/DocumentObject.h
Expand Up @@ -90,7 +90,7 @@ class AppExport DocumentObjectExecReturn
*/
class AppExport DocumentObject: public App::TransactionalObject
{
PROPERTY_HEADER(App::DocumentObject);
PROPERTY_HEADER_WITH_OVERRIDE(App::DocumentObject);

public:

Expand Down Expand Up @@ -126,8 +126,8 @@ class AppExport DocumentObject: public App::TransactionalObject
std::string getExportName(bool forced=false) const;
/// Return the object full name of the form DocName#ObjName
virtual std::string getFullName() const override;
virtual bool isAttachedToDocument() const;
virtual const char* detachFromDocument();
virtual bool isAttachedToDocument() const override;
virtual const char* detachFromDocument() override;
/// gets the document in which this Object is handled
App::Document *getDocument(void) const;

Expand Down Expand Up @@ -303,7 +303,7 @@ class AppExport DocumentObject: public App::TransactionalObject
* additional or different behavior.
*/
virtual void onLostLinkToObject(DocumentObject*);
virtual PyObject *getPyObject(void);
virtual PyObject *getPyObject(void) override;

/** Get the sub element/object by name
*
Expand Down Expand Up @@ -405,7 +405,7 @@ class AppExport DocumentObject: public App::TransactionalObject

static DocumentObjectExecReturn *StdReturn;

virtual void Save (Base::Writer &writer) const;
virtual void Save (Base::Writer &writer) const override;

/* Expression support */

Expand Down Expand Up @@ -576,9 +576,9 @@ class AppExport DocumentObject: public App::TransactionalObject
void setDocument(App::Document* doc);

/// get called before the value is changed
virtual void onBeforeChange(const Property* prop);
virtual void onBeforeChange(const Property* prop) override;
/// get called by the container when a property was changed
virtual void onChanged(const Property* prop);
virtual void onChanged(const Property* prop) override;
/// get called after a document has been fully restored
virtual void onDocumentRestored();
/// get called after setting the document
Expand Down
4 changes: 2 additions & 2 deletions src/App/DocumentObjectGroup.h
Expand Up @@ -44,11 +44,11 @@ class AppExport DocumentObjectGroup : public DocumentObject, public GroupExtensi
virtual ~DocumentObjectGroup();

/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
virtual const char* getViewProviderName(void) const override{
return "Gui::ViewProviderDocumentObjectGroup";
}

virtual PyObject *getPyObject(void);
virtual PyObject *getPyObject(void) override;
};

typedef App::FeaturePythonT<DocumentObjectGroup> DocumentObjectGroupPython;
Expand Down
6 changes: 3 additions & 3 deletions src/App/Expression.cpp
Expand Up @@ -423,8 +423,8 @@ static Py::Object _pyObjectFromAny(const App::any &value, const Expression *e) {
return Py::Long(cast<int>(value));
#endif
else if (is_type(value,typeid(long))) {
long l = cast<long>(value);
#if PY_MAJOR_VERSION < 3
long l = cast<long>(value);
if(std::abs(l)<=INT_MAX)
return Py::Int(int(l));
#endif
Expand Down Expand Up @@ -505,7 +505,7 @@ bool pyToQuantity(Quantity &q, const Py::Object &pyobj) {
return true;
}

static inline Quantity pyToQuantity(const Py::Object &pyobj,
/*static inline Quantity pyToQuantity(const Py::Object &pyobj,
const Expression *e, const char *msg=0)
{
Quantity q;
Expand All @@ -515,7 +515,7 @@ static inline Quantity pyToQuantity(const Py::Object &pyobj,
__EXPR_THROW(TypeError,msg,e);
}
return q;
}
}*/

Py::Object pyFromQuantity(const Quantity &quantity) {
if(!quantity.getUnit().isEmpty())
Expand Down
11 changes: 11 additions & 0 deletions src/App/Expression.h
Expand Up @@ -35,6 +35,12 @@
#include <deque>
#include <App/Range.h>

//FIXME: PyObjectExpression hides overloaded virtual functions
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Woverloaded-virtual"
#endif

namespace App {

class DocumentObject;
Expand Down Expand Up @@ -654,4 +660,9 @@ class semantic_type {
}

}

#if defined(__clang__)
# pragma clang diagnostic pop
#endif

#endif // EXPRESSION_H
2 changes: 1 addition & 1 deletion src/App/ExtensionContainer.h
Expand Up @@ -193,7 +193,7 @@ class AppExport ExtensionContainer : public App::PropertyContainer
};

#define PROPERTY_HEADER_WITH_EXTENSIONS(_class_) \
PROPERTY_HEADER(_class)
PROPERTY_HEADER_WITH_OVERRIDE(_class)

/// We make sur that the PropertyData of the container is not connected to the one of the extension
#define PROPERTY_SOURCE_WITH_EXTENSIONS(_class_, _parentclass_) \
Expand Down
18 changes: 9 additions & 9 deletions src/App/FeaturePython.h
Expand Up @@ -159,7 +159,7 @@ class AppExport FeaturePythonImp
template <class FeatureT>
class FeaturePythonT : public FeatureT
{
PROPERTY_HEADER(App::FeaturePythonT<FeatureT>);
PROPERTY_HEADER_WITH_OVERRIDE(App::FeaturePythonT<FeatureT>);

public:
FeaturePythonT() {
Expand All @@ -173,15 +173,15 @@ class FeaturePythonT : public FeatureT

/** @name methods override DocumentObject */
//@{
short mustExecute() const {
short mustExecute() const override {
if (this->isTouched())
return 1;
auto ret = FeatureT::mustExecute();
if(ret) return ret;
return imp->mustExecute()?1:0;
}
/// recalculate the Feature
virtual DocumentObjectExecReturn *execute(void) {
virtual DocumentObjectExecReturn *execute(void) override {
try {
bool handled = imp->execute();
if (!handled)
Expand All @@ -199,7 +199,7 @@ class FeaturePythonT : public FeatureT
return FeatureT::getViewProviderNameOverride();
}
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
virtual const char* getViewProviderName(void) const override {
return FeatureT::getViewProviderName();
//return "Gui::ViewProviderPythonFeature";
}
Expand Down Expand Up @@ -279,36 +279,36 @@ class FeaturePythonT : public FeatureT
return FeatureT::canLoadPartial();
}

PyObject *getPyObject(void) {
PyObject *getPyObject(void) override {
if (FeatureT::PythonObject.is(Py::_None())) {
// ref counter is set to 1
FeatureT::PythonObject = Py::Object(imp->getPyObject(),true);
}
return Py::new_reference_to(FeatureT::PythonObject);
}
void setPyObject(PyObject *obj) {
void setPyObject(PyObject *obj) override {
if (obj)
FeatureT::PythonObject = obj;
else
FeatureT::PythonObject = Py::None();
}

protected:
virtual void onBeforeChange(const Property* prop) {
virtual void onBeforeChange(const Property* prop) override {
FeatureT::onBeforeChange(prop);
imp->onBeforeChange(prop);
}
virtual void onBeforeChangeLabel(std::string &newLabel) override{
if(!imp->onBeforeChangeLabel(newLabel))
FeatureT::onBeforeChangeLabel(newLabel);
}
virtual void onChanged(const Property* prop) {
virtual void onChanged(const Property* prop) override {
if(prop == &Proxy)
imp->init(Proxy.getValue().ptr());
imp->onChanged(prop);
FeatureT::onChanged(prop);
}
virtual void onDocumentRestored() {
virtual void onDocumentRestored() override {
imp->onDocumentRestored();
FeatureT::onDocumentRestored();
}
Expand Down
4 changes: 2 additions & 2 deletions src/App/Link.h
Expand Up @@ -50,7 +50,7 @@ namespace App

class AppExport LinkBaseExtension : public App::DocumentObjectExtension
{
EXTENSION_PROPERTY_HEADER(App::LinkExtension);
EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::LinkExtension);
typedef App::DocumentObjectExtension inherited;

public:
Expand Down Expand Up @@ -318,7 +318,7 @@ typedef ExtensionPythonT<LinkBaseExtension> LinkBaseExtensionPython;

class AppExport LinkExtension : public LinkBaseExtension
{
EXTENSION_PROPERTY_HEADER(App::LinkExtension);
EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::LinkExtension);
typedef LinkBaseExtension inherited;

public:
Expand Down
4 changes: 2 additions & 2 deletions src/App/Part.h
Expand Up @@ -80,7 +80,7 @@ class AppExport Part : public App::GeoFeature, public App::OriginGroupExtension
virtual ~Part();

/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
virtual const char* getViewProviderName(void) const override {
return "Gui::ViewProviderPart";
}

Expand All @@ -91,7 +91,7 @@ class AppExport Part : public App::GeoFeature, public App::OriginGroupExtension
*/
static App::Part* getPartOfObject (const DocumentObject* obj);

virtual PyObject *getPyObject(void);
virtual PyObject *getPyObject(void) override;
};

//typedef App::FeaturePythonT<Part> PartPython;
Expand Down
6 changes: 3 additions & 3 deletions src/App/Property.h
Expand Up @@ -57,7 +57,7 @@ class ObjectIdentifier;
*/
class AppExport Property : public Base::Persistence
{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();

public:
enum Status
Expand Down Expand Up @@ -110,7 +110,7 @@ class AppExport Property : public Base::Persistence
* This method is defined in Base::Persistence
* @see Base::Persistence
*/
virtual unsigned int getMemSize (void) const {
virtual unsigned int getMemSize (void) const override {
// you have to implement this method in all property classes!
return sizeof(father) + sizeof(StatusBits);
}
Expand Down Expand Up @@ -424,7 +424,7 @@ class AppExport PropertyListsBase
class AppExport PropertyLists : public Property, public PropertyListsBase

{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
virtual void setPyObject(PyObject *obj) override {
_setPyObject(obj);
Expand Down
20 changes: 10 additions & 10 deletions src/App/PropertyExpressionEngine.h
Expand Up @@ -64,7 +64,7 @@ class AppExport PropertyExpressionContainer : public App::PropertyXLinkContainer
class AppExport PropertyExpressionEngine : public App::PropertyExpressionContainer,
private App::AtomicPropertyChangeInterface<PropertyExpressionEngine>
{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:

virtual void updateElementReference(
Expand Down Expand Up @@ -103,25 +103,25 @@ class AppExport PropertyExpressionEngine : public App::PropertyExpressionContain
PropertyExpressionEngine();
~PropertyExpressionEngine();

unsigned int getMemSize (void) const;
unsigned int getMemSize (void) const override;

virtual std::map<App::ObjectIdentifier, const App::Expression*> getExpressions() const override;
virtual void setExpressions(std::map<App::ObjectIdentifier, App::ExpressionPtr> &&exprs) override;
virtual void onRelabeledDocument(const App::Document &doc) override;

void setValue() { } // Dummy

Property *Copy(void) const;
Property *Copy(void) const override;

void Paste(const Property &from);
void Paste(const Property &from) override;

void Save (Base::Writer & writer) const;
void Save (Base::Writer & writer) const override;

void Restore(Base::XMLReader &reader);
void Restore(Base::XMLReader &reader) override;

void setValue(const App::ObjectIdentifier &path, boost::shared_ptr<App::Expression> expr);

const boost::any getPathValue(const App::ObjectIdentifier & path) const;
const boost::any getPathValue(const App::ObjectIdentifier & path) const override;

/// Execute options
enum ExecuteOption {
Expand Down Expand Up @@ -153,7 +153,7 @@ class AppExport PropertyExpressionEngine : public App::PropertyExpressionContain

void renameObjectIdentifiers(const std::map<App::ObjectIdentifier, App::ObjectIdentifier> & paths);

App::ObjectIdentifier canonicalPath(const App::ObjectIdentifier &p) const;
App::ObjectIdentifier canonicalPath(const App::ObjectIdentifier &p) const override;

size_t numExpressions() const;

Expand All @@ -164,8 +164,8 @@ class AppExport PropertyExpressionEngine : public App::PropertyExpressionContain
virtual void onContainerRestored() override;

/* Python interface */
PyObject *getPyObject(void);
void setPyObject(PyObject *);
PyObject *getPyObject(void) override;
void setPyObject(PyObject *) override;

protected:
virtual void hasSetValue() override;
Expand Down

0 comments on commit 3e6ae0d

Please sign in to comment.