@@ -2,7 +2,6 @@ extern crate bindgen;
2
2
extern crate cc;
3
3
extern crate num_cpus;
4
4
extern crate pkg_config;
5
- extern crate regex;
6
5
7
6
use std:: env;
8
7
use std:: fs:: { self , File } ;
@@ -14,7 +13,6 @@ use std::str;
14
13
use bindgen:: callbacks:: {
15
14
EnumVariantCustomBehavior , EnumVariantValue , IntKind , MacroParsingBehavior , ParseCallbacks ,
16
15
} ;
17
- use regex:: Regex ;
18
16
19
17
#[ derive( Debug ) ]
20
18
struct Library {
@@ -76,22 +74,22 @@ struct Callbacks;
76
74
77
75
impl ParseCallbacks for Callbacks {
78
76
fn int_macro ( & self , _name : & str , value : i64 ) -> Option < IntKind > {
79
- let ch_layout = Regex :: new ( r"^AV_CH" ) . unwrap ( ) ;
80
- let codec_cap = Regex :: new ( r"^AV_CODEC_CAP" ) . unwrap ( ) ;
81
- let codec_flag = Regex :: new ( r"^AV_CODEC_FLAG" ) . unwrap ( ) ;
82
- let error_max_size = Regex :: new ( r"^ AV_ERROR_MAX_STRING_SIZE") . unwrap ( ) ;
77
+ let ch_layout_prefix = "AV_CH_" ;
78
+ let codec_cap_prefix = "AV_CODEC_CAP_" ;
79
+ let codec_flag_prefix = "AV_CODEC_FLAG_" ;
80
+ let error_max_size = " AV_ERROR_MAX_STRING_SIZE";
83
81
84
82
if value >= i64:: min_value ( ) as i64
85
83
&& value <= i64:: max_value ( ) as i64
86
- && ch_layout . is_match ( _name )
84
+ && _name . starts_with ( ch_layout_prefix )
87
85
{
88
86
Some ( IntKind :: ULongLong )
89
87
} else if value >= i32:: min_value ( ) as i64
90
88
&& value <= i32:: max_value ( ) as i64
91
- && ( codec_cap . is_match ( _name ) || codec_flag . is_match ( _name ) )
89
+ && ( _name . starts_with ( codec_cap_prefix ) || _name . starts_with ( codec_flag_prefix ) )
92
90
{
93
91
Some ( IntKind :: UInt )
94
- } else if error_max_size . is_match ( _name) {
92
+ } else if _name == error_max_size {
95
93
Some ( IntKind :: Custom {
96
94
name : "usize" ,
97
95
is_signed : false ,
@@ -109,8 +107,8 @@ impl ParseCallbacks for Callbacks {
109
107
original_variant_name : & str ,
110
108
_variant_value : EnumVariantValue ,
111
109
) -> Option < EnumVariantCustomBehavior > {
112
- let dummy_codec_id = Regex :: new ( r"^AV_CODEC_ID_FIRST" ) . unwrap ( ) ;
113
- if dummy_codec_id . is_match ( original_variant_name ) {
110
+ let dummy_codec_id_prefix = "AV_CODEC_ID_FIRST_" ;
111
+ if original_variant_name . starts_with ( dummy_codec_id_prefix ) {
114
112
Some ( EnumVariantCustomBehavior :: Constify )
115
113
} else {
116
114
None
0 commit comments