mirror of
https://git.proxmox.com/git/perlmod
synced 2025-10-05 22:41:14 +00:00
don't export xs wrappers from modules
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
d6b0097481
commit
5491907876
@ -57,6 +57,7 @@ pub fn handle_function(
|
||||
attr: FunctionAttrs,
|
||||
mut func: syn::ItemFn,
|
||||
mangled_package_name: Option<&str>,
|
||||
export_public: bool,
|
||||
) -> Result<XSub, Error> {
|
||||
if !func.sig.generics.params.is_empty() {
|
||||
bail!(&func.sig.generics => "generic functions cannot be exported as xsubs");
|
||||
@ -194,6 +195,7 @@ pub fn handle_function(
|
||||
&xs_name,
|
||||
&impl_xs_name,
|
||||
passed_arguments,
|
||||
export_public,
|
||||
)?;
|
||||
|
||||
let tokens = quote! {
|
||||
@ -248,6 +250,7 @@ fn handle_return_kind(
|
||||
xs_name: &Ident,
|
||||
impl_xs_name: &Ident,
|
||||
passed_arguments: TokenStream,
|
||||
export_public: bool,
|
||||
) -> Result<ReturnHandling, Error> {
|
||||
let return_type;
|
||||
let mut handle_return;
|
||||
@ -283,10 +286,15 @@ fn handle_return_kind(
|
||||
};
|
||||
}
|
||||
|
||||
let vis = if export_public {
|
||||
quote! { #[no_mangle] pub }
|
||||
} else {
|
||||
quote! { #[allow(non_snake_case)] }
|
||||
};
|
||||
|
||||
wrapper_func = quote! {
|
||||
#[no_mangle]
|
||||
#[doc(hidden)]
|
||||
pub extern "C" fn #xs_name(#pthx _cv: &::perlmod::ffi::CV) {
|
||||
#vis extern "C" fn #xs_name(#pthx _cv: &::perlmod::ffi::CV) {
|
||||
unsafe {
|
||||
match #impl_xs_name() {
|
||||
Ok(()) => (),
|
||||
|
@ -107,7 +107,7 @@ fn export_impl(attr: AttributeArgs, item: TokenStream) -> Result<TokenStream, Er
|
||||
let func: syn::ItemFn = syn::parse2(item)?;
|
||||
|
||||
let attr = attribs::FunctionAttrs::try_from(attr)?;
|
||||
let func = function::handle_function(attr, func, None)?;
|
||||
let func = function::handle_function(attr, func, None, true)?;
|
||||
Ok(func.tokens)
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ pub fn handle_module(attr: AttributeArgs, mut module: syn::ItemMod) -> Result<To
|
||||
attribs,
|
||||
func,
|
||||
Some(&mangled_package_name),
|
||||
false,
|
||||
)?;
|
||||
*item = syn::Item::Verbatim(func.tokens);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user