Skip to content

[WIP] Applying modernize-use-override #6007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
93 changes: 49 additions & 44 deletions bindings/pyroot/cppyy/CPyCppyy/src/CPPOverload.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,65 +50,70 @@ class TPythonCallback : public PyCallable {
fCallable = callable;
}

virtual ~TPythonCallback() {
Py_DECREF(fCallable);
fCallable = nullptr;
~TPythonCallback() override
{
Py_DECREF(fCallable);
fCallable = nullptr;
}

virtual PyObject* GetSignature(bool /*show_formalargs*/ = true) {
return CPyCppyy_PyText_FromString("*args, **kwargs");
PyObject *GetSignature(bool /*show_formalargs*/ = true) override
{
return CPyCppyy_PyText_FromString("*args, **kwargs");
}
virtual PyObject* GetPrototype(bool /*show_formalargs*/ = true) {
return CPyCppyy_PyText_FromString("<callback>");
PyObject *GetPrototype(bool /*show_formalargs*/ = true) override
{
return CPyCppyy_PyText_FromString("<callback>");
}
virtual PyObject* GetDocString() {
if (PyObject_HasAttrString(fCallable, "__doc__")) {
return PyObject_GetAttrString(fCallable, "__doc__");
} else {
return GetPrototype();
}
PyObject *GetDocString() override
{
if (PyObject_HasAttrString(fCallable, "__doc__")) {
return PyObject_GetAttrString(fCallable, "__doc__");
} else {
return GetPrototype();
}
}

virtual int GetPriority() { return 100; };
virtual bool IsGreedy() { return false; };
int GetPriority() override { return 100; };
bool IsGreedy() override { return false; };

virtual int GetMaxArgs() { return 100; };
virtual PyObject* GetCoVarNames() { // TODO: pick these up from the callable
Py_RETURN_NONE;
int GetMaxArgs() override { return 100; };
PyObject *GetCoVarNames() override
{ // TODO: pick these up from the callable
Py_RETURN_NONE;
}
virtual PyObject* GetArgDefault(int /* iarg */) { // TODO: pick these up from the callable
Py_RETURN_NONE;
PyObject *GetArgDefault(int /* iarg */) override
{ // TODO: pick these up from the callable
Py_RETURN_NONE;
}

virtual PyObject* GetScopeProxy() { // should this be the module ??
Py_RETURN_NONE;
PyObject *GetScopeProxy() override
{ // should this be the module ??
Py_RETURN_NONE;
}

virtual Cppyy::TCppFuncAddr_t GetFunctionAddress() {
return (Cppyy::TCppFuncAddr_t)nullptr;
}
Cppyy::TCppFuncAddr_t GetFunctionAddress() override { return (Cppyy::TCppFuncAddr_t) nullptr; }

virtual PyCallable* Clone() { return new TPythonCallback(*this); }
PyCallable *Clone() override { return new TPythonCallback(*this); }

virtual PyObject* Call(
CPPInstance*& self, PyObject* args, PyObject* kwds, CallContext* /* ctxt = 0 */) {
PyObject *Call(CPPInstance *&self, PyObject *args, PyObject *kwds, CallContext * /* ctxt = 0 */) override
{

PyObject* newArgs = nullptr;
if (self) {
Py_ssize_t nargs = PyTuple_Size(args);
newArgs = PyTuple_New(nargs+1);
Py_INCREF(self);
PyTuple_SET_ITEM(newArgs, 0, (PyObject*)self);
for (Py_ssize_t iarg = 0; iarg < nargs; ++iarg) {
PyObject* pyarg = PyTuple_GET_ITEM(args, iarg);
Py_INCREF(pyarg);
PyTuple_SET_ITEM(newArgs, iarg+1, pyarg);
}
} else {
Py_INCREF(args);
newArgs = args;
}
return PyObject_Call(fCallable, newArgs, kwds);
PyObject *newArgs = nullptr;
if (self) {
Py_ssize_t nargs = PyTuple_Size(args);
newArgs = PyTuple_New(nargs + 1);
Py_INCREF(self);
PyTuple_SET_ITEM(newArgs, 0, (PyObject *)self);
for (Py_ssize_t iarg = 0; iarg < nargs; ++iarg) {
PyObject *pyarg = PyTuple_GET_ITEM(args, iarg);
Py_INCREF(pyarg);
PyTuple_SET_ITEM(newArgs, iarg + 1, pyarg);
}
} else {
Py_INCREF(args);
newArgs = args;
}
return PyObject_Call(fCallable, newArgs, kwds);
}
};

Expand Down
59 changes: 31 additions & 28 deletions bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -212,49 +212,52 @@ struct CountedItemGetter : public ItemGetter {

struct TupleItemGetter : public CountedItemGetter {
using CountedItemGetter::CountedItemGetter;
virtual Py_ssize_t size() { return PyTuple_GET_SIZE(fPyObject); }
virtual PyObject* get() {
if (fCur < PyTuple_GET_SIZE(fPyObject)) {
PyObject* item = PyTuple_GET_ITEM(fPyObject, fCur++);
Py_INCREF(item);
return item;
}
PyErr_SetString(PyExc_StopIteration, "end of tuple");
return nullptr;
Py_ssize_t size() override { return PyTuple_GET_SIZE(fPyObject); }
PyObject * get() override
{
if (fCur < PyTuple_GET_SIZE(fPyObject)) {
PyObject *item = PyTuple_GET_ITEM(fPyObject, fCur++);
Py_INCREF(item);
return item;
}
PyErr_SetString(PyExc_StopIteration, "end of tuple");
return nullptr;
}
};

struct ListItemGetter : public CountedItemGetter {
using CountedItemGetter::CountedItemGetter;
virtual Py_ssize_t size() { return PyList_GET_SIZE(fPyObject); }
virtual PyObject* get() {
if (fCur < PyList_GET_SIZE(fPyObject)) {
PyObject* item = PyList_GET_ITEM(fPyObject, fCur++);
Py_INCREF(item);
return item;
}
PyErr_SetString(PyExc_StopIteration, "end of list");
return nullptr;
Py_ssize_t size() override { return PyList_GET_SIZE(fPyObject); }
PyObject * get() override
{
if (fCur < PyList_GET_SIZE(fPyObject)) {
PyObject *item = PyList_GET_ITEM(fPyObject, fCur++);
Py_INCREF(item);
return item;
}
PyErr_SetString(PyExc_StopIteration, "end of list");
return nullptr;
}
};

struct SequenceItemGetter : public CountedItemGetter {
using CountedItemGetter::CountedItemGetter;
virtual Py_ssize_t size() {
Py_ssize_t sz = PySequence_Size(fPyObject);
if (sz < 0) {
PyErr_Clear();
return PyObject_LengthHint(fPyObject, 8);
}
return sz;
Py_ssize_t size() override
{
Py_ssize_t sz = PySequence_Size(fPyObject);
if (sz < 0) {
PyErr_Clear();
return PyObject_LengthHint(fPyObject, 8);
}
return sz;
}
virtual PyObject* get() { return PySequence_GetItem(fPyObject, fCur++); }
PyObject *get() override { return PySequence_GetItem(fPyObject, fCur++); }
};

struct IterItemGetter : public ItemGetter {
using ItemGetter::ItemGetter;
virtual Py_ssize_t size() { return PyObject_LengthHint(fPyObject, 8); }
virtual PyObject* get() { return (*(Py_TYPE(fPyObject)->tp_iternext))(fPyObject); }
Py_ssize_t size() override { return PyObject_LengthHint(fPyObject, 8); }
PyObject * get() override { return (*(Py_TYPE(fPyObject)->tp_iternext))(fPyObject); }
};

PyObject* VectorInit(PyObject* self, PyObject* args, PyObject* /* kwds */)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,24 @@ static void inline do_trace(int sig) {

class TExceptionHandlerImp : public TExceptionHandler {
public:
virtual void HandleException(Int_t sig) {
if (TROOT::Initialized()) {
if (gException) {
gInterpreter->RewindDictionary();
gInterpreter->ClearFileBusy();
}

if (!getenv("CPPYY_CRASH_QUIET"))
do_trace(sig);

// jump back, if catch point set
Throw(sig);
}

do_trace(sig);
gSystem->Exit(128 + sig);
}
void HandleException(Int_t sig) override
{
if (TROOT::Initialized()) {
if (gException) {
gInterpreter->RewindDictionary();
gInterpreter->ClearFileBusy();
}

if (!getenv("CPPYY_CRASH_QUIET"))
do_trace(sig);

// jump back, if catch point set
Throw(sig);
}

do_trace(sig);
gSystem->Exit(128 + sig);
}
};

class ApplicationStarter {
Expand Down
2 changes: 1 addition & 1 deletion bindings/pyroot_legacy/inc/TPyDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TPyDispatcher : public TObject {
TPyDispatcher( PyObject* callable );
TPyDispatcher( const TPyDispatcher& );
TPyDispatcher& operator=( const TPyDispatcher& );
~TPyDispatcher();
~TPyDispatcher() override;

public:
#ifndef __CINT__
Expand Down
6 changes: 3 additions & 3 deletions bindings/pyroot_legacy/inc/TPyException.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class TPyException : public std::exception {
TPyException();

// destructor
virtual ~TPyException() noexcept;
~TPyException() noexcept override;

// give reason for raised exception
virtual const char* what() const noexcept;
// give reason for raised exception
const char *what() const noexcept override;

ClassDef(TPyException,0) //C++ exception for throwing python exceptions
};
Expand Down
28 changes: 13 additions & 15 deletions bindings/pyroot_legacy/inc/TPyFitFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ class TPyMultiGenFunction : public ROOT::Math::IMultiGenFunction {
public:
// ctor/dtor, and assignment
TPyMultiGenFunction( PyObject* self = 0 );
virtual ~TPyMultiGenFunction();
~TPyMultiGenFunction() override;

// Math::IMultiGenFunction implementation
virtual ROOT::Math::IBaseFunctionMultiDim* Clone() const
{ return new TPyMultiGenFunction( fPySelf ); }
virtual unsigned int NDim() const;
virtual double DoEval( const double* x ) const;
// Math::IMultiGenFunction implementation
ROOT::Math::IBaseFunctionMultiDim *Clone() const override { return new TPyMultiGenFunction(fPySelf); }
unsigned int NDim() const override;
double DoEval(const double *x) const override;

ClassDef( TPyMultiGenFunction, 1 ); //Python for Math::IMultiGenFunction equivalent

Expand All @@ -49,17 +48,16 @@ class TPyMultiGradFunction : public ROOT::Math::IMultiGradFunction {
public:
// ctor/dtor, and assignment
TPyMultiGradFunction( PyObject* self = 0 );
virtual ~TPyMultiGradFunction();
~TPyMultiGradFunction() override;

// Math::IMultiGenFunction implementation
virtual ROOT::Math::IBaseFunctionMultiDim* Clone() const
{ return new TPyMultiGradFunction( fPySelf ); }
virtual unsigned int NDim() const;
virtual double DoEval( const double* x ) const;
// Math::IMultiGenFunction implementation
ROOT::Math::IBaseFunctionMultiDim *Clone() const override { return new TPyMultiGradFunction(fPySelf); }
unsigned int NDim() const override;
double DoEval(const double *x) const override;

virtual void Gradient( const double* x, double* grad ) const;
virtual void FdF( const double* x, double& f, double* df ) const;
virtual double DoDerivative( const double * x, unsigned int icoord ) const;
void Gradient(const double *x, double *grad) const override;
void FdF(const double *x, double &f, double *df) const override;
double DoDerivative(const double *x, unsigned int icoord) const override;

ClassDef( TPyMultiGradFunction, 1 ); //Python for Math::IMultiGradFunction equivalent

Expand Down
2 changes: 1 addition & 1 deletion bindings/pyroot_legacy/inc/TPyROOTApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TPyROOTApplication : public TApplication {
TPyROOTApplication(
const char* acn, Int_t* argc, char** argv, Bool_t bLoadLibs = kTRUE );

virtual ~TPyROOTApplication() { }
~TPyROOTApplication() override {}
ClassDef(TPyROOTApplication,0) //Setup interactive application
};

Expand Down
24 changes: 12 additions & 12 deletions bindings/pyroot_legacy/inc/TPySelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ class TPySelector : public TSelector {
public:
// ctor/dtor ... cctor and assignment are private in base class
TPySelector( TTree* /* tree */ = 0, PyObject* self = 0 );
virtual ~TPySelector();
~TPySelector() override;

// TSelector set of forwarded (overridden) methods
virtual Int_t Version() const;
virtual Int_t GetEntry( Long64_t entry, Int_t getall = 0 );
virtual Bool_t Notify();
// TSelector set of forwarded (overridden) methods
Int_t Version() const override;
Int_t GetEntry(Long64_t entry, Int_t getall = 0) override;
Bool_t Notify() override;

virtual void Init( TTree* tree );
virtual void Begin( TTree* tree = 0 /* not used */ );
virtual void SlaveBegin( TTree* tree );
virtual Bool_t Process( Long64_t entry );
virtual void SlaveTerminate();
virtual void Terminate();
void Init(TTree *tree) override;
void Begin(TTree *tree = 0 /* not used */) override;
void SlaveBegin(TTree *tree) override;
Bool_t Process(Long64_t entry) override;
void SlaveTerminate() override;
void Terminate() override;

virtual void Abort( const char* why, EAbort what = kAbortProcess );
void Abort(const char *why, EAbort what = kAbortProcess) override;

ClassDef( TPySelector, 1 ); //Python equivalent base class for PROOF

Expand Down
Loading