Python stable ABI: Adjust type usage & declarations

The previous commit removed all *_Type variables.
This adds them back, but as *pointers* to Python type objects
rather than type objects themselves.

All usages now need an extra pointer dereference (or removing an
address-of).
(The compiler will complain of type safety if we miss a spot,
so I'm OK using the original names.)

Also, add header declarations for the Spec structs.
This commit is contained in:
Petr Viktorin 2023-01-11 13:39:30 +01:00 committed by Panu Matilainen
parent 0d33ad8530
commit 2e74eec244
28 changed files with 91 additions and 57 deletions

View File

@ -647,6 +647,7 @@ static PyType_Slot hdr_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* hdr_Type;
PyType_Spec hdr_Type_Spec = { PyType_Spec hdr_Type_Spec = {
.name = "rpm.hdr", .name = "rpm.hdr",
.basicsize = sizeof(hdrObject), .basicsize = sizeof(hdrObject),
@ -679,8 +680,8 @@ PyObject * versionCompare (PyObject * self, PyObject * args, PyObject * kwds)
hdrObject * h1, * h2; hdrObject * h1, * h2;
char * kwlist[] = {"version0", "version1", NULL}; char * kwlist[] = {"version0", "version1", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", kwlist, &hdr_Type, if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", kwlist, hdr_Type,
&h1, &hdr_Type, &h2)) &h1, hdr_Type, &h2))
return NULL; return NULL;
return Py_BuildValue("i", rpmVersionCompare(h1->h, h2->h)); return Py_BuildValue("i", rpmVersionCompare(h1->h, h2->h));

View File

@ -5,9 +5,10 @@
typedef struct hdrObject_s hdrObject; typedef struct hdrObject_s hdrObject;
extern PyTypeObject hdr_Type; extern PyTypeObject* hdr_Type;
extern PyType_Spec hdr_Type_Spec;
#define hdrObject_Check(v) ((v)->ob_type == &hdr_Type) #define hdrObject_Check(v) ((v)->ob_type == hdr_Type)
#define DEPRECATED_METHOD(_msg) \ #define DEPRECATED_METHOD(_msg) \
PyErr_WarnEx(PyExc_PendingDeprecationWarning, (_msg), 2); PyErr_WarnEx(PyExc_PendingDeprecationWarning, (_msg), 2);

View File

