Skip to content

Commit

Permalink
WIP: types: allow for duplicate names if the cfg options are different
Browse files Browse the repository at this point in the history
  • Loading branch information
ahayzen-kdab committed Sep 5, 2024
1 parent 55bfb54 commit 33a83cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions syntax/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ fn parse_rust_name_attribute(meta: &Meta) -> Result<Ident> {
Err(Error::new_spanned(meta, "unsupported rust_name attribute"))
}

#[derive(Clone)]
pub(crate) struct OtherAttrs(Vec<Attribute>);
#[derive(Clone, Debug)]
pub(crate) struct OtherAttrs(pub(crate) Vec<Attribute>);

impl OtherAttrs {
pub(crate) fn none() -> Self {
Expand Down
2 changes: 1 addition & 1 deletion syntax/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::mem;
use syn::parse::{Error, ParseStream, Result};
use syn::{parenthesized, token, Attribute, LitStr, Token};

#[derive(Clone)]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub(crate) enum CfgExpr {
Unconditional,
#[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
Expand Down
6 changes: 5 additions & 1 deletion syntax/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ impl<'a> Types<'a> {
Api::CxxFunction(efn) | Api::RustFunction(efn) => {
// Note: duplication of the C++ name is fine because C++ has
// function overloading.
if !function_names.insert((&efn.receiver, &efn.name.rust)) {
if !matches!(efn.cfg, crate::syntax::CfgExpr::Unconditional) {
println!("FUNCTION: cfg -> {:?}", efn.cfg);
// println!("FUNCTION: attrs -> {:?}", efn.attrs);
}
if !function_names.insert((&efn.receiver, &efn.name.rust, &efn.cfg)) {
duplicate_name(cx, efn, &efn.name.rust);
}
for arg in &efn.args {
Expand Down

0 comments on commit 33a83cc

Please sign in to comment.