Skip to content

Commit e43b737

Browse files
committed
Release 0.1.0
1 parent 7db7369 commit e43b737

File tree

14 files changed

+99
-99
lines changed

14 files changed

+99
-99
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
22
name = "cxx"
3-
version = "0.0.0"
3+
version = "0.1.0"
44
authors = ["David Tolnay <[email protected]>"]
55
edition = "2018"
6-
links = "cxxbridge00"
6+
links = "cxxbridge01"
77
license = "MIT OR Apache-2.0"
88
description = "Safe interop between Rust and C++"
99
repository = "https://github.com/dtolnay/cxx"
@@ -18,7 +18,7 @@ anyhow = "1.0"
1818
cc = "1.0.49"
1919
codespan = "0.7"
2020
codespan-reporting = "0.7"
21-
cxxbridge-macro = { version = "0.0", path = "macro" }
21+
cxxbridge-macro = { version = "0.1", path = "macro" }
2222
proc-macro2 = { version = "1.0", features = ["span-locations"] }
2323
quote = "1.0"
2424
syn = { version = "1.0", features = ["full"] }

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using bindgen or cbindgen to generate unsafe C-style bindings.
1111

1212
```toml
1313
[dependencies]
14-
cxx = "0.0"
14+
cxx = "0.1"
1515
```
1616

