]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-5.4.5-python-export-spec-macros.patch
- rel 51; fix -Werror=trampolines option
[packages/rpm.git] / rpm-5.4.5-python-export-spec-macros.patch
CommitLineData
70f8787d
JR
1--- rpm-5.4.5/python/spec-py.c.py_macros~ 2012-03-01 22:55:19.592995392 +0100
2+++ rpm-5.4.5/python/spec-py.c 2012-03-01 22:56:02.081016570 +0100
3@@ -6,6 +6,8 @@
4
5 #include <rpmiotypes.h>
6 #include <rpmio.h>
7+#define _MACRO_INTERNAL
8+#include <rpmmacro.h>
9 #include "spec-py.h"
10
11 /** \ingroup python
12@@ -146,6 +148,50 @@ spec_get_sources(specObject *s)
13
14 }
15
16+static PyObject *
17+spec_get_macros(specObject *s)
18+ /*@*/
19+{
20+ MacroContext mc;
21+ PyObject *macroDict;
22+ Spec spec;
23+
24+ macroDict = PyDict_New();
25+ if (!macroDict) {
26+ return NULL;
27+ }
28+ spec = specFromSpec(s);
29+ if ( spec != NULL) {
30+ mc = spec->macros;
31+ if (mc->macroTable != NULL) {
32+ int i;
33+ for (i = 0; i < mc->firstFree; i++) {
34+ MacroEntry me;
35+ PyObject *macro;
36+ if ((me = mc->macroTable[i]) == NULL) {
37+ /* XXX this should never happen */
38+ continue;
39+ }
40+ macro = PyDict_New();
41+
42+ PyMapping_SetItemString(macro, "used", PyInt_FromLong(me->used));
43+ PyMapping_SetItemString(macro, "level", PyInt_FromLong(me->level));
44+ if (me->opts && *me->opts)
45+ PyMapping_SetItemString(macro, "opts", PyString_FromString(me->opts));
46+ if (me->body && *me->body)
47+ PyMapping_SetItemString(macro, "body", PyString_FromString(me->body));
48+ PyMapping_SetItemString(macroDict, strdup(me->name), macro);
49+ }
50+ }
51+
52+ return macroDict;
53+ }
54+ else {
55+ return NULL;
56+ }
57+
58+}
59+
60 /**
61 */
62 /*@unchecked@*/ /*@observer@*/
63@@ -161,6 +207,7 @@ static PyMethodDef spec_Spec_methods[] =
64 {"check", (PyCFunction) spec_get_check, METH_VARARGS, NULL },
65 {"clean", (PyCFunction) spec_get_clean, METH_VARARGS, NULL },
66 {"buildRoot", (PyCFunction) spec_get_buildroot, METH_VARARGS, NULL },
67+ {"macros", (PyCFunction) spec_get_macros, METH_VARARGS, NULL },
68 {NULL} /* Sentinel */
69 };
70 /*@=fullinitblock@*/
This page took 0.036208 seconds and 4 git commands to generate.