summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-04-06 09:32:09 +0200
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-04-06 09:33:41 +0200
commit03ccb5a1997d7c7745826da38ea2aa6e9026b08b (patch)
treeb40ab8547297b5ce1b6c30fab2ec7c119c664e03
parente71c4fb4773768c6b5266896a33338ff29e49bad (diff)
parser: Add support for using declarations.
-rw-r--r--src/parser.rs15
-rw-r--r--tests/headers/using.hpp10
2 files changed, 19 insertions, 6 deletions
diff --git a/src/parser.rs b/src/parser.rs
index f0e55909..5aafd751 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -159,7 +159,7 @@ fn decl_name(ctx: &mut ClangParserCtx, cursor: &Cursor) -> Global {
ci.borrow_mut().has_non_type_template_params = has_non_type_template_params;
GCompDecl(ci)
}
- CXCursor_TypedefDecl => {
+ CXCursor_TypeAliasDecl | CXCursor_TypedefDecl => {
let ti = Rc::new(RefCell::new(TypeInfo::new(spelling, ctx.current_module_id, TVoid, layout)));
GType(ti)
}
@@ -366,7 +366,7 @@ fn conv_decl_ty_resolving_typedefs(ctx: &mut ClangParserCtx,
let ei = decl.enuminfo();
TEnum(ei)
}
- CXCursor_TypedefDecl => {
+ CXCursor_TypeAliasDecl | CXCursor_TypedefDecl => {
if resolve_typedefs {
return conv_ty_resolving_typedefs(ctx, &ty_decl.typedef_type(), &ty_decl.typedef_type().declaration(), resolve_typedefs);
}
@@ -375,7 +375,7 @@ fn conv_decl_ty_resolving_typedefs(ctx: &mut ClangParserCtx,
let ti = decl.typeinfo();
TNamed(ti)
}
- CXCursor_NoDeclFound | CXCursor_TypeAliasDecl => {
+ CXCursor_NoDeclFound => {
let layout = Layout::new(ty.size(), ty.align());
TNamed(Rc::new(RefCell::new(TypeInfo::new(ty.spelling().replace("const ", ""), ctx.current_module_id, TVoid, layout))))
}
@@ -526,7 +526,7 @@ fn visit_composite(cursor: &Cursor, parent: &Cursor,
}
match cursor.kind() {
- CXCursor_TypedefDecl => {
+ CXCursor_TypeAliasDecl | CXCursor_TypedefDecl => {
ci.typedefs.push(cursor.spelling().to_owned());
}
CXCursor_FieldDecl => {
@@ -977,7 +977,7 @@ fn visit_top(cursor: &Cursor,
CXChildVisit_Continue
}
- CXCursor_TypedefDecl => {
+ CXCursor_TypeAliasDecl | CXCursor_TypedefDecl => {
let anno = Annotations::new(cursor);
if anno.hide {
return CXChildVisit_Continue;
@@ -1074,7 +1074,10 @@ fn visit_top(cursor: &Cursor,
return CXChildVisit_Continue;
}
- _ => return CXChildVisit_Continue,
+ _ => {
+ // println!("Not handled cursor: {}", cursor.kind());
+ return CXChildVisit_Continue;
+ }
}
}
diff --git a/tests/headers/using.hpp b/tests/headers/using.hpp
new file mode 100644
index 00000000..f402ef32
--- /dev/null
+++ b/tests/headers/using.hpp
@@ -0,0 +1,10 @@
+
+template<typename T>
+class Point {
+ T x;
+ T y;
+};
+
+typedef Point<int> IntPoint2D;
+
+using IntVec2D = Point<int>;