@@ -6,7 +6,7 @@ use syn::parse::{Parse, ParseStream, Parser};
66use syn:: punctuated:: Punctuated ;
77use syn:: spanned:: Spanned ;
88use syn:: token:: { self , Comma } ;
9- use syn:: { Arm , Attribute , Expr , ExprMatch , Ident , Meta , Token , bracketed} ;
9+ use syn:: { Arm , Attribute , Expr , ExprMatch , Ident , LitBool , Meta , Token , bracketed} ;
1010
1111/// The input to our macro; just a list of `field: value` items.
1212#[ derive( Debug ) ]
@@ -50,6 +50,8 @@ pub struct StructuredInput {
5050 pub emit_types : Vec < Ident > ,
5151 /// Skip these functions
5252 pub skip : Vec < Ident > ,
53+ /// If true, omit f16 and f128 functions that aren't present in other libraries.
54+ pub skip_f16_f128 : bool ,
5355 /// Invoke only for these functions
5456 pub only : Option < Vec < Ident > > ,
5557 /// Attributes that get applied to specific functions
@@ -70,6 +72,7 @@ impl StructuredInput {
7072 let cb_expr = expect_field ( & mut map, "callback" ) ?;
7173 let emit_types_expr = expect_field ( & mut map, "emit_types" ) . ok ( ) ;
7274 let skip_expr = expect_field ( & mut map, "skip" ) . ok ( ) ;
75+ let skip_f16_f128 = expect_field ( & mut map, "skip_f16_f128" ) . ok ( ) ;
7376 let only_expr = expect_field ( & mut map, "only" ) . ok ( ) ;
7477 let attr_expr = expect_field ( & mut map, "attributes" ) . ok ( ) ;
7578 let extra = expect_field ( & mut map, "extra" ) . ok ( ) ;
@@ -93,6 +96,11 @@ impl StructuredInput {
9396 None => Vec :: new ( ) ,
9497 } ;
9598
99+ let skip_f16_f128 = match skip_f16_f128 {
100+ Some ( expr) => expect_litbool ( expr) ?. value ,
101+ None => false ,
102+ } ;
103+
96104 let only_span = only_expr. as_ref ( ) . map ( |expr| expr. span ( ) ) ;
97105 let only = match only_expr {
98106 Some ( expr) => Some ( Parser :: parse2 ( parse_ident_array, expr. into_token_stream ( ) ) ?) ,
@@ -122,6 +130,7 @@ impl StructuredInput {
122130 callback : expect_ident ( cb_expr) ?,
123131 emit_types,
124132 skip,
133+ skip_f16_f128,
125134 only,
126135 only_span,
127136 attributes,
@@ -220,6 +229,11 @@ fn expect_ident(expr: Expr) -> syn::Result<Ident> {
220229 syn:: parse2 ( expr. into_token_stream ( ) )
221230}
222231
232+ /// Coerce an expression into a simple keyword.
233+ fn expect_litbool ( expr : Expr ) -> syn:: Result < LitBool > {
234+ syn:: parse2 ( expr. into_token_stream ( ) )
235+ }
236+
223237/// Parse either a single identifier (`foo`) or an array of identifiers (`[foo, bar, baz]`).
224238fn parse_ident_or_array ( input : ParseStream ) -> syn:: Result < Vec < Ident > > {
225239 if !input. peek ( token:: Bracket ) {
0 commit comments