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

@@ -66,8 +66,8 @@ PYCXX_EXPORT bool _Bytes_Check( PyObject *op ) { return op->ob_type == _By
#if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL)
#if defined(MS_WINDOWS)
#include <windows.h>
# if defined(MS_WINDOWS)
# include <windows.h>
static HMODULE python_dll;
@@ -128,14 +128,14 @@ static PyTypeObject *ptr__TraceBack_Type = NULL;
static PyTypeObject *ptr__Tuple_Type = NULL;
static PyTypeObject *ptr__Type_Type = NULL;
static PyTypeObject *ptr__Unicode_Type = NULL;
#if PY_MAJOR_VERSION == 2
# if PY_MAJOR_VERSION == 2
static PyTypeObject *ptr__Int_Type = NULL;
static PyTypeObject *ptr__String_Type = NULL;
static PyTypeObject *ptr__CObject_Type = NULL;
#endif
#if PY_MAJOR_VERSION >= 3
# endif
# if PY_MAJOR_VERSION >= 3
static PyTypeObject *ptr__Bytes_Type = NULL;
#endif
# endif
static int *ptr_Py_DebugFlag = NULL;
@@ -146,9 +146,9 @@ static int *ptr_Py_VerboseFlag = NULL;
static char **ptr__Py_PackageContext = NULL;
#ifdef Py_REF_DEBUG
# ifdef Py_REF_DEBUG
int *ptr_Py_RefTotal;
#endif
# endif
//--------------------------------------------------------------------------------
@@ -219,11 +219,11 @@ static char **GetCharPointer_as_CharPointerPointer( const char *name )
}
#ifdef _DEBUG
# ifdef _DEBUG
static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d_D.DLL";
#else
# else
static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d.DLL";
#endif
# endif
//--------------------------------------------------------------------------------
bool InitialisePythonIndirectInterface()
@@ -238,9 +238,9 @@ bool InitialisePythonIndirectInterface()
try
{
#ifdef Py_REF_DEBUG
# ifdef Py_REF_DEBUG
ptr_Py_RefTotal = GetInt_as_IntPointer( "_Py_RefTotal" );
#endif
# endif
ptr_Py_DebugFlag = GetInt_as_IntPointer( "Py_DebugFlag" );
ptr_Py_InteractiveFlag = GetInt_as_IntPointer( "Py_InteractiveFlag" );
ptr_Py_OptimizeFlag = GetInt_as_IntPointer( "Py_OptimizeFlag" );
@@ -285,11 +285,11 @@ bool InitialisePythonIndirectInterface()
ptr__Exc_UnicodeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnicodeError" );
ptr__PyNone = GetPyObject_As_PyObjectPointer( "_Py_NoneStruct" );
#if PY_MAJOR_VERSION == 2
# if PY_MAJOR_VERSION == 2
ptr__PyFalse = GetPyObject_As_PyObjectPointer( "_Py_ZeroStruct" );
#else
# else
ptr__PyFalse = GetPyObject_As_PyObjectPointer( "_Py_FalseStruct" );
#endif
# endif
ptr__PyTrue = GetPyObject_As_PyObjectPointer( "_Py_TrueStruct" );
ptr__CFunction_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
@@ -308,14 +308,14 @@ bool InitialisePythonIndirectInterface()
ptr__Tuple_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTuple_Type" );
ptr__Type_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyType_Type" );
ptr__Unicode_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyUnicode_Type" );
#if PY_MAJOR_VERSION == 2
# if PY_MAJOR_VERSION == 2
ptr__String_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyString_Type" );
ptr__Int_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInt_Type" );
ptr__CObject_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCObject_Type" );
#endif
#if PY_MAJOR_VERSION >= 3
# endif
# if PY_MAJOR_VERSION >= 3
ptr__Bytes_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBytes_Type" );
#endif
# endif
}
catch( GetAddressException &e )
{
@@ -352,17 +352,17 @@ PYCXX_EXPORT PyObject *_Exc_NotImplementedError() { return ptr__Exc_NotImplem
PYCXX_EXPORT PyObject *_Exc_OSError() { return ptr__Exc_OSError; }
PYCXX_EXPORT PyObject *_Exc_OverflowError() { return ptr__Exc_OverflowError; }
PYCXX_EXPORT PyObject *_Exc_RuntimeError() { return ptr__Exc_RuntimeError; }
#if PY_MAJOR_VERSION == 2
# if PY_MAJOR_VERSION == 2
PYCXX_EXPORT PyObject *_Exc_StandardError() { return ptr__Exc_StandardError; }
#endif
# endif
PYCXX_EXPORT PyObject *_Exc_SyntaxError() { return ptr__Exc_SyntaxError; }
PYCXX_EXPORT PyObject *_Exc_SystemError() { return ptr__Exc_SystemError; }
PYCXX_EXPORT PyObject *_Exc_SystemExit() { return ptr__Exc_SystemExit; }
PYCXX_EXPORT PyObject *_Exc_TypeError() { return ptr__Exc_TypeError; }
PYCXX_EXPORT PyObject *_Exc_ValueError() { return ptr__Exc_ValueError; }
#ifdef MS_WINDOWS
# ifdef MS_WINDOWS
PYCXX_EXPORT PyObject *_Exc_WindowsError() { return ptr__Exc_WindowsError; }
#endif
# endif
PYCXX_EXPORT PyObject *_Exc_ZeroDivisionError() { return ptr__Exc_ZeroDivisionError; }
PYCXX_EXPORT PyObject *_Exc_IndentationError() { return ptr__Exc_IndentationError; }
PYCXX_EXPORT PyObject *_Exc_TabError() { return ptr__Exc_TabError; }
@@ -393,17 +393,14 @@ PYCXX_EXPORT PyTypeObject *_TraceBack_Type() { return ptr__TraceBack_Typ
PYCXX_EXPORT PyTypeObject *_Tuple_Type() { return ptr__Tuple_Type; }
PYCXX_EXPORT PyTypeObject *_Type_Type() { return ptr__Type_Type; }
PYCXX_EXPORT PyTypeObject *_Unicode_Type() { return ptr__Unicode_Type; }
#if PY_MAJOR_VERSION == 2
# if PY_MAJOR_VERSION == 2
PYCXX_EXPORT PyTypeObject *_String_Type() { return ptr__String_Type; }
PYCXX_EXPORT PyTypeObject *_Int_Type() { return ptr__Int_Type; }
PYCXX_EXPORT PyTypeObject *_CObject_Type() { return ptr__CObject_Type; }
#endif
#if PY_MAJOR_VERSION >= 3
# endif
# if PY_MAJOR_VERSION >= 3
PYCXX_EXPORT PyTypeObject *_Bytes_Type() { return ptr__Bytes_Type; }
#endif
PYCXX_EXPORT char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
# endif
//
// wrap the Python Flag variables
@@ -414,18 +411,20 @@ PYCXX_EXPORT int &_Py_OptimizeFlag() { return *ptr_Py_OptimizeFl
PYCXX_EXPORT int &_Py_NoSiteFlag() { return *ptr_Py_NoSiteFlag; }
PYCXX_EXPORT int &_Py_VerboseFlag() { return *ptr_Py_VerboseFlag; }
#if 0
#define Py_INCREF(op) ( \
PYCXX_EXPORT char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
# if 0
# define Py_INCREF(op) ( \
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
((PyObject*)(op))->ob_refcnt++)
#define Py_DECREF(op) \
# define Py_DECREF(op) \
if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
--((PyObject*)(op))->ob_refcnt != 0) \
_Py_CHECK_REFCNT(op) \
else \
_Py_Dealloc((PyObject *)(op))
#endif
# endif
void _XINCREF( PyObject *op )
{
@@ -433,9 +432,9 @@ void _XINCREF( PyObject *op )
if( op == NULL )
return;
#ifdef Py_REF_DEBUG
# ifdef Py_REF_DEBUG
(*ptr_Py_RefTotal)++;
#endif
# endif
(op)->ob_refcnt++;
}
@@ -446,18 +445,18 @@ void _XDECREF( PyObject *op )
if( op == NULL )
return;
#ifdef Py_REF_DEBUG
# ifdef Py_REF_DEBUG
(*ptr_Py_RefTotal)--;
#endif
# endif
if (--(op)->ob_refcnt == 0)
_Py_Dealloc((PyObject *)(op));
}
#else
#error "Can only delay load under Win32"
#endif
# else
# error "Can only delay load under Win32"
# endif
#else
@@ -532,14 +531,14 @@ PYCXX_EXPORT PyTypeObject *_TraceBack_Type() { return &PyTraceBack_Type;
PYCXX_EXPORT PyTypeObject *_Tuple_Type() { return &PyTuple_Type; }
PYCXX_EXPORT PyTypeObject *_Type_Type() { return &PyType_Type; }
PYCXX_EXPORT PyTypeObject *_Unicode_Type() { return &PyUnicode_Type; }
#if PY_MAJOR_VERSION == 2
# if PY_MAJOR_VERSION == 2
PYCXX_EXPORT PyTypeObject *_String_Type() { return &PyString_Type; }
PYCXX_EXPORT PyTypeObject *_Int_Type() { return &PyInt_Type; }
PYCXX_EXPORT PyTypeObject *_CObject_Type() { return &PyCObject_Type; }
#endif
#if PY_MAJOR_VERSION >= 3
# endif
# if PY_MAJOR_VERSION >= 3
PYCXX_EXPORT PyTypeObject *_Bytes_Type() { return &PyBytes_Type; }
#endif
# endif
//
// wrap flags

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

View File

@@ -56,18 +56,9 @@
// pull in python definitions
#include <Python.h>
#ifdef FC_OS_MACOSX
#undef toupper
#undef tolower
#undef isupper
#undef islower
#undef isspace
#undef isalpha
#undef isalnum
#endif
// fix issue with Python assuming that isspace, toupper etc are macros
#if defined(isspace)
#if defined(isspace) || defined(FC_OS_MACOSX)
#undef isspace
#undef isupper
#undef islower