File tree 4 files changed +22
-5
lines changed
4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 1
1
extern crate bindgen;
2
2
extern crate cc;
3
3
4
- use bindgen:: callbacks:: { MacroParsingBehavior , ParseCallbacks } ;
4
+ use bindgen:: callbacks:: { MacroParsingBehavior , ParseCallbacks , IntKind } ;
5
5
use bindgen:: Builder ;
6
6
use std:: collections:: HashSet ;
7
7
use std:: env;
@@ -59,6 +59,17 @@ impl ParseCallbacks for MacroCallback {
59
59
_ => { }
60
60
}
61
61
}
62
+
63
+ fn int_macro ( & self , name : & str , _value : i64 ) -> Option < IntKind > {
64
+ match name {
65
+ "TESTMACRO_CUSTOMINTKIND_PATH" => Some ( IntKind :: Custom {
66
+ name : "crate::MacroInteger" ,
67
+ is_signed : true ,
68
+ } ) ,
69
+
70
+ _ => None ,
71
+ }
72
+ }
62
73
}
63
74
64
75
impl Drop for MacroCallback {
Original file line number Diff line number Diff line change 5
5
#define TESTMACRO_INTEGER 42
6
6
#define TESTMACRO_STRING " Hello Preprocessor!"
7
7
#define TESTMACRO_STRING_EXPANDED TESTMACRO_STRING
8
+ #define TESTMACRO_CUSTOMINTKIND_PATH 123
8
9
9
10
#include < cwchar>
10
11
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ use std::os::raw::c_int;
11
11
#[ allow( unused) ]
12
12
use bindings:: testing:: Bar ; // This type is generated from module_raw_line.
13
13
14
+ type MacroInteger = isize ;
15
+
14
16
#[ test]
15
17
fn test_static_array ( ) {
16
18
let mut test = unsafe { bindings:: Test_COUNTDOWN . as_ptr ( ) } ;
@@ -242,3 +244,9 @@ fn test_item_rename() {
242
244
member : bindings:: bar { foo : 2 } ,
243
245
} ;
244
246
}
247
+
248
+ #[ test]
249
+ fn test_macro_customintkind_path ( ) {
250
+ let v: & std:: any:: Any = & bindings:: TESTMACRO_CUSTOMINTKIND_PATH ;
251
+ assert ! ( v. is:: <MacroInteger >( ) )
252
+ }
Original file line number Diff line number Diff line change @@ -3328,10 +3328,7 @@ impl TryToRustTy for Type {
3328
3328
IntKind :: I64 => Ok ( quote ! { i64 } ) ,
3329
3329
IntKind :: U64 => Ok ( quote ! { u64 } ) ,
3330
3330
IntKind :: Custom { name, .. } => {
3331
- let ident = ctx. rust_ident_raw ( name) ;
3332
- Ok ( quote ! {
3333
- #ident
3334
- } )
3331
+ Ok ( proc_macro2:: TokenStream :: from_str ( name) . unwrap ( ) )
3335
3332
}
3336
3333
IntKind :: U128 => {
3337
3334
Ok ( if ctx. options ( ) . rust_features . i128_and_u128 {
You can’t perform that action at this time.
0 commit comments