@@ -6,7 +6,7 @@ use syn::parse::{Parse, ParseStream, Parser};
6
6
use syn:: punctuated:: Punctuated ;
7
7
use syn:: spanned:: Spanned ;
8
8
use 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} ;
10
10
11
11
/// The input to our macro; just a list of `field: value` items.
12
12
#[ derive( Debug ) ]
@@ -50,6 +50,8 @@ pub struct StructuredInput {
50
50
pub emit_types : Vec < Ident > ,
51
51
/// Skip these functions
52
52
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 ,
53
55
/// Invoke only for these functions
54
56
pub only : Option < Vec < Ident > > ,
55
57
/// Attributes that get applied to specific functions
@@ -70,6 +72,7 @@ impl StructuredInput {
70
72
let cb_expr = expect_field ( & mut map, "callback" ) ?;
71
73
let emit_types_expr = expect_field ( & mut map, "emit_types" ) . ok ( ) ;
72
74
let skip_expr = expect_field ( & mut map, "skip" ) . ok ( ) ;
75
+ let skip_f16_f128 = expect_field ( & mut map, "skip_f16_f128" ) . ok ( ) ;
73
76
let only_expr = expect_field ( & mut map, "only" ) . ok ( ) ;
74
77
let attr_expr = expect_field ( & mut map, "attributes" ) . ok ( ) ;
75
78
let extra = expect_field ( & mut map, "extra" ) . ok ( ) ;
@@ -93,6 +96,11 @@ impl StructuredInput {
93
96
None => Vec :: new ( ) ,
94
97
} ;
95
98
99
+ let skip_f16_f128 = match skip_f16_f128 {
100
+ Some ( expr) => expect_litbool ( expr) ?. value ,
101
+ None => false ,
102
+ } ;
103
+
96
104
let only_span = only_expr. as_ref ( ) . map ( |expr| expr. span ( ) ) ;
97
105
let only = match only_expr {
98
106
Some ( expr) => Some ( Parser :: parse2 ( parse_ident_array, expr. into_token_stream ( ) ) ?) ,
@@ -122,6 +130,7 @@ impl StructuredInput {
122
130
callback : expect_ident ( cb_expr) ?,
123
131
emit_types,
124
132
skip,
133
+ skip_f16_f128,
125
134
only,
126
135
only_span,
127
136
attributes,
@@ -220,6 +229,11 @@ fn expect_ident(expr: Expr) -> syn::Result<Ident> {
220
229
syn:: parse2 ( expr. into_token_stream ( ) )
221
230
}
222
231
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
+
223
237
/// Parse either a single identifier (`foo`) or an array of identifiers (`[foo, bar, baz]`).
224
238
fn parse_ident_or_array ( input : ParseStream ) -> syn:: Result < Vec < Ident > > {
225
239
if !input. peek ( token:: Bracket ) {
0 commit comments