1717
*Compiler support: requires rustc 1.42+ (beta on January 30, stable on March
@@ -294,9 +294,9 @@ of functions.
294294
<tr><th>name in Rust</th><th>name in C++</th><th>restrictions</th></tr>
295295
<tr><td>String</td><td>cxxbridge::RustString</td><td></td></tr>
296296
<tr><td>&amp;str</td><td>cxxbridge::RustStr</td><td></td></tr>
297-
<tr><td><a href="https://docs.rs/cxx/0.0/cxx/struct.CxxString.html">CxxString</a></td><td>std::string</td><td><sup><i>cannot be passed by value</i></sup></td></tr>
297+
<tr><td><a href="https://docs.rs/cxx/0.1/cxx/struct.CxxString.html">CxxString</a></td><td>std::string</td><td><sup><i>cannot be passed by value</i></sup></td></tr>
298298
<tr><td>Box&lt;T&gt;</td><td>cxxbridge::RustBox&lt;T&gt;</td><td><sup><i>cannot hold opaque C++ type</i></sup></td></tr>
299-
<tr><td><a href="https://docs.rs/cxx/0.0/cxx/struct.UniquePtr.html">UniquePtr&lt;T&gt;</a></td><td>std::unique_ptr&lt;T&gt;</td><td><sup><i>cannot hold opaque Rust type</i></sup></td></tr>
299+
<tr><td><a href="https://docs.rs/cxx/0.1/cxx/struct.UniquePtr.html">UniquePtr&lt;T&gt;</a></td><td>std::unique_ptr&lt;T&gt;</td><td><sup><i>cannot hold opaque Rust type</i></sup></td></tr>
300300
<tr><td></td><td></td><td></td></tr>
301301
</table>
302302

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ fn main() {
22
cc::Build::new()
33
.file("src/cxxbridge.cc")
44
.flag("-std=c++11")
5-
.compile("cxxbridge00");
5+
.compile("cxxbridge01");
66
println!("cargo:rustc-flags=-l dylib=stdc++");
77
println!("cargo:rerun-if-changed=src/cxxbridge.cc");
88
println!("cargo:rerun-if-changed=include/cxxbridge.h");

cmd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cxxbridge-cmd"
3-
version = "0.0.0"
3+
version = "0.1.0"
44
authors = ["David Tolnay <[email protected]>"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"

gen/write.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ fn write_include_cxxbridge(out: &mut OutFile, types: &Types) {
124124
}
125125
}
126126

127-
out.begin_block("namespace cxxbridge00");
127+
out.begin_block("namespace cxxbridge01");
128128
if needs_rust_box {
129129
writeln!(out, "// #include \"cxxbridge.h\"");
130-
for line in include::get("CXXBRIDGE00_RUST_BOX").lines() {
130+
for line in include::get("CXXBRIDGE01_RUST_BOX").lines() {
131131
if !line.trim_start().starts_with("//") {
132132
writeln!(out, "{}", line);
133133
}
@@ -146,7 +146,7 @@ fn write_namespace_alias(out: &mut OutFile, types: &Types) {
146146
}
147147

148148
if needs_namespace_alias {
149-
writeln!(out, "namespace cxxbridge = cxxbridge00;");
149+
writeln!(out, "namespace cxxbridge = cxxbridge01;");
150150
}
151151
}
152152

@@ -176,7 +176,7 @@ fn write_cxx_function_shim(out: &mut OutFile, efn: &ExternFn, types: &Types) {
176176
for name in out.namespace.clone() {
177177
write!(out, "{}$", name);
178178
}
179-
write!(out, "cxxbridge00${}(", efn.ident);
179+
write!(out, "cxxbridge01${}(", efn.ident);
180180
for (i, arg) in efn.args.iter().enumerate() {
181181
if i > 0 {
182182
write!(out, ", ");
@@ -244,7 +244,7 @@ fn write_rust_function_decl(out: &mut OutFile, efn: &ExternFn, types: &Types) {
244244
for name in out.namespace.clone() {
245245
write!(out, "{}$", name);
246246
}
247-
write!(out, "cxxbridge00${}(", efn.ident);
247+
write!(out, "cxxbridge01${}(", efn.ident);
248248
for (i, arg) in efn.args.iter().enumerate() {
249249
if i > 0 {
250250
write!(out, ", ");
@@ -299,7 +299,7 @@ fn write_rust_function_shim(out: &mut OutFile, efn: &ExternFn, types: &Types) {
299299
for name in out.namespace.clone() {
300300
write!(out, "{}$", name);
301301
}
302-
write!(out, "cxxbridge00${}(", efn.ident);
302+
write!(out, "cxxbridge01${}(", efn.ident);
303303
for (i, arg) in efn.args.iter().enumerate() {
304304
if i > 0 {
305305
write!(out, ", ");
@@ -435,7 +435,7 @@ fn write_generic_instantiations(out: &mut OutFile, types: &Types) {
435435
}
436436
out.end_block();
437437

438-
out.begin_block("namespace cxxbridge00");
438+
out.begin_block("namespace cxxbridge01");
439439
for ty in types {
440440
if let Type::RustBox(ty) = ty {
441441
if let Type::Ident(inner) = &ty.inner {
@@ -455,34 +455,34 @@ fn write_rust_box_extern(out: &mut OutFile, ident: &Ident) {
455455
inner += &ident.to_string();
456456
let instance = inner.replace("::", "$");
457457

458-
writeln!(out, "#ifndef CXXBRIDGE00_RUST_BOX_{}", instance);
459-
writeln!(out, "#define CXXBRIDGE00_RUST_BOX_{}", instance);
458+
writeln!(out, "#ifndef CXXBRIDGE01_RUST_BOX_{}", instance);
459+
writeln!(out, "#define CXXBRIDGE01_RUST_BOX_{}", instance);
460460
writeln!(
461461
out,
462-
"void cxxbridge00$rust_box${}$uninit(cxxbridge::RustBox<{}> *ptr) noexcept;",
462+
"void cxxbridge01$rust_box${}$uninit(cxxbridge::RustBox<{}> *ptr) noexcept;",
463463
instance, inner,
464464
);
465465
writeln!(
466466
out,
467-
"void cxxbridge00$rust_box${}$set_raw(cxxbridge::RustBox<{}> *ptr, {} *raw) noexcept;",
467+
"void cxxbridge01$rust_box${}$set_raw(cxxbridge::RustBox<{}> *ptr, {} *raw) noexcept;",
468468
instance, inner, inner
469469
);
470470
writeln!(
471471
out,
472-
"void cxxbridge00$rust_box${}$drop(cxxbridge::RustBox<{}> *ptr) noexcept;",
472+
"void cxxbridge01$rust_box${}$drop(cxxbridge::RustBox<{}> *ptr) noexcept;",
473473
instance, inner,
474474
);
475475
writeln!(
476476
out,
477-
"const {} *cxxbridge00$rust_box${}$deref(const cxxbridge::RustBox<{}> *ptr) noexcept;",
477+
"const {} *cxxbridge01$rust_box${}$deref(const cxxbridge::RustBox<{}> *ptr) noexcept;",
478478
inner, instance, inner,
479479
);
480480
writeln!(
481481
out,
482-
"{} *cxxbridge00$rust_box${}$deref_mut(cxxbridge::RustBox<{}> *ptr) noexcept;",
482+
"{} *cxxbridge01$rust_box${}$deref_mut(cxxbridge::RustBox<{}> *ptr) noexcept;",
483483
inner, instance, inner,
484484
);
485-
writeln!(out, "#endif // CXXBRIDGE00_RUST_BOX_{}", instance);
485+
writeln!(out, "#endif // CXXBRIDGE01_RUST_BOX_{}", instance);
486486
}
487487

488488
fn write_rust_box_impl(out: &mut OutFile, ident: &Ident) {
@@ -498,7 +498,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Ident) {
498498
writeln!(out, "void RustBox<{}>::uninit() noexcept {{", inner);
499499
writeln!(
500500
out,
501-
" return cxxbridge00$rust_box${}$uninit(this);",
501+
" return cxxbridge01$rust_box${}$uninit(this);",
502502
instance
503503
);
504504
writeln!(out, "}}");
@@ -511,7 +511,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Ident) {
511511
);
512512
writeln!(
513513
out,
514-
" return cxxbridge00$rust_box${}$set_raw(this, raw);",
514+
" return cxxbridge01$rust_box${}$set_raw(this, raw);",
515515
instance
516516
);
517517
writeln!(out, "}}");
@@ -520,7 +520,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Ident) {
520520
writeln!(out, "void RustBox<{}>::drop() noexcept {{", inner);
521521
writeln!(
522522
out,
523-
" return cxxbridge00$rust_box${}$drop(this);",
523+
" return cxxbridge01$rust_box${}$drop(this);",
524524
instance
525525
);
526526
writeln!(out, "}}");
@@ -533,7 +533,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Ident) {
533533
);
534534
writeln!(
535535
out,
536-
" return cxxbridge00$rust_box${}$deref(this);",
536+
" return cxxbridge01$rust_box${}$deref(this);",
537537
instance
538538
);
539539
writeln!(out, "}}");
@@ -546,7 +546,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Ident) {
546546
);
547547
writeln!(
548548
out,
549-
" return cxxbridge00$rust_box${}$deref_mut(this);",
549+
" return cxxbridge01$rust_box${}$deref_mut(this);",
550550
instance
551551
);
552552
writeln!(out, "}}");
@@ -561,8 +561,8 @@ fn write_unique_ptr(out: &mut OutFile, ident: &Ident) {
561561
inner += &ident.to_string();
562562
let instance = inner.replace("::", "$");
563563

564-
writeln!(out, "#ifndef CXXBRIDGE00_UNIQUE_PTR_{}", instance);
565-
writeln!(out, "#define CXXBRIDGE00_UNIQUE_PTR_{}", instance);
564+
writeln!(out, "#ifndef CXXBRIDGE01_UNIQUE_PTR_{}", instance);
565+
writeln!(out, "#define CXXBRIDGE01_UNIQUE_PTR_{}", instance);
566566
writeln!(
567567
out,
568568
"static_assert(sizeof(std::unique_ptr<{}>) == sizeof(void *), \"\");",
@@ -575,14 +575,14 @@ fn write_unique_ptr(out: &mut OutFile, ident: &Ident) {
575575
);
576576
writeln!(
577577
out,
578-
"void cxxbridge00$unique_ptr${}$null(std::unique_ptr<{}> *ptr) noexcept {{",
578+
"void cxxbridge01$unique_ptr${}$null(std::unique_ptr<{}> *ptr) noexcept {{",
579579
instance, inner,
580580
);
581581
writeln!(out, " new (ptr) std::unique_ptr<{}>();", inner);
582582
writeln!(out, "}}");
583583
writeln!(
584584
out,
585-
"void cxxbridge00$unique_ptr${}$new(std::unique_ptr<{}> *ptr, {} *value) noexcept {{",
585+
"void cxxbridge01$unique_ptr${}$new(std::unique_ptr<{}> *ptr, {} *value) noexcept {{",
586586
instance, inner, inner,
587587
);
588588
writeln!(
@@ -593,31 +593,31 @@ fn write_unique_ptr(out: &mut OutFile, ident: &Ident) {
593593
writeln!(out, "}}");
594594
writeln!(
595595
out,
596-
"void cxxbridge00$unique_ptr${}$raw(std::unique_ptr<{}> *ptr, {} *raw) noexcept {{",
596+
"void cxxbridge01$unique_ptr${}$raw(std::unique_ptr<{}> *ptr, {} *raw) noexcept {{",
597597
instance, inner, inner,
598598
);
599599
writeln!(out, " new (ptr) std::unique_ptr<{}>(raw);", inner);
600600
writeln!(out, "}}");
601601
writeln!(
602602
out,
603-
"const {} *cxxbridge00$unique_ptr${}$get(const std::unique_ptr<{}>& ptr) noexcept {{",
603+
"const {} *cxxbridge01$unique_ptr${}$get(const std::unique_ptr<{}>& ptr) noexcept {{",
604604
inner, instance, inner,
605605
);
606606
writeln!(out, " return ptr.get();");
607607
writeln!(out, "}}");
608608
writeln!(
609609
out,
610-
"{} *cxxbridge00$unique_ptr${}$release(std::unique_ptr<{}>& ptr) noexcept {{",
610+
"{} *cxxbridge01$unique_ptr${}$release(std::unique_ptr<{}>& ptr) noexcept {{",
611611
inner, instance, inner,
612612
);
613613
writeln!(out, " return ptr.release();");
614614
writeln!(out, "}}");
615615
writeln!(
616616
out,
617-
"void cxxbridge00$unique_ptr${}$drop(std::unique_ptr<{}> *ptr) noexcept {{",
617+
"void cxxbridge01$unique_ptr${}$drop(std::unique_ptr<{}> *ptr) noexcept {{",
618618
instance, inner,
619619
);
620620
writeln!(out, " ptr->~unique_ptr();");
621621
writeln!(out, "}}");
622-
writeln!(out, "#endif // CXXBRIDGE00_UNIQUE_PTR_{}", instance);
622+
writeln!(out, "#endif // CXXBRIDGE01_UNIQUE_PTR_{}", instance);
623623
}

include/cxxbridge.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <iostream>
55
#include <string>
66

7-
namespace cxxbridge00 {
7+
namespace cxxbridge01 {
88

99
class RustString final {
1010
public:
@@ -58,8 +58,8 @@ class RustStr final {
5858
Repr repr;
5959
};
6060

61-
#ifndef CXXBRIDGE00_RUST_BOX
62-
#define CXXBRIDGE00_RUST_BOX
61+
#ifndef CXXBRIDGE01_RUST_BOX
62+
#define CXXBRIDGE01_RUST_BOX
6363
template <typename T> class RustBox final {
6464
public:
6565
RustBox(const RustBox &other) : RustBox(*other) {}
@@ -122,11 +122,11 @@ template <typename T> class RustBox final {
122122
T *deref_mut() noexcept;
123123
uintptr_t repr;
124124
};
125-
#endif // CXXBRIDGE00_RUST_BOX
125+
#endif // CXXBRIDGE01_RUST_BOX
126126

127127
std::ostream &operator<<(std::ostream &os, const RustString &s);
128128
std::ostream &operator<<(std::ostream &os, const RustStr &s);
129129

130-
} // namespace cxxbridge00
130+
} // namespace cxxbridge01
131131

132-
namespace cxxbridge = cxxbridge00;
132+
namespace cxxbridge = cxxbridge01;

macro/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cxxbridge-macro"
3-
version = "0.0.0"
3+
version = "0.1.0"
44
authors = ["David Tolnay <[email protected]>"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"
@@ -19,4 +19,4 @@ quote = "1.0"
1919
syn = { version = "1.0", features = ["full"] }
2020

2121
[dev-dependencies]
22-
cxx = { version = "0.0", path = ".." }
22+
cxx = { version = "0.1", path = ".." }

macro/src/expand.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn expand_cxx_function_decl(namespace: &Namespace, efn: &ExternFn, types: &Types
128128
let ret = expand_extern_type(efn.ret.as_ref().unwrap());
129129
outparam = Some(quote!(__return: *mut #ret));
130130
}
131-
let link_name = format!("{}cxxbridge00${}", namespace, ident);
131+
let link_name = format!("{}cxxbridge01${}", namespace, ident);
132132
let local_name = format_ident!("__{}", ident);
133133
quote! {
134134
#[link_name = #link_name]
@@ -266,7 +266,7 @@ fn expand_rust_function_shim(namespace: &Namespace, efn: &ExternFn, types: &Type
266266
expr = quote!(::std::ptr::write(__return, #expr));
267267
}
268268
let ret = expand_extern_return_type(&efn.ret, types);
269-
let link_name = format!("{}cxxbridge00${}", namespace, ident);
269+
let link_name = format!("{}cxxbridge01${}", namespace, ident);
270270
let local_name = format_ident!("__{}", ident);
271271
let catch_unwind_label = format!("::{}", ident);
272272
quote! {
@@ -280,7 +280,7 @@ fn expand_rust_function_shim(namespace: &Namespace, efn: &ExternFn, types: &Type
280280
}
281281

282282
fn expand_rust_box(namespace: &Namespace, ident: &Ident) -> TokenStream {
283-
let link_prefix = format!("cxxbridge00$rust_box${}{}$", namespace, ident);
283+
let link_prefix = format!("cxxbridge01$rust_box${}{}$", namespace, ident);
284284
let link_uninit = format!("{}uninit", link_prefix);
285285
let link_set_raw = format!("{}set_raw", link_prefix);
286286
let link_drop = format!("{}drop", link_prefix);
@@ -337,7 +337,7 @@ fn expand_rust_box(namespace: &Namespace, ident: &Ident) -> TokenStream {
337337
}
338338

339339
fn expand_unique_ptr(namespace: &Namespace, ident: &Ident) -> TokenStream {
340-
let prefix = format!("cxxbridge00$unique_ptr${}{}$", namespace, ident);
340+
let prefix = format!("cxxbridge01$unique_ptr${}{}$", namespace, ident);
341341
let link_null = format!("{}null", prefix);
342342
let link_new = format!("{}new", prefix);
343343
let link_raw = format!("{}raw", prefix);

src/cxx_string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use std::slice;
44
use std::str::{self, Utf8Error};
55

66
extern "C" {
7-
#[link_name = "cxxbridge00$cxx_string$data"]
7+
#[link_name = "cxxbridge01$cxx_string$data"]
88
fn string_data(_: &CxxString) -> *const u8;
9-
#[link_name = "cxxbridge00$cxx_string$length"]
9+
#[link_name = "cxxbridge01$cxx_string$length"]
1010
fn string_length(_: &CxxString) -> usize;
1111
}
1212

0 commit comments

Comments
 (0)