summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-03-24 03:57:05 +0100
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-03-24 03:57:05 +0100
commit853608f9be79d2f35a825a47d862f4017a361df4 (patch)
treeb978fa07ff60439f3d5c909e0b173596a6039526
parentd7a3b81d9416c37af5bdb049d5ea222cc0adca15 (diff)
parser: Nits from trying to implement partial template specialisation
-rw-r--r--src/clang.rs6
-rw-r--r--src/parser.rs8
-rw-r--r--src/types.rs8
3 files changed, 17 insertions, 5 deletions
diff --git a/src/clang.rs b/src/clang.rs
index f41ca939..fd3d9ad3 100644
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -95,6 +95,12 @@ impl Cursor {
}
}
+ pub fn referenced(&self) -> Cursor {
+ unsafe {
+ Cursor { x: clang_getCursorReferenced(self.x) }
+ }
+ }
+
pub fn canonical(&self) -> Cursor {
unsafe {
Cursor { x: clang_getCanonicalCursor(self.x) }
diff --git a/src/parser.rs b/src/parser.rs
index 8db8031b..8347fe5a 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -320,12 +320,18 @@ fn conv_decl_ty_resolving_typedefs(ctx: &mut ClangParserCtx,
cursor: &Cursor,
resolve_typedefs: bool) -> il::Type {
let ty_decl = ty.declaration();
+ // println!("conv_ty_decl: `{}`, ty kind {}: {}, decl `{}` kind {}: {}", cursor.spelling(), ty.kind(), type_to_str(ty.kind()), ty_decl.spelling(), ty_decl.kind(), kind_to_str(ty_decl.kind()));
return match ty_decl.kind() {
CXCursor_StructDecl |
CXCursor_UnionDecl |
CXCursor_ClassTemplate |
CXCursor_ClassDecl => {
let decl = decl_name(ctx, &ty_decl);
+ // NB: This will only return a number greater than 0 if this is a **full** class
+ // template specialization.
+ //
+ // 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!(),
len => {
@@ -349,10 +355,10 @@ fn conv_decl_ty_resolving_typedefs(ctx: &mut ClangParserCtx,
let cref = c.definition();
ci.borrow_mut().ref_template = Some(conv_decl_ty(ctx, &cref.cur_type(), &cref));
}
-
CXChildVisit_Continue
});
}
+
TComp(ci)
}
CXCursor_EnumDecl => {
diff --git a/src/types.rs b/src/types.rs
index 925efdbf..e31fe480 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -141,7 +141,7 @@ impl fmt::Debug for Global {
}
}
-#[derive(Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq)]
pub struct FuncSig {
pub ret_ty: Box<Type>,
pub args: Vec<(String, Type)>,
@@ -150,7 +150,7 @@ pub struct FuncSig {
pub abi: abi::Abi,
}
-#[derive(Clone, PartialEq)]
+#[derive(Clone, PartialEq, Debug)]
pub enum Type {
TVoid,
TInt(IKind, Layout),
@@ -232,7 +232,7 @@ impl Layout {
}
}
-#[derive(Copy, Clone, PartialEq)]
+#[derive(Debug, Copy, Clone, PartialEq)]
pub enum IKind {
IBool,
ISChar,
@@ -266,7 +266,7 @@ impl IKind {
}
}
-#[derive(Copy, Clone, PartialEq)]
+#[derive(Debug, Copy, Clone, PartialEq)]
pub enum FKind {
FFloat,
FDouble