Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ fn cstruct_to_rs(ctx: &mut GenCtx, name: &str, ci: CompInfo,
vffields.push(field);
}

let mut counts: HashMap<String, isize> = HashMap::new();
for vm in ci.vmethods.iter() {
let ty = match vm.ty {
TFuncPtr(ref sig) => {
Expand All @@ -977,7 +978,19 @@ fn cstruct_to_rs(ctx: &mut GenCtx, name: &str, ci: CompInfo,
_ => unreachable!()
};

let name = first(rust_id(ctx, &vm.name));
let mut name = vm.name.clone();
let mut count = 0;
match counts.get(&vm.name) {
Some(x) => {
count = *x;
name.push_str(&x.to_string());
},
None => ()
}
count += 1;
counts.insert(vm.name.clone(), count);

let name = first(rust_id(ctx, &name));

vffields.push(ast::StructField {
span: ctx.span,
Expand Down
2 changes: 2 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,7 @@ pub fn parse(options: ClangParserOptions, logger: &Logger) -> Result<ModuleMap,
}

if ctx.err_count > 0 {
logger.error(&format!("{} errors after diagnostics", ctx.err_count));
return Err(())
}

Expand All @@ -1510,6 +1511,7 @@ pub fn parse(options: ClangParserOptions, logger: &Logger) -> Result<ModuleMap,
ix.dispose();

if ctx.err_count > 0 {
logger.error(&format!("{} errors after translation", ctx.err_count));
return Err(())
}

Expand Down
26 changes: 26 additions & 0 deletions tests/expectations/virtual_overloaded.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]


#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_C {
pub _vftable: *const _vftable_Struct_C,
}
#[repr(C)]
pub struct _vftable_Struct_C {
pub do_thing: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void,
arg1: ::std::os::raw::c_char),
pub do_thing1: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void,
arg1: ::std::os::raw::c_int),
}
impl ::std::clone::Clone for Struct_C {
fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_C() {
assert_eq!(::std::mem::size_of::<Struct_C>() , 8usize);
assert_eq!(::std::mem::align_of::<Struct_C>() , 8usize);
}
5 changes: 5 additions & 0 deletions tests/headers/virtual_overloaded.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class C {
public:
virtual void do_thing(char) { };
virtual void do_thing(int) { };
};