Skip to content

Commit

Permalink
Update write.rs to generate $new
Browse files Browse the repository at this point in the history
  • Loading branch information
capickett committed Aug 29, 2023
1 parent b733e16 commit db549b5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion gen/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) {
"static_assert(alignof(::std::unique_ptr<{}>) == alignof(void *), \"\");",
inner,
);

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

if can_construct_from_value {
out.builtin.maybe_uninit = true;
begin_function_definition(out);
Expand Down Expand Up @@ -1926,6 +1928,20 @@ fn write_cxx_vector(out: &mut OutFile, key: NamedImplKey) {
writeln!(out, "}}");
}

let ty = UniquePtr::CxxVector(element);

out.include.memory = true;
write_unique_ptr_common(out, UniquePtr::CxxVector(element));
write_unique_ptr_common(out, ty);

let inner = ty.to_typename(out.types);
let instance = ty.to_mangled(out.types);

begin_function_definition(out);
writeln!(
out,
"{} *cxxbridge1$unique_ptr${}$new() noexcept {{",
inner, instance,
);
writeln!(out, " return new {}();", inner);
writeln!(out, "}}");
}

0 comments on commit db549b5

Please sign in to comment.