}
+static PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg)
+{
+ specPkgObject * s = (specPkgObject *)subtype->tp_alloc(subtype, 0);
+ if (s == NULL) return NULL;
+
+ s->pkg = pkg;
+ return (PyObject *) s;
+}
+
static PyObject * spec_get_packages(specObject *s, void *closure)
{
rpmSpecPkg pkg;
{NULL} /* Sentinel */
};
-static PyObject *spec_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
+static int spec_init(specObject *self, PyObject *args, PyObject *kwds)
{
char * kwlist[] = {"specfile", "flags", NULL};
const char * specfile;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|i:spec_new", kwlist,
&specfile, &flags))
- return NULL;
+ return -1;
spec = rpmSpecParse(specfile, flags, NULL);
- if (spec == NULL) {
+ if (spec != NULL) {
+ rpmSpecFree(self->spec);
+ self->spec = spec;
+ } else {
PyErr_SetString(PyExc_ValueError, "can't parse specfile\n");
- return NULL;
}
- return spec_Wrap(subtype, spec);
+ return (spec == NULL) ? -1 : 0;
}
static PyObject * spec_doBuild(specObject *self, PyObject *args, PyObject *kwds)
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
- 0, /* tp_init */
+ (initproc) spec_init, /* tp_init */
0, /* tp_alloc */
- spec_new, /* tp_new */
+ PyType_GenericNew, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
};
-PyObject *
-spec_Wrap(PyTypeObject *subtype, rpmSpec spec)
-{
- specObject * s = (specObject *)subtype->tp_alloc(subtype, 0);
- if (s == NULL) return NULL;
-
- s->spec = spec;
- return (PyObject *) s;
-}
-
-PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg)
-{
- specPkgObject * s = (specPkgObject *)subtype->tp_alloc(subtype, 0);
- if (s == NULL) return NULL;
-
- s->pkg = pkg;
- return (PyObject *) s;
-}
-
#define specObject_Check(v) ((v)->ob_type == &spec_Type)
#define specPkgObject_Check(v) ((v)->ob_type == &specPkg_Type)
-PyObject * spec_Wrap(PyTypeObject *subtype, rpmSpec spec);
-PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg);
-
#endif /* RPMPYTHON_SPEC */