Re: [PATCH python 08/15] generator: Sort enums and functions when generating code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 3, 2013 at 10:36 AM, Daniel P. Berrange <berrange@xxxxxxxxxx> wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
>
> To assist in diff comparisons between code generated with
> different versions of Python, do an explicit sort of all
> functions and enums.
>
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  generator.py | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/generator.py b/generator.py
> index af05d7c..17f00d6 100755
> --- a/generator.py
> +++ b/generator.py
> @@ -865,7 +865,10 @@ def buildStubs(module, api_xml):
>      wrapper.write("#include \"typewrappers.h\"\n")
>      wrapper.write("#include \"build/" + module + ".h\"\n\n")
>
> -    for function in list(funcs.keys()):
> +    funcnames = list(funcs.keys())
> +    if funcnames is not None:
> +        funcnames.sort()
> +    for function in funcnames:
>          # Skip the functions which are not for the module
>          ret = print_function_wrapper(module, function, wrapper, export, include)
>          if ret < 0:
> @@ -1758,7 +1761,10 @@ def buildWrappers(module):
>      #
>      # Generate enum constants
>      #
> -    for type,enum in list(enums.items()):
> +    enumvals = list(enums.items())
> +    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.sort(key=lambda i: int(i[1]))
> --
> 1.8.3.1

ACK.

-- 
Doug Goldstein

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]