In the libvirt.h we have one enum defined by references from another enum and it leads in wrong order of definitons in python code. To prevent this we should resolve that references before we generate the python code. For now we have only one level of references so we will count with that in the generator but we should update it in the future to be more flexible. Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- generator.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/generator.py b/generator.py index a12c52b..0d41e20 100755 --- a/generator.py +++ b/generator.py @@ -1785,12 +1785,26 @@ def buildWrappers(module): value = float('inf') return value + # Resolve only one level of reference + def resolveEnum(enum, data): + for name,val in enum.items(): + try: + int(val) + except ValueError: + enum[name] = data[val] + return enum + enumvals = list(enums.items()) + # convert list of dicts to one dict + enumData = {} + for type,enum in enumvals: + enumData.update(enum) + if enumvals is not None: enumvals.sort(key=lambda x: x[0]) for type,enum in enumvals: classes.write("# %s\n" % type) - items = list(enum.items()) + items = list(resolveEnum(enum, enumData).items()) items.sort(key=enumsSortKey) if items[-1][0].endswith('_LAST'): del items[-1] -- 1.8.5.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list