summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parser.rs27
-rw-r--r--tests/test_func.rs6
2 files changed, 5 insertions, 28 deletions
diff --git a/src/parser.rs b/src/parser.rs
index c6fc174f..385cdc17 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -66,7 +66,6 @@ fn match_pattern(ctx: &mut ClangParserCtx, cursor: &Cursor) -> bool {
return true;
}
- let name = file.name();
ctx.options.match_pat.iter().any(|pat| name.contains(pat))
}
@@ -81,7 +80,7 @@ fn decl_name(ctx: &mut ClangParserCtx, cursor: &Cursor) -> Global {
let (file, _, _, _) = cursor.location().location();
let ty = cursor.cur_type();
let layout = Layout::new(ty.size(), ty.align());
- let filename = match Path::new(&file.name()).file_name() {
+ let filename = match Path::new(&file.name().unwrap_or("".to_owned())).file_name() {
Some(name) => name.to_string_lossy().replace(".", "_"),
_ => "".to_string()
};
@@ -450,12 +449,7 @@ impl Annotations {
/// nested composites that make up the visited composite.
fn visit_composite(cursor: &Cursor, parent: &Cursor,
ctx: &mut ClangParserCtx,
-<<<<<<< 6f1904e52612db3a2517727c053e7cbc84601b2a
- compinfo: &mut CompInfo) -> Enum_CXVisitorResult {
-=======
ci: &mut CompInfo) -> Enum_CXVisitorResult {
-
->>>>>>> SM hacks squash
fn is_bitfield_continuation(field: &il::FieldInfo, ty: &il::Type, width: u32) -> bool {
match (&field.bitfields, ty) {
(&Some(ref bitfields), &il::TInt(_, layout)) if *ty == field.ty => {
@@ -473,15 +467,13 @@ fn visit_composite(cursor: &Cursor, parent: &Cursor,
loop {
match *ty {
TComp(ref comp_ty) => return Some(comp_ty),
- TPtr(ref ptr_ty, _, _) => ty = &**ptr_ty,
+ TPtr(ref ptr_ty, _, _, _) => ty = &**ptr_ty,
TArray(ref array_ty, _, _) => ty = &**array_ty,
_ => return None
}
}
}
- let members = &mut compinfo.members;
-
match cursor.kind() {
CXCursor_FieldDecl => {
let anno = Annotations::new(cursor);
@@ -547,22 +539,7 @@ fn visit_composite(cursor: &Cursor, parent: &Cursor,
// };
//
-<<<<<<< 6f1904e52612db3a2517727c053e7cbc84601b2a
- let is_composite = match (inner_composite(&ty), members.last()) {
-=======
- fn inner_composite(mut ty: &il::Type) -> Option<&Rc<RefCell<CompInfo>>> {
- loop {
- match ty {
- &TComp(ref comp_ty) => return Some(comp_ty),
- &TPtr(ref ptr_ty, _, _, _) => ty = &**ptr_ty,
- &TArray(ref array_ty, _, _) => ty = &**array_ty,
- _ => return None
- }
- }
- }
-
let is_composite = match (inner_composite(&ty), ci.members.last()) {
->>>>>>> SM hacks squash
(Some(ty_compinfo), Some(&CompMember::Comp(ref c))) => {
c.borrow().deref() as *const _ == ty_compinfo.borrow().deref() as *const _
},
diff --git a/tests/test_func.rs b/tests/test_func.rs
index 434612ef..b210186f 100644
--- a/tests/test_func.rs
+++ b/tests/test_func.rs
@@ -5,7 +5,7 @@ fn func_ptr() {
assert_bind_eq(Default::default(), "headers/func_ptr.h", "
extern \"C\" {
pub static mut foo: ::std::option::Option<
- extern \"C\" fn(x: ::std::os::raw::c_int,
+ unsafe extern \"C\" fn(x: ::std::os::raw::c_int,
y: ::std::os::raw::c_int) -> ::std::os::raw::c_int>;
}
");
@@ -27,7 +27,7 @@ fn func_ptr_in_struct() {
#[test]
fn func_proto() {
assert_bind_eq(Default::default(), "headers/func_proto.h", "
- pub type foo = extern \"C\" fn(bar: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+ pub type foo = unsafe extern \"C\" fn(bar: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
");
}
@@ -35,7 +35,7 @@ fn func_proto() {
fn with_func_ptr_arg() {
assert_bind_eq(Default::default(), "headers/func_with_func_ptr_arg.h", "
extern \"C\" {
- pub fn foo(bar: ::std::option::Option<extern \"C\" fn()>);
+ pub fn foo(bar: ::std::option::Option<unsafe extern \"C\" fn()>);
}
");
}