@@ -73,6 +73,7 @@ fn do_ctest() {
73
73
}
74
74
}
75
75
76
+ #[ expect( unused) ]
76
77
fn ctest_old_cfg ( ) -> ctest_old:: TestGenerator {
77
78
ctest_old:: TestGenerator :: new ( )
78
79
}
@@ -5077,11 +5078,11 @@ fn which_freebsd() -> Option<i32> {
5077
5078
fn test_haiku ( target : & str ) {
5078
5079
assert ! ( target. contains( "haiku" ) ) ;
5079
5080
5080
- let mut cfg = ctest_old_cfg ( ) ;
5081
+ let mut cfg = ctest_cfg ( ) ;
5081
5082
cfg. flag ( "-Wno-deprecated-declarations" ) ;
5082
5083
cfg. define ( "__USE_GNU" , Some ( "1" ) ) ;
5083
5084
cfg. define ( "_GNU_SOURCE" , None ) ;
5084
- cfg. language ( ctest_old :: Lang :: CXX ) ;
5085
+ cfg. language ( ctest :: Language :: CXX ) ;
5085
5086
5086
5087
// POSIX API
5087
5088
headers ! { cfg:
@@ -5216,11 +5217,12 @@ fn test_haiku(target: &str) {
5216
5217
"support/TypeConstants.h"
5217
5218
}
5218
5219
5219
- cfg. skip_struct ( move |ty| {
5220
- if ty. starts_with ( "__c_anonymous_" ) {
5220
+ cfg. skip_union ( |union_| union_. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
5221
+ cfg. skip_struct ( move |struct_| {
5222
+ if struct_. ident ( ) . starts_with ( "__c_anonymous_" ) {
5221
5223
return true ;
5222
5224
}
5223
- match ty {
5225
+ match struct_ . ident ( ) {
5224
5226
// FIXME(haiku): locale_t does not exist on Haiku
5225
5227
"locale_t" => true ,
5226
5228
// FIXME(haiku): rusage has a different layout on Haiku
@@ -5248,8 +5250,8 @@ fn test_haiku(target: &str) {
5248
5250
}
5249
5251
} ) ;
5250
5252
5251
- cfg. skip_type ( move |ty| {
5252
- match ty {
5253
+ cfg. skip_alias ( move |ty| {
5254
+ match ty. ident ( ) {
5253
5255
// FIXME(haiku): locale_t does not exist on Haiku
5254
5256
"locale_t" => true ,
5255
5257
// These cause errors, to be reviewed in the future
@@ -5262,9 +5264,9 @@ fn test_haiku(target: &str) {
5262
5264
}
5263
5265
} ) ;
5264
5266
5265
- cfg. skip_fn ( move |name | {
5267
+ cfg. skip_fn ( move |func | {
5266
5268
// skip those that are manually verified
5267
- match name {
5269
+ match func . ident ( ) {
5268
5270
// FIXME(haiku): does not exist on haiku
5269
5271
"open_wmemstream" => true ,
5270
5272
"mlockall" | "munlockall" => true ,
@@ -5287,8 +5289,8 @@ fn test_haiku(target: &str) {
5287
5289
}
5288
5290
} ) ;
5289
5291
5290
- cfg. skip_const ( move |name | {
5291
- match name {
5292
+ cfg. skip_const ( move |constant | {
5293
+ match constant . ident ( ) {
5292
5294
// FIXME(haiku): these constants do not exist on Haiku
5293
5295
"DT_UNKNOWN" | "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK"
5294
5296
| "DT_SOCK" => true ,
@@ -5313,8 +5315,8 @@ fn test_haiku(target: &str) {
5313
5315
}
5314
5316
} ) ;
5315
5317
5316
- cfg. skip_field ( move |struct_, field| {
5317
- match ( struct_, field) {
5318
+ cfg. skip_struct_field ( move |struct_, field| {
5319
+ match ( struct_. ident ( ) , field. ident ( ) ) {
5318
5320
// FIXME(time): the stat struct actually has timespec members, whereas
5319
5321
// the current representation has these unpacked.
5320
5322
( "stat" , "st_atime" ) => true ,
@@ -5348,7 +5350,14 @@ fn test_haiku(target: &str) {
5348
5350
_ => false ,
5349
5351
} ) ;
5350
5352
5351
- cfg. type_name ( move |ty, is_struct, is_union| {
5353
+ let c_enums = [
5354
+ "directory_which" ,
5355
+ "path_base_directory" ,
5356
+ "cpu_platform" ,
5357
+ "cpu_vendor" ,
5358
+ ] ;
5359
+ cfg. alias_is_c_enum ( move |e| c_enums. contains ( & e) ) ;
5360
+ cfg. rename_struct_ty ( move |ty| {
5352
5361
match ty {
5353
5362
// Just pass all these through, no need for a "struct" prefix
5354
5363
"area_info"
@@ -5372,34 +5381,29 @@ fn test_haiku(target: &str) {
5372
5381
| "cpu_topology_node_info"
5373
5382
| "cpu_topology_root_info"
5374
5383
| "cpu_topology_package_info"
5375
- | "cpu_topology_core_info" => ty. to_string ( ) ,
5376
-
5377
- // enums don't need a prefix
5378
- "directory_which" | "path_base_directory" | "cpu_platform" | "cpu_vendor" => {
5379
- ty. to_string ( )
5380
- }
5384
+ | "cpu_topology_core_info" => Some ( ty. to_string ( ) ) ,
5381
5385
5382
- t if is_union => format ! ( "union {t}" ) ,
5383
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
5384
- t if is_struct => format ! ( "struct {t}" ) ,
5385
- t => t. to_string ( ) ,
5386
+ t if t. ends_with ( "_t" ) => Some ( t. to_string ( ) ) ,
5387
+ _ => None ,
5386
5388
}
5387
5389
} ) ;
5388
5390
5389
- cfg. field_name ( move |struct_, field| {
5390
- match field {
5391
+ cfg. rename_struct_field ( move |struct_, field| {
5392
+ let struct_ = struct_. ident ( ) ;
5393
+ match field. ident ( ) {
5391
5394
// Field is named `type` in C but that is a Rust keyword,
5392
5395
// so these fields are translated to `type_` in the bindings.
5393
- "type_" if struct_ == "object_wait_info" => "type" . to_string ( ) ,
5394
- "type_" if struct_ == "sem_t" => "type" . to_string ( ) ,
5395
- "type_" if struct_ == "attr_info" => "type" . to_string ( ) ,
5396
- "type_" if struct_ == "index_info" => "type" . to_string ( ) ,
5397
- "type_" if struct_ == "cpu_topology_node_info" => "type" . to_string ( ) ,
5398
- "image_type" if struct_ == "image_info" => "type" . to_string ( ) ,
5399
- s => s . to_string ( ) ,
5396
+ "type_" if struct_ == "object_wait_info" => Some ( "type" . to_string ( ) ) ,
5397
+ "type_" if struct_ == "sem_t" => Some ( "type" . to_string ( ) ) ,
5398
+ "type_" if struct_ == "attr_info" => Some ( "type" . to_string ( ) ) ,
5399
+ "type_" if struct_ == "index_info" => Some ( "type" . to_string ( ) ) ,
5400
+ "type_" if struct_ == "cpu_topology_node_info" => Some ( "type" . to_string ( ) ) ,
5401
+ "image_type" if struct_ == "image_info" => Some ( "type" . to_string ( ) ) ,
5402
+ _ => None ,
5400
5403
}
5401
5404
} ) ;
5402
- cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "ctest_output.rs" ) ;
5405
+
5406
+ ctest:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
5403
5407
}
5404
5408
5405
5409
fn test_aix ( target : & str ) {
0 commit comments