Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86a34ca

Browse files
committed
Update PyCXX to 6.2.2 and remove dependency on PyCObject
1 parent 3878f85 commit 86a34ca

6 files changed

Lines changed: 177 additions & 37 deletions

File tree

CXX/Python2/cxx_extensions.cxx

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,84 @@ PythonExtensionBase::~PythonExtensionBase()
13201320
assert( ob_refcnt == 0 );
13211321
}
13221322

1323+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name )
1324+
{
1325+
Py::TupleN args;
1326+
return self().callMemberFunction( fn_name, args );
1327+
}
1328+
1329+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
1330+
const Py::Object &arg1 )
1331+
{
1332+
Py::TupleN args( arg1 );
1333+
return self().callMemberFunction( fn_name, args );
1334+
}
1335+
1336+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
1337+
const Py::Object &arg1, const Py::Object &arg2 )
1338+
{
1339+
Py::TupleN args( arg1, arg2 );
1340+
return self().callMemberFunction( fn_name, args );
1341+
}
1342+
1343+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
1344+
const Py::Object &arg1, const Py::Object &arg2, const Py::Object &arg3 )
1345+
{
1346+
Py::TupleN args( arg1, arg2, arg3 );
1347+
return self().callMemberFunction( fn_name, args );
1348+
}
1349+
1350+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
1351+
const Py::Object &arg1, const Py::Object &arg2, const Py::Object &arg3,
1352+
const Py::Object &arg4 )
1353+
{
1354+
Py::TupleN args( arg1, arg2, arg3, arg4 );
1355+
return self().callMemberFunction( fn_name, args );
1356+
}
1357+
1358+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
1359+
const Py::Object &arg1, const Py::Object &arg2, const Py::Object &arg3,
1360+
const Py::Object &arg4, const Py::Object &arg5 )
1361+
{
1362+
Py::TupleN args( arg1, arg2, arg3, arg4, arg5 );
1363+
return self().callMemberFunction( fn_name, args );
1364+
}
1365+
1366+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
1367+
const Py::Object &arg1, const Py::Object &arg2, const Py::Object &arg3,
1368+
const Py::Object &arg4, const Py::Object &arg5, const Py::Object &arg6 )
1369+
{
1370+
Py::TupleN args( arg1, arg2, arg3, arg4, arg5, arg6 );
1371+
return self().callMemberFunction( fn_name, args );
1372+
}
1373+
1374+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
1375+
const Py::Object &arg1, const Py::Object &arg2, const Py::Object &arg3,
1376+
const Py::Object &arg4, const Py::Object &arg5, const Py::Object &arg6,
1377+
const Py::Object &arg7 )
1378+
{
1379+
Py::TupleN args( arg1, arg2, arg3, arg4, arg5, arg6, arg7 );
1380+
return self().callMemberFunction( fn_name, args );
1381+
}
1382+
1383+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
1384+
const Py::Object &arg1, const Py::Object &arg2, const Py::Object &arg3,
1385+
const Py::Object &arg4, const Py::Object &arg5, const Py::Object &arg6,
1386+
const Py::Object &arg7, const Py::Object &arg8 )
1387+
{
1388+
Py::TupleN args( arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 );
1389+
return self().callMemberFunction( fn_name, args );
1390+
}
1391+
1392+
Py::Object PythonExtensionBase::callOnSelf( const std::string &fn_name,
1393+
const Py::Object &arg1, const Py::Object &arg2, const Py::Object &arg3,
1394+
const Py::Object &arg4, const Py::Object &arg5, const Py::Object &arg6,
1395+
const Py::Object &arg7, const Py::Object &arg8, const Py::Object &arg9 )
1396+
{
1397+
Py::TupleN args( arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 );
1398+
return self().callMemberFunction( fn_name, args );
1399+
}
1400+
13231401
void PythonExtensionBase::reinit( Tuple &args, Dict &kwds )
13241402
{
13251403
throw RuntimeError( "Must not call __init__ twice on this class" );
@@ -1353,16 +1431,14 @@ int PythonExtensionBase::setattr( const char *, const Py::Object &)
13531431
return -1;
13541432
}
13551433

