pub fn from_ast(
        crate_name : &str,
        attr_params : TokenStream,
        item : &::syn::ItemStruct,
    ) -> ParseResult< ComStruct >
    {
        let attr : ComStructAttr = ::syn::parse2( attr_params )
            .map_err( |e| ParseError::ComStruct(
                    item.ident.to_string(),
                    format!( "Attribute syntax error: {}", e ) ) )?;

        // First attribute parameter is the CLSID. Parse it.
        let clsid_attr = attr.clsid()
                .map_err( |msg| ParseError::ComStruct(
                    item.ident.to_string(), msg ) )?;
        let clsid = match clsid_attr {
            None => Some( ::utils::generate_clsid(
                    crate_name, &item.ident.to_string() ) ),
            Some( StrOption::Str( clsid ) ) =>
                    Some( GUID::parse( &clsid.value() )
                        .map_err( |_| ParseError::ComStruct(
                                item.ident.to_string(),
                                "Bad CLSID format".into() ) )? ),
            Some( StrOption::None ) => None,
        };

        // Remaining parameters are coclasses.
        let interfaces = attr.args().into_iter().cloned().collect();

        Ok( ComStruct {
            name: item.ident.clone(),
            visibility: item.vis.clone(),
            clsid,
            interfaces,
        } )
    }
/// Creates ComStruct from AST elements.
Creates ComStruct from AST elements.
Creates ComStruct from AST elements .
pub fn from_ast(
        crate_name : &str,
        attr_params : TokenStream,
        item : &::syn::ItemStruct,
    ) -> ParseResult< ComStruct >
    {
        let attr : ComStructAttr = ::syn::parse2( attr_params )
            .map_err( |e| ParseError::ComStruct(
                    item.ident.to_string(),
                    format!( "Attribute syntax error: {}", e ) ) )?;
        // First attribute parameter is the CLSID. Parse it.
        let clsid_attr = attr.clsid()
                .map_err( |msg| ParseError::ComStruct(
                    item.ident.to_string(), msg ) )?;
        let clsid = match clsid_attr {
            None => Some( ::utils::generate_clsid(
                    crate_name, &item.ident.to_string() ) ),
            Some( StrOption::Str( clsid ) ) =>
                    Some( GUID::parse( &clsid.value() )
                        .map_err( |_| ParseError::ComStruct(
                                item.ident.to_string(),
                                "Bad CLSID format".into() ) )? ),
            Some( StrOption::None ) => None,
        };
        // Remaining parameters are coclasses.
        let interfaces = attr.args().into_iter().cloned().collect();
        Ok( ComStruct {
            name: item.ident.clone(),
            visibility: item.vis.clone(),
            clsid,
            interfaces,
        } )
    }
pub fn from_ast ( crate_name : & str , attr_params : TokenStream , item : & :: syn :: ItemStruct , ) -> ParseResult < ComStruct > { let attr : ComStructAttr = :: syn :: parse2 ( attr_params ) . map_err ( | e | ParseError :: ComStruct ( item . ident . to_string ( ) , format ! ( " " e ) ) ) ? ; // First attribute parameter is the CLSID. Parse it. let clsid_attr = attr . clsid ( ) . map_err ( | msg | ParseError :: ComStruct ( item . ident . to_string ( ) , msg ) ) ? ; let clsid = match clsid_attr { None => Some ( :: utils :: generate_clsid ( crate_name , & item . ident . to_string ( ) ) ) , Some ( StrOption :: Str ( clsid ) ) => Some ( GUID :: parse ( & clsid . value ( ) ) . map_err ( | _ | ParseError :: ComStruct ( item . ident . to_string ( ) , " " . into ( ) ) ) ? ) , Some ( StrOption :: None ) => None , } ; // Remaining parameters are coclasses. let interfaces = attr . args ( ) . into_iter ( ) . cloned ( ) . collect ( ) ; Ok ( ComStruct { name : item . ident . clone ( ) , visibility : item . vis . clone ( ) , clsid , interfaces , } ) }
Creates ComStruct from AST elements.
Creates ComStruct from AST elements .
crate_name
&str
attr_params
TokenStream
item
&::syn::ItemStruct