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,
|
attr: FunctionAttrs,
|
||||||
mut func: syn::ItemFn,
|
mut func: syn::ItemFn,
|
||||||
mangled_package_name: Option<&str>,
|
mangled_package_name: Option<&str>,
|
||||||
|
export_public: bool,
|
||||||
) -> Result<XSub, Error> {
|
) -> Result<XSub, Error> {
|
||||||
if !func.sig.generics.params.is_empty() {
|
if !func.sig.generics.params.is_empty() {
|
||||||
bail!(&func.sig.generics => "generic functions cannot be exported as xsubs");
|
bail!(&func.sig.generics => "generic functions cannot be exported as xsubs");
|
||||||
@ -194,6 +195,7 @@ pub fn handle_function(
|
|||||||
&xs_name,
|
&xs_name,
|
||||||
&impl_xs_name,
|
&impl_xs_name,
|
||||||
passed_arguments,
|
passed_arguments,
|
||||||
|
export_public,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let tokens = quote! {
|
let tokens = quote! {
|
||||||
@ -248,6 +250,7 @@ fn handle_return_kind(
|
|||||||
xs_name: &Ident,
|
xs_name: &Ident,
|
||||||
impl_xs_name: &Ident,
|
impl_xs_name: &Ident,
|
||||||
passed_arguments: TokenStream,
|
passed_arguments: TokenStream,
|
||||||
|
export_public: bool,
|
||||||
) -> Result<ReturnHandling, Error> {
|
) -> Result<ReturnHandling, Error> {
|
||||||
let return_type;
|
let return_type;
|
||||||
let mut handle_return;
|
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! {
|
wrapper_func = quote! {
|
||||||
#[no_mangle]
|
|
||||||
#[doc(hidden)]
|
#[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 {
|
unsafe {
|
||||||
match #impl_xs_name() {
|
match #impl_xs_name() {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
|
@ -107,7 +107,7 @@ fn export_impl(attr: AttributeArgs, item: TokenStream) -> Result<TokenStream, Er
|
|||||||
let func: syn::ItemFn = syn::parse2(item)?;
|
let func: syn::ItemFn = syn::parse2(item)?;
|
||||||
|
|
||||||
let attr = attribs::FunctionAttrs::try_from(attr)?;
|
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)
|
Ok(func.tokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ pub fn handle_module(attr: AttributeArgs, mut module: syn::ItemMod) -> Result<To
|
|||||||
attribs,
|
attribs,
|
||||||
func,
|
func,
|
||||||
Some(&mangled_package_name),
|
Some(&mangled_package_name),
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
*item = syn::Item::Verbatim(func.tokens);
|
*item = syn::Item::Verbatim(func.tokens);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user