Skip to content

Commit 8685745

Browse files
authored
Merge pull request #455 from dtolnay/cxxabi
Update cxx::bridge modules to use extern "C++" as the ABI
2 parents 4ab1171 + c72a9f6 commit 8685745

21 files changed

+26
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ items:
151151
- **Functions** — implemented in either language, callable from the other
152152
language.
153153

154-
Within the `extern "C"` part of the CXX bridge we list the types and functions
154+
Within the `extern "C++"` part of the CXX bridge we list the types and functions
155155
for which C++ is the source of truth, as well as the header(s) that declare
156156
those APIs. In the future it's possible that this section could be generated
157157
bindgen-style from the headers but for now we need the signatures written out;

gen/lib/tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn test_positive() {
66
let rs = quote! {
77
#[cxx::bridge]
88
mod ffi {
9-
extern "C" {
9+
extern "C++" {
1010
fn in_C();
1111
}
1212
extern "Rust" {

macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use syn::parse_macro_input;
2727
/// is intended to be used.
2828
///
2929
/// The only additional thing to note here is namespace support — if the
30-
/// types and functions on the `extern "C"` side of our bridge are in a
30+
/// types and functions on the `extern "C++"` side of our bridge are in a
3131
/// namespace, specify that namespace as an argument of the cxx::bridge
3232
/// attribute macro.
3333
///

src/exception.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use alloc::boxed::Box;
22
use core::fmt::{self, Debug, Display};
33

4-
/// Exception thrown from an `extern "C"` function.
4+
/// Exception thrown from an `extern "C++"` function.
55
#[derive(Debug)]
66
pub struct Exception {
77
pub(crate) what: Box<str>,

src/extern_type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use self::kind::{Kind, Opaque, Trivial};
3030
/// # mod file1 {
3131
/// #[cxx::bridge(namespace = "example")]
3232
/// pub mod ffi {
33-
/// extern "C" {
33+
/// extern "C++" {
3434
/// type Demo;
3535
///
3636
/// fn create_demo() -> UniquePtr<Demo>;
@@ -41,7 +41,7 @@ use self::kind::{Kind, Opaque, Trivial};
4141
/// // file2.rs
4242
/// #[cxx::bridge(namespace = "example")]
4343
/// pub mod ffi {
44-
/// extern "C" {
44+
/// extern "C++" {
4545
/// type Demo = crate::file1::ffi::Demo;
4646
///
4747
/// fn take_ref_demo(demo: &Demo);
@@ -80,7 +80,7 @@ use self::kind::{Kind, Opaque, Trivial};
8080
///
8181
/// #[cxx::bridge(namespace = "folly")]
8282
/// pub mod ffi {
83-
/// extern "C" {
83+
/// extern "C++" {
8484
/// include!("rust_cxx_bindings.h");
8585
///
8686
/// type StringPiece = crate::folly_sys::StringPiece;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
//! - **Functions** &mdash; implemented in either language, callable from the
157157
//! other language.
158158
//!
159-
//! Within the `extern "C"` part of the CXX bridge we list the types and
159+
//! Within the `extern "C++"` part of the CXX bridge we list the types and
160160
//! functions for which C++ is the source of truth, as well as the header(s)
161161
//! that declare those APIs. In the future it's possible that this section could
162162
//! be generated bindgen-style from the headers but for now we need the

syntax/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn parse_lang(abi: &Abi) -> Result<Lang> {
280280
None => {
281281
return Err(Error::new_spanned(
282282
abi,
283-
"ABI name is required, extern \"C\" or extern \"Rust\"",
283+
"ABI name is required, extern \"C++\" or extern \"Rust\"",
284284
));
285285
}
286286
};

tests/cxx_gen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::str;
66
const BRIDGE0: &str = r#"
77
#[cxx::bridge]
88
mod ffi {
9-
extern "C" {
9+
extern "C++" {
1010
pub fn do_cpp_thing(foo: &str);
1111
}
1212
}

tests/ffi/extra.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub mod ffi2 {
1515
impl UniquePtr<F> {}
1616
impl UniquePtr<G> {}
1717

18-
extern "C" {
18+
extern "C++" {
1919
include!("tests/ffi/tests.h");
2020

2121
type D = crate::other::D;

tests/ffi/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub mod ffi {
116116
i: i32,
117117
}
118118

119-
extern "C" {
119+
extern "C++" {
120120
include!("tests/ffi/tests.h");
121121

122122
type C;
@@ -219,7 +219,7 @@ pub mod ffi {
219219
fn ns_c_take_ns_shared(shared: AShared);
220220
}
221221

222-
extern "C" {
222+
extern "C++" {
223223
type COwnedEnum;
224224
}
225225

tests/ffi/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#[rustfmt::skip]
44
#[cxx::bridge(namespace = "tests")]
55
pub mod ffi {
6-
extern "C" {
6+
extern "C++" {
77
include!("tests/ffi/tests.h");
88

99
type C = crate::ffi::C;

tests/ui/by_value_not_supported.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod ffi {
66
s: CxxString,
77
}
88

9-
extern "C" {
9+
extern "C++" {
1010
type C;
1111
}
1212

tests/ui/disallow_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cxx::bridge]
22
mod ffi {
3-
extern "C" {
3+
extern "C++" {
44
type C;
55
fn f(&'static self);
66
}

tests/ui/include.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cxx::bridge]
22
mod ffi {
3-
extern "C" {
3+
extern "C++" {
44
include!("path/to" what);
55
include!(<path/to> what);
66
include!(<path/to);

tests/ui/reference_to_reference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cxx::bridge]
22
mod ffi {
3-
extern "C" {
3+
extern "C++" {
44
type ThingC;
55
fn repro_c(t: &&ThingC);
66
}

tests/ui/reserved_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod ffi {
44
val: usize,
55
}
66

7-
extern "C" {
7+
extern "C++" {
88
type Box;
99
}
1010

tests/ui/unique_ptr_to_opaque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod outside {
1111

1212
#[cxx::bridge]
1313
mod ffi {
14-
extern "C" {
14+
extern "C++" {
1515
type C = crate::outside::C;
1616
}
1717

tests/ui/unique_ptr_twice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cxx::bridge]
22
mod here {
3-
extern "C" {
3+
extern "C++" {
44
type C;
55
}
66

@@ -9,7 +9,7 @@ mod here {
99

1010
#[cxx::bridge]
1111
mod there {
12-
extern "C" {
12+
extern "C++" {
1313
type C = crate::here::C;
1414
}
1515

tests/ui/unnamed_receiver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cxx::bridge]
22
mod ffi {
3-
extern "C" {
3+
extern "C++" {
44
type One;
55
type Two;
66
fn f(&mut self);

tests/ui/unrecognized_receiver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cxx::bridge]
22
mod ffi {
3-
extern "C" {
3+
extern "C++" {
44
fn f(self: &Unrecognized);
55
}
66
}

tests/ui/wrong_type_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#[cxx::bridge(namespace = "folly")]
22
mod here {
3-
extern "C" {
3+
extern "C++" {
44
type StringPiece;
55
}
66
}
77

88
#[cxx::bridge(namespace = "folly")]
99
mod there {
10-
extern "C" {
10+
extern "C++" {
1111
type ByteRange = crate::here::StringPiece;
1212
}
1313
}

0 commit comments

Comments
 (0)