mirror of
https://github.com/topjohnwu/cxx.git
synced 2025-02-24 10:03:39 +00:00
Include <new> when placement new is used
This commit is contained in:
parent
2b87b16679
commit
0ecd05a9bf
@ -56,6 +56,7 @@ pub struct Includes {
|
||||
pub cstring: bool,
|
||||
pub exception: bool,
|
||||
pub memory: bool,
|
||||
pub new: bool,
|
||||
pub string: bool,
|
||||
pub type_traits: bool,
|
||||
pub utility: bool,
|
||||
@ -106,6 +107,9 @@ impl Display for Includes {
|
||||
if self.memory {
|
||||
writeln!(f, "#include <memory>")?;
|
||||
}
|
||||
if self.new {
|
||||
writeln!(f, "#include <new>")?;
|
||||
}
|
||||
if self.string {
|
||||
writeln!(f, "#include <string>")?;
|
||||
}
|
||||
|
@ -149,11 +149,13 @@ fn write_include_cxxbridge(out: &mut OutFile, apis: &[Api], types: &Types) {
|
||||
for ty in types {
|
||||
match ty {
|
||||
Type::RustBox(_) => {
|
||||
out.include.new = true;
|
||||
out.include.type_traits = true;
|
||||
needs_rust_box = true;
|
||||
}
|
||||
Type::RustVec(_) => {
|
||||
out.include.array = true;
|
||||
out.include.new = true;
|
||||
out.include.type_traits = true;
|
||||
needs_rust_vec = true;
|
||||
}
|
||||
@ -463,6 +465,7 @@ fn write_cxx_function_shim(out: &mut OutFile, efn: &ExternFn, types: &Types) {
|
||||
write!(out, " ");
|
||||
}
|
||||
if indirect_return {
|
||||
out.include.new = true;
|
||||
write!(out, "new (return$) ");
|
||||
write_indirect_return_type(out, efn.ret.as_ref().unwrap());
|
||||
write!(out, "(");
|
||||
@ -1149,6 +1152,7 @@ fn write_unique_ptr(out: &mut OutFile, ident: &Ident, types: &Types) {
|
||||
|
||||
// Shared by UniquePtr<T> and UniquePtr<CxxVector<T>>.
|
||||
fn write_unique_ptr_common(out: &mut OutFile, ty: &Type, types: &Types) {
|
||||
out.include.new = true;
|
||||
out.include.utility = true;
|
||||
let inner = to_typename(&out.namespace, ty);
|
||||
let instance = to_mangled(&out.namespace, ty);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
Loading…
x
Reference in New Issue
Block a user