diff options
author | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-11-21 19:23:54 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-11-21 19:24:43 +0100 |
commit | f522b613b899e70a6141375dd46da1a6f49db360 (patch) | |
tree | 333293aeff242aaa0c4319bd07eb1c544173560d | |
parent | 91f279f735e3501cd738e4bff0371b41a830410c (diff) |
Address review comments.
-rw-r--r-- | libbindgen/src/ir/item.rs | 57 | ||||
-rw-r--r-- | libbindgen/src/ir/ty.rs | 17 |
2 files changed, 37 insertions, 37 deletions
diff --git a/libbindgen/src/ir/item.rs b/libbindgen/src/ir/item.rs index 4699af78..32e3c4c5 100644 --- a/libbindgen/src/ir/item.rs +++ b/libbindgen/src/ir/item.rs @@ -734,6 +734,31 @@ impl Item { } } +// An utility function to handle recursing inside nested types. +fn visit_child(cur: clang::Cursor, + id: ItemId, + ty: &clang::Type, + parent_id: Option<ItemId>, + ctx: &mut BindgenContext, + result: &mut Result<ItemId, ParseError>) + -> clangll::Enum_CXChildVisitResult { + use clangll::*; + if result.is_ok() { + return CXChildVisit_Break; + } + + *result = Item::from_ty_with_id(id, ty, Some(cur), parent_id, ctx); + + match *result { + Ok(..) => CXChildVisit_Break, + Err(ParseError::Recurse) => { + cur.visit(|c| visit_child(c, id, ty, parent_id, ctx, result)); + CXChildVisit_Continue + } + Err(ParseError::Continue) => CXChildVisit_Continue, + } +} + impl ClangItemParser for Item { fn builtin_type(kind: TypeKind, is_const: bool, @@ -1022,35 +1047,9 @@ impl ClangItemParser for Item { assert_eq!(popped_decl, declaration_to_look_for); } - fn visit_child(cur: clang::Cursor, - id: ItemId, - ty: &clang::Type, - parent_id: Option<ItemId>, - ctx: &mut BindgenContext, - result: &mut Result<ItemId, ParseError>) - -> clangll::Enum_CXChildVisitResult { - use clangll::*; - if result.is_ok() { - return CXChildVisit_Break; - } - - *result = Item::from_ty_with_id(id, - ty, - Some(cur), - parent_id, - ctx); - - match *result { - Ok(..) => CXChildVisit_Break, - Err(ParseError::Recurse) => { - cur.visit(|c| visit_child(c, id, ty, parent_id, ctx, result)); - CXChildVisit_Continue - } - Err(ParseError::Continue) => CXChildVisit_Continue, - } - } - - location.visit(|cur| visit_child(cur, id, ty, parent_id, ctx, &mut result)); + location.visit(|cur| { + visit_child(cur, id, ty, parent_id, ctx, &mut result) + }); if valid_decl { ctx.currently_parsed_types diff --git a/libbindgen/src/ir/ty.rs b/libbindgen/src/ir/ty.rs index 1e4c40ef..7f01e388 100644 --- a/libbindgen/src/ir/ty.rs +++ b/libbindgen/src/ir/ty.rs @@ -686,7 +686,8 @@ impl Type { let referenced = location.referenced().unwrap(); let referenced_ty = referenced.cur_type(); - debug!("TemplateRef {:?} {:?} {:?}", + debug!("TemplateRef: location = {:?}; referenced = \ + {:?}; referenced_ty = {:?}", location, referenced, referenced_ty); @@ -702,18 +703,18 @@ impl Type { let referenced_ty = referenced.cur_type(); let declaration = referenced_ty.declaration(); - debug!("TypeRef {:?} {:?} {:?}", + debug!("TypeRef: location = {:?}; referenced = \ + {:?}; referenced_ty = {:?}", location, referenced, referenced_ty); let item = - Item::from_ty_or_ref_with_id( - potential_id, - referenced_ty, - Some(declaration), - parent_id, - ctx); + Item::from_ty_or_ref_with_id(potential_id, + referenced_ty, + Some(declaration), + parent_id, + ctx); return Ok(ParseResult::AlreadyResolved(item)); } CXCursor_NamespaceRef => { |