3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 04:03:39 +00:00

Fix inconsistent emission of `Enumerations.cs`. The ordering of emitted

enum values is not consistent between python 2 or 3. The root cause
of the problem was a dictionary's keys being iterated over which has
no defined order.

This has been fixed by iterating over the dictionary's items and
ordering by values.  We could order by key rather than the values but
seeing as these represent an enum, ordering by value makes more sense.
This commit is contained in:
Dan Liew 2016-03-26 13:49:37 +00:00
parent d3f87e44a2
commit 23ac66ef42

View file

@ -234,9 +234,9 @@ def mk_z3consts_dotnet_internal(api_files, output_dir):
z3consts.write(' /// <summary>%s</summary>\n' % name) z3consts.write(' /// <summary>%s</summary>\n' % name)
z3consts.write(' public enum %s {\n' % name) z3consts.write(' public enum %s {\n' % name)
z3consts.write z3consts.write
for k in decls: # Iterate over key-value pairs ordered by value
i = decls[k] for k, v in sorted(decls.items(), key=lambda pair: pair[1]):
z3consts.write(' %s = %s,\n' % (k, i)) z3consts.write(' %s = %s,\n' % (k, v))
z3consts.write(' }\n\n') z3consts.write(' }\n\n')
mode = SEARCHING mode = SEARCHING
elif len(words) <= 2: elif len(words) <= 2: