diff options
-rw-r--r-- | src/clang.rs | 4 | ||||
-rw-r--r-- | src/parser.rs | 16 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/clang.rs b/src/clang.rs index c230460d..f8a68e12 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -119,6 +119,10 @@ impl Cursor { } } + pub fn template_kind(&self) -> Enum_CXCursorKind { + unsafe { clang_getTemplateCursorKind(self.x) } + } + pub fn visit<F>(&self, func:F) where F: for<'a, 'b> FnMut(&'a Cursor, &'b Cursor) -> Enum_CXChildVisitResult { diff --git a/src/parser.rs b/src/parser.rs index 4ad5d548..a3311b24 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -124,10 +124,16 @@ fn decl_name(ctx: &mut ClangParserCtx, cursor: &Cursor) -> Global { CXCursor_ClassDecl | CXCursor_StructDecl => { let anno = Annotations::new(&cursor); - let kind = if cursor.kind() == CXCursor_UnionDecl { - CompKind::Union - } else { - CompKind::Struct + + let kind = match cursor.kind() { + CXCursor_UnionDecl => CompKind::Union, + CXCursor_ClassTemplate => { + match cursor.template_kind() { + CXCursor_UnionDecl => CompKind::Union, + _ => CompKind::Struct, + } + } + _ => CompKind::Struct, }; let opaque = ctx.options.opaque_types.iter().any(|name| *name == spelling); @@ -389,7 +395,7 @@ fn conv_decl_ty_resolving_typedefs(ctx: &mut ClangParserCtx, // If the cursor kind is CXCursor_ClassTemplate, this will still return -1 // and we'll have to keep traversing the cursor. let args = match ty.num_template_args() { - -1 => vec!(), + -1 => vec![], len => { let mut list = Vec::with_capacity(len as usize); for i in 0..len { |