Base: apply clang format

This commit is contained in:
wmayer
2023-11-10 18:27:44 +01:00
committed by WandererFan
parent bb333d9a74
commit 985def3416
154 changed files with 11874 additions and 9872 deletions

View File

@@ -29,97 +29,98 @@
#include <CXX/Objects.hxx>
namespace Py {
void SmartPtr::set(PyObject *pyob, bool owned)
{
release();
p = pyob;
if( !owned )
{
Py::_XINCREF( p );
}
}
void SmartPtr::release()
{
Py::_XDECREF( p );
p = nullptr;
}
SmartPtr::SmartPtr()
: p( Py::_None() )
{
Py::_XINCREF( p );
}
SmartPtr::SmartPtr( PyObject *pyob, bool owned)
: p( pyob )
{
if( !owned )
{
Py::_XINCREF( p );
}
}
SmartPtr::SmartPtr( const SmartPtr &ob )
: p( ob.p )
{
Py::_XINCREF( p );
}
SmartPtr &SmartPtr::operator=( const SmartPtr &rhs )
{
set( rhs.ptr() );
return *this;
}
SmartPtr &SmartPtr::operator=( const Object &rhs )
{
set( rhs.ptr() );
return *this;
}
SmartPtr &SmartPtr::operator=( PyObject *rhsp )
{
if( ptr() != rhsp )
set( rhsp );
return *this;
}
SmartPtr::~SmartPtr()
{
release();
}
PyObject *SmartPtr::operator*() const
{
return p;
}
PyObject *SmartPtr::ptr() const
{
return p;
}
bool SmartPtr::is( PyObject *pother ) const
{ // identity test
return p == pother;
}
bool SmartPtr::is( const SmartPtr &other ) const
{ // identity test
return p == other.p;
}
bool SmartPtr::isNull() const
{
return p == nullptr;
}
BaseExport PyObject* new_reference_to(const SmartPtr& g) {
PyObject* p = g.ptr();
namespace Py
{
void SmartPtr::set(PyObject* pyob, bool owned)
{
release();
p = pyob;
if (!owned) {
Py::_XINCREF(p);
return p;
}
}
void SmartPtr::release()
{
Py::_XDECREF(p);
p = nullptr;
}
SmartPtr::SmartPtr()
: p(Py::_None())
{
Py::_XINCREF(p);
}
SmartPtr::SmartPtr(PyObject* pyob, bool owned)
: p(pyob)
{
if (!owned) {
Py::_XINCREF(p);
}
}
SmartPtr::SmartPtr(const SmartPtr& ob)
: p(ob.p)
{
Py::_XINCREF(p);
}
SmartPtr& SmartPtr::operator=(const SmartPtr& rhs)
{
set(rhs.ptr());
return *this;
}
SmartPtr& SmartPtr::operator=(const Object& rhs)
{
set(rhs.ptr());
return *this;
}
SmartPtr& SmartPtr::operator=(PyObject* rhsp)
{
if (ptr() != rhsp) {
set(rhsp);
}
return *this;
}
SmartPtr::~SmartPtr()
{
release();
}
PyObject* SmartPtr::operator*() const
{
return p;
}
PyObject* SmartPtr::ptr() const
{
return p;
}
bool SmartPtr::is(PyObject* pother) const
{ // identity test
return p == pother;
}
bool SmartPtr::is(const SmartPtr& other) const
{ // identity test
return p == other.p;
}
bool SmartPtr::isNull() const
{
return p == nullptr;
}
BaseExport PyObject* new_reference_to(const SmartPtr& g)
{
PyObject* p = g.ptr();
Py::_XINCREF(p);
return p;
}
} // namespace Py