1356-
Py::Object PythonExtensionBase::getattro( const Py::String &)
1434+
Py::Object PythonExtensionBase::getattro( const Py::String &name )
13571435
{
1358-
missing_method( getattro );
1359-
return Py::None();
1436+
return genericGetAttro( name );
13601437
}
13611438

1362-
int PythonExtensionBase::setattro( const Py::String &, const Py::Object &)
1439+
int PythonExtensionBase::setattro( const Py::String &name, const Py::Object &value )
13631440
{
1364-
missing_method( setattro );
1365-
return -1;
1441+
return genericSetAttro( name, value );
13661442
}
13671443

13681444
int PythonExtensionBase::compare( const Py::Object &)

CXX/Python3/ExtensionModule.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ namespace Py
134134
{
135135
MethodDefExt<T> *method_def = (*i).second;
136136

137-
static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );
137+
static PyObject *self = PyCapsule_New( this, NULL, NULL );
138138

139139
Tuple args( 2 );
140140
args[0] = Object( self );
141-
args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ) );
141+
args[1] = Object( PyCapsule_New( method_def, NULL, NULL ) );
142142

143143
PyObject *func = PyCFunction_New
144144
(

CXX/Python3/ExtensionOldType.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ namespace Py
178178
Tuple self( 2 );
179179

180180
self[0] = Object( this );
181-
self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ) );
181+
self[1] = Object( PyCapsule_New( method_def, NULL, NULL ) );
182182

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

@@ -237,7 +237,7 @@ namespace Py
237237
T *self = static_cast<T *>( self_in_cobject );
238238

239239
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
240-
PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
240+
PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ) );
241241

242242
Object result;
243243

@@ -273,7 +273,7 @@ namespace Py
273273
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
274274
T *self = static_cast<T *>( self_in_cobject );
275275
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
276-
PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
276+
PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ) );
277277

278278
Tuple args( _args );
279279

@@ -310,7 +310,7 @@ namespace Py
310310
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
311311
T *self = static_cast<T *>( self_in_cobject );
312312
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
313-
PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
313+
PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ) );
314314

315315
Tuple args( _args );
316316

