summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/clang.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/clang.rs b/src/clang.rs
index 07680367..ba6fc7f6 100755
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -130,9 +130,14 @@ impl Cursor {
/// Return the number of template arguments used by this cursor's referent,
/// if the referent is either a template specialization or
/// declaration. Returns -1 otherwise.
- pub fn num_template_args(&self) -> c_int {
- unsafe {
- clang_Cursor_getNumTemplateArguments(self.x)
+ pub fn num_template_args(&self) -> Option<u32> {
+ let n : c_int = unsafe { clang_Cursor_getNumTemplateArguments(self.x) };
+
+ if n >= 0 {
+ Some(n as u32)
+ } else {
+ debug_assert_eq!(n, -1);
+ None
}
}
@@ -192,7 +197,7 @@ impl Cursor {
/// Is the referent a fully specialized template specialization without any
/// remaining free template arguments?
pub fn is_fully_specialized_template(&self) -> bool {
- self.is_template() && self.num_template_args() > 0
+ self.is_template() && self.num_template_args().unwrap() > 0
}
/// Is the referent a template specialization that still has remaining free