diff options
author | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-08-10 15:20:37 -0700 |
---|---|---|
committer | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-08-13 23:51:02 -0700 |
commit | 19e2a44412646b6dada97ff4c89fd527a95bff50 (patch) | |
tree | d3a992526a5aa7a853c47d07b57aaf23e0f6cecb | |
parent | f509f87ee9db2430ec525d2d01d4a0f08de138ec (diff) |
Properly detect template<typename T> union ...
-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 { |