Skip to content

Commit d85eac7

Browse files
authored
Merge pull request #1442 from google/use-callbacks
Switch to using new version of autocxx-bindgen
2 parents 55c1c60 + b82f450 commit d85eac7

27 files changed

+738
-703
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ exclude = ["examples/s2", "examples/steam-mini", "examples/subclass", "examples/
4141
#[patch.crates-io]
4242
#cxx = { path="../cxx" }
4343
#cxx-gen = { path="../cxx/gen/lib" }
44-
#autocxx-bindgen = { path="../bindgen" }
44+
#autocxx-bindgen = { path="../bindgen/bindgen" }
4545
#moveit = { path="../moveit" }

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.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"] }
33+
autocxx-bindgen = { version = "=0.72.0", default-features = false, features = ["logging", "which-rustfmt"] }
34+
#autocxx-bindgen = { git = "https://github.com/adetaylor/rust-bindgen", branch = "switch-from-attributes-to-callbacks", 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/allocators.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ use syn::{parse_quote, punctuated::Punctuated, token::Comma, FnArg, ReturnType};
1212

1313
use crate::{
1414
conversion::{
15-
api::{
16-
Api, ApiName, CppVisibility, DeletedOrDefaulted, FuncToConvert, Provenance, References,
17-
TraitSynthesis,
18-
},
15+
api::{Api, ApiName, CppVisibility, FuncToConvert, Provenance, TraitSynthesis},
1916
apivec::ApiVec,
2017
},
2118
minisyn::minisynize_punctuated,
@@ -80,17 +77,15 @@ fn create_alloc_and_free(ty_name: QualifiedName) -> impl Iterator<Item = Api<Pod
8077
inputs: minisynize_punctuated(inputs),
8178
output: output.into(),
8279
vis: parse_quote! { pub },
83-
virtualness: crate::conversion::api::Virtualness::None,
80+
virtualness: None,
8481
cpp_vis: CppVisibility::Public,
8582
special_member: None,
86-
unused_template_param: false,
87-
references: References::default(),
8883
original_name: None,
8984
self_ty: None,
9085
synthesized_this_type: None,
9186
synthetic_cpp: Some((cpp_function_body, CppFunctionKind::Function)),
9287
add_to_trait: Some(synthesis),
93-
is_deleted: DeletedOrDefaulted::Neither,
88+
is_deleted: None,
9489
provenance: Provenance::SynthesizedOther,
9590
variadic: false,
9691
}),

engine/src/conversion/analysis/casts.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ use syn::parse_quote;
1313

1414
use crate::{
1515
conversion::{
16-
api::{
17-
Api, ApiName, CastMutability, DeletedOrDefaulted, Provenance, References,
18-
TraitSynthesis,
19-
},
16+
api::{Api, ApiName, CastMutability, Provenance, TraitSynthesis},
2017
apivec::ApiVec,
2118
},
2219
types::{make_ident, QualifiedName},
@@ -100,14 +97,12 @@ fn create_cast(from: &QualifiedName, to: &QualifiedName, mutable: CastMutability
10097
doc_attrs: Vec::new(),
10198
inputs: [fnarg].into_iter().collect(),
10299
output: parse_quote! {
103-
-> * #return_mutability #to_typ
100+
-> __bindgen_marker_Reference < * #return_mutability #to_typ >
104101
},
105102
vis: parse_quote! { pub },
106-
virtualness: crate::conversion::api::Virtualness::None,
103+
virtualness: None,
107104
cpp_vis: crate::conversion::api::CppVisibility::Public,
108105
special_member: None,
109-
unused_template_param: false,
110-
references: References::new_with_this_and_return_as_reference(),
111106
original_name: None,
112107
self_ty: Some(from.clone()),
113108
synthesized_this_type: None,
@@ -116,7 +111,7 @@ fn create_cast(from: &QualifiedName, to: &QualifiedName, mutable: CastMutability
116111
mutable,
117112
}),
118113
synthetic_cpp: Some((CppFunctionBody::Cast, CppFunctionKind::Function)),
119-
is_deleted: DeletedOrDefaulted::Neither,
114+
is_deleted: None,
120115
provenance: Provenance::SynthesizedOther,
121116
variadic: false,
122117
}),

engine/src/conversion/analysis/fun/implicit_constructors.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9+
use autocxx_bindgen::callbacks::{Explicitness, SpecialMemberKind, Visibility as CppVisibility};
910
use indexmap::map::IndexMap as HashMap;
1011
use indexmap::{map::Entry, set::IndexSet as HashSet};
1112

12-
use syn::{Type, TypeArray};
13+
use syn::{PatType, Type, TypeArray};
1314

14-
use crate::conversion::api::DeletedOrDefaulted;
15+
use crate::conversion::type_helpers::type_is_reference;
1516
use crate::{
1617
conversion::{
1718
analysis::{
1819
depth_first::fields_and_bases_first, pod::PodAnalysis, type_converter::TypeKind,
1920
},
20-
api::{Api, ApiName, CppVisibility, FuncToConvert, SpecialMemberKind},
21+
api::{Api, ApiName, FuncToConvert},
2122
apivec::ApiVec,
2223
convert_error::ConvertErrorWithContext,
2324
ConvertErrorFromCpp,
@@ -575,7 +576,7 @@ fn find_explicit_items(
575576
.entry(ExplicitType { ty, kind })
576577
{
577578
Entry::Vacant(entry) => {
578-
entry.insert(if matches!(fun.is_deleted, DeletedOrDefaulted::Deleted) {
579+
entry.insert(if matches!(fun.is_deleted, Some(Explicitness::Deleted)) {
579580
ExplicitFound::Deleted
580581
} else {
581582
ExplicitFound::UserDefined(fun.cpp_vis)
@@ -605,7 +606,7 @@ fn find_explicit_items(
605606
Some(SpecialMemberKind::AssignmentOperator)
606607
) =>
607608
{
608-
let is_move_assignment_operator = !fun.references.rvalue_ref_params.is_empty();
609+
let is_move_assignment_operator = !any_input_is_rvalue_reference(&fun.inputs);
609610
merge_fun(
610611
impl_for.clone(),
611612
if is_move_assignment_operator {
@@ -694,6 +695,15 @@ fn find_explicit_items(
694695
(result, unknown_types)
695696
}
696697

698+
fn any_input_is_rvalue_reference(
699+
inputs: &syn::punctuated::Punctuated<crate::minisyn::FnArg, syn::token::Comma>,
700+
) -> bool {
701+
inputs.iter().any(|input| match &input.0 {
702+
syn::FnArg::Receiver(_) => false,
703+
syn::FnArg::Typed(PatType { ty, .. }, ..) => type_is_reference(ty.as_ref(), true),
704+
})
705+
}
706+
697707
/// Returns the information for a given known type.
698708
fn known_type_items_found(constructor_details: KnownTypeConstructorDetails) -> ItemsFound {
699709
let exists_public = SpecialMemberFound::Explicit(CppVisibility::Public);

0 commit comments

Comments
 (0)