fn generate_reaper_token_stream(fn_ptrs: &Vec<FnPtr>) -> proc_macro2::TokenStream {
            let Compartments {
                names,
                fn_ptr_signatures,
                methods,
            } = build_compartments(
                fn_ptrs,
                &EXTERN_SYSTEM_ABI_REAPER_FUNCTIONS,
                &ADDITIONAL_SAFE_REAPER_FUNCTIONS,
            );
            let total_fn_ptr_count = names.len() as u32;
            quote::quote! {
                //! This file is automatically generated by executing `cargo build --features generate`.
                //!
                //! **Make adjustments in `build.rs`, not in this file!**
                #![allow(clippy::many_single_char_names)]
                #![allow(clippy::too_many_arguments)]
                #![allow(clippy::type_complexity)]
                #![allow(non_upper_case_globals)]
                #![allow(non_camel_case_types)]
                #![allow(non_snake_case)]

                use crate::{bindings::root, PluginContext};

                /// This is the low-level API access point to all REAPER functions.
                ///
                /// In order to use it, you first must obtain an instance of this struct by invoking [`load()`].
                ///
                /// `Default::default()` will give you an instance which panics on each function call. It's
                /// intended to be used for example code only.
                ///
                /// # Panics
                ///
                /// Please note that it's possible that functions are *not available*. This can be the case if
                /// the user runs your plug-in in an older version of REAPER which doesn't have that function yet.
                /// The availability of a function can be checked by inspecting the respective function pointer
                /// option accessible via the [`pointers()`] method. The actual methods in this structs are just
                /// convenience methods which unwrap the function pointers and panic if they are not available.
                ///
                /// [`load()`]: #method.load
                /// [`pointers()`]: #method.pointers
                #[derive(Copy, Clone, Debug, Default)]
                pub struct Reaper {
                    pub(crate) pointers: ReaperFunctionPointers,
                    // The only reason why this can be None is that we want to support Default. We want Default
                    // in order to be able to create rustdoc example code in higher-level APIs without needing a
                    // proper plug-in context.
                    pub(crate) plugin_context: Option<PluginContext>,
                }

                impl Reaper {
                    /// Loads all available REAPER functions from the given plug-in context.
                    ///
                    /// Returns a low-level `Reaper` instance which allows you to call these functions.
                    pub fn load(plugin_context: PluginContext) -> Reaper {
                        let mut loaded_count = 0;
                        let mut pointers = unsafe {
                            ReaperFunctionPointers {
                                loaded_count: 0,
                                #(
                                    #names: std::mem::transmute(plugin_context.GetFunc(c_str_macro::c_str!(stringify!(#names)).as_ptr())),
                                )*
                            }
                        };
                        #(
                            if pointers.#names.is_some() {
                                loaded_count += 1;
                            }
                        )*
                        pointers.loaded_count = loaded_count;
                        Reaper {
                            pointers,
                            plugin_context: Some(plugin_context)
                        }
                    }

                    #(
                        #methods
                    )*
                }

                /// Container for the REAPER function pointers.
                #[derive(Copy, Clone, Default)]
                pub struct ReaperFunctionPointers {
                    pub(crate) loaded_count: u32,
                    #(
                        pub #names: Option<#fn_ptr_signatures>,
                    )*
                }

                impl ReaperFunctionPointers {
                    pub(crate) const TOTAL_COUNT: u32 = #total_fn_ptr_count;
                }
            }
        }
