Skip to content

Commit be6d07a

Browse files
DrChatemilio
authored andcommitted
Mark all vtable functions as unsafe extern "C"
1 parent 0587ff9 commit be6d07a

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

src/codegen/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ impl<'a> CodeGenerator for Vtable<'a> {
10821082
};
10831083

10841084
Some(quote! {
1085-
pub #function_name : fn( #( #args ),* ) #ret
1085+
pub #function_name : unsafe extern "C" fn( #( #args ),* ) #ret
10861086
})
10871087
})
10881088
.collect::<Vec<_>>();

tests/expectations/tests/enum_and_vtable_mangling.rs

+1-1
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: 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

+1-1
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-
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

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
pub const NSID_LENGTH: u32 = 10;
99
#[repr(C)]
1010
pub struct nsID__bindgen_vtable {
11-
pub nsID_ToProvidedString:
12-
fn(this: &mut nsID, aDest: *mut [::std::os::raw::c_char; 10usize]),
11+
pub nsID_ToProvidedString: unsafe extern "C" fn(
12+
this: &mut nsID,
13+
aDest: *mut [::std::os::raw::c_char; 10usize],
14+
),
1315
}
1416
#[repr(C)]
1517
#[derive(Debug, Copy, Clone)]

tests/expectations/tests/virtual_interface.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
#[repr(C)]
99
pub struct PureVirtualIFace__bindgen_vtable {
10-
pub PureVirtualIFace_Foo: fn(this: &mut PureVirtualIFace),
11-
pub PureVirtualIFace_Bar:
12-
fn(this: &mut PureVirtualIFace, arg1: ::std::os::raw::c_uint),
10+
pub PureVirtualIFace_Foo: unsafe extern "C" fn(this: &mut PureVirtualIFace),
11+
pub PureVirtualIFace_Bar: unsafe extern "C" fn(
12+
this: &mut PureVirtualIFace,
13+
arg1: ::std::os::raw::c_uint,
14+
),
1315
}
1416
#[repr(C)]
1517
#[derive(Debug, Copy, Clone)]
@@ -40,7 +42,7 @@ impl Default for PureVirtualIFace {
4042
}
4143
#[repr(C)]
4244
pub struct AnotherInterface__bindgen_vtable {
43-
pub AnotherInterface_Baz: fn(this: &mut AnotherInterface),
45+
pub AnotherInterface_Baz: unsafe extern "C" fn(this: &mut AnotherInterface),
4446
}
4547
#[repr(C)]
4648
#[derive(Debug, Copy, Clone)]

tests/expectations/tests/virtual_overloaded.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
#[repr(C)]
99
pub struct C__bindgen_vtable {
10-
pub C_do_thing: fn(this: &mut C, arg1: ::std::os::raw::c_char),
11-
pub C_do_thing1: fn(this: &mut C, arg1: ::std::os::raw::c_int),
10+
pub C_do_thing:
11+
unsafe extern "C" fn(this: &mut C, arg1: ::std::os::raw::c_char),
12+
pub C_do_thing1:
13+
unsafe extern "C" fn(this: &mut C, arg1: ::std::os::raw::c_int),
1214
}
1315
#[repr(C)]
1416
#[derive(Debug, Copy, Clone)]

tests/expectations/tests/vtable_recursive_sig.rs

+1-1
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: 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)