Skip to content

Commit aff3e6a

Browse files
committed
Merge branch 'main' of github.com:google/autocxx into newtest3
2 parents 13216ef + 0ec7b78 commit aff3e6a

File tree

8 files changed

+628
-463
lines changed

8 files changed

+628
-463
lines changed

Cargo.lock

Lines changed: 582 additions & 454 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

book/src/building.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ fn main() {
1111
let path = std::path::PathBuf::from("src"); // include path
1212
let mut b = autocxx_build::Builder::new("src/main.rs", &[&path])
1313
.extra_clang_args(&["-std=c++17"])
14-
.expect_build();
14+
.build()
15+
.unwrap();
1516
b.flag_if_supported("-std=c++17") // use "-std:c++17" here if using msvc on windows
1617
.compile("autocxx-demo"); // arbitrary library name, pick anything
1718
println!("cargo:rerun-if-changed=src/main.rs");

book/src/tutorial.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ Now, add a `build.rs` next to your `Cargo.toml` (this is a standard `cargo` [bui
3333

3434
```rust,ignore
3535
fn main() -> miette::Result<()> {
36-
let path = std::path::PathBuf::from("src"); // include path
37-
let mut b = autocxx_build::Builder::new("src/main.rs", &[&path]).build()?;
38-
// This assumes all your C++ bindings are in main.rs
36+
let include_path = std::path::PathBuf::from("src");
37+
38+
// This assumes all your C++ bindings are in main.rs
39+
let mut b = autocxx_build::Builder::new("src/main.rs", &[&include_path]).build()?;
3940
b.flag_if_supported("-std=c++14")
4041
.compile("autocxx-demo"); // arbitrary library name, pick anything
4142
println!("cargo:rerun-if-changed=src/main.rs");
43+
4244
// Add instructions to link to any C++ libraries you need.
45+
4346
Ok(())
4447
}
4548
```

engine/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ log = "0.4"
3030
proc-macro2 = "1.0.11"
3131
quote = "1.0"
3232
indoc = "1.0"
33-
autocxx-bindgen = { version = "=0.70.1", default-features = false, features = ["logging", "which-rustfmt"] }
34-
#autocxx-bindgen = { git = "https://github.com/adetaylor/rust-bindgen", branch = "merge-0.70.1", default-features = false, features = ["logging", "which-rustfmt"] }
33+
autocxx-bindgen = { version = "=0.71.1", default-features = false, features = ["logging", "which-rustfmt"] }
34+
#autocxx-bindgen = { git = "https://github.com/adetaylor/rust-bindgen", branch = "merge-latest-upstream", default-features = false, features = ["logging", "which-rustfmt"] }
3535
itertools = "0.10.3"
3636
cc = { version = "1.0", optional = true }
3737
# Note: Keep the patch-level version of cxx-gen and cxx in sync.

engine/src/conversion/analysis/type_converter.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ impl<'a> TypeConverter<'a> {
372372
}
373373
let (new_tn, api) = self.get_templated_typename(&Type::Path(typ))?;
374374
extra_apis.extend(api.into_iter());
375-
deps.remove(&tn);
375+
// Although it's tempting to remove the dep on the original type,
376+
// this means we wouldn't spot cases where the original type can't
377+
// be represented in C++, e.g. because it has an unused template parameter.
378+
// So we keep the original dep too.
376379
typ = new_tn.to_type_path();
377380
deps.insert(new_tn);
378381
}

engine/src/conversion/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'a> BridgeConverter<'a> {
120120
Self::dump_apis("parsing", &apis);
121121
// Inside parse_results, we now have a list of APIs.
122122
// We now enter various analysis phases.
123-
// Next, convert any typedefs.
123+
// First, convert any typedefs.
124124
// "Convert" means replacing bindgen-style type targets
125125
// (e.g. root::std::unique_ptr) with cxx-style targets (e.g. UniquePtr).
126126
let apis = convert_typedef_targets(self.config, apis);

integration-tests/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ categories = ["development-tools::ffi", "api-bindings"]
2020

2121
[dependencies]
2222
proc-macro2 = "1.0.11"
23-
trybuild = "1.0.53"
23+
# More recent versions of trybuild don't work due to
24+
# https://github.com/dtolnay/trybuild/issues/283
25+
# There are some workarounds suggested there if needs be.
26+
trybuild = "=1.0.81"
2427
test-log = "0.2.2"
2528
env_logger = "0.9.0"
2629
rust_info = "0.3.1"

integration-tests/tests/integration_test.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12429,6 +12429,33 @@ fn test_override_typedef_fn() {
1242912429
run_test("", hdr, quote! {}, &["Foo"], &[]);
1243012430
}
1243112431

12432+
#[test]
12433+
fn test_double_template_w_default() {
12434+
let hdr = indoc! {"
12435+
class Widget {};
12436+
12437+
template <class T>
12438+
class RefPtr {
12439+
private:
12440+
T* m_ptr;
12441+
};
12442+
12443+
class FakeAlloc {};
12444+
12445+
template <typename T, typename A=FakeAlloc>
12446+
class Holder {
12447+
A alloc;
12448+
};
12449+
12450+
typedef Holder<RefPtr<Widget>> WidgetRefHolder;
12451+
class Problem {
12452+
public:
12453+
WidgetRefHolder& getWidgets();
12454+
};
12455+
"};
12456+
run_test("", hdr, quote! {}, &["Problem"], &[]);
12457+
}
12458+
1243212459
// Yet to test:
1243312460
// - Ifdef
1243412461
// - Out param pointers

0 commit comments

Comments
 (0)