Skip to content

Commit

Permalink
codegen: Use raw pointers rather than references in vtable functions.
Browse files Browse the repository at this point in the history
Closes #2163
  • Loading branch information
emilio committed Feb 18, 2022
1 parent 68d2b0e commit cd78b65
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,9 +1077,9 @@ impl<'a> CodeGenerator for Vtable<'a> {
let ret = utils::fnsig_return_ty(ctx, signature);

args[0] = if m.is_const() {
quote! { this: & #class_ident }
quote! { this: *const #class_ident }
} else {
quote! { this: &mut #class_ident }
quote! { this: *mut #class_ident }
};

Some(quote! {
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/enum_and_vtable_mangling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum _bindgen_ty_1 {
}
#[repr(C)]
pub struct C__bindgen_vtable {
pub C_match: unsafe extern "C" fn(this: &mut C),
pub C_match: unsafe extern "C" fn(this: *mut C),
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/nested_vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#[repr(C)]
pub struct nsISupports__bindgen_vtable {
pub nsISupports_QueryInterface:
unsafe extern "C" fn(this: &mut nsISupports) -> *mut nsISupports,
unsafe extern "C" fn(this: *mut nsISupports) -> *mut nsISupports,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/ref_argument_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub const NSID_LENGTH: u32 = 10;
#[repr(C)]
pub struct nsID__bindgen_vtable {
pub nsID_ToProvidedString: unsafe extern "C" fn(
this: &mut nsID,
this: *mut nsID,
aDest: *mut [::std::os::raw::c_char; 10usize],
),
}
Expand Down
6 changes: 3 additions & 3 deletions tests/expectations/tests/virtual_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#[repr(C)]
pub struct PureVirtualIFace__bindgen_vtable {
pub PureVirtualIFace_Foo: unsafe extern "C" fn(this: &mut PureVirtualIFace),
pub PureVirtualIFace_Foo: unsafe extern "C" fn(this: *mut PureVirtualIFace),
pub PureVirtualIFace_Bar: unsafe extern "C" fn(
this: &mut PureVirtualIFace,
this: *mut PureVirtualIFace,
arg1: ::std::os::raw::c_uint,
),
}
Expand Down Expand Up @@ -42,7 +42,7 @@ impl Default for PureVirtualIFace {
}
#[repr(C)]
pub struct AnotherInterface__bindgen_vtable {
pub AnotherInterface_Baz: unsafe extern "C" fn(this: &mut AnotherInterface),
pub AnotherInterface_Baz: unsafe extern "C" fn(this: *mut AnotherInterface),
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions tests/expectations/tests/virtual_overloaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#[repr(C)]
pub struct C__bindgen_vtable {
pub C_do_thing:
unsafe extern "C" fn(this: &mut C, arg1: ::std::os::raw::c_char),
unsafe extern "C" fn(this: *mut C, arg1: ::std::os::raw::c_char),
pub C_do_thing1:
unsafe extern "C" fn(this: &mut C, arg1: ::std::os::raw::c_int),
unsafe extern "C" fn(this: *mut C, arg1: ::std::os::raw::c_int),
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/vtable_recursive_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#[repr(C)]
pub struct Base__bindgen_vtable {
pub Base_AsDerived: unsafe extern "C" fn(this: &mut Base) -> *mut Derived,
pub Base_AsDerived: unsafe extern "C" fn(this: *mut Base) -> *mut Derived,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down

0 comments on commit cd78b65

Please sign in to comment.