-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow negative values for enum in ISAR #7
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct the code - I'll pull it afterwards.
if len(elem): | ||
return model.Enum(elem.get("name"), [make_enum_member(member) for member in elem]) | ||
values = set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider refactoring duplicate-checking logic to separate function.
It could be private module-scope function (_check...) or function defined inside make_enum function.
value = "0x{:X}".format(0x100000000 + int_value) | ||
except ValueError as e: | ||
if warn: | ||
warn(str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's allowed to use identifiers as enum values in isar, but its safer if we assume its possible.
Let's assume enum like this is correct:
<x>
<enum name="EEnum">
<enum-member name="EEnum_A" value="SOME_VALUE"/>
</enum>
</x>
And remove this warning:
prophyc: warning: invalid literal for int() with base 0: 'SOME_VALUE'
You can add/change a testcase to ensure that such enum value compiles correctly.
…entifier as value
See if it is OK now. |
Merged, thank you. When would you like it released? I can do it immediately or wait until the end of week (and release it with yet another change then). |
It can wait. |
Feature will work as it already is implemented for Sack: negative values are stored as positive.
Exception will be thrown if as a result the same value will be used twice.