Skip to content

clang::Cursor::num_template_args should return Option<u32> #121

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 24, 2016 · 5 comments
Closed

clang::Cursor::num_template_args should return Option<u32> #121

fitzgen opened this issue Oct 24, 2016 · 5 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Oct 24, 2016

Right now it returns a c_int, but the documentation for clang_Cursor_getNumTemplateArgs says it returns -1 if the cursor's referent is not a template declaration or specialization. We should translate negative values into None and positive values into Some. This will also require fixing up callers.

I can mentor someone who wants to pick up this bug.

@highfive
Copy link

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

@Incognitas
Copy link

Incognitas commented Nov 1, 2016

Should it return Option instead of Option (as c_int == i32, this is the closest unsigned type) ?
Furthermore, This would be more consistent with other API definitions like Type::num_template_args() returning already Option.

@emilio
Copy link
Contributor

emilio commented Nov 1, 2016

Yeah, both u32 and usize are fine. Type::num_template_args is gone now, but I agree.

@emilio emilio changed the title clang::Cursor::num_template_args should return Option<usize> clang::Cursor::num_template_args should return Option<u32> Nov 1, 2016
@Incognitas
Copy link

Ok, I will take care of this issue then.

@emilio
Copy link
Contributor

emilio commented Nov 1, 2016

Great, thanks!

Incognitas pushed a commit to Incognitas/rust-bindgen that referenced this issue Nov 1, 2016
bors-servo pushed a commit that referenced this issue Nov 1, 2016
Fix #121: Cursor::num_template_args(...) returns Option<u32> instead of c_int

Now, functions calling Cursor::num_template_args() call expect() on the return value to make sure it is a valid value
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

4 participants