7
7
#![ deny( missing_docs) ]
8
8
#![ deny( warnings) ]
9
9
#![ deny( unused_extern_crates) ]
10
- // We internally use the deprecated BindgenOptions all over the place. Once we
11
- // remove its `pub` declaration, we can un-deprecate it and remove this pragma.
12
- #![ allow( deprecated) ]
13
10
// To avoid rather annoying warnings when matching with CXCursor_xxx as a
14
11
// constant.
15
12
#![ allow( non_upper_case_globals) ]
@@ -1101,152 +1098,149 @@ impl Builder {
1101
1098
}
1102
1099
1103
1100
/// Configuration options for generated bindings.
1104
- ///
1105
- /// Deprecated: use a `Builder` instead.
1106
1101
#[ derive( Debug ) ]
1107
- #[ deprecated]
1108
- pub struct BindgenOptions {
1102
+ struct BindgenOptions {
1109
1103
/// The set of types that have been blacklisted and should not appear
1110
1104
/// anywhere in the generated code.
1111
- pub blacklisted_types : RegexSet ,
1105
+ blacklisted_types : RegexSet ,
1112
1106
1113
1107
/// The set of types that should be treated as opaque structures in the
1114
1108
/// generated code.
1115
- pub opaque_types : RegexSet ,
1109
+ opaque_types : RegexSet ,
1116
1110
1117
1111
/// The set of types that we should have bindings for in the generated
1118
1112
/// code.
1119
1113
///
1120
1114
/// This includes all types transitively reachable from any type in this
1121
1115
/// set. One might think of whitelisted types/vars/functions as GC roots,
1122
1116
/// and the generated Rust code as including everything that gets marked.
1123
- pub whitelisted_types : RegexSet ,
1117
+ whitelisted_types : RegexSet ,
1124
1118
1125
1119
/// Whitelisted functions. See docs for `whitelisted_types` for more.
1126
- pub whitelisted_functions : RegexSet ,
1120
+ whitelisted_functions : RegexSet ,
1127
1121
1128
1122
/// Whitelisted variables. See docs for `whitelisted_types` for more.
1129
- pub whitelisted_vars : RegexSet ,
1123
+ whitelisted_vars : RegexSet ,
1130
1124
1131
1125
/// The enum patterns to mark an enum as bitfield.
1132
- pub bitfield_enums : RegexSet ,
1126
+ bitfield_enums : RegexSet ,
1133
1127
1134
1128
/// The enum patterns to mark an enum as a Rust enum.
1135
- pub rustified_enums : RegexSet ,
1129
+ rustified_enums : RegexSet ,
1136
1130
1137
1131
/// The enum patterns to mark an enum as a module of constants.
1138
- pub constified_enum_modules : RegexSet ,
1132
+ constified_enum_modules : RegexSet ,
1139
1133
1140
1134
/// Whether we should generate builtins or not.
1141
- pub builtins : bool ,
1135
+ builtins : bool ,
1142
1136
1143
1137
/// The set of libraries we should link in the generated Rust code.
1144
- pub links : Vec < ( String , LinkType ) > ,
1138
+ links : Vec < ( String , LinkType ) > ,
1145
1139
1146
1140
/// True if we should dump the Clang AST for debugging purposes.
1147
- pub emit_ast : bool ,
1141
+ emit_ast : bool ,
1148
1142
1149
1143
/// True if we should dump our internal IR for debugging purposes.
1150
- pub emit_ir : bool ,
1144
+ emit_ir : bool ,
1151
1145
1152
1146
/// Output graphviz dot file.
1153
- pub emit_ir_graphviz : Option < String > ,
1147
+ emit_ir_graphviz : Option < String > ,
1154
1148
1155
1149
/// True if we should emulate C++ namespaces with Rust modules in the
1156
1150
/// generated bindings.
1157
- pub enable_cxx_namespaces : bool ,
1151
+ enable_cxx_namespaces : bool ,
1158
1152
1159
1153
/// True if we should avoid mangling names with namespaces.
1160
- pub disable_name_namespacing : bool ,
1154
+ disable_name_namespacing : bool ,
1161
1155
1162
1156
/// True if we should generate layout tests for generated structures.
1163
- pub layout_tests : bool ,
1157
+ layout_tests : bool ,
1164
1158
1165
1159
/// True if we should derive Copy trait implementations for C/C++ structures
1166
1160
/// and types.
1167
- pub derive_copy : bool ,
1161
+ derive_copy : bool ,
1168
1162
1169
1163
/// True if we should derive Debug trait implementations for C/C++ structures
1170
1164
/// and types.
1171
- pub derive_debug : bool ,
1165
+ derive_debug : bool ,
1172
1166
1173
1167
/// True if we should implement the Debug trait for C/C++ structures and types
1174
1168
/// that do not support automatically deriving Debug.
1175
- pub impl_debug : bool ,
1169
+ impl_debug : bool ,
1176
1170
1177
1171
/// True if we should derive Default trait implementations for C/C++ structures
1178
1172
/// and types.
1179
- pub derive_default : bool ,
1173
+ derive_default : bool ,
1180
1174
1181
1175
/// True if we should derive Hash trait implementations for C/C++ structures
1182
1176
/// and types.
1183
- pub derive_hash : bool ,
1177
+ derive_hash : bool ,
1184
1178
1185
1179
/// True if we should derive PartialEq trait implementations for C/C++ structures
1186
1180
/// and types.
1187
- pub derive_partialeq : bool ,
1181
+ derive_partialeq : bool ,
1188
1182
1189
1183
/// True if we should derive Eq trait implementations for C/C++ structures
1190
1184
/// and types.
1191
- pub derive_eq : bool ,
1185
+ derive_eq : bool ,
1192
1186
1193
1187
/// True if we should avoid using libstd to use libcore instead.
1194
- pub use_core : bool ,
1188
+ use_core : bool ,
1195
1189
1196
1190
/// An optional prefix for the "raw" types, like `c_int`, `c_void`...
1197
- pub ctypes_prefix : Option < String > ,
1191
+ ctypes_prefix : Option < String > ,
1198
1192
1199
1193
/// Whether to time the bindgen phases.
1200
- pub time_phases : bool ,
1194
+ time_phases : bool ,
1201
1195
1202
1196
/// True if we should generate constant names that are **directly** under
1203
1197
/// namespaces.
1204
- pub namespaced_constants : bool ,
1198
+ namespaced_constants : bool ,
1205
1199
1206
1200
/// True if we should use MSVC name mangling rules.
1207
- pub msvc_mangling : bool ,
1201
+ msvc_mangling : bool ,
1208
1202
1209
1203
/// Whether we should convert float types to f32/f64 types.
1210
- pub convert_floats : bool ,
1204
+ convert_floats : bool ,
1211
1205
1212
1206
/// The set of raw lines to prepend to the generated Rust code.
1213
- pub raw_lines : Vec < String > ,
1207
+ raw_lines : Vec < String > ,
1214
1208
1215
1209
/// The set of arguments to pass straight through to Clang.
1216
- pub clang_args : Vec < String > ,
1210
+ clang_args : Vec < String > ,
1217
1211
1218
1212
/// The input header file.
1219
- pub input_header : Option < String > ,
1213
+ input_header : Option < String > ,
1220
1214
1221
1215
/// Unsaved files for input.
1222
- pub input_unsaved_files : Vec < clang:: UnsavedFile > ,
1216
+ input_unsaved_files : Vec < clang:: UnsavedFile > ,
1223
1217
1224
1218
/// A user-provided visitor to allow customizing different kinds of
1225
1219
/// situations.
1226
- pub parse_callbacks : Option < Box < callbacks:: ParseCallbacks > > ,
1220
+ parse_callbacks : Option < Box < callbacks:: ParseCallbacks > > ,
1227
1221
1228
1222
/// Which kind of items should we generate? By default, we'll generate all
1229
1223
/// of them.
1230
- pub codegen_config : CodegenConfig ,
1224
+ codegen_config : CodegenConfig ,
1231
1225
1232
1226
/// Whether to treat inline namespaces conservatively.
1233
1227
///
1234
1228
/// See the builder method description for more details.
1235
- pub conservative_inline_namespaces : bool ,
1229
+ conservative_inline_namespaces : bool ,
1236
1230
1237
1231
/// Wether to keep documentation comments in the generated output. See the
1238
1232
/// documentation for more details.
1239
- pub generate_comments : bool ,
1233
+ generate_comments : bool ,
1240
1234
1241
1235
/// Whether to generate inline functions. Defaults to false.
1242
- pub generate_inline_functions : bool ,
1236
+ generate_inline_functions : bool ,
1243
1237
1244
1238
/// Wether to whitelist types recursively. Defaults to true.
1245
- pub whitelist_recursively : bool ,
1239
+ whitelist_recursively : bool ,
1246
1240
1247
1241
/// Intead of emitting 'use objc;' to files generated from objective c files,
1248
1242
/// generate '#[macro_use] extern crate objc;'
1249
- pub objc_extern_crate : bool ,
1243
+ objc_extern_crate : bool ,
1250
1244
1251
1245
/// Whether to use the clang-provided name mangling. This is true and
1252
1246
/// probably needed for C++ features.
@@ -1255,10 +1249,10 @@ pub struct BindgenOptions {
1255
1249
/// some cases for non-mangled functions, see [1], so we allow disabling it.
1256
1250
///
1257
1251
/// [1]: https://github.com/rust-lang-nursery/rust-bindgen/issues/528
1258
- pub enable_mangling : bool ,
1252
+ enable_mangling : bool ,
1259
1253
1260
1254
/// Whether to prepend the enum name to bitfield or constant variants.
1261
- pub prepend_enum_name : bool ,
1255
+ prepend_enum_name : bool ,
1262
1256
1263
1257
/// Version of the Rust compiler to target
1264
1258
rust_target : RustTarget ,
@@ -1267,11 +1261,11 @@ pub struct BindgenOptions {
1267
1261
rust_features : RustFeatures ,
1268
1262
1269
1263
/// Whether rustfmt should format the generated bindings.
1270
- pub rustfmt_bindings : bool ,
1264
+ rustfmt_bindings : bool ,
1271
1265
1272
1266
/// The absolute path to the rustfmt configuration file, if None, the standard rustfmt
1273
1267
/// options are used.
1274
- pub rustfmt_configuration_file : Option < PathBuf > ,
1268
+ rustfmt_configuration_file : Option < PathBuf > ,
1275
1269
}
1276
1270
1277
1271
/// TODO(emilio): This is sort of a lie (see the error message that results from
@@ -1299,11 +1293,6 @@ impl BindgenOptions {
1299
1293
self . rust_features = rust_target. into ( ) ;
1300
1294
}
1301
1295
1302
- /// Get target Rust version
1303
- pub fn rust_target ( & self ) -> RustTarget {
1304
- self . rust_target
1305
- }
1306
-
1307
1296
/// Get features supported by target Rust version
1308
1297
pub fn rust_features ( & self ) -> RustFeatures {
1309
1298
self . rust_features
@@ -1408,10 +1397,7 @@ pub struct Bindings {
1408
1397
1409
1398
impl Bindings {
1410
1399
/// Generate bindings for the given options.
1411
- ///
1412
- /// Deprecated - use a `Builder` instead
1413
- #[ deprecated]
1414
- pub fn generate (
1400
+ pub ( crate ) fn generate (
1415
1401
mut options : BindgenOptions ,
1416
1402
) -> Result < Bindings , ( ) > {
1417
1403
ensure_libclang_is_loaded ( ) ;
@@ -1737,8 +1723,8 @@ fn commandline_flag_unit_test_function() {
1737
1723
//Test 2
1738
1724
let bindings = :: builder ( )
1739
1725
. header ( "input_header" )
1740
- . whitelisted_type ( "Distinct_Type" )
1741
- . whitelisted_function ( "safe_function" ) ;
1726
+ . whitelist_type ( "Distinct_Type" )
1727
+ . whitelist_function ( "safe_function" ) ;
1742
1728
1743
1729
let command_line_flags = bindings. command_line_flags ( ) ;
1744
1730
let test_cases = vec ! [
0 commit comments