summaryrefslogtreecommitdiff
blob: 84c02f4aee49e4d0007edcfcdc0bff6428e35e1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
http://cxx.svn.sourceforge.net/viewvc?view=revision&revision=266

--- CXX/Python3/ExtensionModule.hxx
+++ CXX/Python3/ExtensionModule.hxx
@@ -82,8 +82,6 @@
     extern "C" PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple, PyObject *_args );
     extern "C" PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple, PyObject *_args, PyObject *_keywords );
 
-    extern "C" void do_not_dealloc( void * );
-
     template<TEMPLATE_TYPENAME T>
     class ExtensionModule : public ExtensionModuleBase
     {
@@ -134,11 +132,11 @@
             {
                 MethodDefExt<T> *method_def = (*i).second;
 
-                static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );
+                static PyObject *self = PyCapsule_New( this, NULL, NULL );
 
                 Tuple args( 2 );
                 args[0] = Object( self );
-                args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ) );
+                args[1] = Object( PyCapsule_New( method_def, NULL, NULL ) );
 
                 PyObject *func = PyCFunction_New
                                     (
--- CXX/Python3/ExtensionOldType.hxx
+++ CXX/Python3/ExtensionOldType.hxx
@@ -178,7 +178,7 @@
             Tuple self( 2 );
 
             self[0] = Object( this );
-            self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ) );
+            self[1] = Object( PyCapsule_New( method_def, NULL, NULL ) );
 
             PyObject *func = PyCFunction_New( &method_def->ext_meth_def, self.ptr() );
 
@@ -237,7 +237,7 @@
                 T *self = static_cast<T *>( self_in_cobject );
 
                 MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
-                                                PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
+                                                PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ) );
 
                 Object result;
 
@@ -273,7 +273,7 @@
                 PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
                 T *self = static_cast<T *>( self_in_cobject );
                 MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
-                                                PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
+                                                PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ) );
 
                 Tuple args( _args );
 
@@ -310,7 +310,7 @@
                 PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
                 T *self = static_cast<T *>( self_in_cobject );
                 MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
-                                                PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
+                                                PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ) );
 
                 Tuple args( _args );
 
--- CXX/Python3/IndirectPythonInterface.hxx
+++ CXX/Python3/IndirectPythonInterface.hxx
@@ -109,9 +109,6 @@
 PyTypeObject * _Method_Type();
 bool _Method_Check( PyObject *op );
 
-PyTypeObject * _CObject_Type();
-bool _CObject_Check( PyObject *op );
-
 PyTypeObject * _Complex_Type();
 bool _Complex_Check( PyObject *op );
 
