Skip to content

clang::Cursor::enum_val_unsigned should return Option<u64> #128

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

Closed
fitzgen opened this issue Oct 25, 2016 · 5 comments
Closed

clang::Cursor::enum_val_unsigned should return Option<u64> #128

fitzgen opened this issue Oct 25, 2016 · 5 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Oct 25, 2016

(Similar to #127)

Right now it always returns u64, but the FFI call it makes says

http://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gaf7cbd4f2d371dd93e8bc997c951a1aef

Retrieve the integer value of an enum constant declaration as an unsigned long long.

If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned. Since this is also potentially a valid constant value, the kind of the cursor must be verified before calling this function.

We shouldn't force callers to check the kind of the cursor, we should do the check ourselves in this function and return an option. This would result in one less foot gun.

I can mentor anyone who'd like to pick up this bug.

@highfive
Copy link

Please make a comment here if you intend to work on this issue. Thank you!

@afluth
Copy link
Contributor

afluth commented Nov 5, 2016

I would like to take a swing at this.

@emilio
Copy link
Contributor

emilio commented Nov 5, 2016

Sure, thanks for it! :)

@jcdyer
Copy link

jcdyer commented Nov 6, 2016

@afluth, I've got PR #220 coming in that (if accepted) reorganizes the calling code in enum_ty.rs a little bit.

@afluth
Copy link
Contributor

afluth commented Nov 7, 2016

@jcdyer, thanks for the heads up!

bors-servo pushed a commit that referenced this issue Nov 7, 2016
Wrap enum_val_unsigned in an Option

Patterned after the changes merged in #220.

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

No branches or pull requests

5 participants