Skip to content

Commit 7b1480d

Browse files
author
bors-servo
authored
Auto merge of rust-lang#411 - fitzgen:js-value-and-js-why-magic, r=emilio
Trace methods in CompInfo's TypeCollector impl Fixes rust-lang#410 r? @emilio
2 parents f83fe38 + 93dd68f commit 7b1480d

File tree

7 files changed

+79
-8
lines changed

7 files changed

+79
-8
lines changed

src/ir/comp.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,8 @@ impl TypeCollector for CompInfo {
957957
types.insert(var);
958958
}
959959

960-
// FIXME(emilio): Methods, VTable?
960+
for method in self.methods() {
961+
types.insert(method.signature);
962+
}
961963
}
962964
}

src/ir/item.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,12 @@ impl TypeCollector for Item {
205205
ItemKind::Var(ref var) => {
206206
types.insert(var.ty());
207207
}
208-
_ => {} // FIXME.
208+
ItemKind::Module(_) => {
209+
// Module -> children edges are "weak", and we do not want to
210+
// trace them. If we did, then whitelisting wouldn't work as
211+
// expected: everything in every module would end up
212+
// whitelisted.
213+
}
209214
}
210215
}
211216
}

src/ir/ty.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,24 @@ impl TypeCollector for Type {
914914
TypeKind::Function(ref sig) => {
915915
sig.collect_types(context, types, item)
916916
}
917-
TypeKind::Named(_) => {}
918-
// FIXME: Pending types!
919-
ref other @ _ => {
920-
debug!("<Type as TypeCollector>::collect_types: Ignoring: \
921-
{:?}",
922-
other);
917+
TypeKind::Enum(ref en) => {
918+
if let Some(repr) = en.repr() {
919+
types.insert(repr);
920+
}
921+
}
922+
TypeKind::UnresolvedTypeRef(_, _, Some(id)) => {
923+
types.insert(id);
923924
}
925+
926+
// None of these variants have edges to other items and types.
927+
TypeKind::UnresolvedTypeRef(_, _, None) |
928+
TypeKind::Named(_) |
929+
TypeKind::Void |
930+
TypeKind::NullPtr |
931+
TypeKind::Int(_) |
932+
TypeKind::Float(_) |
933+
TypeKind::Complex(_) |
934+
TypeKind::BlockPointer => {}
924935
}
925936
}
926937
}

tests/expectations/tests/issue-410.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
pub mod root {
8+
#[allow(unused_imports)]
9+
use self::super::root;
10+
pub mod JS {
11+
#[allow(unused_imports)]
12+
use self::super::super::root;
13+
pub use root::_bindgen_ty_1 as JSWhyMagic;
14+
#[repr(C)]
15+
#[derive(Debug, Copy)]
16+
pub struct Value {
17+
pub _address: u8,
18+
}
19+
#[test]
20+
fn bindgen_test_layout_Value() {
21+
assert_eq!(::std::mem::size_of::<Value>() , 1usize);
22+
assert_eq!(::std::mem::align_of::<Value>() , 1usize);
23+
}
24+
extern "C" {
25+
#[link_name = "_ZN2JS5Value1aE10JSWhyMagic"]
26+
pub fn Value_a(this: *mut root::JS::Value,
27+
arg1: root::JS::JSWhyMagic);
28+
}
29+
impl Clone for Value {
30+
fn clone(&self) -> Self { *self }
31+
}
32+
impl Value {
33+
#[inline]
34+
pub unsafe fn a(&mut self, arg1: root::JS::JSWhyMagic) {
35+
Value_a(&mut *self, arg1)
36+
}
37+
}
38+
}
39+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
40+
pub enum _bindgen_ty_1 { }
41+
}

tests/headers/issue-410.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// bindgen-flags: --enable-cxx-namespaces --whitelist-type JS::Value
2+
3+
namespace JS {
4+
class Value;
5+
}
6+
typedef enum {} JSWhyMagic;
7+
namespace JS {
8+
class Value {
9+
public:
10+
void a(JSWhyMagic);
11+
};
12+
}

0 commit comments

Comments
 (0)