--- Src/IndirectPythonInterface.cxx
+++ Src/IndirectPythonInterface.cxx
@@ -40,7 +40,6 @@
 namespace Py
 {
 bool _CFunction_Check( PyObject *op )   { return op->ob_type == _CFunction_Type(); }
-bool _CObject_Check( PyObject *op )     { return op->ob_type == _CObject_Type(); }
 bool _Complex_Check( PyObject *op )     { return op->ob_type == _Complex_Type(); }
 bool _Dict_Check( PyObject *op )        { return op->ob_type == _Dict_Type(); }
 bool _Float_Check( PyObject *op )       { return op->ob_type == _Float_Type(); }
@@ -59,6 +58,7 @@
 #if PY_MAJOR_VERSION == 2
 bool _String_Check( PyObject *op )      { return op->ob_type == _String_Type(); }
 bool _Int_Check( PyObject *op )         { return op->ob_type == _Int_Type(); }
+bool _CObject_Check( PyObject *op )     { return op->ob_type == _CObject_Type(); }
 #endif
 #if PY_MAJOR_VERSION >= 3
 bool _Bytes_Check( PyObject *op )       { return op->ob_type == _Bytes_Type(); }
@@ -111,7 +111,6 @@
 static PyObject *ptr__PyFalse = NULL;
 static PyObject *ptr__PyTrue = NULL;
 static PyTypeObject *ptr__CFunction_Type = NULL;
-static PyTypeObject *ptr__CObject_Type = NULL;
 static PyTypeObject *ptr__Complex_Type = NULL;
 static PyTypeObject *ptr__Dict_Type = NULL;
 static PyTypeObject *ptr__Float_Type = NULL;
@@ -129,6 +128,7 @@
 #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
 static PyTypeObject *ptr__Bytes_Type = NULL;
@@ -284,7 +284,6 @@
     ptr__PyTrue                 = GetPyObject_As_PyObjectPointer( "_Py_TrueStruct" );
 
     ptr__CFunction_Type         = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
-    ptr__CObject_Type           = GetPyTypeObject_As_PyTypeObjectPointer( "PyCObject_Type" );
     ptr__Complex_Type           = GetPyTypeObject_As_PyTypeObjectPointer( "PyComplex_Type" );
     ptr__Dict_Type              = GetPyTypeObject_As_PyTypeObjectPointer( "PyDict_Type" );
     ptr__Float_Type             = GetPyTypeObject_As_PyTypeObjectPointer( "PyFloat_Type" );
@@ -303,6 +302,7 @@
 #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
     ptr__Bytes_Type             = GetPyTypeObject_As_PyTypeObjectPointer( "PyBytes_Type" );
@@ -367,7 +367,6 @@
 PyObject *_True()                       { return ptr__PyTrue; }
 
 PyTypeObject *_CFunction_Type()         { return ptr__CFunction_Type; }
-PyTypeObject *_CObject_Type()           { return ptr__CObject_Type; }
 PyTypeObject *_Complex_Type()           { return ptr__Complex_Type; }
 PyTypeObject *_Dict_Type()              { return ptr__Dict_Type; }
 PyTypeObject *_Float_Type()             { return ptr__Float_Type; }
@@ -386,6 +385,7 @@
 #if PY_MAJOR_VERSION == 2
 PyTypeObject *_String_Type()            { return ptr__String_Type; }
 PyTypeObject *_Int_Type()               { return ptr__Int_Type; }
+PyTypeObject *_CObject_Type()           { return ptr__CObject_Type; }
 #endif
 #if PY_MAJOR_VERSION >= 3
 PyTypeObject *_Bytes_Type()             { return ptr__Bytes_Type; }
@@ -506,7 +506,6 @@
 PyObject *_True()                       { return Py_True; }
 
 PyTypeObject *_CFunction_Type()         { return &PyCFunction_Type; }
-PyTypeObject *_CObject_Type()           { return &PyCObject_Type; }
 PyTypeObject *_Complex_Type()           { return &PyComplex_Type; }
 PyTypeObject *_Dict_Type()              { return &PyDict_Type; }
 PyTypeObject *_Float_Type()             { return &PyFloat_Type; }
@@ -525,6 +524,7 @@
 #if PY_MAJOR_VERSION == 2
 PyTypeObject *_String_Type()            { return &PyString_Type; }
 PyTypeObject *_Int_Type()               { return &PyInt_Type; }
+PyTypeObject *_CObject_Type()           { return &PyCObject_Type; }
 #endif
 #if PY_MAJOR_VERSION >= 3
 PyTypeObject *_Bytes_Type()             { return &PyBytes_Type; }
--- Src/Python3/cxx_extensions.cxx
+++ Src/Python3/cxx_extensions.cxx
@@ -1471,13 +1471,13 @@
         Tuple self_and_name_tuple( _self_and_name_tuple );
 
         PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
-        void *self_as_void = PyCObject_AsVoidPtr( self_in_cobject );
+        void *self_as_void = PyCapsule_GetPointer( self_in_cobject, NULL );
         if( self_as_void == NULL )
             return NULL;
 
         ExtensionModuleBase *self = static_cast<ExtensionModuleBase *>( self_as_void );
 
-        Object result( self->invoke_method_noargs( PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) ) );
+        Object result( self->invoke_method_noargs( PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ) ) );
 
         return new_reference_to( result.ptr() );
     }
@@ -1494,7 +1494,7 @@
         Tuple self_and_name_tuple( _self_and_name_tuple );
 
         PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
-        void *self_as_void = PyCObject_AsVoidPtr( self_in_cobject );
+        void *self_as_void = PyCapsule_GetPointer( self_in_cobject, NULL );
         if( self_as_void == NULL )
             return NULL;
 
@@ -1504,7 +1504,7 @@
                 (
                 self->invoke_method_varargs
                     (
-                    PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ),
+                    PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ),
                     args
                     )
                 );
@@ -1524,7 +1524,7 @@
         Tuple self_and_name_tuple( _self_and_name_tuple );
 
         PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
-        void *self_as_void = PyCObject_AsVoidPtr( self_in_cobject );
+        void *self_as_void = PyCapsule_GetPointer( self_in_cobject, NULL );
         if( self_as_void == NULL )
             return NULL;
 
@@ -1540,7 +1540,7 @@
                 (
                 self->invoke_method_keyword
                     (
-                    PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ),
+                    PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ),
                     args,
                     keywords
                     )
@@ -1556,7 +1556,7 @@
                     (
                     self->invoke_method_keyword
                         (
-                        PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ),
+                        PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ),
                         args,
                         keywords
                         )
@@ -1571,9 +1571,6 @@
     }
 }
 
-extern "C" void do_not_dealloc( void * )
-{}
-
 
 //--------------------------------------------------------------------------------
 //