Skip to content

clang::Type::num_template_args should return Option<u32> #135

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 · 4 comments
Closed

clang::Type::num_template_args should return Option<u32> #135

fitzgen opened this issue Oct 25, 2016 · 4 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Oct 25, 2016

Right now it returns -1 if the type is not a class template specialization. We should check for this case and return None, otherwise Some. This will be one less foot gun for callers of this method.

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

-1 if type T is not a class template specialization.

I can mentor whoever would like to work on this.

@highfive
Copy link

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

@jeanphilippeD
Copy link
Contributor

Hi, I'll be happy to take this one.

@jeanphilippeD
Copy link
Contributor

Hello,
I have a question regarding this change:

This function used to return a signed 'c_int' (i32).
Was it the intention to convert it to an unsigned u32: Option instead of using Option<c_int>?

If so, how should be best handle calling clang::Type::template_arg_type?

  • should we use template_arg_type(i as i32)?
  • should we change the interface of template_arg_type to take u32 and convert in the implementation?

@emilio
Copy link
Contributor

emilio commented Oct 30, 2016

That sounds right, in general, it makes sense to return an Option<u32>, since if there are template arguments the number is going to be unsigned.

It also makes sense for template_arg_type to get an unsigned integer, so I'm fine to convert it inside that function to what libclang expects.

jeanphilippeD added a commit to jeanphilippeD/rust-bindgen that referenced this issue Oct 30, 2016
jeanphilippeD added a commit to jeanphilippeD/rust-bindgen that referenced this issue Oct 31, 2016
bors-servo pushed a commit that referenced this issue Oct 31, 2016
clang::Type::num_template_args return Option<u32> fix #135

Fix #135
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