Skip to content

Commit

Permalink
py3: CXX: remaining diff:
Browse files Browse the repository at this point in the history
win: exernalize missing CXX-functions
define PYCXX_PYTHON_2TO3
  • Loading branch information
looooo authored and yorikvanhavre committed May 27, 2017
1 parent d5c5870 commit 852a984
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 36 deletions.
29 changes: 17 additions & 12 deletions src/CXX/Python3/Config.hxx
Expand Up @@ -106,20 +106,20 @@
# define EXPLICIT_CLASS
# define TEMPLATE_TYPENAME class
#endif

// export macro

// export macro
#if defined( _MSC_VER )
# pragma warning( disable : 4251 )
#endif
# pragma warning( disable : 4251 )
#endif
#if defined( _MSC_VER ) || defined( __MINGW32__ )
# ifdef PYCXX_DLL
# define PYCXX_EXPORT __declspec(dllexport)
# else
# define PYCXX_EXPORT __declspec(dllimport)
# endif
#else
# define PYCXX_EXPORT
#endif
# ifdef PYCXX_DLL
# define PYCXX_EXPORT __declspec(dllexport)
# else
# define PYCXX_EXPORT __declspec(dllimport)
# endif
#else
# define PYCXX_EXPORT
#endif

// before 3.2 Py_hash_t was missing
#ifndef PY_MAJOR_VERSION
Expand All @@ -128,4 +128,9 @@
#if PY_MINOR_VERSION < 2
typedef long int Py_hash_t;
#endif

#ifndef PYCXX_PYTHON_2TO3
#define PYCXX_PYTHON_2TO3
#endif

#endif // __PyCXX_config_hh__
2 changes: 1 addition & 1 deletion src/CXX/Python3/ExtensionType.hxx
Expand Up @@ -104,7 +104,7 @@

