PyCXX: [skip ci] harmonize whitespaces with upstream

This commit is contained in:
wmayer
2022-08-01 12:36:07 +02:00
parent fd6dc844be
commit a45a787b4e
11 changed files with 95 additions and 117 deletions

View File

@@ -53,7 +53,7 @@
#endif
//
// Assume all other compilers do
// Assume all other compilers do
//
#else
@@ -68,7 +68,7 @@
#endif
//
// Which C++ standard is in use?
// Which C++ standard is in use?
//
#if defined( _MSC_VER )

View File

@@ -111,7 +111,6 @@ namespace Py
PythonExtensionBase *m_pycxx_object;
};
class PYCXX_EXPORT ExtensionClassMethodsTable
{
public:
@@ -194,7 +193,7 @@ namespace Py
}
virtual ~PythonClass()
{}
{}
static ExtensionClassMethodsTable &methodTable()
{
@@ -212,7 +211,7 @@ namespace Py
static PythonType &behaviors()
{
static PythonType *p;
if( p == NULL )
if( p == NULL )
{
#if defined( _CPPRTTI ) || defined( __GNUG__ )
const char *default_name = (typeid( T )).name();

View File

@@ -47,14 +47,14 @@ namespace Py
// There are two ways that extension objects can get destroyed.
// 1. Their reference count goes to zero
// 2. Someone does an explicit delete on a pointer.
// In(1) the problem is to get the destructor called
// In(1) the problem is to get the destructor called
// We register a special deallocator in the Python type object
// (see behaviors()) to do this.
// In(2) there is no problem, the dtor gets called.
// PythonExtension does not use the usual Python heap allocator,
// PythonExtension does not use the usual Python heap allocator,
// instead using new/delete. We do the setting of the type object
// and reference count, usually done by PyObject_New, in the
// and reference count, usually done by PyObject_New, in the
// base class ctor.
// This special deallocator does a delete on the pointer.
@@ -66,7 +66,7 @@ namespace Py
virtual ~PythonExtensionBase();
public:
// object
// object
virtual void reinit( Tuple &args, Dict &kwds );
// object basics
@@ -98,6 +98,7 @@ namespace Py
// Mapping
virtual int mapping_length();
virtual Object mapping_subscript( const Object & );
virtual int mapping_ass_subscript( const Object &, const Object & );
// Number

View File

@@ -36,9 +36,9 @@
//-----------------------------------------------------------------------------
#ifndef __CXX_INDIRECT_PYTHON_INTERFACE__HXX__
#define __CXX_INDIRECT_PYTHON_INTERFACE__HXX__
# define __CXX_INDIRECT_PYTHON_INTERFACE__HXX__
#include "CXX/WrapPython.h"
# include "CXX/WrapPython.h"
#include "CXX/Config.hxx"
namespace Py
@@ -110,6 +110,9 @@ PYCXX_EXPORT bool _Instance_Check( PyObject *op );
PYCXX_EXPORT PyTypeObject * _Method_Type();
PYCXX_EXPORT bool _Method_Check( PyObject *op );
PYCXX_EXPORT PyTypeObject * _Function_Type();
PYCXX_EXPORT bool _Function_Check( PyObject *op );
PYCXX_EXPORT PyTypeObject * _Complex_Type();
PYCXX_EXPORT bool _Complex_Check( PyObject *op );
@@ -125,9 +128,6 @@ PYCXX_EXPORT bool _Float_Check( PyObject *op );
PYCXX_EXPORT PyTypeObject * _Frame_Type();
PYCXX_EXPORT bool _Frame_Check( PyObject *op );
PYCXX_EXPORT PyTypeObject * _Function_Type();
PYCXX_EXPORT bool _Function_Check( PyObject *op );
PYCXX_EXPORT PyTypeObject * _Bool_Type();
PYCXX_EXPORT bool _Boolean_Check( PyObject *op );
@@ -175,10 +175,10 @@ PYCXX_EXPORT int &_Py_TabcheckFlag();
PYCXX_EXPORT int &_Py_VerboseFlag();
PYCXX_EXPORT int &_Py_UnicodeFlag();
PYCXX_EXPORT const char *__Py_PackageContext();
PYCXX_EXPORT void _XINCREF( PyObject *op );
PYCXX_EXPORT void _XDECREF( PyObject *op );
PYCXX_EXPORT const char *__Py_PackageContext();
}
#endif // __CXX_INDIRECT_PYTHON_INTERFACE__HXX__

View File

@@ -240,7 +240,7 @@ namespace Py
//
// Can pyob be used in this object's constructor?
virtual bool accepts( PyObject * /* pyob */ ) const
virtual bool accepts( PyObject * ) const
{
// allow any object or NULL
return true;
@@ -291,16 +291,6 @@ namespace Py
return PyObject_IsTrue( ptr() ) != 0;
}
//operator bool() const
//{
// return as_bool();
//}
// int print( FILE *fp, int flags=Py_Print_RAW )
//{
// return PyObject_Print( p, fp, flags );
//}
bool is( PyObject *pother ) const
{ // identity test
return p == pother;
@@ -703,11 +693,6 @@ namespace Py
}
#endif
//operator bool() const
//{
// return as_bool();
//}
// convert to long
long as_long() const
{
@@ -730,6 +715,7 @@ namespace Py
return PyLong_AsUnsignedLong( ptr() );
}
// convert to unsigned
operator unsigned long() const
{
return as_unsigned_long();
@@ -1068,6 +1054,7 @@ namespace Py
return PyComplex_ImagAsDouble( ptr() );
}
};
// Sequences
// Sequences are here represented as sequences of items of type T.
// The base class SeqBase<T> represents that.
@@ -1768,7 +1755,7 @@ namespace Py
template <TEMPLATE_TYPENAME T> bool operator< ( const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &left, const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &right );
template <TEMPLATE_TYPENAME T> bool operator> ( const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &left, const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &right );
template <TEMPLATE_TYPENAME T> bool operator<=( const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &left, const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &right );
template <TEMPLATE_TYPENAME T> bool operator>=( const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &left, const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &right );
template <TEMPLATE_TYPENAME T> bool operator>=( const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &left, const EXPLICIT_TYPENAME SeqBase<T>::const_iterator &right );
PYCXX_EXPORT extern bool operator==( const Sequence::iterator &left, const Sequence::iterator &right );
@@ -1783,7 +1770,7 @@ namespace Py
PYCXX_EXPORT extern bool operator< ( const Sequence::const_iterator &left, const Sequence::const_iterator &right );
PYCXX_EXPORT extern bool operator> ( const Sequence::const_iterator &left, const Sequence::const_iterator &right );
PYCXX_EXPORT extern bool operator<=( const Sequence::const_iterator &left, const Sequence::const_iterator &right );
PYCXX_EXPORT extern bool operator>=( const Sequence::const_iterator &left, const Sequence::const_iterator &right );
PYCXX_EXPORT extern bool operator>=( const Sequence::const_iterator &left, const Sequence::const_iterator &right );
// ==================================================
// class Char
@@ -1959,7 +1946,9 @@ namespace Py
// Membership
virtual bool accepts( PyObject *pyob ) const
{
return pyob != 0 &&( Py::_Unicode_Check( pyob ) ) && PySequence_Length( pyob ) == 1;
return (pyob != 0 &&
Py::_Unicode_Check( pyob ) &&
PySequence_Length( pyob ) == 1);
}
explicit Char( PyObject *pyob, bool owned = false )
@@ -2082,7 +2071,7 @@ namespace Py
Many of these APIs take two arguments encoding and errors. These
parameters encoding and errors have the same semantics as the ones
of the builtin unicode() API.
of the builtin unicode() API.
Setting encoding to NULL causes the default encoding to be used.
@@ -2783,7 +2772,7 @@ namespace Py
T getItem( const std::string &s ) const
{
return T( asObject( PyMapping_GetItemString( ptr(),const_cast<char*>( s.c_str() ) ) ) );
return T( asObject( PyMapping_GetItemString( ptr(), const_cast<char*>( s.c_str() ) ) ) );
}
T getItem( const Object &s ) const
@@ -2860,9 +2849,9 @@ namespace Py
friend class MapBase<T>;
//
MapBase<T> *map;
List keys; // for iterating over the map
size_type pos; // index into the keys
MapBase<T> *map;
List keys; // for iterating over the map
size_type pos; // index into the keys
public:
~iterator()
@@ -2945,7 +2934,7 @@ namespace Py
// postfix --
iterator operator--( int )
{
{
return iterator( map, keys, pos-- );
}

View File

@@ -43,7 +43,7 @@ namespace Py
class PYCXX_EXPORT PythonType
{
public:
// if you define one sequence method you must define
// if you define one sequence method you must define
// all of them except the assigns
PythonType( size_t base_size, int itemsize, const char *default_name );

View File

@@ -525,7 +525,7 @@ PythonType &PythonType::supportClass()
return *this;
}
#ifdef PYCXX_PYTHON_2TO3
#if defined( PYCXX_PYTHON_2TO3 )
PythonType &PythonType::supportPrint()
{
#if PY_VERSION_HEX < 0x03080000
@@ -622,7 +622,7 @@ PythonExtensionBase *getPythonExtensionBase( PyObject *self )
}
}
#if defined( PYCXX_PYTHON_2TO3 ) && !defined( Py_LIMITED_API ) && PY_MINOR_VERSION <= 7
#if defined( PYCXX_PYTHON_2TO3 ) && !defined ( Py_LIMITED_API ) && PY_MINOR_VERSION <= 7
extern "C" int print_handler( PyObject *self, FILE *fp, int flags )
{
try
@@ -1245,7 +1245,7 @@ int PythonExtensionBase::genericSetAttro( const Py::String &name, const Py::Obje
return PyObject_GenericSetAttr( selfPtr(), name.ptr(), value.ptr() );
}
#ifdef PYCXX_PYTHON_2TO3
#if defined( PYCXX_PYTHON_2TO3 )
int PythonExtensionBase::print( FILE *, int )
{
missing_method( print );
@@ -1321,15 +1321,15 @@ Py::Object PythonExtensionBase::iter()
PyObject *PythonExtensionBase::iternext()
{
missing_method( iternext );
return NULL; }
return NULL;
}
// Sequence methods
int PythonExtensionBase::sequence_length()
{
missing_method( sequence_length );
return -1; }
return -1;
}
Py::Object PythonExtensionBase::sequence_concat( const Py::Object & )
@@ -1487,7 +1487,7 @@ Py::Object PythonExtensionBase::number_power( const Py::Object &, const Py::Obje
// Buffer
int PythonExtensionBase::buffer_get( Py_buffer * /* buf */, int /* flags */ )
int PythonExtensionBase::buffer_get( Py_buffer * /*buf*/, int /*flags*/ )
{
missing_method( buffer_get );
return -1;
@@ -1495,8 +1495,8 @@ int PythonExtensionBase::buffer_get( Py_buffer * /* buf */, int /* flags */ )
int PythonExtensionBase::buffer_release( Py_buffer * /*buf*/ )
{
/* This method is optional and only required if the buffer's
memory is dynamic. */
// This method is optional and only required if the buffer's
// memory is dynamic.
return 0;
}

View File

@@ -38,14 +38,14 @@
#include "CXX/WrapPython.h"
#ifdef __cplusplus
extern "C"
extern "C"
{
#endif
PyObject py_object_initializer =
PyObject py_object_initializer =
{
_PyObject_EXTRA_INIT
1,
1,
NULL // type must be init'ed by user
};

View File

@@ -37,7 +37,7 @@
#include "CXX/Objects.hxx"
#include <limits>
namespace Py
namespace Py
{
Py_ssize_t numeric_limits_max()
@@ -48,7 +48,7 @@ Py_ssize_t numeric_limits_max()
Py_UNICODE unicode_null_string[1] = { 0 };
Type Object::type() const
{
{
return Type( PyObject_Type( p ), true );
}
@@ -58,7 +58,7 @@ String Object::str() const
}
String Object::repr() const
{
{
return String( PyObject_Repr( p ), true );
}
@@ -73,7 +73,7 @@ List Object::dir() const
}
bool Object::isType( const Type &t ) const
{
{
return type().ptr() == t.ptr();
}
@@ -102,7 +102,6 @@ bool operator!=( const Object &o1, const Object &o2 )
if( PyErr_Occurred() )
throw Exception();
return k != 0;
}
bool operator>=( const Object &o1, const Object &o2 )
@@ -228,7 +227,7 @@ bool operator!=( const Mapping::const_iterator &left, const Mapping::const_itera
std::ostream &operator<<( std::ostream &os, const Object &ob )
{
return( os << static_cast<std::string>( ob.str() ) );
}
}
#endif
} // Py