Remove prefix from mangled string symbols
diff --git a/src/cxxbridge.cc b/src/cxxbridge.cc
index 1f7c8dd..c58b7c5 100644
--- a/src/cxxbridge.cc
+++ b/src/cxxbridge.cc
@@ -14,63 +14,63 @@
}
// rust::String
-void cxxbridge01$rust_string$new(rust::String *self) noexcept;
-void cxxbridge01$rust_string$clone(rust::String *self,
- const rust::String &other) noexcept;
-bool cxxbridge01$rust_string$from(rust::String *self, const char *ptr,
- size_t len) noexcept;
-void cxxbridge01$rust_string$drop(rust::String *self) noexcept;
-const char *cxxbridge01$rust_string$ptr(const rust::String *self) noexcept;
-size_t cxxbridge01$rust_string$len(const rust::String *self) noexcept;
+void cxxbridge01$string$new(rust::String *self) noexcept;
+void cxxbridge01$string$clone(rust::String *self,
+ const rust::String &other) noexcept;
+bool cxxbridge01$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;
// rust::Str
-bool cxxbridge01$rust_str$valid(const char *ptr, size_t len) noexcept;
+bool cxxbridge01$str$valid(const char *ptr, size_t len) noexcept;
} // extern "C"
namespace rust {
inline namespace cxxbridge01 {
-String::String() noexcept { cxxbridge01$rust_string$new(this); }
+String::String() noexcept { cxxbridge01$string$new(this); }
String::String(const String &other) noexcept {
- cxxbridge01$rust_string$clone(this, other);
+ cxxbridge01$string$clone(this, other);
}
String::String(String &&other) noexcept {
this->repr = other.repr;
- cxxbridge01$rust_string$new(&other);
+ cxxbridge01$string$new(&other);
}
-String::~String() noexcept { cxxbridge01$rust_string$drop(this); }
+String::~String() noexcept { cxxbridge01$string$drop(this); }
String::String(const std::string &s) {
auto ptr = s.data();
auto len = s.length();
- if (!cxxbridge01$rust_string$from(this, ptr, len)) {
+ if (!cxxbridge01$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$rust_string$from(this, s, len)) {
+ if (!cxxbridge01$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$rust_string$drop(this);
- cxxbridge01$rust_string$clone(this, other);
+ cxxbridge01$string$drop(this);
+ cxxbridge01$string$clone(this, other);
}
return *this;
}
String &String::operator=(String &&other) noexcept {
if (this != &other) {
- cxxbridge01$rust_string$drop(this);
+ cxxbridge01$string$drop(this);
this->repr = other.repr;
- cxxbridge01$rust_string$new(&other);
+ cxxbridge01$string$new(&other);
}
return *this;
}
@@ -80,16 +80,12 @@
}
const char *String::data() const noexcept {
- return cxxbridge01$rust_string$ptr(this);
+ return cxxbridge01$string$ptr(this);
}
-size_t String::size() const noexcept {
- return cxxbridge01$rust_string$len(this);
-}
+size_t String::size() const noexcept { return cxxbridge01$string$len(this); }
-size_t String::length() const noexcept {
- return cxxbridge01$rust_string$len(this);
-}
+size_t String::length() const noexcept { return cxxbridge01$string$len(this); }
std::ostream &operator<<(std::ostream &os, const String &s) {
os.write(s.data(), s.size());
@@ -101,13 +97,13 @@
Str::Str(const Str &) noexcept = default;
Str::Str(const std::string &s) : repr(Repr{s.data(), s.length()}) {
- if (!cxxbridge01$rust_str$valid(this->repr.ptr, this->repr.len)) {
+ if (!cxxbridge01$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$rust_str$valid(this->repr.ptr, this->repr.len)) {
+ if (!cxxbridge01$str$valid(this->repr.ptr, this->repr.len)) {
throw std::invalid_argument("data for rust::Str is not utf-8");
}
}
diff --git a/src/rust_str.rs b/src/rust_str.rs
index 59a7784..3d8a9f0 100644
--- a/src/rust_str.rs
+++ b/src/rust_str.rs
@@ -23,7 +23,7 @@
}
}
-#[export_name = "cxxbridge01$rust_str$valid"]
+#[export_name = "cxxbridge01$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 250a46f..43cd5a6 100644
--- a/src/rust_string.rs
+++ b/src/rust_string.rs
@@ -26,17 +26,17 @@
}
}
-#[export_name = "cxxbridge01$rust_string$new"]
+#[export_name = "cxxbridge01$string$new"]
unsafe extern "C" fn string_new(this: &mut MaybeUninit<String>) {
ptr::write(this.as_mut_ptr(), String::new());
}
-#[export_name = "cxxbridge01$rust_string$clone"]
+#[export_name = "cxxbridge01$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$rust_string$from"]
+#[export_name = "cxxbridge01$string$from"]
unsafe extern "C" fn string_from(
this: &mut MaybeUninit<String>,
ptr: *const u8,
@@ -52,17 +52,17 @@
}
}
-#[export_name = "cxxbridge01$rust_string$drop"]
+#[export_name = "cxxbridge01$string$drop"]
unsafe extern "C" fn string_drop(this: &mut ManuallyDrop<String>) {
ManuallyDrop::drop(this);
}
-#[export_name = "cxxbridge01$rust_string$ptr"]
+#[export_name = "cxxbridge01$string$ptr"]
unsafe extern "C" fn string_ptr(this: &String) -> *const u8 {
this.as_ptr()
}
-#[export_name = "cxxbridge01$rust_string$len"]
+#[export_name = "cxxbridge01$string$len"]
unsafe extern "C" fn string_len(this: &String) -> usize {
this.len()
}