@@ -90,6 +90,7 @@ typedef struct {
9090 Py_ssize_t x_exports ; /* how many buffer are exported */
9191} XxoObject ;
9292
93+ #define XxoObject_CAST (op ) ((XxoObject *)(op))
9394// XXX: no good way to do this yet
9495// #define XxoObject_Check(v) Py_IS_TYPE(v, Xxo_Type)
9596
@@ -114,28 +115,29 @@ newXxoObject(PyObject *module)
114115/* Xxo finalization */
115116
116117static int
117- Xxo_traverse (PyObject * self_obj , visitproc visit , void * arg )
118+ Xxo_traverse (PyObject * op , visitproc visit , void * arg )
118119{
119120 // Visit the type
120- Py_VISIT (Py_TYPE (self_obj ));
121+ Py_VISIT (Py_TYPE (op ));
121122
122123 // Visit the attribute dict
123- XxoObject * self = ( XxoObject * ) self_obj ;
124+ XxoObject * self = XxoObject_CAST ( op ) ;
124125 Py_VISIT (self -> x_attr );
125126 return 0 ;
126127}
127128
128129static int
129- Xxo_clear (XxoObject * self )
130+ Xxo_clear (PyObject * op )
130131{
132+ XxoObject * self = XxoObject_CAST (op );
131133 Py_CLEAR (self -> x_attr );
132134 return 0 ;
133135}
134136
135137static void
136- Xxo_finalize (PyObject * self_obj )
138+ Xxo_finalize (PyObject * op )
137139{
138- XxoObject * self = ( XxoObject * ) self_obj ;
140+ XxoObject * self = XxoObject_CAST ( op ) ;
139141 Py_CLEAR (self -> x_attr );
140142}
141143
@@ -154,8 +156,9 @@ Xxo_dealloc(PyObject *self)
154156/* Xxo attribute handling */
155157
156158static PyObject *
157- Xxo_getattro (XxoObject * self , PyObject * name )
159+ Xxo_getattro (PyObject * op , PyObject * name )
158160{
161+ XxoObject * self = XxoObject_CAST (op );
159162 if (self -> x_attr != NULL ) {
160163 PyObject * v = PyDict_GetItemWithError (self -> x_attr , name );
161164 if (v != NULL ) {
@@ -165,12 +168,13 @@ Xxo_getattro(XxoObject *self, PyObject *name)
165168 return NULL ;
166169 }
167170 }
168- return PyObject_GenericGetAttr (( PyObject * ) self , name );
171+ return PyObject_GenericGetAttr (op , name );
169172}
170173
171174static int
172- Xxo_setattro (XxoObject * self , PyObject * name , PyObject * v )
175+ Xxo_setattro (PyObject * op , PyObject * name , PyObject * v )
173176{
177+ XxoObject * self = XxoObject_CAST (op );
174178 if (self -> x_attr == NULL ) {
175179 // prepare the attribute dict
176180 self -> x_attr = PyDict_New ();
@@ -197,8 +201,8 @@ Xxo_setattro(XxoObject *self, PyObject *name, PyObject *v)
197201/* Xxo methods */
198202
199203static PyObject *
200- Xxo_demo (XxoObject * self , PyTypeObject * defining_class ,
201- PyObject * * args , Py_ssize_t nargs , PyObject * kwnames )
204+ Xxo_demo (PyObject * op , PyTypeObject * defining_class ,
205+ PyObject * const * args , Py_ssize_t nargs , PyObject * kwnames )
202206{
203207 if (kwnames != NULL && PyObject_Length (kwnames )) {
204208 PyErr_SetString (PyExc_TypeError , "demo() takes no keyword arguments" );
@@ -233,9 +237,10 @@ static PyMethodDef Xxo_methods[] = {
233237/* Xxo buffer interface */
234238
235239static int
236- Xxo_getbuffer (XxoObject * self , Py_buffer * view , int flags )
240+ Xxo_getbuffer (PyObject * op , Py_buffer * view , int flags )
237241{
238- int res = PyBuffer_FillInfo (view , (PyObject * )self ,
242+ XxoObject * self = XxoObject_CAST (op );
243+ int res = PyBuffer_FillInfo (view , op ,
239244 (void * )self -> x_buffer , BUFSIZE ,
240245 0 , flags );
241246 if (res == 0 ) {
@@ -245,14 +250,16 @@ Xxo_getbuffer(XxoObject *self, Py_buffer *view, int flags)
245250}
246251
247252static void
248- Xxo_releasebuffer (XxoObject * self , Py_buffer * view )
253+ Xxo_releasebuffer (PyObject * op , Py_buffer * Py_UNUSED ( view ) )
249254{
255+ XxoObject * self = XxoObject_CAST (op );
250256 self -> x_exports -- ;
251257}
252258
253259static PyObject *
254- Xxo_get_x_exports (XxoObject * self , void * c )
260+ Xxo_get_x_exports (PyObject * op , void * Py_UNUSED ( closure ) )
255261{
262+ XxoObject * self = XxoObject_CAST (op );
256263 return PyLong_FromSsize_t (self -> x_exports );
257264}
258265
@@ -262,7 +269,7 @@ PyDoc_STRVAR(Xxo_doc,
262269 "A class that explicitly stores attributes in an internal dict" );
263270
264271static PyGetSetDef Xxo_getsetlist [] = {
265- {"x_exports" , ( getter ) Xxo_get_x_exports , NULL , NULL },
272+ {"x_exports" , Xxo_get_x_exports , NULL , NULL },
266273 {NULL },
267274};
268275
0 commit comments