static PyObject *Polygon_new(PyObject *self, PyObject *args) { PyObject *O = NULL, *TMP = NULL; int hole = 0; Polygon *p = Polygon_NEW(NULL); if (! PyArg_ParseTuple(args, "|Oi", &O, &hole)) Polygon_Raise(ERR_ARG); if (O != NULL) { if ((PyTypeObject *)PyObject_Type(O) == &Polygon_Type) { if (poly_p_clone(((Polygon *)O)->p, p->p) != 0) { Polygon_dealloc(p); return Polygon_Raise(ERR_MEM); } } else if (PyString_Check(O)) { TMP = Polygon_read(p, args); } else if (PySequence_Check(O)) { TMP = Polygon_addContour(p, args); } else if (PyFile_Check(O)) { TMP = Polygon_read(p, args); } else return Polygon_Raise(ERR_ARG); if (TMP) Py_DECREF(TMP); if (PyErr_Occurred()) { Polygon_dealloc(p); return NULL; } } return (PyObject *)p; }
static int Polygon_init(Polygon *self, PyObject *args, PyObject *kwds) { PyObject *O = NULL, *TMP = NULL; int hole; static char *kwlist[] = {"contour", "hole", NULL}; if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", kwlist, &O, &hole)) return -1; if (O != NULL) { if ((PyTypeObject *)PyObject_Type(O) == &Polygon_Type) { if (poly_p_clone(((Polygon *)O)->gpc_p, self->gpc_p) != 0) { Polygon_dealloc(self); Polygon_Raise(ERR_MEM); return -1; } } else if (PyString_Check(O)) { TMP = Polygon_read(self, args); } else if (PySequence_Check(O)) { TMP = Polygon_addContour(self, args); } else if (PyFile_Check(O)) { TMP = Polygon_read(self, args); } else { Polygon_Raise(ERR_ARG); return -1; } if (TMP) { Py_DECREF(TMP); } } return 0; }