diff options
author | Michael Wu <mwu@mozilla.com> | 2015-03-25 04:21:43 -0400 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2015-12-30 23:28:46 +0100 |
commit | 8a5186040470a800f7867477daeaf70a62534d36 (patch) | |
tree | cfa75888c55c987caac2e2d041467fd8430ec889 | |
parent | 6e33fbe74de0c38c68658cc51c6d8fe584691367 (diff) |
Recurse into unexposed decls
This fixes functions that use extern "C".
-rw-r--r-- | src/parser.rs | 3 | ||||
-rw-r--r-- | tests/headers/extern.hpp | 3 | ||||
-rw-r--r-- | tests/support.rs | 3 | ||||
-rw-r--r-- | tests/test_extern.rs | 8 | ||||
-rw-r--r-- | tests/tests.rs | 1 |
5 files changed, 18 insertions, 0 deletions
diff --git a/src/parser.rs b/src/parser.rs index 8c80ea3e..075470a5 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -498,6 +498,9 @@ fn visit_top<'r>(cursor: &Cursor, } match cursor.kind() { + CXCursor_UnexposedDecl => { + return CXChildVisit_Recurse; + } CXCursor_StructDecl | CXCursor_UnionDecl => { fwd_decl(ctx, cursor, |ctx_| { let decl = decl_name(ctx_, cursor); diff --git a/tests/headers/extern.hpp b/tests/headers/extern.hpp new file mode 100644 index 00000000..0779e038 --- /dev/null +++ b/tests/headers/extern.hpp @@ -0,0 +1,3 @@ +extern "C" { +#include "func_proto.h" +} diff --git a/tests/support.rs b/tests/support.rs index dd414649..94cdf952 100644 --- a/tests/support.rs +++ b/tests/support.rs @@ -25,6 +25,9 @@ impl Logger for TestLogger { pub fn generate_bindings(filename: &str) -> Result<Vec<P<ast::Item>>, ()> { let mut options:BindgenOptions = Default::default(); + if filename.ends_with("hpp") { + options.clang_args.push("-std=c++11".to_string()); + } options.clang_args.push(filename.to_string()); let logger = TestLogger; diff --git a/tests/test_extern.rs b/tests/test_extern.rs new file mode 100644 index 00000000..495bf160 --- /dev/null +++ b/tests/test_extern.rs @@ -0,0 +1,8 @@ +use support::assert_bind_eq; + +#[test] +fn extern_c_in_hpp() { + assert_bind_eq("headers/extern.hpp", " + pub type foo = extern \"C\" fn(bar: ::libc::c_int) -> ::libc::c_int; + "); +} diff --git a/tests/tests.rs b/tests/tests.rs index b9a4f61c..28764bea 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -9,6 +9,7 @@ mod support; // Unused until we can generate code for tests //mod test_cmath; mod test_decl; +mod test_extern; mod test_func; mod test_struct; mod test_union; |