Bump inline namespace to match minor version
diff --git a/Cargo.toml b/Cargo.toml
index 188eca3..f81cdb9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@
version = "0.2.0" # remember to update html_root_url
authors = ["David Tolnay <dtolnay@gmail.com>"]
edition = "2018"
-links = "cxxbridge01"
+links = "cxxbridge02"
license = "MIT OR Apache-2.0"
description = "Safe interop between Rust and C++"
repository = "https://github.com/dtolnay/cxx"
diff --git a/build.rs b/build.rs
index bdda779..5173658 100644
--- a/build.rs
+++ b/build.rs
@@ -2,7 +2,7 @@
cc::Build::new()
.file("src/cxx.cc")
.flag("-std=c++11")
- .compile("cxxbridge01");
+ .compile("cxxbridge02");
println!("cargo:rerun-if-changed=src/cxx.cc");
println!("cargo:rerun-if-changed=include/cxx.h");
}
diff --git a/gen/write.rs b/gen/write.rs
index 6ff04e5..f74fb74 100644
--- a/gen/write.rs
+++ b/gen/write.rs
@@ -123,7 +123,7 @@
}
out.begin_block("namespace rust");
- out.begin_block("inline namespace cxxbridge01");
+ out.begin_block("inline namespace cxxbridge02");
if needs_rust_box || needs_manually_drop || needs_maybe_uninit {
writeln!(out, "// #include \"rust/cxx.h\"");
@@ -131,7 +131,7 @@
if needs_rust_box {
out.next_section();
- for line in include::get("CXXBRIDGE01_RUST_BOX").lines() {
+ for line in include::get("CXXBRIDGE02_RUST_BOX").lines() {
if !line.trim_start().starts_with("//") {
writeln!(out, "{}", line);
}
@@ -161,7 +161,7 @@
writeln!(out, "}};");
}
- out.end_block("namespace cxxbridge01");
+ out.end_block("namespace cxxbridge02");
out.end_block("namespace rust");
}
@@ -195,7 +195,7 @@
for name in out.namespace.clone() {
write!(out, "{}$", name);
}
- write!(out, "cxxbridge01${}(", efn.ident);
+ write!(out, "cxxbridge02${}(", efn.ident);
for (i, arg) in efn.args.iter().enumerate() {
if i > 0 {
write!(out, ", ");
@@ -278,7 +278,7 @@
for name in out.namespace.clone() {
write!(out, "{}$", name);
}
- write!(out, "cxxbridge01${}(", efn.ident);
+ write!(out, "cxxbridge02${}(", efn.ident);
for (i, arg) in efn.args.iter().enumerate() {
if i > 0 {
write!(out, ", ");
@@ -352,7 +352,7 @@
for name in out.namespace.clone() {
write!(out, "{}$", name);
}
- write!(out, "cxxbridge01${}(", efn.ident);
+ write!(out, "cxxbridge02${}(", efn.ident);
for (i, arg) in efn.args.iter().enumerate() {
if i > 0 {
write!(out, ", ");
@@ -507,7 +507,7 @@
out.end_block("extern \"C\"");
out.begin_block("namespace rust");
- out.begin_block("inline namespace cxxbridge01");
+ out.begin_block("inline namespace cxxbridge02");
for ty in types {
if let Type::RustBox(ty) = ty {
if let Type::Ident(inner) = &ty.inner {
@@ -515,7 +515,7 @@
}
}
}
- out.end_block("namespace cxxbridge01");
+ out.end_block("namespace cxxbridge02");
out.end_block("namespace rust");
}
@@ -528,19 +528,19 @@
inner += &ident.to_string();
let instance = inner.replace("::", "$");
- writeln!(out, "#ifndef CXXBRIDGE01_RUST_BOX_{}", instance);
- writeln!(out, "#define CXXBRIDGE01_RUST_BOX_{}", instance);
+ writeln!(out, "#ifndef CXXBRIDGE02_RUST_BOX_{}", instance);
+ writeln!(out, "#define CXXBRIDGE02_RUST_BOX_{}", instance);
writeln!(
out,
- "void cxxbridge01$box${}$uninit(::rust::Box<{}> *ptr) noexcept;",
+ "void cxxbridge02$box${}$uninit(::rust::Box<{}> *ptr) noexcept;",
instance, inner,
);
writeln!(
out,
- "void cxxbridge01$box${}$drop(::rust::Box<{}> *ptr) noexcept;",
+ "void cxxbridge02$box${}$drop(::rust::Box<{}> *ptr) noexcept;",
instance, inner,
);
- writeln!(out, "#endif // CXXBRIDGE01_RUST_BOX_{}", instance);
+ writeln!(out, "#endif // CXXBRIDGE02_RUST_BOX_{}", instance);
}
fn write_rust_box_impl(out: &mut OutFile, ident: &Ident) {
@@ -554,12 +554,12 @@
writeln!(out, "template <>");
writeln!(out, "void Box<{}>::uninit() noexcept {{", inner);
- writeln!(out, " return cxxbridge01$box${}$uninit(this);", instance);
+ writeln!(out, " return cxxbridge02$box${}$uninit(this);", instance);
writeln!(out, "}}");
writeln!(out, "template <>");
writeln!(out, "void Box<{}>::drop() noexcept {{", inner);
- writeln!(out, " return cxxbridge01$box${}$drop(this);", instance);
+ writeln!(out, " return cxxbridge02$box${}$drop(this);", instance);
writeln!(out, "}}");
}
@@ -572,8 +572,8 @@
inner += &ident.to_string();
let instance = inner.replace("::", "$");
- writeln!(out, "#ifndef CXXBRIDGE01_UNIQUE_PTR_{}", instance);
- writeln!(out, "#define CXXBRIDGE01_UNIQUE_PTR_{}", instance);
+ writeln!(out, "#ifndef CXXBRIDGE02_UNIQUE_PTR_{}", instance);
+ writeln!(out, "#define CXXBRIDGE02_UNIQUE_PTR_{}", instance);
writeln!(
out,
"static_assert(sizeof(::std::unique_ptr<{}>) == sizeof(void *), \"\");",
@@ -586,14 +586,14 @@
);
writeln!(
out,
- "void cxxbridge01$unique_ptr${}$null(::std::unique_ptr<{}> *ptr) noexcept {{",
+ "void cxxbridge02$unique_ptr${}$null(::std::unique_ptr<{}> *ptr) noexcept {{",
instance, inner,
);
writeln!(out, " new (ptr) ::std::unique_ptr<{}>();", inner);
writeln!(out, "}}");
writeln!(
out,
- "void cxxbridge01$unique_ptr${}$new(::std::unique_ptr<{}> *ptr, {} *value) noexcept {{",
+ "void cxxbridge02$unique_ptr${}$new(::std::unique_ptr<{}> *ptr, {} *value) noexcept {{",
instance, inner, inner,
);
writeln!(
@@ -604,31 +604,31 @@
writeln!(out, "}}");
writeln!(
out,
- "void cxxbridge01$unique_ptr${}$raw(::std::unique_ptr<{}> *ptr, {} *raw) noexcept {{",
+ "void cxxbridge02$unique_ptr${}$raw(::std::unique_ptr<{}> *ptr, {} *raw) noexcept {{",
instance, inner, inner,
);
writeln!(out, " new (ptr) ::std::unique_ptr<{}>(raw);", inner);
writeln!(out, "}}");
writeln!(
out,
- "const {} *cxxbridge01$unique_ptr${}$get(const ::std::unique_ptr<{}>& ptr) noexcept {{",
+ "const {} *cxxbridge02$unique_ptr${}$get(const ::std::unique_ptr<{}>& ptr) noexcept {{",
inner, instance, inner,
);
writeln!(out, " return ptr.get();");
writeln!(out, "}}");
writeln!(
out,
- "{} *cxxbridge01$unique_ptr${}$release(::std::unique_ptr<{}>& ptr) noexcept {{",
+ "{} *cxxbridge02$unique_ptr${}$release(::std::unique_ptr<{}>& ptr) noexcept {{",
inner, instance, inner,
);
writeln!(out, " return ptr.release();");
writeln!(out, "}}");
writeln!(
out,
- "void cxxbridge01$unique_ptr${}$drop(::std::unique_ptr<{}> *ptr) noexcept {{",
+ "void cxxbridge02$unique_ptr${}$drop(::std::unique_ptr<{}> *ptr) noexcept {{",
instance, inner,
);
writeln!(out, " ptr->~unique_ptr();");
writeln!(out, "}}");
- writeln!(out, "#endif // CXXBRIDGE01_UNIQUE_PTR_{}", instance);
+ writeln!(out, "#endif // CXXBRIDGE02_UNIQUE_PTR_{}", instance);
}
diff --git a/include/cxx.h b/include/cxx.h
index 81bdad5..e02145b 100644
--- a/include/cxx.h
+++ b/include/cxx.h
@@ -6,7 +6,7 @@
#include <type_traits>
namespace rust {
-inline namespace cxxbridge01 {
+inline namespace cxxbridge02 {
struct unsafe_bitcopy_t;
@@ -71,8 +71,8 @@
Repr repr;
};
-#ifndef CXXBRIDGE01_RUST_BOX
-#define CXXBRIDGE01_RUST_BOX
+#ifndef CXXBRIDGE02_RUST_BOX
+#define CXXBRIDGE02_RUST_BOX
template <typename T> class Box final {
public:
using value_type = T;
@@ -136,7 +136,7 @@
void drop() noexcept;
T *ptr;
};
-#endif // CXXBRIDGE01_RUST_BOX
+#endif // CXXBRIDGE02_RUST_BOX
std::ostream &operator<<(std::ostream &, const String &);
std::ostream &operator<<(std::ostream &, const Str &);
@@ -151,5 +151,5 @@
};
constexpr unsafe_bitcopy_t unsafe_bitcopy{};
-} // namespace cxxbridge01
+} // namespace cxxbridge02
} // namespace rust
diff --git a/macro/src/expand.rs b/macro/src/expand.rs
index 8519c1e..fcfa1d9 100644
--- a/macro/src/expand.rs
+++ b/macro/src/expand.rs
@@ -140,7 +140,7 @@
let ret = expand_extern_type(efn.ret.as_ref().unwrap());
outparam = Some(quote!(__return: *mut #ret));
}
- let link_name = format!("{}cxxbridge01${}", namespace, ident);
+ let link_name = format!("{}cxxbridge02${}", namespace, ident);
let local_name = format_ident!("__{}", ident);
quote! {
#[link_name = #link_name]
@@ -295,7 +295,7 @@
expr = quote!(::std::ptr::write(__return, #expr));
}
let ret = expand_extern_return_type(&efn.ret, types);
- let link_name = format!("{}cxxbridge01${}", namespace, ident);
+ let link_name = format!("{}cxxbridge02${}", namespace, ident);
let local_name = format_ident!("__{}", ident);
let catch_unwind_label = format!("::{}", ident);
quote! {
@@ -309,7 +309,7 @@
}
fn expand_rust_box(namespace: &Namespace, ident: &Ident) -> TokenStream {
- let link_prefix = format!("cxxbridge01$box${}{}$", namespace, ident);
+ let link_prefix = format!("cxxbridge02$box${}{}$", namespace, ident);
let link_uninit = format!("{}uninit", link_prefix);
let link_drop = format!("{}drop", link_prefix);
@@ -338,7 +338,7 @@
}
fn expand_unique_ptr(namespace: &Namespace, ident: &Ident) -> TokenStream {
- let prefix = format!("cxxbridge01$unique_ptr${}{}$", namespace, ident);
+ let prefix = format!("cxxbridge02$unique_ptr${}{}$", namespace, ident);
let link_null = format!("{}null", prefix);
let link_new = format!("{}new", prefix);
let link_raw = format!("{}raw", prefix);
diff --git a/src/cxx.cc b/src/cxx.cc
index f7b02ec..f55d062 100644
--- a/src/cxx.cc
+++ b/src/cxx.cc
@@ -5,72 +5,72 @@
#include <stdexcept>
extern "C" {
-const char *cxxbridge01$cxx_string$data(const std::string &s) noexcept {
+const char *cxxbridge02$cxx_string$data(const std::string &s) noexcept {
return s.data();
}
-size_t cxxbridge01$cxx_string$length(const std::string &s) noexcept {
+size_t cxxbridge02$cxx_string$length(const std::string &s) noexcept {
return s.length();
}
// rust::String
-void cxxbridge01$string$new(rust::String *self) noexcept;
-void cxxbridge01$string$clone(rust::String *self,
+void cxxbridge02$string$new(rust::String *self) noexcept;
+void cxxbridge02$string$clone(rust::String *self,
const rust::String &other) noexcept;
-bool cxxbridge01$string$from(rust::String *self, const char *ptr,
+bool cxxbridge02$string$from(rust::String *self, const char *ptr,
size_t len) noexcept;
-void cxxbridge01$string$drop(rust::String *self) noexcept;
-const char *cxxbridge01$string$ptr(const rust::String *self) noexcept;
-size_t cxxbridge01$string$len(const rust::String *self) noexcept;
+void cxxbridge02$string$drop(rust::String *self) noexcept;
+const char *cxxbridge02$string$ptr(const rust::String *self) noexcept;
+size_t cxxbridge02$string$len(const rust::String *self) noexcept;
// rust::Str
-bool cxxbridge01$str$valid(const char *ptr, size_t len) noexcept;
+bool cxxbridge02$str$valid(const char *ptr, size_t len) noexcept;
} // extern "C"
namespace rust {
-inline namespace cxxbridge01 {
+inline namespace cxxbridge02 {
-String::String() noexcept { cxxbridge01$string$new(this); }
+String::String() noexcept { cxxbridge02$string$new(this); }
String::String(const String &other) noexcept {
- cxxbridge01$string$clone(this, other);
+ cxxbridge02$string$clone(this, other);
}
String::String(String &&other) noexcept {
this->repr = other.repr;
- cxxbridge01$string$new(&other);
+ cxxbridge02$string$new(&other);
}
-String::~String() noexcept { cxxbridge01$string$drop(this); }
+String::~String() noexcept { cxxbridge02$string$drop(this); }
String::String(const std::string &s) {
auto ptr = s.data();
auto len = s.length();
- if (!cxxbridge01$string$from(this, ptr, len)) {
+ if (!cxxbridge02$string$from(this, ptr, len)) {
throw std::invalid_argument("data for rust::String is not utf-8");
}
}
String::String(const char *s) {
auto len = strlen(s);
- if (!cxxbridge01$string$from(this, s, len)) {
+ if (!cxxbridge02$string$from(this, s, len)) {
throw std::invalid_argument("data for rust::String is not utf-8");
}
}
String &String::operator=(const String &other) noexcept {
if (this != &other) {
- cxxbridge01$string$drop(this);
- cxxbridge01$string$clone(this, other);
+ cxxbridge02$string$drop(this);
+ cxxbridge02$string$clone(this, other);
}
return *this;
}
String &String::operator=(String &&other) noexcept {
if (this != &other) {
- cxxbridge01$string$drop(this);
+ cxxbridge02$string$drop(this);
this->repr = other.repr;
- cxxbridge01$string$new(&other);
+ cxxbridge02$string$new(&other);
}
return *this;
}
@@ -80,12 +80,12 @@
}
const char *String::data() const noexcept {
- return cxxbridge01$string$ptr(this);
+ return cxxbridge02$string$ptr(this);
}
-size_t String::size() const noexcept { return cxxbridge01$string$len(this); }
+size_t String::size() const noexcept { return cxxbridge02$string$len(this); }
-size_t String::length() const noexcept { return cxxbridge01$string$len(this); }
+size_t String::length() const noexcept { return cxxbridge02$string$len(this); }
String::String(unsafe_bitcopy_t, const String &bits) noexcept
: repr(bits.repr) {}
@@ -100,13 +100,13 @@
Str::Str(const Str &) noexcept = default;
Str::Str(const std::string &s) : repr(Repr{s.data(), s.length()}) {
- if (!cxxbridge01$str$valid(this->repr.ptr, this->repr.len)) {
+ if (!cxxbridge02$str$valid(this->repr.ptr, this->repr.len)) {
throw std::invalid_argument("data for rust::Str is not utf-8");
}
}
Str::Str(const char *s) : repr(Repr{s, strlen(s)}) {
- if (!cxxbridge01$str$valid(this->repr.ptr, this->repr.len)) {
+ if (!cxxbridge02$str$valid(this->repr.ptr, this->repr.len)) {
throw std::invalid_argument("data for rust::Str is not utf-8");
}
}
@@ -135,31 +135,31 @@
return os;
}
-} // namespace cxxbridge01
+} // namespace cxxbridge02
} // namespace rust
extern "C" {
-void cxxbridge01$unique_ptr$std$string$null(
+void cxxbridge02$unique_ptr$std$string$null(
std::unique_ptr<std::string> *ptr) noexcept {
new (ptr) std::unique_ptr<std::string>();
}
-void cxxbridge01$unique_ptr$std$string$new(std::unique_ptr<std::string> *ptr,
+void cxxbridge02$unique_ptr$std$string$new(std::unique_ptr<std::string> *ptr,
std::string *value) noexcept {
new (ptr) std::unique_ptr<std::string>(new std::string(std::move(*value)));
}
-void cxxbridge01$unique_ptr$std$string$raw(std::unique_ptr<std::string> *ptr,
+void cxxbridge02$unique_ptr$std$string$raw(std::unique_ptr<std::string> *ptr,
std::string *raw) noexcept {
new (ptr) std::unique_ptr<std::string>(raw);
}
-const std::string *cxxbridge01$unique_ptr$std$string$get(
+const std::string *cxxbridge02$unique_ptr$std$string$get(
const std::unique_ptr<std::string> &ptr) noexcept {
return ptr.get();
}
-std::string *cxxbridge01$unique_ptr$std$string$release(
+std::string *cxxbridge02$unique_ptr$std$string$release(
std::unique_ptr<std::string> &ptr) noexcept {
return ptr.release();
}
-void cxxbridge01$unique_ptr$std$string$drop(
+void cxxbridge02$unique_ptr$std$string$drop(
std::unique_ptr<std::string> *ptr) noexcept {
ptr->~unique_ptr();
}
diff --git a/src/cxx_string.rs b/src/cxx_string.rs
index 40a1731..f2cca5b 100644
--- a/src/cxx_string.rs
+++ b/src/cxx_string.rs
@@ -4,9 +4,9 @@
use std::str::{self, Utf8Error};
extern "C" {
- #[link_name = "cxxbridge01$cxx_string$data"]
+ #[link_name = "cxxbridge02$cxx_string$data"]
fn string_data(_: &CxxString) -> *const u8;
- #[link_name = "cxxbridge01$cxx_string$length"]
+ #[link_name = "cxxbridge02$cxx_string$length"]
fn string_length(_: &CxxString) -> usize;
}
diff --git a/src/rust_str.rs b/src/rust_str.rs
index 3d8a9f0..5b8eaed 100644
--- a/src/rust_str.rs
+++ b/src/rust_str.rs
@@ -23,7 +23,7 @@
}
}
-#[export_name = "cxxbridge01$str$valid"]
+#[export_name = "cxxbridge02$str$valid"]
unsafe extern "C" fn str_valid(ptr: *const u8, len: usize) -> bool {
let slice = slice::from_raw_parts(ptr, len);
str::from_utf8(slice).is_ok()
diff --git a/src/rust_string.rs b/src/rust_string.rs
index 345d969..258576d 100644
--- a/src/rust_string.rs
+++ b/src/rust_string.rs
@@ -30,17 +30,17 @@
}
}
-#[export_name = "cxxbridge01$string$new"]
+#[export_name = "cxxbridge02$string$new"]
unsafe extern "C" fn string_new(this: &mut MaybeUninit<String>) {
ptr::write(this.as_mut_ptr(), String::new());
}
-#[export_name = "cxxbridge01$string$clone"]
+#[export_name = "cxxbridge02$string$clone"]
unsafe extern "C" fn string_clone(this: &mut MaybeUninit<String>, other: &String) {
ptr::write(this.as_mut_ptr(), other.clone());
}
-#[export_name = "cxxbridge01$string$from"]
+#[export_name = "cxxbridge02$string$from"]
unsafe extern "C" fn string_from(
this: &mut MaybeUninit<String>,
ptr: *const u8,
@@ -56,17 +56,17 @@
}
}
-#[export_name = "cxxbridge01$string$drop"]
+#[export_name = "cxxbridge02$string$drop"]
unsafe extern "C" fn string_drop(this: &mut ManuallyDrop<String>) {
ManuallyDrop::drop(this);
}
-#[export_name = "cxxbridge01$string$ptr"]
+#[export_name = "cxxbridge02$string$ptr"]
unsafe extern "C" fn string_ptr(this: &String) -> *const u8 {
this.as_ptr()
}
-#[export_name = "cxxbridge01$string$len"]
+#[export_name = "cxxbridge02$string$len"]
unsafe extern "C" fn string_len(this: &String) -> usize {
this.len()
}
diff --git a/src/unique_ptr.rs b/src/unique_ptr.rs
index 19718bb..94b6e25 100644
--- a/src/unique_ptr.rs
+++ b/src/unique_ptr.rs
@@ -130,17 +130,17 @@
}
extern "C" {
- #[link_name = "cxxbridge01$unique_ptr$std$string$null"]
+ #[link_name = "cxxbridge02$unique_ptr$std$string$null"]
fn unique_ptr_std_string_null(this: *mut *mut c_void);
- #[link_name = "cxxbridge01$unique_ptr$std$string$new"]
+ #[link_name = "cxxbridge02$unique_ptr$std$string$new"]
fn unique_ptr_std_string_new(this: *mut *mut c_void, value: *mut CxxString);
- #[link_name = "cxxbridge01$unique_ptr$std$string$raw"]
+ #[link_name = "cxxbridge02$unique_ptr$std$string$raw"]
fn unique_ptr_std_string_raw(this: *mut *mut c_void, raw: *mut CxxString);
- #[link_name = "cxxbridge01$unique_ptr$std$string$get"]
+ #[link_name = "cxxbridge02$unique_ptr$std$string$get"]
fn unique_ptr_std_string_get(this: *const *mut c_void) -> *const CxxString;
- #[link_name = "cxxbridge01$unique_ptr$std$string$release"]
+ #[link_name = "cxxbridge02$unique_ptr$std$string$release"]
fn unique_ptr_std_string_release(this: *mut *mut c_void) -> *mut CxxString;
- #[link_name = "cxxbridge01$unique_ptr$std$string$drop"]
+ #[link_name = "cxxbridge02$unique_ptr$std$string$drop"]
fn unique_ptr_std_string_drop(this: *mut *mut c_void);
}