diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-01-16 20:03:30 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-01-16 20:04:18 +0100 |
commit | d021caab5ea0180395cb790eb8ecafa8f66dc7b6 (patch) | |
tree | ffe5b5e678a8bfb632dc31b04abd237c8e5f0e6e /libbindgen/src | |
parent | b570ce853e33bfcfa05dd339bf432377c4a2fab8 (diff) |
ir: Unify function checks so they apply to non-methods.
Diffstat (limited to 'libbindgen/src')
-rw-r--r-- | libbindgen/src/ir/comp.rs | 29 | ||||
-rw-r--r-- | libbindgen/src/ir/function.rs | 19 |
2 files changed, 23 insertions, 25 deletions
diff --git a/libbindgen/src/ir/comp.rs b/libbindgen/src/ir/comp.rs index 70dfd4a6..30654901 100644 --- a/libbindgen/src/ir/comp.rs +++ b/libbindgen/src/ir/comp.rs @@ -652,29 +652,6 @@ impl CompInfo { ci.has_destructor |= cur.kind() == CXCursor_Destructor; ci.has_vtable |= is_virtual; - let linkage = cur.linkage(); - if linkage != CXLinkage_External { - return CXChildVisit_Continue; - } - - if cur.access_specifier() == CX_CXXPrivate { - return CXChildVisit_Continue; - } - - let visibility = cur.visibility(); - if visibility != CXVisibility_Default { - return CXChildVisit_Continue; - } - - if cur.is_inlined_function() { - return CXChildVisit_Continue; - } - - let spelling = cur.spelling(); - if spelling.starts_with("operator") { - return CXChildVisit_Continue; - } - // This used to not be here, but then I tried generating // stylo bindings with this (without path filters), and // cried a lot with a method in gfx/Point.h @@ -691,8 +668,10 @@ impl CompInfo { // NB: This gets us an owned `Function`, not a // `FunctionSig`. - let signature = Item::parse(cur, Some(potential_id), ctx) - .expect("CXXMethod"); + let signature = match Item::parse(cur, Some(potential_id), ctx) { + Ok(item) if ctx.resolve_item(item).kind().is_function() => item, + _ => return CXChildVisit_Continue, + }; match cur.kind() { CXCursor_Constructor => { diff --git a/libbindgen/src/ir/function.rs b/libbindgen/src/ir/function.rs index 88ab861d..50c442db 100644 --- a/libbindgen/src/ir/function.rs +++ b/libbindgen/src/ir/function.rs @@ -150,6 +150,7 @@ impl FunctionSig { } else { ty.declaration() }; + let mut args: Vec<_> = match cursor.kind() { CXCursor_FunctionDecl | CXCursor_Constructor | @@ -262,6 +263,24 @@ impl ClangSubItemParser for Function { debug!("Function::parse({:?}, {:?})", cursor, cursor.cur_type()); + let visibility = cursor.visibility(); + if visibility != CXVisibility_Default { + return Err(ParseError::Continue); + } + + if cursor.access_specifier() == CX_CXXPrivate { + return Err(ParseError::Continue); + } + + if cursor.is_inlined_function() { + return Err(ParseError::Continue); + } + + let linkage = cursor.linkage(); + if linkage != CXLinkage_External && linkage != CXLinkage_UniqueExternal { + return Err(ParseError::Continue); + } + // Grab the signature using Item::from_ty. let sig = try!(Item::from_ty(&cursor.cur_type(), Some(cursor), |