Skip to content

Commit

Permalink
Space function definitions and ensure all have begin_function_definition
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 29, 2023
1 parent 541daa0 commit 4213e92
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gen/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) {
writeln!(out, " return uninit;");
writeln!(out, "}}");
}

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1706,6 +1707,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) {
);
writeln!(out, " ::new (ptr) ::std::unique_ptr<{}>(raw);", inner);
writeln!(out, "}}");

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1714,6 +1716,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) {
);
writeln!(out, " return ptr.get();");
writeln!(out, "}}");

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1722,6 +1725,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) {
);
writeln!(out, " return ptr.release();");
writeln!(out, "}}");

begin_function_definition(out);
writeln!(
out,
Expand Down Expand Up @@ -1766,6 +1770,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) {
"static_assert(alignof(::std::shared_ptr<{}>) == alignof(void *), \"\");",
inner,
);

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1774,6 +1779,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) {
);
writeln!(out, " ::new (ptr) ::std::shared_ptr<{}>();", inner);
writeln!(out, "}}");

if can_construct_from_value {
out.builtin.maybe_uninit = true;
begin_function_definition(out);
Expand All @@ -1791,6 +1797,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) {
writeln!(out, " return uninit;");
writeln!(out, "}}");
}

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1799,6 +1806,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) {
);
writeln!(out, " ::new (ptr) ::std::shared_ptr<{}>(self);", inner);
writeln!(out, "}}");

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1807,6 +1815,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) {
);
writeln!(out, " return self.get();");
writeln!(out, "}}");

begin_function_definition(out);
writeln!(
out,
Expand Down Expand Up @@ -1835,13 +1844,16 @@ fn write_weak_ptr(out: &mut OutFile, key: NamedImplKey) {
"static_assert(alignof(::std::weak_ptr<{}>) == alignof(void *), \"\");",
inner,
);

begin_function_definition(out);
writeln!(
out,
"void cxxbridge1$weak_ptr${}$null(::std::weak_ptr<{}> *ptr) noexcept {{",
instance, inner,
);
writeln!(out, " ::new (ptr) ::std::weak_ptr<{}>();", inner);
writeln!(out, "}}");

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1850,6 +1862,7 @@ fn write_weak_ptr(out: &mut OutFile, key: NamedImplKey) {
);
writeln!(out, " ::new (ptr) ::std::weak_ptr<{}>(self);", inner);
writeln!(out, "}}");

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1858,6 +1871,7 @@ fn write_weak_ptr(out: &mut OutFile, key: NamedImplKey) {
);
writeln!(out, " ::new (weak) ::std::weak_ptr<{}>(shared);", inner);
writeln!(out, "}}");

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1870,6 +1884,7 @@ fn write_weak_ptr(out: &mut OutFile, key: NamedImplKey) {
inner,
);
writeln!(out, "}}");

begin_function_definition(out);
writeln!(
out,
Expand All @@ -1889,6 +1904,7 @@ fn write_cxx_vector(out: &mut OutFile, key: NamedImplKey) {
out.include.utility = true;
out.builtin.destroy = true;

begin_function_definition(out);
writeln!(
out,
"::std::size_t cxxbridge1$std$vector${}$size(::std::vector<{}> const &s) noexcept {{",
Expand Down

0 comments on commit 4213e92

Please sign in to comment.