Skip to content

Commit cd78b65

Browse files
committed
codegen: Use raw pointers rather than references in vtable functions.
Closes #2163
1 parent 68d2b0e commit cd78b65

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

src/codegen/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,9 +1077,9 @@ impl<'a> CodeGenerator for Vtable<'a> {
10771077
let ret = utils::fnsig_return_ty(ctx, signature);
10781078

10791079
args[0] = if m.is_const() {
1080-
quote! { this: & #class_ident }
1080+
quote! { this: *const #class_ident }
10811081
} else {
1082-
quote! { this: &mut #class_ident }
1082+
quote! { this: *mut #class_ident }
10831083
};
10841084

10851085
Some(quote! {

tests/expectations/tests/enum_and_vtable_mangling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum _bindgen_ty_1 {
1515
}
1616
#[repr(C)]
1717
pub struct C__bindgen_vtable {
18-
pub C_match: unsafe extern "C" fn(this: &mut C),
18+
pub C_match: unsafe extern "C" fn(this: *mut C),
1919
}
2020
#[repr(C)]
2121
#[derive(Debug, Copy, Clone)]

tests/expectations/tests/nested_vtable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#[repr(C)]
99
pub struct nsISupports__bindgen_vtable {
1010
pub nsISupports_QueryInterface:
11-
unsafe extern "C" fn(this: &mut nsISupports) -> *mut nsISupports,
11+
unsafe extern "C" fn(this: *mut nsISupports) -> *mut nsISupports,
1212
}
1313
#[repr(C)]
1414
#[derive(Debug, Copy, Clone)]

tests/expectations/tests/ref_argument_array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub const NSID_LENGTH: u32 = 10;
99
#[repr(C)]
1010
pub struct nsID__bindgen_vtable {
1111
pub nsID_ToProvidedString: unsafe extern "C" fn(
12-
this: &mut nsID,
12+
this: *mut nsID,
1313
aDest: *mut [::std::os::raw::c_char; 10usize],
1414
),
1515
}

tests/expectations/tests/virtual_interface.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
#[repr(C)]
99
pub struct PureVirtualIFace__bindgen_vtable {
10-
pub PureVirtualIFace_Foo: unsafe extern "C" fn(this: &mut PureVirtualIFace),
10+
pub PureVirtualIFace_Foo: unsafe extern "C" fn(this: *mut PureVirtualIFace),
1111
pub PureVirtualIFace_Bar: unsafe extern "C" fn(
12-
this: &mut PureVirtualIFace,
12+
this: *mut PureVirtualIFace,
1313
arg1: ::std::os::raw::c_uint,
1414
),
1515
}
@@ -42,7 +42,7 @@ impl Default for PureVirtualIFace {
4242
}
4343
#[repr(C)]
4444
pub struct AnotherInterface__bindgen_vtable {
45-
pub AnotherInterface_Baz: unsafe extern "C" fn(this: &mut AnotherInterface),
45+
pub AnotherInterface_Baz: unsafe extern "C" fn(this: *mut AnotherInterface),
4646
}
4747
#[repr(C)]
4848
#[derive(Debug, Copy, Clone)]

tests/expectations/tests/virtual_overloaded.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#[repr(C)]
99
pub struct C__bindgen_vtable {
1010
pub C_do_thing:
11-
unsafe extern "C" fn(this: &mut C, arg1: ::std::os::raw::c_char),
11+
unsafe extern "C" fn(this: *mut C, arg1: ::std::os::raw::c_char),
1212
pub C_do_thing1:
13-
unsafe extern "C" fn(this: &mut C, arg1: ::std::os::raw::c_int),
13+
unsafe extern "C" fn(this: *mut C, arg1: ::std::os::raw::c_int),
1414
}
1515
#[repr(C)]
1616
#[derive(Debug, Copy, Clone)]

tests/expectations/tests/vtable_recursive_sig.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#[repr(C)]
99
pub struct Base__bindgen_vtable {
10-
pub Base_AsDerived: unsafe extern "C" fn(this: &mut Base) -> *mut Derived,
10+
pub Base_AsDerived: unsafe extern "C" fn(this: *mut Base) -> *mut Derived,
1111
}
1212
#[repr(C)]
1313
#[derive(Debug, Copy, Clone)]

0 commit comments

Comments
 (0)