CXX/Python3/IndirectPythonInterface.cxx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
namespace Py
4141
{
4242
bool _CFunction_Check( PyObject *op ) { return op->ob_type == _CFunction_Type(); }
43-
bool _CObject_Check( PyObject *op ) { return op->ob_type == _CObject_Type(); }
4443
bool _Complex_Check( PyObject *op ) { return op->ob_type == _Complex_Type(); }
4544
bool _Dict_Check( PyObject *op ) { return op->ob_type == _Dict_Type(); }
4645
bool _Float_Check( PyObject *op ) { return op->ob_type == _Float_Type(); }
@@ -80,7 +79,6 @@ static PyObject *ptr__Exc_KeyboardInterrupt = NULL;
8079
static PyObject *ptr__Exc_KeyError = NULL;
8180
static PyObject *ptr__Exc_LookupError = NULL;
8281
static PyObject *ptr__Exc_MemoryError = NULL;
83-
static PyObject *ptr__Exc_MemoryErrorInst = NULL;
8482
static PyObject *ptr__Exc_NameError = NULL;
8583
static PyObject *ptr__Exc_NotImplementedError = NULL;
8684
static PyObject *ptr__Exc_OSError = NULL;
@@ -106,7 +104,6 @@ static PyObject *ptr__PyNone = NULL;
106104
static PyObject *ptr__PyFalse = NULL;
107105
static PyObject *ptr__PyTrue = NULL;
108106
static PyTypeObject *ptr__CFunction_Type = NULL;
109-
static PyTypeObject *ptr__CObject_Type = NULL;
110107
static PyTypeObject *ptr__Complex_Type = NULL;
111108
static PyTypeObject *ptr__Dict_Type = NULL;
112109
static PyTypeObject *ptr__Float_Type = NULL;
@@ -245,7 +242,6 @@ bool InitialisePythonIndirectInterface()
245242
ptr__Exc_KeyError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyError" );
246243
ptr__Exc_LookupError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_LookupError" );
247244
ptr__Exc_MemoryError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryError" );
248-
ptr__Exc_MemoryErrorInst = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryErrorInst" );
249245
ptr__Exc_NameError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NameError" );
250246
ptr__Exc_NotImplementedError= GetPyObjectPointer_As_PyObjectPointer( "PyExc_NotImplementedError" );
251247
ptr__Exc_OSError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OSError" );
@@ -271,7 +267,6 @@ bool InitialisePythonIndirectInterface()
271267
ptr__PyTrue = GetPyObject_As_PyObjectPointer( "_Py_TrueStruct" );
272268

273269
ptr__CFunction_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
274-
ptr__CObject_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCObject_Type" );
275270
ptr__Complex_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyComplex_Type" );
276271
ptr__Dict_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyDict_Type" );
277272
ptr__Float_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFloat_Type" );
@@ -318,7 +313,6 @@ PyObject *_Exc_KeyboardInterrupt() { return ptr__Exc_KeyboardInterrupt; }
318313
PyObject *_Exc_KeyError() { return ptr__Exc_KeyError; }
319314
PyObject *_Exc_LookupError() { return ptr__Exc_LookupError; }
320315
PyObject *_Exc_MemoryError() { return ptr__Exc_MemoryError; }
321-
PyObject *_Exc_MemoryErrorInst() { return ptr__Exc_MemoryErrorInst; }
322316
PyObject *_Exc_NameError() { return ptr__Exc_NameError; }
323317
PyObject *_Exc_NotImplementedError() { return ptr__Exc_NotImplementedError; }
324318
PyObject *_Exc_OSError() { return ptr__Exc_OSError; }
@@ -348,7 +342,6 @@ PyObject *_False() { return ptr__PyFalse; }
348342
PyObject *_True() { return ptr__PyTrue; }
349343

350344
PyTypeObject *_CFunction_Type() { return ptr__CFunction_Type; }
351-
PyTypeObject *_CObject_Type() { return ptr__CObject_Type; }
352345
PyTypeObject *_Complex_Type() { return ptr__Complex_Type; }
353346
PyTypeObject *_Dict_Type() { return ptr__Dict_Type; }
354347
PyTypeObject *_Float_Type() { return ptr__Float_Type; }
@@ -449,7 +442,6 @@ PyObject *_Exc_KeyboardInterrupt() { return ::PyExc_KeyboardInterrupt; }
449442
PyObject *_Exc_KeyError() { return ::PyExc_KeyError; }
450443
PyObject *_Exc_LookupError() { return ::PyExc_LookupError; }
451444
PyObject *_Exc_MemoryError() { return ::PyExc_MemoryError; }
452-
PyObject *_Exc_MemoryErrorInst() { return ::PyExc_MemoryErrorInst; }
453445
PyObject *_Exc_NameError() { return ::PyExc_NameError; }
454446
PyObject *_Exc_NotImplementedError() { return ::PyExc_NotImplementedError; }
455447
PyObject *_Exc_OSError() { return ::PyExc_OSError; }
@@ -482,7 +474,6 @@ PyObject *_False() { return Py_False; }
482474
PyObject *_True() { return Py_True; }
483475

484476
PyTypeObject *_CFunction_Type() { return &PyCFunction_Type; }
485-
PyTypeObject *_CObject_Type() { return &PyCObject_Type; }
486477
PyTypeObject *_Complex_Type() { return &PyComplex_Type; }
487478
PyTypeObject *_Dict_Type() { return &PyDict_Type; }
488479
PyTypeObject *_Float_Type() { return &PyFloat_Type; }

CXX/Python3/IndirectPythonInterface.hxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ bool _Instance_Check( PyObject *op );
109109
PyTypeObject * _Method_Type();
110110
bool _Method_Check( PyObject *op );
111111

112-
PyTypeObject * _CObject_Type();
113-
bool _CObject_Check( PyObject *op );
114-
115112
PyTypeObject * _Complex_Type();
116113
bool _Complex_Check( PyObject *op );
117114

0 commit comments

Comments
 (0)