/// Generates the token stream. All of this could also be done in a procedural macro but
/// I prefer the code generation approach for now.
Generates the token stream. All of this could also be done in a procedural macro but
I prefer the code generation approach for now.
Generates the token stream . All of this could also be done in a procedural macro but I prefer the code generation approach for now .
fn generate_reaper_token_stream(fn_ptrs: &Vec<FnPtr>) -> proc_macro2::TokenStream {
            let Compartments {
                names,
                fn_ptr_signatures,
                methods,
            } = build_compartments(
                fn_ptrs,
                &EXTERN_SYSTEM_ABI_REAPER_FUNCTIONS,
                &ADDITIONAL_SAFE_REAPER_FUNCTIONS,
            );
            let total_fn_ptr_count = names.len() as u32;
            quote::quote! {
                //! This file is automatically generated by executing `cargo build --features generate`.
                //!
                //! **Make adjustments in `build.rs`, not in this file!**
                #![allow(clippy::many_single_char_names)]
                #![allow(clippy::too_many_arguments)]
                #![allow(clippy::type_complexity)]
                #![allow(non_upper_case_globals)]
                #![allow(non_camel_case_types)]
                #![allow(non_snake_case)]
                use crate::{bindings::root, PluginContext};
                /// This is the low-level API access point to all REAPER functions.
                ///
                /// In order to use it, you first must obtain an instance of this struct by invoking [`load()`].
                ///
                /// `Default::default()` will give you an instance which panics on each function call. It's
                /// intended to be used for example code only.
                ///
                /// # Panics
                ///
                /// Please note that it's possible that functions are *not available*. This can be the case if
                /// the user runs your plug-in in an older version of REAPER which doesn't have that function yet.
                /// The availability of a function can be checked by inspecting the respective function pointer
                /// option accessible via the [`pointers()`] method. The actual methods in this structs are just
                /// convenience methods which unwrap the function pointers and panic if they are not available.
                ///
                /// [`load()`]: #method.load
                /// [`pointers()`]: #method.pointers
                #[derive(Copy, Clone, Debug, Default)]
                pub struct Reaper {
                    pub(crate) pointers: ReaperFunctionPointers,
                    // The only reason why this can be None is that we want to support Default. We want Default
                    // in order to be able to create rustdoc example code in higher-level APIs without needing a
                    // proper plug-in context.
                    pub(crate) plugin_context: Option<PluginContext>,
                }
                impl Reaper {
                    /// Loads all available REAPER functions from the given plug-in context.
                    ///
                    /// Returns a low-level `Reaper` instance which allows you to call these functions.
                    pub fn load(plugin_context: PluginContext) -> Reaper {
                        let mut loaded_count = 0;
                        let mut pointers = unsafe {
                            ReaperFunctionPointers {
                                loaded_count: 0,
                                #(
                                    #names: std::mem::transmute(plugin_context.GetFunc(c_str_macro::c_str!(stringify!(#names)).as_ptr())),
                                )*
                            }
                        };
                        #(
                            if pointers.#names.is_some() {
                                loaded_count += 1;
                            }
                        )*
                        pointers.loaded_count = loaded_count;
                        Reaper {
                            pointers,
                            plugin_context: Some(plugin_context)
                        }
                    }
                    #(
                        #methods
                    )*
                }
                /// Container for the REAPER function pointers.
                #[derive(Copy, Clone, Default)]
                pub struct ReaperFunctionPointers {
                    pub(crate) loaded_count: u32,
                    #(
                        pub #names: Option<#fn_ptr_signatures>,
                    )*
                }
                impl ReaperFunctionPointers {
                    pub(crate) const TOTAL_COUNT: u32 = #total_fn_ptr_count;
                }
            }
        }
fn generate_reaper_token_stream ( fn_ptrs : & Vec < FnPtr > ) -> proc_macro2 :: TokenStream { let Compartments { names , fn_ptr_signatures , methods , } = build_compartments ( fn_ptrs , & EXTERN_SYSTEM_ABI_REAPER_FUNCTIONS , & ADDITIONAL_SAFE_REAPER_FUNCTIONS , ) ; let total_fn_ptr_count = names . len ( ) as u32 ; quote :: quote ! { //! This file is automatically generated by executing `cargo build --features generate`. //! **Make adjustments in `build.rs`, not in this file!** [ allow ( clippy many_single_char_names ) ] [ allow ( clippy too_many_arguments ) ] [ allow ( clippy type_complexity ) ] [ allow ( non_upper_case_globals ) ] [ allow ( non_camel_case_types ) ] [ allow ( non_snake_case ) ] use crate { bindings root PluginContext } /// This is the low-level API access point to all REAPER functions. /// In order to use it, you first must obtain an instance of this struct by invoking [`load()`]. /// `Default::default()` will give you an instance which panics on each function call. It's /// intended to be used for example code only. /// # Panics /// Please note that it's possible that functions are *not available*. This can be the case if /// the user runs your plug-in in an older version of REAPER which doesn't have that function yet. /// The availability of a function can be checked by inspecting the respective function pointer /// option accessible via the [`pointers()`] method. The actual methods in this structs are just /// convenience methods which unwrap the function pointers and panic if they are not available. /// [`load()`]: #method.load /// [`pointers()`]: #method.pointers [ derive ( Copy Clone Debug Default ) ] pub struct Reaper { pub ( crate ) pointers ReaperFunctionPointers // The only reason why this can be None is that we want to support Default. We want Default // in order to be able to create rustdoc example code in higher-level APIs without needing a // proper plug-in context. pub ( crate ) plugin_context Option PluginContext } impl Reaper { /// Loads all available REAPER functions from the given plug-in context. /// Returns a low-level `Reaper` instance which allows you to call these functions. pub fn load ( plugin_context PluginContext ) Reaper { let mut loaded_count 0 let mut pointers unsafe { ReaperFunctionPointers { loaded_count 0 ( names std mem transmute ( plugin_context GetFunc ( c_str_macro c_str ( stringify ( names ) ) as_ptr ( ) ) ) ) } } ( if pointers names is_some ( ) { loaded_count 1 } ) pointers loaded_count loaded_count Reaper { pointers plugin_context Some ( plugin_context ) } } ( methods ) } /// Container for the REAPER function pointers. [ derive ( Copy Clone Default ) ] pub struct ReaperFunctionPointers { pub ( crate ) loaded_count u32 ( pub names Option fn_ptr_signatures ) } impl ReaperFunctionPointers { pub ( crate ) const TOTAL_COUNT u32 total_fn_ptr_count } } }
Generates the token stream.
Generates the token stream .
fn_ptrs
&Vec<FnPtr>
fn_ptrs
&Vec<FnPtr>