Skip to content

Commit b478fcb

Browse files
committed
Add C++ symbol visibility annotations for Rust functions and impls
1 parent 1eadd26 commit b478fcb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

gen/src/write.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,9 @@ fn write_rust_function_shim_impl(
950950
// We've already defined this inside the struct.
951951
return;
952952
}
953+
if !out.header {
954+
begin_function_definition(out);
955+
}
953956
write_rust_function_shim_decl(out, local_name, sig, indirect_call);
954957
if out.header {
955958
writeln!(out, ";");
@@ -1487,6 +1490,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Pair) {
14871490
let instance = ident.to_symbol();
14881491

14891492
writeln!(out, "template <>");
1493+
begin_function_definition(out);
14901494
writeln!(
14911495
out,
14921496
"{} *Box<{}>::allocation::alloc() noexcept {{",
@@ -1496,6 +1500,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Pair) {
14961500
writeln!(out, "}}");
14971501

14981502
writeln!(out, "template <>");
1503+
begin_function_definition(out);
14991504
writeln!(
15001505
out,
15011506
"void Box<{}>::allocation::dealloc({} *ptr) noexcept {{",
@@ -1505,6 +1510,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Pair) {
15051510
writeln!(out, "}}");
15061511

15071512
writeln!(out, "template <>");
1513+
begin_function_definition(out);
15081514
writeln!(out, "void Box<{}>::drop() noexcept {{", inner);
15091515
writeln!(out, " cxxbridge1$box${}$drop(this);", instance);
15101516
writeln!(out, "}}");
@@ -1517,16 +1523,19 @@ fn write_rust_vec_impl(out: &mut OutFile, element: &RustName) {
15171523
out.include.cstddef = true;
15181524

15191525
writeln!(out, "template <>");
1526+
begin_function_definition(out);
15201527
writeln!(out, "Vec<{}>::Vec() noexcept {{", inner);
15211528
writeln!(out, " cxxbridge1$rust_vec${}$new(this);", instance);
15221529
writeln!(out, "}}");
15231530

15241531
writeln!(out, "template <>");
1532+
begin_function_definition(out);
15251533
writeln!(out, "void Vec<{}>::drop() noexcept {{", inner);
15261534
writeln!(out, " return cxxbridge1$rust_vec${}$drop(this);", instance);
15271535
writeln!(out, "}}");
15281536

15291537
writeln!(out, "template <>");
1538+
begin_function_definition(out);
15301539
writeln!(
15311540
out,
15321541
"::std::size_t Vec<{}>::size() const noexcept {{",
@@ -1536,6 +1545,7 @@ fn write_rust_vec_impl(out: &mut OutFile, element: &RustName) {
15361545
writeln!(out, "}}");
15371546

15381547
writeln!(out, "template <>");
1548+
begin_function_definition(out);
15391549
writeln!(
15401550
out,
15411551
"::std::size_t Vec<{}>::capacity() const noexcept {{",
@@ -1549,11 +1559,13 @@ fn write_rust_vec_impl(out: &mut OutFile, element: &RustName) {
15491559
writeln!(out, "}}");
15501560

15511561
writeln!(out, "template <>");
1562+
begin_function_definition(out);
15521563
writeln!(out, "const {} *Vec<{0}>::data() const noexcept {{", inner);
15531564
writeln!(out, " return cxxbridge1$rust_vec${}$data(this);", instance);
15541565
writeln!(out, "}}");
15551566

15561567
writeln!(out, "template <>");
1568+
begin_function_definition(out);
15571569
writeln!(
15581570
out,
15591571
"void Vec<{}>::reserve_total(::std::size_t cap) noexcept {{",
@@ -1567,6 +1579,7 @@ fn write_rust_vec_impl(out: &mut OutFile, element: &RustName) {
15671579
writeln!(out, "}}");
15681580

15691581
writeln!(out, "template <>");
1582+
begin_function_definition(out);
15701583
writeln!(
15711584
out,
15721585
"void Vec<{}>::set_len(::std::size_t len) noexcept {{",

0 commit comments

Comments
 (0)