|
4 | 4 | // SPDX-License-Identifier: MIT OR Apache-2.0
|
5 | 5 |
|
6 | 6 | use crate::parser::parameter::ParsedFunctionParameter;
|
7 |
| -use crate::syntax::attribute::attribute_take_path; |
| 7 | +use crate::syntax::attribute::{attribute_find_path, attribute_take_path}; |
8 | 8 | use crate::syntax::expr::expr_to_string;
|
9 | 9 | use crate::syntax::foreignmod;
|
10 | 10 | use crate::syntax::safety::Safety;
|
@@ -70,10 +70,17 @@ impl ParsedSignal {
|
70 | 70 |
|
71 | 71 | let mut ident = CombinedIdent::from_rust_function(method.sig.ident.clone());
|
72 | 72 |
|
73 |
| - if let Some(attr) = attribute_take_path(&mut method.attrs, &["cxx_name"]) { |
| 73 | + if let Some(index) = attribute_find_path(&method.attrs, &["cxx_name"]) { |
74 | 74 | ident.cpp = format_ident!(
|
75 | 75 | "{}",
|
76 |
| - expr_to_string(&attr.meta.require_name_value()?.value)? |
| 76 | + expr_to_string(&method.attrs[index].meta.require_name_value()?.value)? |
| 77 | + ); |
| 78 | + } |
| 79 | + |
| 80 | + if let Some(index) = attribute_find_path(&method.attrs, &["rust_name"]) { |
| 81 | + ident.rust = format_ident!( |
| 82 | + "{}", |
| 83 | + expr_to_string(&method.attrs[index].meta.require_name_value()?.value)? |
77 | 84 | );
|
78 | 85 | }
|
79 | 86 |
|
@@ -130,6 +137,7 @@ mod tests {
|
130 | 137 | let signal = ParsedSignal::parse(method, Safety::Safe).unwrap();
|
131 | 138 |
|
132 | 139 | let expected_method: ForeignItemFn = parse_quote! {
|
| 140 | + #[cxx_name = "cppReady"] |
133 | 141 | fn ready(self: Pin<&mut MyObject>);
|
134 | 142 | };
|
135 | 143 | assert_eq!(signal.method, expected_method);
|
|
0 commit comments