namespace Py
{
extern PythonExtensionBase *getPythonExtensionBase( PyObject *self );
PYCXX_EXPORT extern PythonExtensionBase *getPythonExtensionBase( PyObject *self );
struct PythonClassInstance
{
PyObject_HEAD
Expand Down
4 changes: 2 additions & 2 deletions src/CXX/Python3/IndirectPythonInterface.hxx
Expand Up @@ -175,8 +175,8 @@ PYCXX_EXPORT int &_Py_TabcheckFlag();
PYCXX_EXPORT int &_Py_VerboseFlag();
PYCXX_EXPORT int &_Py_UnicodeFlag();

void _XINCREF( PyObject *op );
void _XDECREF( PyObject *op );
PYCXX_EXPORT void _XINCREF( PyObject *op );
PYCXX_EXPORT void _XDECREF( PyObject *op );

PYCXX_EXPORT char *__Py_PackageContext();
};
Expand Down
38 changes: 19 additions & 19 deletions src/CXX/Python3/Objects.hxx
Expand Up @@ -239,7 +239,7 @@ namespace Py
//

// Can pyob be used in this object's constructor?
virtual bool accepts( PyObject *pyob ) const
virtual bool accepts( PyObject * /* pyob */ ) const
{
// allow any object or NULL
return true;
Expand Down Expand Up @@ -429,12 +429,12 @@ namespace Py
};

//------------------------------------------------------------
bool operator==( const Object &o1, const Object &o2 );
bool operator!=( const Object &o1, const Object &o2 );
bool operator>=( const Object &o1, const Object &o2 );
bool operator<=( const Object &o1, const Object &o2 );
bool operator<( const Object &o1, const Object &o2 );
bool operator>( const Object &o1, const Object &o2 );
PYCXX_EXPORT bool operator==( const Object &o1, const Object &o2 );
PYCXX_EXPORT bool operator!=( const Object &o1, const Object &o2 );
PYCXX_EXPORT bool operator>=( const Object &o1, const Object &o2 );
PYCXX_EXPORT bool operator<=( const Object &o1, const Object &o2 );
PYCXX_EXPORT bool operator<( const Object &o1, const Object &o2 );
PYCXX_EXPORT bool operator>( const Object &o1, const Object &o2 );

//------------------------------------------------------------

Expand Down Expand Up @@ -480,7 +480,7 @@ namespace Py

// TMM: 31May'01 - Added the #ifndef so I can exlude iostreams.
#ifndef CXX_NO_IOSTREAMS
std::ostream &operator<<( std::ostream &os, const Object &ob );
PYCXX_EXPORT std::ostream &operator<<( std::ostream &os, const Object &ob );
#endif

// Class Type
Expand Down Expand Up @@ -1285,7 +1285,7 @@ namespace Py
// ...the base class for all sequence types

template<TEMPLATE_TYPENAME T>
class PYCXX_EXPORT SeqBase: public Object
class SeqBase: public Object
{
public:
// STL definitions
Expand Down Expand Up @@ -2179,7 +2179,7 @@ namespace Py
}

// New tuple of a given size
explicit Tuple( int size = 0 )
explicit Tuple( sequence_index_type size = 0 )
{
set( PyTuple_New( size ), true );
validate();
Expand Down Expand Up @@ -2237,7 +2237,7 @@ namespace Py
{
public:
TupleN()
: Tuple( 0 )
: Tuple( (sequence_index_type)0 )
{
}

Expand Down Expand Up @@ -2362,7 +2362,7 @@ namespace Py
validate();
}
// Creation at a fixed size
List( int size = 0 )
List( sequence_index_type size = 0 )
{
set( PyList_New( size ), true );
validate();
Expand All @@ -2379,7 +2379,7 @@ namespace Py
List( const Sequence &s )
: Sequence()
{
int n =( int )s.length();
sequence_index_type n =( int )s.length();
set( PyList_New( n ), true );
validate();
for( sequence_index_type i=0; i < n; i++ )
Expand Down Expand Up @@ -2648,7 +2648,7 @@ namespace Py
#endif

template<TEMPLATE_TYPENAME T>
class PYCXX_EXPORT MapBase: public Object
class MapBase: public Object
{
protected:
explicit MapBase<T>()
Expand Down Expand Up @@ -3059,10 +3059,10 @@ namespace Py
template <TEMPLATE_TYPENAME T> bool operator==( const EXPLICIT_TYPENAME MapBase<T>::const_iterator &left, const EXPLICIT_TYPENAME MapBase<T>::const_iterator &right );
template <TEMPLATE_TYPENAME T> bool operator!=( const EXPLICIT_TYPENAME MapBase<T>::const_iterator &left, const EXPLICIT_TYPENAME MapBase<T>::const_iterator &right );

extern bool operator==( const Mapping::iterator &left, const Mapping::iterator &right );
extern bool operator!=( const Mapping::iterator &left, const Mapping::iterator &right );
extern bool operator==( const Mapping::const_iterator &left, const Mapping::const_iterator &right );
extern bool operator!=( const Mapping::const_iterator &left, const Mapping::const_iterator &right );
PYCXX_EXPORT extern bool operator==( const Mapping::iterator &left, const Mapping::iterator &right );
PYCXX_EXPORT extern bool operator!=( const Mapping::iterator &left, const Mapping::iterator &right );
PYCXX_EXPORT extern bool operator==( const Mapping::const_iterator &left, const Mapping::const_iterator &right );
PYCXX_EXPORT extern bool operator!=( const Mapping::const_iterator &left, const Mapping::const_iterator &right );


// ==================================================
Expand Down Expand Up @@ -3233,7 +3233,7 @@ namespace Py
inline Object Object::callMemberFunction( const std::string &function_name ) const
{
Callable target( getAttr( function_name ) );
Tuple args( 0 );
Tuple args( (sequence_index_type)0 );
return target.apply( args );
}

Expand Down
6 changes: 4 additions & 2 deletions src/CXX/Python3/cxx_extensions.cxx
Expand Up @@ -222,7 +222,9 @@ extern "C"
// All the following functions redirect the call from Python
// onto the matching virtual function in PythonExtensionBase
//
#ifdef PYCXX_PYTHON_2TO3
static int print_handler( PyObject *, FILE *, int );
#endif
static PyObject *getattr_handler( PyObject *, char * );
static int setattr_handler( PyObject *, char *, PyObject * );
static PyObject *getattro_handler( PyObject *, PyObject * );
Expand Down Expand Up @@ -1221,7 +1223,7 @@ Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
return self().callMemberFunction( fn_name, args );
}

void PythonExtensionBase::reinit( Tuple &args, Dict &kwds )
void PythonExtensionBase::reinit( Tuple & /* args */, Dict & /* kwds */)
{
throw RuntimeError( "Must not call __init__ twice on this class" );
}
Expand Down Expand Up @@ -1479,7 +1481,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;
Expand Down

0 comments on commit 852a984

Please sign in to comment.