File tree 5 files changed +64
-19
lines changed
5 files changed +64
-19
lines changed Original file line number Diff line number Diff line change @@ -519,8 +519,8 @@ impl CodeGenerator for Type {
519
519
TypeKind :: BlockPointer |
520
520
TypeKind :: Reference ( ..) |
521
521
TypeKind :: TemplateRef ( ..) |
522
- TypeKind :: Function ( ..) |
523
522
TypeKind :: ResolvedTypeRef ( ..) |
523
+ TypeKind :: Function ( ..) |
524
524
TypeKind :: Named => {
525
525
// These items don't need code generation, they only need to be
526
526
// converted to rust types in fields, arguments, and such.
@@ -2057,7 +2057,7 @@ impl ToRustTy for Type {
2057
2057
. map ( |arg| arg. to_rust_ty ( ctx) )
2058
2058
. collect :: < Vec < _ > > ( ) ;
2059
2059
2060
- path. segments . last_mut ( ) . unwrap ( ) . parameters = if
2060
+ path. segments . last_mut ( ) . unwrap ( ) . parameters = if
2061
2061
template_args. is_empty ( ) {
2062
2062
None
2063
2063
} else {
Original file line number Diff line number Diff line change @@ -605,11 +605,17 @@ impl CompInfo {
605
605
CXCursor_UnionDecl |
606
606
CXCursor_ClassTemplate |
607
607
CXCursor_ClassDecl => {
608
+ // We can find non-semantic children here, see:
609
+ // https://github.com/servo/rust-bindgen/issues/482
610
+ if cur. semantic_parent ( ) != cursor {
611
+ return CXChildVisit_Continue ;
612
+ }
613
+
608
614
let inner = Item :: parse ( cur, Some ( potential_id) , ctx)
609
615
. expect ( "Inner ClassDecl" ) ;
610
- if !ci . inner_types . contains ( & inner ) {
611
- ci. inner_types . push ( inner) ;
612
- }
616
+
617
+ ci. inner_types . push ( inner) ;
618
+
613
619
// A declaration of an union or a struct without name could
614
620
// also be an unnamed field, unfortunately.
615
621
if cur. spelling ( ) . is_empty ( ) &&
Original file line number Diff line number Diff line change @@ -22,6 +22,24 @@ fn bindgen_test_layout_A_B() {
22
22
impl Clone for A_B {
23
23
fn clone ( & self ) -> Self { * self }
24
24
}
25
+ #[ repr( C ) ]
26
+ #[ derive( Debug , Copy ) ]
27
+ pub struct A_C {
28
+ pub baz : :: std:: os:: raw:: c_int ,
29
+ }
30
+ #[ test]
31
+ fn bindgen_test_layout_A_C ( ) {
32
+ assert_eq ! ( :: std:: mem:: size_of:: <A_C >( ) , 4usize ) ;
33
+ assert_eq ! ( :: std:: mem:: align_of:: <A_C >( ) , 4usize ) ;
34
+ }
35
+ impl Clone for A_C {
36
+ fn clone ( & self ) -> Self { * self }
37
+ }
38
+ #[ repr( C ) ]
39
+ #[ derive( Debug , Copy , Clone ) ]
40
+ pub struct A_D < T > {
41
+ pub foo : T ,
42
+ }
25
43
#[ test]
26
44
fn bindgen_test_layout_A ( ) {
27
45
assert_eq ! ( :: std:: mem:: size_of:: <A >( ) , 4usize ) ;
@@ -34,6 +52,15 @@ extern "C" {
34
52
#[ link_name = "var" ]
35
53
pub static mut var: A_B ;
36
54
}
55
+ #[ test]
56
+ fn __bindgen_test_layout_template_1 ( ) {
57
+ assert_eq ! ( :: std:: mem:: size_of:: <A_D <:: std:: os:: raw:: c_int>>( ) , 4usize ) ;
58
+ assert_eq ! ( :: std:: mem:: align_of:: <A_D <:: std:: os:: raw:: c_int>>( ) , 4usize ) ;
59
+ }
60
+ extern "C" {
61
+ #[ link_name = "baz" ]
62
+ pub static mut baz: A_D < :: std:: os:: raw:: c_int > ;
63
+ }
37
64
#[ repr( C ) ]
38
65
#[ derive( Debug , Copy ) ]
39
66
pub struct D {
Original file line number Diff line number Diff line change 7
7
#[ repr( C ) ]
8
8
#[ derive( Debug , Copy ) ]
9
9
pub struct a {
10
- pub val_a : * mut a_b ,
11
- }
12
- #[ repr( C ) ]
13
- #[ derive( Debug , Copy ) ]
14
- pub struct a_b {
15
- pub val_b : :: std:: os:: raw:: c_int ,
16
- }
17
- #[ test]
18
- fn bindgen_test_layout_a_b ( ) {
19
- assert_eq ! ( :: std:: mem:: size_of:: <a_b>( ) , 4usize ) ;
20
- assert_eq ! ( :: std:: mem:: align_of:: <a_b>( ) , 4usize ) ;
21
- }
22
- impl Clone for a_b {
23
- fn clone ( & self ) -> Self { * self }
10
+ pub val_a : * mut b ,
24
11
}
25
12
#[ test]
26
13
fn bindgen_test_layout_a ( ) {
@@ -30,3 +17,16 @@ fn bindgen_test_layout_a() {
30
17
impl Clone for a {
31
18
fn clone ( & self ) -> Self { * self }
32
19
}
20
+ #[ repr( C ) ]
21
+ #[ derive( Debug , Copy ) ]
22
+ pub struct b {
23
+ pub val_b : :: std:: os:: raw:: c_int ,
24
+ }
25
+ #[ test]
26
+ fn bindgen_test_layout_b ( ) {
27
+ assert_eq ! ( :: std:: mem:: size_of:: <b>( ) , 4usize ) ;
28
+ assert_eq ! ( :: std:: mem:: align_of:: <b>( ) , 4usize ) ;
29
+ }
30
+ impl Clone for b {
31
+ fn clone ( & self ) -> Self { * self }
32
+ }
Original file line number Diff line number Diff line change @@ -4,9 +4,21 @@ class A {
4
4
class B {
5
5
int member_b;
6
6
};
7
+
8
+ class C ;
9
+
10
+ template <typename T>
11
+ class D {
12
+ T foo;
13
+ };
14
+ };
15
+
16
+ class A ::C {
17
+ int baz;
7
18
};
8
19
9
20
A::B var;
21
+ A::D<int > baz;
10
22
11
23
class D {
12
24
A::B member;
You can’t perform that action at this time.
0 commit comments