fn build_compartments(
            fn_ptrs: &Vec<FnPtr>,
            extern_system_functions: &phf::Set<&'static str>,
            safe_functions: &phf::Set<&'static str>,
        ) -> Compartments {
            Compartments {
                names: fn_ptrs.iter().map(|p| p.name.clone()).collect(),
                fn_ptr_signatures: fn_ptrs
                    .iter()
                    .map(|p| {
                        let function_name = p.name.to_string();
                        let abi = if extern_system_functions.contains(function_name.as_str()) {
                            "system"
                        } else {
                            "C"
                        };
                        TypeBareFn {
                            abi: Some(Abi {
                                extern_token: Extern {
                                    span: Span::call_site(),
                                },
                                name: Some(syn::LitStr::new(abi, Span::call_site())),
                            }),
                            unsafety: if p.is_safe(safe_functions) {
                                None
                            } else {
                                p.signature.unsafety.clone()
                            },
                            ..p.signature.clone()
                        }
                    })
                    .collect(),
                methods: fn_ptrs
                    .iter()
                    .map(|p| generate_method(&p, generate_method_body(&p), safe_functions))
                    .collect(),
            }
        }
/// This also modifies some unsafety and ABI fields based on the given sets.
This also modifies some unsafety and ABI fields based on the given sets.
This also modifies some unsafety and ABI fields based on the given sets .
fn build_compartments(
            fn_ptrs: &Vec<FnPtr>,
            extern_system_functions: &phf::Set<&'static str>,
            safe_functions: &phf::Set<&'static str>,
        ) -> Compartments {
            Compartments {
                names: fn_ptrs.iter().map(|p| p.name.clone()).collect(),
                fn_ptr_signatures: fn_ptrs
                    .iter()
                    .map(|p| {
                        let function_name = p.name.to_string();
                        let abi = if extern_system_functions.contains(function_name.as_str()) {
                            "system"
                        } else {
                            "C"
                        };
                        TypeBareFn {
                            abi: Some(Abi {
                                extern_token: Extern {
                                    span: Span::call_site(),
                                },
                                name: Some(syn::LitStr::new(abi, Span::call_site())),
                            }),
                            unsafety: if p.is_safe(safe_functions) {
                                None
                            } else {
                                p.signature.unsafety.clone()
                            },
                            ..p.signature.clone()
                        }
                    })
                    .collect(),
                methods: fn_ptrs
                    .iter()
                    .map(|p| generate_method(&p, generate_method_body(&p), safe_functions))
                    .collect(),
            }
        }
fn build_compartments ( fn_ptrs : & Vec < FnPtr > , extern_system_functions : & phf :: Set < & ' static str > , safe_functions : & phf :: Set < & ' static str > , ) -> Compartments { Compartments { names : fn_ptrs . iter ( ) . map ( | p | p . name . clone ( ) ) . collect ( ) , fn_ptr_signatures : fn_ptrs . iter ( ) . map ( | p | { let function_name = p . name . to_string ( ) ; let abi = if extern_system_functions . contains ( function_name . as_str ( ) ) { " " } else { " " } ; TypeBareFn { abi : Some ( Abi { extern_token : Extern { span : Span :: call_site ( ) , } , name : Some ( syn :: LitStr :: new ( abi , Span :: call_site ( ) ) ) , } ) , unsafety : if p . is_safe ( safe_functions ) { None } else { p . signature . unsafety . clone ( ) } , .. p . signature . clone ( ) } } ) . collect ( ) , methods : fn_ptrs . iter ( ) . map ( | p | generate_method ( & p , generate_method_body ( & p ) , safe_functions ) ) . collect ( ) , } }
This also modifies some unsafety and ABI fields based on the given sets.
This also modifies some unsafety and ABI fields based on the given sets .
fn_ptrs
&Vec<FnPtr>
extern_system_functions
&phf::Set<&'static str>
safe_functions
&phf::Set<&'static str>
fn_ptrs
&Vec<FnPtr>
extern_system_functions
&phf::Set<&'static str>
safe_functions
&phf::Set<&'static str>