pub fn expand_com_library(
    arg_tokens: TokenStreamNightly,
) -> Result<TokenStreamNightly, model::ParseError>
{
    let mut output = vec![];
    let lib = model::ComLibrary::parse( &lib_name(), arg_tokens.into() )?;

    // Create the match-statmeent patterns for each supposedly visible COM class.
    let mut match_arms = vec![];
    let mut creatable_classes = vec![];
    for struct_path in lib.coclasses() {

        // Construct the match pattern.
        let clsid_path = idents::clsid_path( struct_path );
        match_arms.push( quote!(
            self::#clsid_path =>
                Ok( ::intercom::ComBox::new(
                        #struct_path::new()
                    ) as ::intercom::RawComPtr )
        ) );

        // Collect class identifies of classes that have a guid and
        // which others outside the library can create.
        creatable_classes.push( quote!( #clsid_path ) );
    }

    // Generate built-in type data.
    for bti in builtin_model::builtin_intercom_types( lib.name() ) {

        // CLSID
        let clsid_tokens = utils::get_guid_tokens(
                bti.class.clsid().as_ref().unwrap() );
        let clsid_doc = format!( "Built-in {} class ID.", bti.class.name() );
        let builtin_clsid = idents::clsid( bti.class.name() );
        output.push( quote!(
            #[allow(non_upper_case_globals)]
            #[doc = #clsid_doc ]
            pub const #builtin_clsid : ::intercom::CLSID = #clsid_tokens;
        ) );

        // Match arm
        let ctor = bti.ctor;
        match_arms.push( quote!(
            self::#builtin_clsid =>
                Ok( ::intercom::ComBox::new( #ctor ) as ::intercom::RawComPtr )
        ) );

        // Include also built-in classes. They have a custom CLSID in every library.
        creatable_classes.push( quote!( #builtin_clsid ) );
    }

    // Implement DllGetClassObject.
    //
    // This is more or less the only symbolic entry point that the COM
    // infrastructure uses. The COM client uses this method to acquire
    // the IClassFactory interfaces that are then used to construct the
    // actual coclasses.
    let dll_get_class_object = get_dll_get_class_object_function( &match_arms );
    output.push( dll_get_class_object );

    // Implement DllListClassObjects
    // DllListClassObjects returns all CLSIDs implemented in the crate.
    let list_class_objects = get_intercom_list_class_objects_function( &creatable_classes );
    output.push( list_class_objects );

    Ok( TokenStream::from_iter( output.into_iter() ).into() )
}
/// Expands the `com_library` macro.
///
/// The macro expansion results in the following items:
///
/// - `DllGetClassObject` extern function implementation.
/// - `IntercomListClassObjects` extern function implementation.
Expands the `com_library` macro.
The macro expansion results in the following items.

`DllGetClassObject` extern function implementation.
`IntercomListClassObjects` extern function implementation.
Expands the ` com_library ` macro . The macro expansion results in the following items . ` DllGetClassObject ` extern function implementation . ` IntercomListClassObjects ` extern function implementation .
pub fn expand_com_library(
    arg_tokens: TokenStreamNightly,
) -> Result<TokenStreamNightly, model::ParseError>
{
    let mut output = vec![];
    let lib = model::ComLibrary::parse( &lib_name(), arg_tokens.into() )?;
    // Create the match-statmeent patterns for each supposedly visible COM class.
    let mut match_arms = vec![];
    let mut creatable_classes = vec![];
    for struct_path in lib.coclasses() {
        // Construct the match pattern.
        let clsid_path = idents::clsid_path( struct_path );
        match_arms.push( quote!(
            self::#clsid_path =>
                Ok( ::intercom::ComBox::new(
                        #struct_path::new()
                    ) as ::intercom::RawComPtr )
        ) );
        // Collect class identifies of classes that have a guid and
        // which others outside the library can create.
        creatable_classes.push( quote!( #clsid_path ) );
    }
    // Generate built-in type data.
    for bti in builtin_model::builtin_intercom_types( lib.name() ) {
        // CLSID
        let clsid_tokens = utils::get_guid_tokens(
                bti.class.clsid().as_ref().unwrap() );
        let clsid_doc = format!( "Built-in {} class ID.", bti.class.name() );
        let builtin_clsid = idents::clsid( bti.class.name() );
        output.push( quote!(
            #[allow(non_upper_case_globals)]
            #[doc = #clsid_doc ]
            pub const #builtin_clsid : ::intercom::CLSID = #clsid_tokens;
        ) );
        // Match arm
        let ctor = bti.ctor;
        match_arms.push( quote!(
            self::#builtin_clsid =>
                Ok( ::intercom::ComBox::new( #ctor ) as ::intercom::RawComPtr )
        ) );
        // Include also built-in classes. They have a custom CLSID in every library.
        creatable_classes.push( quote!( #builtin_clsid ) );
    }
    // Implement DllGetClassObject.
    //
    // This is more or less the only symbolic entry point that the COM
    // infrastructure uses. The COM client uses this method to acquire
    // the IClassFactory interfaces that are then used to construct the
    // actual coclasses.
    let dll_get_class_object = get_dll_get_class_object_function( &match_arms );
    output.push( dll_get_class_object );
    // Implement DllListClassObjects
    // DllListClassObjects returns all CLSIDs implemented in the crate.
    let list_class_objects = get_intercom_list_class_objects_function( &creatable_classes );
    output.push( list_class_objects );
    Ok( TokenStream::from_iter( output.into_iter() ).into() )
}
pub fn expand_com_library ( arg_tokens : TokenStreamNightly , ) -> Result < TokenStreamNightly , model :: ParseError > { let mut output = vec ! [ ] ; let lib = model :: ComLibrary :: parse ( & lib_name ( ) , arg_tokens . into ( ) ) ? ; // Create the match-statmeent patterns for each supposedly visible COM class. let mut match_arms = vec ! [ ] ; let mut creatable_classes = vec ! [ ] ; for struct_path in lib . coclasses ( ) { // Construct the match pattern. let clsid_path = idents :: clsid_path ( struct_path ) ; match_arms . push ( quote ! ( self clsid_path Ok ( intercom ComBox new ( struct_path new ( ) ) as intercom RawComPtr ) ) ) ; // Collect class identifies of classes that have a guid and // which others outside the library can create. creatable_classes . push ( quote ! ( clsid_path ) ) ; } // Generate built-in type data. for bti in builtin_model :: builtin_intercom_types ( lib . name ( ) ) { // CLSID let clsid_tokens = utils :: get_guid_tokens ( bti . class . clsid ( ) . as_ref ( ) . unwrap ( ) ) ; let clsid_doc = format ! ( " " bti class name ( ) ) ; let builtin_clsid = idents :: clsid ( bti . class . name ( ) ) ; output . push ( quote ! ( [ allow ( non_upper_case_globals ) ] [ doc clsid_doc ] pub const builtin_clsid intercom CLSID clsid_tokens ) ) ; // Match arm let ctor = bti . ctor ; match_arms . push ( quote ! ( self builtin_clsid Ok ( intercom ComBox new ( ctor ) as intercom RawComPtr ) ) ) ; // Include also built-in classes. They have a custom CLSID in every library. creatable_classes . push ( quote ! ( builtin_clsid ) ) ; } // Implement DllGetClassObject. // // This is more or less the only symbolic entry point that the COM // infrastructure uses. The COM client uses this method to acquire // the IClassFactory interfaces that are then used to construct the // actual coclasses. let dll_get_class_object = get_dll_get_class_object_function ( & match_arms ) ; output . push ( dll_get_class_object ) ; // Implement DllListClassObjects // DllListClassObjects returns all CLSIDs implemented in the crate. let list_class_objects = get_intercom_list_class_objects_function ( & creatable_classes ) ; output . push ( list_class_objects ) ; Ok ( TokenStream :: from_iter ( output . into_iter ( ) ) . into ( ) ) }
Expands the `com_library` macro.
Expands the ` com_library ` macro .
arg_tokens
TokenStreamNightly