@ -229,6 +229,7 @@ static PyType_Slot rpmarchive_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmarchive_Type;
PyType_Spec rpmarchive_Type_Spec = { PyType_Spec rpmarchive_Type_Spec = {
.name = "rpm.archive", .name = "rpm.archive",
.basicsize = sizeof(rpmarchiveObject), .basicsize = sizeof(rpmarchiveObject),

View File

@ -5,9 +5,10 @@
typedef struct rpmarchiveObject_s rpmarchiveObject; typedef struct rpmarchiveObject_s rpmarchiveObject;
extern PyTypeObject rpmarchive_Type; extern PyTypeObject* rpmarchive_Type;
extern PyType_Spec rpmarchive_Type_Spec;
#define rpmarchiveObject_Check(v) ((v)->ob_type == &rpmarchive_Type) #define rpmarchiveObject_Check(v) ((v)->ob_type == rpmarchive_Type)
PyObject * rpmarchive_Wrap(PyTypeObject *subtype, PyObject * rpmarchive_Wrap(PyTypeObject *subtype,
rpmfiles files, rpmfi archive); rpmfiles files, rpmfi archive);

View File

@ -115,7 +115,7 @@ rpmds_Find(rpmdsObject * s, PyObject * arg)
{ {
rpmdsObject * o; rpmdsObject * o;
if (!PyArg_Parse(arg, "O!:Find", &rpmds_Type, &o)) if (!PyArg_Parse(arg, "O!:Find", rpmds_Type, &o))
return NULL; return NULL;
/* XXX make sure ods index is valid, real fix in lib/rpmds.c. */ /* XXX make sure ods index is valid, real fix in lib/rpmds.c. */
@ -129,7 +129,7 @@ rpmds_Merge(rpmdsObject * s, PyObject * arg)
{ {
rpmdsObject * o; rpmdsObject * o;
if (!PyArg_Parse(arg, "O!:Merge", &rpmds_Type, &o)) if (!PyArg_Parse(arg, "O!:Merge", rpmds_Type, &o))
return NULL; return NULL;
return Py_BuildValue("i", rpmdsMerge(&s->ds, o->ds)); return Py_BuildValue("i", rpmdsMerge(&s->ds, o->ds));
@ -139,7 +139,7 @@ rpmds_Search(rpmdsObject * s, PyObject * arg)
{ {
rpmdsObject * o; rpmdsObject * o;
if (!PyArg_Parse(arg, "O!:Merge", &rpmds_Type, &o)) if (!PyArg_Parse(arg, "O!:Merge", rpmds_Type, &o))
return NULL; return NULL;
return Py_BuildValue("i", rpmdsSearch(s->ds, o->ds)); return Py_BuildValue("i", rpmdsSearch(s->ds, o->ds));
@ -149,7 +149,7 @@ static PyObject *rpmds_Compare(rpmdsObject * s, PyObject * o)
{ {
rpmdsObject * ods; rpmdsObject * ods;
if (!PyArg_Parse(o, "O!:Compare", &rpmds_Type, &ods)) if (!PyArg_Parse(o, "O!:Compare", rpmds_Type, &ods))
return NULL; return NULL;
return PyBool_FromLong(rpmdsCompare(s->ds, ods->ds)); return PyBool_FromLong(rpmdsCompare(s->ds, ods->ds));
@ -173,7 +173,7 @@ static PyObject * rpmds_Rpmlib(rpmdsObject * s, PyObject *args, PyObject *kwds)
/* XXX check return code, permit arg (NULL uses system default). */ /* XXX check return code, permit arg (NULL uses system default). */
rpmdsRpmlibPool(pool, &ds, NULL); rpmdsRpmlibPool(pool, &ds, NULL);
return rpmds_Wrap(&rpmds_Type, ds); return rpmds_Wrap(rpmds_Type, ds);
} }
static struct PyMethodDef rpmds_methods[] = { static struct PyMethodDef rpmds_methods[] = {
@ -363,6 +363,7 @@ static PyType_Slot rpmds_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmds_Type;
PyType_Spec rpmds_Type_Spec = { PyType_Spec rpmds_Type_Spec = {
.name = "rpm.ds", .name = "rpm.ds",
.basicsize = sizeof(rpmdsObject), .basicsize = sizeof(rpmdsObject),

View File

@ -5,9 +5,10 @@
typedef struct rpmdsObject_s rpmdsObject; typedef struct rpmdsObject_s rpmdsObject;
extern PyTypeObject rpmds_Type; extern PyTypeObject* rpmds_Type;
extern PyType_Spec rpmds_Type_Spec;
#define rpmdsObject_Check(v) ((v)->ob_type == &rpmds_Type) #define rpmdsObject_Check(v) ((v)->ob_type == rpmds_Type)
rpmds dsFromDs(rpmdsObject * ds); rpmds dsFromDs(rpmdsObject * ds);

View File

@ -25,7 +25,7 @@ int rpmfdFromPyObject(PyObject *obj, rpmfdObject **fdop)
Py_INCREF(obj); Py_INCREF(obj);
fdo = (rpmfdObject *) obj; fdo = (rpmfdObject *) obj;
} else { } else {
fdo = (rpmfdObject *) PyObject_CallFunctionObjArgs((PyObject *)&rpmfd_Type, fdo = (rpmfdObject *) PyObject_CallFunctionObjArgs((PyObject *)rpmfd_Type,
obj, NULL); obj, NULL);
} }
if (fdo == NULL) return 0; if (fdo == NULL) return 0;
@ -356,6 +356,7 @@ static PyType_Slot rpmfd_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmfd_Type;
PyType_Spec rpmfd_Type_Spec = { PyType_Spec rpmfd_Type_Spec = {
.name = "rpm.fd", .name = "rpm.fd",
.basicsize = sizeof(rpmfdObject), .basicsize = sizeof(rpmfdObject),

View File

@ -5,9 +5,10 @@
typedef struct rpmfdObject_s rpmfdObject; typedef struct rpmfdObject_s rpmfdObject;
extern PyTypeObject rpmfd_Type; extern PyTypeObject* rpmfd_Type;
extern PyType_Spec rpmfd_Type_Spec;
#define rpmfdObject_Check(v) ((v)->ob_type == &rpmfd_Type) #define rpmfdObject_Check(v) ((v)->ob_type == rpmfd_Type)
FD_t rpmfdGetFd(rpmfdObject *fdo); FD_t rpmfdGetFd(rpmfdObject *fdo);

View File

@ -327,6 +327,7 @@ static PyType_Slot rpmfile_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmfile_Type;
PyType_Spec rpmfile_Type_Spec = { PyType_Spec rpmfile_Type_Spec = {
.name = "rpm.file", .name = "rpm.file",
.basicsize = sizeof(rpmfileObject), .basicsize = sizeof(rpmfileObject),
@ -336,7 +337,7 @@ PyType_Spec rpmfile_Type_Spec = {
PyObject * rpmfile_Wrap(rpmfiles files, int ix) PyObject * rpmfile_Wrap(rpmfiles files, int ix)
{ {
rpmfileObject *s = PyObject_New(rpmfileObject, &rpmfile_Type); rpmfileObject *s = PyObject_New(rpmfileObject, rpmfile_Type);
if (s == NULL) return NULL; if (s == NULL) return NULL;
s->files = rpmfilesLink(files); s->files = rpmfilesLink(files);
@ -450,7 +451,7 @@ static PyObject *rpmfiles_archive(rpmfilesObject *s,
archive = rpmfiNewArchiveReader(fd, s->files, RPMFI_ITER_READ_ARCHIVE); archive = rpmfiNewArchiveReader(fd, s->files, RPMFI_ITER_READ_ARCHIVE);
} }
return rpmarchive_Wrap(&rpmarchive_Type, s->files, archive); return rpmarchive_Wrap(rpmarchive_Type, s->files, archive);
} }
static PyObject *rpmfiles_subscript(rpmfilesObject *s, PyObject *item) static PyObject *rpmfiles_subscript(rpmfilesObject *s, PyObject *item)
@ -537,6 +538,7 @@ static PyType_Slot rpmfiles_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmfiles_Type;
PyType_Spec rpmfiles_Type_Spec = { PyType_Spec rpmfiles_Type_Spec = {
.name = "rpm.files", .name = "rpm.files",
.basicsize = sizeof(rpmfilesObject), .basicsize = sizeof(rpmfilesObject),

View File

@ -6,11 +6,13 @@
typedef struct rpmfileObject_s rpmfileObject; typedef struct rpmfileObject_s rpmfileObject;
typedef struct rpmfilesObject_s rpmfilesObject; typedef struct rpmfilesObject_s rpmfilesObject;
extern PyTypeObject rpmfile_Type; extern PyTypeObject* rpmfile_Type;
extern PyTypeObject rpmfiles_Type; extern PyType_Spec rpmfile_Type_Spec;
extern PyTypeObject* rpmfiles_Type;
extern PyType_Spec rpmfiles_Type_Spec;
#define rpmfileObject_Check(v) ((v)->ob_type == &rpmfile_Type) #define rpmfileObject_Check(v) ((v)->ob_type == rpmfile_Type)
#define rpmfilesObject_Check(v) ((v)->ob_type == &rpmfiles_Type) #define rpmfilesObject_Check(v) ((v)->ob_type == rpmfiles_Type)
PyObject * rpmfile_Wrap(rpmfiles files, int ix); PyObject * rpmfile_Wrap(rpmfiles files, int ix);
PyObject * rpmfiles_Wrap(PyTypeObject *subtype, rpmfiles files); PyObject * rpmfiles_Wrap(PyTypeObject *subtype, rpmfiles files);

View File

@ -111,6 +111,7 @@ static PyType_Slot rpmii_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmii_Type;
PyType_Spec rpmii_Type_Spec = { PyType_Spec rpmii_Type_Spec = {
.name = "rpm.ii", .name = "rpm.ii",
.basicsize = sizeof(rpmiiObject), .basicsize = sizeof(rpmiiObject),

View File

@ -3,9 +3,10 @@
typedef struct rpmiiObject_s rpmiiObject; typedef struct rpmiiObject_s rpmiiObject;
extern PyTypeObject rpmii_Type; extern PyTypeObject* rpmii_Type;
extern PyType_Spec rpmii_Type_Spec;
#define rpmiiObject_Check(v) ((v)->ob_type == &rpmii_Type) #define rpmiiObject_Check(v) ((v)->ob_type == rpmii_Type)
PyObject * rpmii_Wrap(PyTypeObject *subtype, rpmdbIndexIterator ii, PyObject *s); PyObject * rpmii_Wrap(PyTypeObject *subtype, rpmdbIndexIterator ii, PyObject *s);

View File

@ -67,6 +67,7 @@ static PyType_Slot rpmPubkey_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmPubkey_Type;
PyType_Spec rpmPubkey_Type_Spec = { PyType_Spec rpmPubkey_Type_Spec = {
.name = "rpm.pubkey", .name = "rpm.pubkey",
.basicsize = sizeof(rpmPubkeyObject), .basicsize = sizeof(rpmPubkeyObject),
@ -98,7 +99,7 @@ static PyObject *rpmKeyring_addKey(rpmKeyringObject *s, PyObject *arg)
{ {
rpmPubkeyObject *pubkey = NULL; rpmPubkeyObject *pubkey = NULL;
if (!PyArg_Parse(arg, "O!", &rpmPubkey_Type, &pubkey)) if (!PyArg_Parse(arg, "O!", rpmPubkey_Type, &pubkey))
return NULL; return NULL;
return Py_BuildValue("i", rpmKeyringAddKey(s->keyring, pubkey->pubkey)); return Py_BuildValue("i", rpmKeyringAddKey(s->keyring, pubkey->pubkey));
@ -123,6 +124,7 @@ static PyType_Slot rpmKeyring_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmKeyring_Type;
PyType_Spec rpmKeyring_Type_Spec = { PyType_Spec rpmKeyring_Type_Spec = {
.name = "rpm.keyring", .name = "rpm.keyring",
.basicsize = sizeof(rpmKeyringObject), .basicsize = sizeof(rpmKeyringObject),
@ -153,7 +155,7 @@ PyObject * rpmKeyring_Wrap(PyTypeObject *subtype, rpmKeyring keyring)
int rpmKeyringFromPyObject(PyObject *item, rpmKeyring *keyring) int rpmKeyringFromPyObject(PyObject *item, rpmKeyring *keyring)
{ {
rpmKeyringObject *kro; rpmKeyringObject *kro;
if (!PyArg_Parse(item, "O!", &rpmKeyring_Type, &kro)) if (!PyArg_Parse(item, "O!", rpmKeyring_Type, &kro))
return 0; return 0;
*keyring = kro->keyring; *keyring = kro->keyring;
return 1; return 1;

View File

@ -6,8 +6,10 @@
typedef struct rpmPubkeyObject_s rpmPubkeyObject; typedef struct rpmPubkeyObject_s rpmPubkeyObject;
typedef struct rpmKeyringObject_s rpmKeyringObject; typedef struct rpmKeyringObject_s rpmKeyringObject;
extern PyTypeObject rpmKeyring_Type; extern PyTypeObject* rpmKeyring_Type;
extern PyTypeObject rpmPubkey_Type; extern PyType_Spec rpmKeyring_Type_Spec;
extern PyTypeObject* rpmPubkey_Type;
extern PyType_Spec rpmPubkey_Type_Spec;
PyObject * rpmPubkey_Wrap(PyTypeObject *subtype, rpmPubkey pubkey); PyObject * rpmPubkey_Wrap(PyTypeObject *subtype, rpmPubkey pubkey);
PyObject * rpmKeyring_Wrap(PyTypeObject *subtype, rpmKeyring keyring); PyObject * rpmKeyring_Wrap(PyTypeObject *subtype, rpmKeyring keyring);

View File

@ -76,7 +76,7 @@ rpmmi_iternext(rpmmiObject * s)
return NULL; return NULL;
} }
headerLink(h); headerLink(h);
return hdr_Wrap(&hdr_Type, h); return hdr_Wrap(hdr_Type, h);
} }
static PyObject * static PyObject *
@ -194,6 +194,7 @@ static PyType_Slot rpmmi_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmmi_Type;
PyType_Spec rpmmi_Type_Spec = { PyType_Spec rpmmi_Type_Spec = {
.name = "rpm.mi", .name = "rpm.mi",
.basicsize = sizeof(rpmmiObject), .basicsize = sizeof(rpmmiObject),

View File

@ -3,9 +3,10 @@
typedef struct rpmmiObject_s rpmmiObject; typedef struct rpmmiObject_s rpmmiObject;
extern PyTypeObject rpmmi_Type; extern PyTypeObject* rpmmi_Type;
extern PyType_Spec rpmmi_Type_Spec;
#define rpmmiObject_Check(v) ((v)->ob_type == &rpmmi_Type) #define rpmmiObject_Check(v) ((v)->ob_type == rpmmi_Type)
PyObject * rpmmi_Wrap(PyTypeObject *subtype, rpmdbMatchIterator mi, PyObject *s); PyObject * rpmmi_Wrap(PyTypeObject *subtype, rpmdbMatchIterator mi, PyObject *s);

View File

@ -81,6 +81,7 @@ static PyType_Slot rpmProblem_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmProblem_Type;
PyType_Spec rpmProblem_Type_Spec = { PyType_Spec rpmProblem_Type_Spec = {
.name = "rpm.prob", .name = "rpm.prob",
.basicsize = sizeof(rpmProblemObject), .basicsize = sizeof(rpmProblemObject),
@ -112,7 +113,7 @@ PyObject *rpmps_AsList(rpmps ps)
psi = rpmpsInitIterator(ps); psi = rpmpsInitIterator(ps);
while ((prob = rpmpsiNext(psi))) { while ((prob = rpmpsiNext(psi))) {
PyObject *pyprob = rpmprob_Wrap(&rpmProblem_Type, prob); PyObject *pyprob = rpmprob_Wrap(rpmProblem_Type, prob);
if (!pyprob) { if (!pyprob) {
Py_DECREF(problems); Py_DECREF(problems);
rpmpsFreeIterator(psi); rpmpsFreeIterator(psi);

View File

@ -5,9 +5,10 @@
typedef struct rpmProblemObject_s rpmProblemObject; typedef struct rpmProblemObject_s rpmProblemObject;
extern PyTypeObject rpmProblem_Type; extern PyTypeObject* rpmProblem_Type;
extern PyType_Spec rpmProblem_Type_Spec;
#define rpmProblemObject_Check(v) ((v)->ob_type == &rpmProblem_Type) #define rpmProblemObject_Check(v) ((v)->ob_type == rpmProblem_Type)
PyObject * rpmprob_Wrap(PyTypeObject *subtype, rpmProblem prob); PyObject * rpmprob_Wrap(PyTypeObject *subtype, rpmProblem prob);

View File

@ -101,6 +101,7 @@ static PyType_Slot rpmstrPool_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmstrPool_Type;
PyType_Spec rpmstrPool_Type_Spec = { PyType_Spec rpmstrPool_Type_Spec = {
.name = "rpm.strpool", .name = "rpm.strpool",
.basicsize = sizeof(rpmstrPoolObject), .basicsize = sizeof(rpmstrPoolObject),
@ -123,7 +124,7 @@ PyObject * rpmstrPool_Wrap(PyTypeObject *subtype, rpmstrPool pool)
int poolFromPyObject(PyObject *item, rpmstrPool *pool) int poolFromPyObject(PyObject *item, rpmstrPool *pool)
{ {
rpmstrPoolObject *p = NULL; rpmstrPoolObject *p = NULL;
if (PyArg_Parse(item, "O!", &rpmstrPool_Type, &p)) if (PyArg_Parse(item, "O!", rpmstrPool_Type, &p))
*pool = p->pool; *pool = p->pool;
return (p != NULL); return (p != NULL);
} }

View File

@ -5,7 +5,8 @@
typedef struct rpmstrPoolObject_s rpmstrPoolObject; typedef struct rpmstrPoolObject_s rpmstrPoolObject;
extern PyTypeObject rpmstrPool_Type; extern PyTypeObject* rpmstrPool_Type;
extern PyType_Spec rpmstrPool_Type_Spec;
PyObject * rpmstrPool_Wrap(PyTypeObject *subtype, rpmstrPool pool); PyObject * rpmstrPool_Wrap(PyTypeObject *subtype, rpmstrPool pool);

View File

@ -116,7 +116,7 @@ rpmte_Parent(rpmteObject * s, PyObject * unused)
{ {
rpmte parent = rpmteParent(s->te); rpmte parent = rpmteParent(s->te);
if (parent) if (parent)
return rpmte_Wrap(&rpmte_Type, parent); return rpmte_Wrap(rpmte_Type, parent);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -190,7 +190,7 @@ rpmte_DS(rpmteObject * s, PyObject * args, PyObject * kwds)
if (ds == NULL) { if (ds == NULL) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
return rpmds_Wrap(&rpmds_Type, rpmdsLink(ds)); return rpmds_Wrap(rpmds_Type, rpmdsLink(ds));
} }
static PyObject * static PyObject *
@ -200,7 +200,7 @@ rpmte_Files(rpmteObject * s, PyObject * args, PyObject * kwds)
if (files == NULL) { if (files == NULL) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
return rpmfiles_Wrap(&rpmfiles_Type, files); return rpmfiles_Wrap(rpmfiles_Type, files);
} }
static PyObject * static PyObject *
@ -273,6 +273,7 @@ static PyType_Slot rpmte_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmte_Type;
PyType_Spec rpmte_Type_Spec = { PyType_Spec rpmte_Type_Spec = {
.name = "rpm.te", .name = "rpm.te",
.basicsize = sizeof(rpmteObject), .basicsize = sizeof(rpmteObject),

View File

@ -5,9 +5,10 @@
typedef struct rpmteObject_s rpmteObject; typedef struct rpmteObject_s rpmteObject;
extern PyTypeObject rpmte_Type; extern PyTypeObject* rpmte_Type;
extern PyType_Spec rpmte_Type_Spec;
#define rpmteObject_Check(v) ((v)->ob_type == &rpmte_Type) #define rpmteObject_Check(v) ((v)->ob_type == rpmte_Type)
PyObject * rpmte_Wrap(PyTypeObject *subtype, rpmte te); PyObject * rpmte_Wrap(PyTypeObject *subtype, rpmte te);

View File

@ -420,7 +420,7 @@ rpmts_HdrFromFdno(rpmtsObject * s, PyObject *arg)
Py_XDECREF(fdo); Py_XDECREF(fdo);
if (rpmrc == RPMRC_OK) { if (rpmrc == RPMRC_OK) {
ho = hdr_Wrap(&hdr_Type, h); ho = hdr_Wrap(hdr_Type, h);
} else { } else {
Py_INCREF(Py_None); Py_INCREF(Py_None);
ho = Py_None; ho = Py_None;
@ -494,7 +494,7 @@ static PyObject *rpmts_getKeyring(rpmtsObject *s, PyObject *args, PyObject *kwds
keyring = rpmtsGetKeyring(s->ts, autoload); keyring = rpmtsGetKeyring(s->ts, autoload);
if (keyring) { if (keyring) {
return rpmKeyring_Wrap(&rpmKeyring_Type, keyring); return rpmKeyring_Wrap(rpmKeyring_Type, keyring);
} else { } else {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -534,7 +534,7 @@ rpmtsCallback(const void * arg, const rpmCallbackType what,
} else { } else {
PyObject *o; PyObject *o;
if (arg) { if (arg) {
o = rpmte_Wrap(&rpmte_Type, (rpmte) arg); o = rpmte_Wrap(rpmte_Type, (rpmte) arg);
} else { } else {
o = Py_None; o = Py_None;
Py_INCREF(o); Py_INCREF(o);
@ -632,7 +632,7 @@ rpmts_iternext(rpmtsObject * s)
te = rpmtsiNext(s->tsi, 0); te = rpmtsiNext(s->tsi, 0);
if (te != NULL) { if (te != NULL) {
result = rpmte_Wrap(&rpmte_Type, te); result = rpmte_Wrap(rpmte_Type, te);
} else { } else {
s->tsi = rpmtsiFree(s->tsi); s->tsi = rpmtsiFree(s->tsi);
} }
@ -683,7 +683,7 @@ rpmts_Match(rpmtsObject * s, PyObject * args, PyObject * kwds)
} }
} }
mio = rpmmi_Wrap(&rpmmi_Type, rpmtsInitIterator(s->ts, tag, key, len), (PyObject*)s); mio = rpmmi_Wrap(rpmmi_Type, rpmtsInitIterator(s->ts, tag, key, len), (PyObject*)s);
exit: exit:
Py_XDECREF(str); Py_XDECREF(str);
@ -714,7 +714,7 @@ rpmts_index(rpmtsObject * s, PyObject * args, PyObject * kwds)
PyErr_SetString(PyExc_KeyError, "No index for this tag"); PyErr_SetString(PyExc_KeyError, "No index for this tag");
return NULL; return NULL;
} }
mio = rpmii_Wrap(&rpmii_Type, ii, (PyObject*)s); mio = rpmii_Wrap(rpmii_Type, ii, (PyObject*)s);
exit: exit:
return mio; return mio;
@ -1061,6 +1061,7 @@ static PyType_Slot rpmts_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmts_Type;
PyType_Spec rpmts_Type_Spec = { PyType_Spec rpmts_Type_Spec = {
.name = "rpm.ts", .name = "rpm.ts",
.basicsize = sizeof(rpmtsObject), .basicsize = sizeof(rpmtsObject),

View File

@ -5,9 +5,10 @@
typedef struct rpmtsObject_s rpmtsObject; typedef struct rpmtsObject_s rpmtsObject;
extern PyTypeObject rpmts_Type; extern PyTypeObject* rpmts_Type;
extern PyType_Spec rpmts_Type_Spec;
#define rpmtsObject_Check(v) ((v)->ob_type == &rpmts_Type) #define rpmtsObject_Check(v) ((v)->ob_type == rpmts_Type)
int rpmtsFromPyObject(PyObject *item, rpmts *ts); int rpmtsFromPyObject(PyObject *item, rpmts *ts);

View File

@ -135,6 +135,7 @@ static PyType_Slot rpmver_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* rpmver_Type;
PyType_Spec rpmver_Type_Spec = { PyType_Spec rpmver_Type_Spec = {
.name = "rpm.ver", .name = "rpm.ver",
.basicsize = sizeof(rpmverObject), .basicsize = sizeof(rpmverObject),

View File

@ -5,9 +5,10 @@
typedef struct rpmverObject_s rpmverObject; typedef struct rpmverObject_s rpmverObject;
extern PyTypeObject rpmver_Type; extern PyTypeObject* rpmver_Type;
extern PyType_Spec rpmver_Type_Spec;
#define verObject_Check(v) (((PyObject*)v)->ob_type == &rpmver_Type) #define verObject_Check(v) (((PyObject*)v)->ob_type == rpmver_Type)
int verFromPyObject(PyObject *item, rpmver *ver); int verFromPyObject(PyObject *item, rpmver *ver);
PyObject * rpmver_Wrap(PyTypeObject *subtype, rpmver ver); PyObject * rpmver_Wrap(PyTypeObject *subtype, rpmver ver);

View File

@ -31,7 +31,7 @@
static PyObject *makeHeader(Header h) static PyObject *makeHeader(Header h)
{ {
return hdr_Wrap(&hdr_Type, headerLink(h)); return hdr_Wrap(hdr_Type, headerLink(h));
} }
struct specPkgObject_s { struct specPkgObject_s {
@ -98,6 +98,7 @@ static PyType_Slot specPkg_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* specPkg_Type;
PyType_Spec specPkg_Type_Spec = { PyType_Spec specPkg_Type_Spec = {
.name = "rpm.specpkg", .name = "rpm.specpkg",
.basicsize = sizeof(specPkgObject), .basicsize = sizeof(specPkgObject),
@ -206,7 +207,7 @@ static PyObject * spec_get_packages(specObject *s, void *closure)
iter = rpmSpecPkgIterInit(s->spec); iter = rpmSpecPkgIterInit(s->spec);
while ((pkg = rpmSpecPkgIterNext(iter)) != NULL) { while ((pkg = rpmSpecPkgIterNext(iter)) != NULL) {
PyObject *po = specPkg_Wrap(&specPkg_Type, pkg, s); PyObject *po = specPkg_Wrap(specPkg_Type, pkg, s);
if (!po) { if (!po) {
rpmSpecPkgIterFree(iter); rpmSpecPkgIterFree(iter);
Py_DECREF(pkgList); Py_DECREF(pkgList);
@ -273,6 +274,7 @@ static PyType_Slot spec_Type_Slots[] = {
{0, NULL}, {0, NULL},
}; };
PyTypeObject* spec_Type;
PyType_Spec spec_Type_Spec = { PyType_Spec spec_Type_Spec = {
.name = "rpm.spec", .name = "rpm.spec",
.basicsize = sizeof(specObject), .basicsize = sizeof(specObject),

View File

@ -6,11 +6,13 @@
typedef struct specPkgObject_s specPkgObject; typedef struct specPkgObject_s specPkgObject;
typedef struct specObject_s specObject; typedef struct specObject_s specObject;
extern PyTypeObject spec_Type; extern PyTypeObject* spec_Type;
extern PyTypeObject specPkg_Type; extern PyType_Spec spec_Type_Spec;
extern PyTypeObject* specPkg_Type;
extern PyType_Spec specPkg_Type_Spec;
#define specObject_Check(v) ((v)->ob_type == &spec_Type) #define specObject_Check(v) ((v)->ob_type == spec_Type)
#define specPkgObject_Check(v) ((v)->ob_type == &specPkg_Type) #define specPkgObject_Check(v) ((v)->ob_type == specPkg_Type)
PyObject * spec_Wrap(PyTypeObject *subtype, rpmSpec spec); PyObject * spec_Wrap(PyTypeObject *subtype, rpmSpec spec);
PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg, specObject *source); PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg, specObject *source);