@@ -181,7 +181,7 @@ impl<'a> Gen<'a> {
181181 }
182182 }
183183 TypeKind :: Delegate => {
184- if self . reader . type_def_flags ( * def) . winrt ( ) {
184+ if self . reader . type_def_flags ( * def) . contains ( TypeAttributes :: WINRT ) {
185185 quote ! { * mut :: core:: ffi:: c_void }
186186 } else {
187187 self . type_def_name ( * def, & [ ] )
@@ -619,7 +619,7 @@ impl<'a> Gen<'a> {
619619 }
620620 }
621621 pub fn interface_winrt_trait ( & self , def : TypeDef , generics : & [ Type ] , ident : & TokenStream , constraints : & TokenStream , _phantoms : & TokenStream , features : & TokenStream ) -> TokenStream {
622- if self . reader . type_def_flags ( def) . winrt ( ) {
622+ if self . reader . type_def_flags ( def) . contains ( TypeAttributes :: WINRT ) {
623623 let type_signature = if self . reader . type_def_kind ( def) == TypeKind :: Class {
624624 let type_signature = Literal :: byte_string ( self . reader . type_def_signature ( def, generics) . as_bytes ( ) ) ;
625625 quote ! { :: windows:: core:: ConstBuffer :: from_slice( #type_signature) }
@@ -673,7 +673,7 @@ impl<'a> Gen<'a> {
673673 }
674674 }
675675 pub fn runtime_name_trait ( & self , def : TypeDef , _generics : & [ Type ] , name : & TokenStream , constraints : & TokenStream , features : & TokenStream ) -> TokenStream {
676- if self . reader . type_def_flags ( def) . winrt ( ) {
676+ if self . reader . type_def_flags ( def) . contains ( TypeAttributes :: WINRT ) {
677677 // TODO: this needs to use a ConstBuffer-like facility to accomodate generics
678678 let runtime_name = format ! ( "{}" , self . reader. type_def_type_name( def) ) ;
679679
@@ -793,7 +793,7 @@ impl<'a> Gen<'a> {
793793 }
794794 }
795795 pub fn vtbl_signature ( & self , def : TypeDef , _generics : & [ Type ] , signature : & Signature ) -> TokenStream {
796- let is_winrt = self . reader . type_def_flags ( def) . winrt ( ) ;
796+ let is_winrt = self . reader . type_def_flags ( def) . contains ( TypeAttributes :: WINRT ) ;
797797 let hresult = self . type_name ( & Type :: HRESULT ) ;
798798
799799 let ( trailing_return_type, return_type, udt_return_type) = if is_winrt {
@@ -826,7 +826,7 @@ impl<'a> Gen<'a> {
826826 let abi = self . type_abi_name ( & p. ty ) ;
827827 let abi_size_name: TokenStream = format ! ( "{}_array_size" , self . reader. param_name( p. def) ) . into ( ) ;
828828
829- if self . reader . param_flags ( p. def ) . input ( ) {
829+ if self . reader . param_flags ( p. def ) . contains ( ParamAttributes :: INPUT ) {
830830 if p. ty . is_winrt_array ( ) {
831831 quote ! { #abi_size_name: u32 , #name: * const #abi, }
832832 } else if p. ty . is_winrt_const_ref ( ) {
@@ -894,7 +894,7 @@ impl<'a> Gen<'a> {
894894 let flags = self . reader . param_flags ( param. def ) ;
895895 match param. kind {
896896 SignatureParamKind :: ArrayFixed ( _) | SignatureParamKind :: ArrayRelativeLen ( _) | SignatureParamKind :: ArrayRelativeByteLen ( _) => {
897- let map = if flags. optional ( ) {
897+ let map = if flags. contains ( ParamAttributes :: OPTIONAL ) {
898898 quote ! { #name. as_deref( ) . map_or( :: core:: ptr:: null( ) , |slice|slice. as_ptr( ) ) }
899899 } else {
900900 quote ! { #name. as_ptr( ) }
@@ -904,7 +904,7 @@ impl<'a> Gen<'a> {
904904 SignatureParamKind :: ArrayRelativePtr ( relative) => {
905905 let name = self . param_name ( params[ relative] . def ) ;
906906 let flags = self . reader . param_flags ( params[ relative] . def ) ;
907- if flags. optional ( ) {
907+ if flags. contains ( ParamAttributes :: OPTIONAL ) {
908908 quote ! { #name. as_deref( ) . map_or( 0 , |slice|slice. len( ) as _) , }
909909 } else {
910910 quote ! { #name. len( ) as _, }
@@ -920,7 +920,7 @@ impl<'a> Gen<'a> {
920920 quote ! { #name. into( ) , }
921921 }
922922 SignatureParamKind :: OptionalPointer => {
923- if flags. output ( ) {
923+ if flags. contains ( ParamAttributes :: OUTPUT ) {
924924 quote ! { :: core:: mem:: transmute( #name. unwrap_or( :: std:: ptr:: null_mut( ) ) ) , }
925925 } else {
926926 quote ! { :: core:: mem:: transmute( #name. unwrap_or( :: std:: ptr:: null( ) ) ) , }
@@ -967,12 +967,12 @@ impl<'a> Gen<'a> {
967967 let ty = param. ty . deref ( ) ;
968968 let ty = self . type_default_name ( & ty) ;
969969 let len = Literal :: u32_unsuffixed ( fixed as _ ) ;
970- let ty = if self . reader . param_flags ( param. def ) . output ( ) {
970+ let ty = if self . reader . param_flags ( param. def ) . contains ( ParamAttributes :: OUTPUT ) {
971971 quote ! { & mut [ #ty; #len] }
972972 } else {
973973 quote ! { & [ #ty; #len] }
974974 } ;
975- if self . reader . param_flags ( param. def ) . optional ( ) {
975+ if self . reader . param_flags ( param. def ) . contains ( ParamAttributes :: OPTIONAL ) {
976976 tokens. combine ( & quote ! { #name: :: core:: option:: Option <#ty>, } ) ;
977977 } else {
978978 tokens. combine ( & quote ! { #name: #ty, } ) ;
@@ -981,24 +981,24 @@ impl<'a> Gen<'a> {
981981 SignatureParamKind :: ArrayRelativeLen ( _) => {
982982 let ty = param. ty . deref ( ) ;
983983 let ty = self . type_default_name ( & ty) ;
984- let ty = if self . reader . param_flags ( param. def ) . output ( ) {
984+ let ty = if self . reader . param_flags ( param. def ) . contains ( ParamAttributes :: OUTPUT ) {
985985 quote ! { & mut [ #ty] }
986986 } else {
987987 quote ! { & [ #ty] }
988988 } ;
989- if self . reader . param_flags ( param. def ) . optional ( ) {
989+ if self . reader . param_flags ( param. def ) . contains ( ParamAttributes :: OPTIONAL ) {
990990 tokens. combine ( & quote ! { #name: :: core:: option:: Option <#ty>, } ) ;
991991 } else {
992992 tokens. combine ( & quote ! { #name: #ty, } ) ;
993993 }
994994 }
995995 SignatureParamKind :: ArrayRelativeByteLen ( _) => {
996- let ty = if self . reader . param_flags ( param. def ) . output ( ) {
996+ let ty = if self . reader . param_flags ( param. def ) . contains ( ParamAttributes :: OUTPUT ) {
997997 quote ! { & mut [ u8 ] }
998998 } else {
999999 quote ! { & [ u8 ] }
10001000 } ;
1001- if self . reader . param_flags ( param. def ) . optional ( ) {
1001+ if self . reader . param_flags ( param. def ) . contains ( ParamAttributes :: OPTIONAL ) {
10021002 tokens. combine ( & quote ! { #name: :: core:: option:: Option <#ty>, } ) ;
10031003 } else {
10041004 tokens. combine ( & quote ! { #name: #ty, } ) ;
@@ -1029,7 +1029,7 @@ impl<'a> Gen<'a> {
10291029 }
10301030
10311031 pub fn impl_signature ( & self , def : TypeDef , signature : & Signature ) -> TokenStream {
1032- if self . reader . type_def_flags ( def) . winrt ( ) {
1032+ if self . reader . type_def_flags ( def) . contains ( TypeAttributes :: WINRT ) {
10331033 let is_delegate = self . reader . type_def_kind ( def) == TypeKind :: Delegate ;
10341034 let params = signature. params . iter ( ) . map ( |p| self . winrt_produce_type ( p, !is_delegate) ) ;
10351035
@@ -1084,7 +1084,7 @@ impl<'a> Gen<'a> {
10841084 fn winrt_produce_type ( & self , param : & SignatureParam , include_param_names : bool ) -> TokenStream {
10851085 let default_type = self . type_default_name ( & param. ty ) ;
10861086
1087- let sig = if self . reader . param_flags ( param. def ) . input ( ) {
1087+ let sig = if self . reader . param_flags ( param. def ) . contains ( ParamAttributes :: INPUT ) {
10881088 if param. ty . is_winrt_array ( ) {
10891089 quote ! { & [ #default_type] }
10901090 } else if self . reader . type_is_primitive ( & param. ty ) {
@@ -1115,7 +1115,7 @@ impl<'a> Gen<'a> {
11151115 let name = self . param_name ( param. def ) ;
11161116 let kind = self . type_default_name ( & param. ty ) ;
11171117
1118- if self . reader . param_flags ( param. def ) . input ( ) {
1118+ if self . reader . param_flags ( param. def ) . contains ( ParamAttributes :: INPUT ) {
11191119 if self . reader . type_is_primitive ( & param. ty ) {
11201120 quote ! { #name: #kind, }
11211121 } else if self . reader . type_is_nullable ( & param. ty ) {
0 commit comments