Skip to content

Commit

Permalink
Update to PyCXX 6.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom committed Feb 25, 2013
1 parent ce1da9b commit e0735bf
Show file tree
Hide file tree
Showing 13 changed files with 566 additions and 1,233 deletions.
520 changes: 517 additions & 3 deletions CXX/IndirectPythonInterface.cxx

Large diffs are not rendered by default.

17 changes: 3 additions & 14 deletions CXX/Python2/ExtensionModule.hxx
Expand Up @@ -66,9 +66,6 @@ namespace Py
const std::string m_module_name;
const std::string m_full_module_name;
MethodTable m_method_table;
#if PY3
PyModuleDef m_module_def;
#endif
PyObject *m_module;

private:
Expand Down Expand Up @@ -136,19 +133,11 @@ namespace Py
{
MethodDefExt<T> *method_def = (*i).second;

#if PY_VERSION_HEX < 0x02070000
static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );
#else
static PyObject *self = PyCapsule_New( this, NULL, NULL );
#endif
static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );

Tuple args( 2 );
args[0] = Object( self );
#if PY_VERSION_HEX < 0x02070000
args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ) );
#else
args[1] = Object( PyCapsule_New( method_def, NULL, NULL ) );
#endif
args[0] = Object( self, true );
args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );

PyObject *func = PyCFunction_New
(
Expand Down
31 changes: 8 additions & 23 deletions CXX/Python2/ExtensionOldType.hxx
Expand Up @@ -178,11 +178,8 @@ namespace Py
Tuple self( 2 );

self[0] = Object( this );
#if PY_VERSION_HEX < 0x02070000
self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );
#else
self[1] = Object( PyCapsule_New( method_def, NULL, NULL ), true );
#endif
self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );

PyObject *func = PyCFunction_New( &method_def->ext_meth_def, self.ptr() );

return Object(func, true);
Expand Down Expand Up @@ -238,12 +235,8 @@ namespace Py

PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
T *self = static_cast<T *>( self_in_cobject );
#if PY_VERSION_HEX < 0x02070000
void *capsule = PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() );
#else
void *capsule = PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL );
#endif
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>( capsule );
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
Object result;

// Adding try & catch in case of STL debug-mode exceptions.
Expand Down Expand Up @@ -278,12 +271,8 @@ namespace Py
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
T *self = static_cast<T *>( self_in_cobject );

#if PY_VERSION_HEX < 0x02070000
void *capsule = PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() );
#else
void *capsule = PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL );
#endif
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>( capsule );
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
Tuple args( _args );

Object result;
Expand Down Expand Up @@ -319,12 +308,8 @@ namespace Py
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
T *self = static_cast<T *>( self_in_cobject );

#if PY_VERSION_HEX < 0x02070000
void *capsule = PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() );
#else
void *capsule = PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL );
#endif
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>( capsule );
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );

Tuple args( _args );

Expand Down
2 changes: 0 additions & 2 deletions CXX/Python2/ExtensionTypeBase.hxx
Expand Up @@ -70,9 +70,7 @@ namespace Py
virtual void reinit( Tuple &args, Dict &kwds );

// object basics
#if defined( PYCXX_PYTHON_2TO3 ) || !defined( PY3 )
virtual int print( FILE *, int );
#endif
virtual Object getattr( const char * );
virtual int setattr( const char *, const Object & );
virtual Object getattro( const String & );
Expand Down

0 comments on commit e0735bf

Please sign in to comment.