-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable savvy-cli to handle duplicated definitions #334
Conversation
The last failure was due to missing #[cfg(not(target_os = "windows"))]
#[allow(non_snake_case)]
unsafe fn savvy_StructWithConfig_new_inner(
self__: savvy::ffi::SEXP,
x: savvy::ffi::SEXP,
) -> savvy::Result<StructWithConfig> {
...
}
#[allow(clippy::missing_safety_doc)]
#[no_mangle]
pub unsafe extern "C" fn savvy_StructWithConfig_new__ffi(
self__: savvy::ffi::SEXP,
x: savvy::ffi::SEXP,
) -> savvy::ffi::SEXP {
match savvy_StructWithConfig_new_inner(self__, x) {
...
}
#[allow(clippy::missing_safety_doc)]
#[no_mangle]
pub unsafe extern "C" fn savvy_StructWithConfig_new__ffi(
self__: savvy::ffi::SEXP,
x: savvy::ffi::SEXP,
) -> savvy::ffi::SEXP {
match savvy_StructWithConfig_new_inner(self__, x) {
...
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#(#attrs)*
seems needed here too.
_ => parse_quote!(
#[allow(clippy::missing_safety_doc)]
#[no_mangle]
pub unsafe extern "C" fn #fn_name_ffi( #(#args_pat: #args_ty),* ) -> savvy::ffi::SEXP {
match #fn_name_inner(#(#args_pat),*) {
Ok(#ok_lhs) => #ok_rhs,
Err(e) => savvy::handle_error(e),
}
}
),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. Thanks for catching!
Close #333
Users might use
#[cfg()]
to switch implementations on the same function. However, from the viewpoint ofsavvy-cli
, who cannot evaluate#[cfg()]
, these are just duplicated definitions. This pull request enables the cli to ignore the duplication to generate the proper C & R bindings.