3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-06 01:24:08 +00:00

Fix inconsistent emission of Java enumeration files. 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-04-06 22:53:07 +01:00
parent b3713e7496
commit 3042f0f964

View file

@ -330,13 +330,13 @@ def mk_z3consts_java_internal(api_files, package_name, output_dir):
efile.write('public enum %s {\n' % name)
efile.write
first = True
for k in decls:
i = decls[k]
# Iterate over key-value pairs ordered by value
for k, v in sorted(decls.items(), key=lambda pair: pair[1]):
if first:
first = False
else:
efile.write(',\n')
efile.write(' %s (%s)' % (k, i))
efile.write(' %s (%s)' % (k, v))
efile.write(";\n")
efile.write('\n private final int intValue;\n\n')
efile.write(' %s(int v) {\n' % name)