diff options
Diffstat (limited to 'bindgen/ir/function.rs')
-rw-r--r-- | bindgen/ir/function.rs | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/bindgen/ir/function.rs b/bindgen/ir/function.rs index 8e83d980..baa2c36c 100644 --- a/bindgen/ir/function.rs +++ b/bindgen/ir/function.rs @@ -664,7 +664,6 @@ impl ClangSubItemParser for Function { }; debug!("Function::parse({:?}, {:?})", cursor, cursor.cur_type()); - let visibility = cursor.visibility(); if visibility != CXVisibility_Default { return Err(ParseError::Continue); @@ -674,25 +673,36 @@ impl ClangSubItemParser for Function { return Err(ParseError::Continue); } + let linkage = cursor.linkage(); + let linkage = match linkage { + CXLinkage_External | CXLinkage_UniqueExternal => Linkage::External, + CXLinkage_Internal => Linkage::Internal, + _ => return Err(ParseError::Continue), + }; + if cursor.is_inlined_function() || cursor .definition() .map_or(false, |x| x.is_inlined_function()) { - if !context.options().generate_inline_functions { + if !context.options().generate_inline_functions && + !context.options().wrap_static_fns + { return Err(ParseError::Continue); } + if cursor.is_deleted_function() { return Err(ParseError::Continue); } - } - let linkage = cursor.linkage(); - let linkage = match linkage { - CXLinkage_External | CXLinkage_UniqueExternal => Linkage::External, - CXLinkage_Internal => Linkage::Internal, - _ => return Err(ParseError::Continue), - }; + // We cannot handle `inline` functions that are not `static`. + if context.options().wrap_static_fns && + cursor.is_inlined_function() && + matches!(linkage, Linkage::External) + { + return Err(ParseError::Continue); + } + } // Grab the signature using Item::from_ty. let sig = Item::from_ty(&cursor.cur_type(), cursor, None, context)?; @@ -727,7 +737,8 @@ impl ClangSubItemParser for Function { let comment = cursor.raw_comment(); let function = - Self::new(name, mangled_name, sig, comment, kind, linkage); + Self::new(name.clone(), mangled_name, sig, comment, kind, linkage); + Ok(ParseResult::New(function, Some(cursor))) } } |