Skip to content
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

Merged
merged 4 commits into from
Dec 19, 2016

Conversation

rafaljas
Copy link

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.

Copy link
Owner

@aurzenligl aurzenligl left a 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()
Copy link
Owner

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))
Copy link
Owner

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.

@rafaljas
Copy link
Author

See if it is OK now.

@aurzenligl aurzenligl merged commit 98d8ecb into aurzenligl:master Dec 19, 2016
@aurzenligl
Copy link
Owner

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).

@rafaljas
Copy link
Author

It can wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants