1
1
#include "geometry.h"
2
+ #include "doc/geometry_doc.h"
2
3
3
4
static PyObject *
4
5
_pg_circle_subtype_new (PyTypeObject * type , pgCircleBase * circle )
@@ -34,6 +35,7 @@ pgCircle_FromObject(PyObject *obj, pgCircleBase *out)
34
35
return 1 ;
35
36
}
36
37
38
+ /* Paths for sequences */
37
39
if (pgSequenceFast_Check (obj )) {
38
40
PyObject * * f_arr = PySequence_Fast_ITEMS (obj );
39
41
length = PySequence_Fast_GET_SIZE (obj );
@@ -66,7 +68,6 @@ pgCircle_FromObject(PyObject *obj, pgCircleBase *out)
66
68
}
67
69
}
68
70
else if (PySequence_Check (obj )) {
69
- /* Path for other sequences or Types that count as sequences*/
70
71
PyObject * tmp = NULL ;
71
72
length = PySequence_Length (obj );
72
73
if (length == 3 ) {
@@ -128,41 +129,41 @@ pgCircle_FromObject(PyObject *obj, pgCircleBase *out)
128
129
}
129
130
}
130
131
131
- if (PyObject_HasAttrString (obj , "circle" )) {
132
- PyObject * circleattr ;
133
- circleattr = PyObject_GetAttrString (obj , "circle" );
134
- if (!circleattr ) {
135
- PyErr_Clear ();
136
- return 0 ;
137
- }
138
- if (PyCallable_Check (circleattr )) /*call if it's a method*/
139
- {
140
- PyObject * circleresult = PyObject_CallObject (circleattr , NULL );
141
- Py_DECREF (circleattr );
142
- if (!circleresult ) {
143
- PyErr_Clear ();
144
- return 0 ;
145
- }
146
- circleattr = circleresult ;
147
- }
148
- if (!pgCircle_FromObject (circleattr , out )) {
132
+ /* Path for objects that have a circle attribute */
133
+ PyObject * circleattr ;
134
+ if (!(circleattr = PyObject_GetAttrString (obj , "circle" ))) {
135
+ PyErr_Clear ();
136
+ return 0 ;
137
+ }
138
+
139
+ if (PyCallable_Check (circleattr )) /*call if it's a method*/
140
+ {
141
+ PyObject * circleresult = PyObject_CallObject (circleattr , NULL );
142
+ Py_DECREF (circleattr );
143
+ if (!circleresult ) {
149
144
PyErr_Clear ();
150
- Py_DECREF (circleattr );
151
145
return 0 ;
152
146
}
153
- Py_DECREF (circleattr );
147
+ circleattr = circleresult ;
148
+ }
154
149
155
- return 1 ;
150
+ if (!pgCircle_FromObject (circleattr , out )) {
151
+ PyErr_Clear ();
152
+ Py_DECREF (circleattr );
153
+ return 0 ;
156
154
}
157
- return 0 ;
155
+
156
+ Py_DECREF (circleattr );
157
+
158
+ return 1 ;
158
159
}
159
160
160
161
static PyObject *
161
162
pg_circle_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
162
163
{
163
164
pgCircleObject * self = (pgCircleObject * )type -> tp_alloc (type , 0 );
164
165
165
- if (self != NULL ) {
166
+ if (self ) {
166
167
self -> circle .x = self -> circle .y = 0 ;
167
168
self -> circle .r = 1 ;
168
169
self -> weakreflist = NULL ;
@@ -186,7 +187,7 @@ pg_circle_init(pgCircleObject *self, PyObject *args, PyObject *kwds)
186
187
static void
187
188
pg_circle_dealloc (pgCircleObject * self )
188
189
{
189
- if (self -> weakreflist != NULL ) {
190
+ if (self -> weakreflist ) {
190
191
PyObject_ClearWeakRefs ((PyObject * )self );
191
192
}
192
193
@@ -236,8 +237,8 @@ pg_circle_str(pgCircleObject *self)
236
237
}
237
238
238
239
static struct PyMethodDef pg_circle_methods [] = {
239
- {"__copy__" , (PyCFunction )pg_circle_copy , METH_NOARGS , NULL },
240
- {"copy" , (PyCFunction )pg_circle_copy , METH_NOARGS , NULL },
240
+ {"__copy__" , (PyCFunction )pg_circle_copy , METH_NOARGS , DOC_CIRCLE_COPY },
241
+ {"copy" , (PyCFunction )pg_circle_copy , METH_NOARGS , DOC_CIRCLE_COPY },
241
242
{NULL , NULL , 0 , NULL }};
242
243
243
244
#define GETTER_SETTER (name ) \
@@ -294,9 +295,9 @@ pg_circle_setr(pgCircleObject *self, PyObject *value, void *closure)
294
295
}
295
296
296
297
static PyGetSetDef pg_circle_getsets [] = {
297
- {"x" , (getter )pg_circle_getx , (setter )pg_circle_setx , NULL , NULL },
298
- {"y" , (getter )pg_circle_gety , (setter )pg_circle_sety , NULL , NULL },
299
- {"r" , (getter )pg_circle_getr , (setter )pg_circle_setr , NULL , NULL },
298
+ {"x" , (getter )pg_circle_getx , (setter )pg_circle_setx , DOC_CIRCLE_X , NULL },
299
+ {"y" , (getter )pg_circle_gety , (setter )pg_circle_sety , DOC_CIRCLE_Y , NULL },
300
+ {"r" , (getter )pg_circle_getr , (setter )pg_circle_setr , DOC_CIRCLE_R , NULL },
300
301
{NULL , 0 , NULL , NULL , NULL }};
301
302
302
303
static PyTypeObject pgCircle_Type = {
@@ -306,7 +307,7 @@ static PyTypeObject pgCircle_Type = {
306
307
.tp_repr = (reprfunc )pg_circle_repr ,
307
308
.tp_str = (reprfunc )pg_circle_str ,
308
309
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE ,
309
- .tp_doc = NULL ,
310
+ .tp_doc = DOC_CIRCLE ,
310
311
.tp_weaklistoffset = offsetof(pgCircleObject , weakreflist ),
311
312
.tp_methods = pg_circle_methods ,
312
313
.tp_getset = pg_circle_getsets ,
0 commit comments