Switch python bindings to use rpm(Dbi)TagVal as appropriate
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 22 Oct 2010 08:57:38 +0000 (11:57 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 22 Oct 2010 08:57:38 +0000 (11:57 +0300)
- None of these are true enum uses as the value typically originates
  from python integers etc.

python/header-py.c
python/header-py.h
python/rpmds-py.c
python/rpmfi-py.c
python/rpmmi-py.c
python/rpmmodule.c
python/rpmtd-py.c
python/rpmte-py.c
python/rpmts-py.c

index 5eb8dd8..c83b1a2 100644 (file)
@@ -136,7 +136,7 @@ static PyObject * hdrKeyList(hdrObject * s)
 {
     PyObject * keys = PyList_New(0);
     HeaderIterator hi = headerInitIterator(s->h);
-    rpmTag tag;
+    rpmTagVal tag;
 
     while ((tag = headerNextTag(hi)) != RPMTAG_NOT_FOUND) {
        PyObject *to = PyInt_FromLong(tag);
@@ -248,7 +248,7 @@ static PyObject *hdrIsSource(hdrObject *s)
 
 static int hdrContains(hdrObject *s, PyObject *pytag)
 {
-    rpmTag tag;
+    rpmTagVal tag;
     if (!tagNumFromPyObject(pytag, &tag)) return -1;
 
     return headerIsEntry(s->h, tag);
@@ -301,7 +301,7 @@ static PyObject * hdr_fiFromHeader(PyObject * s, PyObject * args, PyObject * kwd
 /* Backwards compatibility. Flags argument is just a dummy and discarded. */
 static PyObject * hdr_dsFromHeader(PyObject * s, PyObject * args, PyObject * kwds)
 {
-    rpmTag tag = RPMTAG_REQUIRENAME;
+    rpmTagVal tag = RPMTAG_REQUIRENAME;
     rpmsenseFlags flags = 0;
     char * kwlist[] = {"to", "flags", NULL};
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&i:dsFromHeader", kwlist,
@@ -401,7 +401,7 @@ static void hdr_dealloc(hdrObject * s)
 static PyObject * hdr_iternext(hdrObject *s)
 {
     PyObject *res = NULL;
-    rpmTag tag;
+    rpmTagVal tag;
 
     if (s->hi == NULL) s->hi = headerInitIterator(s->h);
 
@@ -428,9 +428,9 @@ int utf8FromPyObject(PyObject *item, PyObject **str)
     return 1;
 }
 
-int tagNumFromPyObject (PyObject *item, rpmTag *tagp)
+int tagNumFromPyObject (PyObject *item, rpmTagVal *tagp)
 {
-    rpmTag tag = RPMTAG_NOT_FOUND;
+    rpmTagVal tag = RPMTAG_NOT_FOUND;
     PyObject *str = NULL;
 
     if (PyInt_Check(item)) {
@@ -452,7 +452,7 @@ int tagNumFromPyObject (PyObject *item, rpmTag *tagp)
     return 1;
 }
 
-static PyObject * hdrGetTag(Header h, rpmTag tag)
+static PyObject * hdrGetTag(Header h, rpmTagVal tag)
 {
     PyObject *res = NULL;
     struct rpmtd_s td;
@@ -485,7 +485,7 @@ static int validItem(rpmTagClass tclass, PyObject *item)
     return rc;
 }
 
-static int validData(rpmTag tag, rpmTagType type, rpmTagReturnType retype, PyObject *value)
+static int validData(rpmTagVal tag, rpmTagType type, rpmTagReturnType retype, PyObject *value)
 {
     rpmTagClass tclass = rpmTagGetClass(tag);
     int valid = 1;
@@ -508,7 +508,7 @@ static int validData(rpmTag tag, rpmTagType type, rpmTagReturnType retype, PyObj
     return valid;
 }
 
-static int hdrAppendItem(Header h, rpmTag tag, rpmTagType type, PyObject *item)
+static int hdrAppendItem(Header h, rpmTagVal tag, rpmTagType type, PyObject *item)
 {
     int rc = 0;
 
@@ -549,7 +549,7 @@ static int hdrAppendItem(Header h, rpmTag tag, rpmTagType type, PyObject *item)
     return rc;
 }
 
-static int hdrPutTag(Header h, rpmTag tag, PyObject *value)
+static int hdrPutTag(Header h, rpmTagVal tag, PyObject *value)
 {
     rpmTagType type = rpmTagGetTagType(tag);
     rpmTagReturnType retype = rpmTagGetReturnType(tag);
@@ -584,7 +584,7 @@ static int hdrPutTag(Header h, rpmTag tag, PyObject *value)
 
 static PyObject * hdr_subscript(hdrObject * s, PyObject * item)
 {
-    rpmTag tag;
+    rpmTagVal tag;
 
     if (!tagNumFromPyObject(item, &tag)) return NULL;
     return hdrGetTag(s->h, tag);
@@ -592,7 +592,7 @@ static PyObject * hdr_subscript(hdrObject * s, PyObject * item)
 
 static int hdr_ass_subscript(hdrObject *s, PyObject *key, PyObject *value)
 {
-    rpmTag tag;
+    rpmTagVal tag;
     if (!tagNumFromPyObject(key, &tag)) return -1;
 
     if (value == NULL) {
@@ -608,7 +608,7 @@ static PyObject * hdr_getattro(hdrObject * s, PyObject * n)
 {
     PyObject *res = PyObject_GenericGetAttr((PyObject *) s, n);
     if (res == NULL) {
-       rpmTag tag;
+       rpmTagVal tag;
        if (tagNumFromPyObject(n, &tag)) {
            PyErr_Clear();
            res = hdrGetTag(s->h, tag);
@@ -715,7 +715,7 @@ static int rpmMergeHeaders(PyObject * list, FD_t fd, int matchTag)
 {
     Header h;
     HeaderIterator hi;
-    rpmTag newMatch, oldMatch;
+    rpmTagVal newMatch, oldMatch;
     hdrObject * hdr;
     rpm_count_t count = 0;
     int rc = 1; /* assume failure */
index 28378ac..1103876 100644 (file)
@@ -18,7 +18,7 @@ PyObject * hdr_Wrap(PyTypeObject *subtype, Header h);
 
 int hdrFromPyObject(PyObject *item, Header *h);
 int utf8FromPyObject(PyObject *item, PyObject **str);
-int tagNumFromPyObject (PyObject *item, rpmTag *tagp);
+int tagNumFromPyObject (PyObject *item, rpmTagVal *tagp);
 
 PyObject * labelCompare (PyObject * self, PyObject * args);
 PyObject * versionCompare (PyObject * self, PyObject * args, PyObject * kwds);
index 4587201..cd933b5 100644 (file)
@@ -266,7 +266,7 @@ static int rpmds_init(rpmdsObject * s, PyObject *args, PyObject *kwds)
 static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
 {
     PyObject *obj;
-    rpmTag tagN = RPMTAG_REQUIRENAME;
+    rpmTagVal tagN = RPMTAG_REQUIRENAME;
     rpmds ds = NULL;
     Header h = NULL;
     char * kwlist[] = {"obj", "tag", NULL};
index 5ac0c3a..52a2a3a 100644 (file)
@@ -299,7 +299,7 @@ static PyObject * rpmfi_new(PyTypeObject * subtype, PyObject *args, PyObject *kw
     PyObject * to = NULL;
     Header h = NULL;
     rpmfi fi = NULL;
-    rpmTag tagN = RPMTAG_BASENAMES;
+    rpmTagVal tagN = RPMTAG_BASENAMES;
     int flags = 0;
     char * kwlist[] = {"header", "tag", "flags", NULL};
 
index 5287671..0b1c27a 100644 (file)
@@ -102,7 +102,7 @@ rpmmi_Pattern(rpmmiObject * s, PyObject * args, PyObject * kwds)
 {
     int type;
     char * pattern;
-    rpmTag tag;
+    rpmTagVal tag;
     char * kwlist[] = {"tag", "type", "patern", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&is:Pattern", kwlist,
index e396cd0..bbf538b 100644 (file)
@@ -174,7 +174,7 @@ static void addRpmTags(PyObject *module)
     rpmtd names = rpmtdNew();
     rpmTagGetNames(names, 1);
     const char *tagname, *shortname;
-    rpmTag tagval;
+    rpmTagVal tagval;
 
     while ((tagname = rpmtdNextString(names))) {
        shortname = tagname + strlen("RPMTAG_");
index 4138f55..8232127 100644 (file)
@@ -91,7 +91,7 @@ static PyObject *rpmtd_new(PyTypeObject * subtype, PyObject *args, PyObject *kwd
 {
     rpmtdObject *s = NULL;
     Header h = NULL;
-    rpmTag tag;
+    rpmTagVal tag;
     int raw = 0;
     int noext = 0;
     headerGetFlags flags = (HEADERGET_EXT | HEADERGET_ALLOC);
@@ -143,7 +143,7 @@ static PyObject *rpmtd_get_tag(rpmtdObject *s, void *closure)
 
 static int rpmtd_set_tag(rpmtdObject *s, PyObject *value, void *closure)
 {
-    rpmTag tag;
+    rpmTagVal tag;
     if (!tagNumFromPyObject(value, &tag)) return -1;
 
     if (!rpmtdSetTag(&(s->td), tag)) {
index edf417a..0001ef4 100644 (file)
@@ -159,7 +159,7 @@ static PyObject *
 rpmte_DS(rpmteObject * s, PyObject * args, PyObject * kwds)
 {
     rpmds ds;
-    rpmTag tag;
+    rpmTagVal tag;
     char * kwlist[] = {"tag", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&:DS", kwlist,
index fb8f0c2..626140c 100644 (file)
@@ -590,7 +590,7 @@ rpmts_Match(rpmtsObject * s, PyObject * args, PyObject * kwds)
 /* XXX lkey *must* be a 32 bit integer, int "works" on all known platforms. */
     int lkey = 0;
     int len = 0;
-    rpmTag tag = RPMDBI_PACKAGES;
+    rpmDbiTagVal tag = RPMDBI_PACKAGES;
     char * kwlist[] = {"tagNumber", "key", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&O:Match", kwlist,
@@ -632,7 +632,7 @@ exit:
 static PyObject *
 rpmts_Keys(rpmtsObject * s, PyObject * args, PyObject * kwds)
 {
-    rpmTag tag;
+    rpmDbiTagVal tag;
     PyObject *mio = NULL;
     char * kwlist[] = {"tag", NULL};