summaryrefslogtreecommitdiff
path: root/libbindgen/tests/headers
diff options
context:
space:
mode:
authorJeff Waugh <jdub@bethesignal.org>2016-11-15 14:37:20 +1100
committerJeff Waugh <jdub@bethesignal.org>2016-11-16 05:31:02 +1100
commit8270a0ca766ea834032daeb67c7f32a1947ab3bd (patch)
treeb3bbdb0f98e5da995f91c89fbf5b10ecb8290bde /libbindgen/tests/headers
parent6e78bb8d56d875619d20e343d0f3109e2d6b6841 (diff)
Transition to libbindgen sub-crate
- The root crate is the `bindgen` binary - Rust-ify the test suite, no more subprocesses! - Update Travis config to test both crates
Diffstat (limited to 'libbindgen/tests/headers')
-rw-r--r--libbindgen/tests/headers/accessors.hpp46
-rw-r--r--libbindgen/tests/headers/annotation_hide.hpp16
-rw-r--r--libbindgen/tests/headers/anon_enum.hpp5
-rw-r--r--libbindgen/tests/headers/anon_enum_whitelist.h6
-rw-r--r--libbindgen/tests/headers/anon_union.hpp20
-rw-r--r--libbindgen/tests/headers/arg_keyword.hpp1
-rw-r--r--libbindgen/tests/headers/base-to-derived.hpp19
-rw-r--r--libbindgen/tests/headers/bitfield-enum-basic.h27
-rw-r--r--libbindgen/tests/headers/blocks.h3
-rw-r--r--libbindgen/tests/headers/class.hpp29
-rw-r--r--libbindgen/tests/headers/class_nested.hpp24
-rw-r--r--libbindgen/tests/headers/class_no_members.hpp16
-rw-r--r--libbindgen/tests/headers/class_static.hpp7
-rw-r--r--libbindgen/tests/headers/class_static_const.hpp8
-rw-r--r--libbindgen/tests/headers/class_use_as.hpp15
-rw-r--r--libbindgen/tests/headers/class_with_dtor.hpp13
-rw-r--r--libbindgen/tests/headers/class_with_inner_struct.hpp43
-rw-r--r--libbindgen/tests/headers/class_with_typedef.hpp22
-rw-r--r--libbindgen/tests/headers/complex.h16
-rw-r--r--libbindgen/tests/headers/complex_global.h3
-rw-r--r--libbindgen/tests/headers/const_enum_unnamed.hpp9
-rw-r--r--libbindgen/tests/headers/const_ptr.hpp3
-rw-r--r--libbindgen/tests/headers/const_resolved_ty.h3
-rw-r--r--libbindgen/tests/headers/const_tparam.hpp5
-rw-r--r--libbindgen/tests/headers/convert-floats.h9
-rw-r--r--libbindgen/tests/headers/crtp.hpp12
-rw-r--r--libbindgen/tests/headers/decl_extern_int_twice.h2
-rw-r--r--libbindgen/tests/headers/decl_ptr_to_array.h1
-rw-r--r--libbindgen/tests/headers/duplicated_constants_in_ns.hpp7
-rw-r--r--libbindgen/tests/headers/elaborated.hpp5
-rw-r--r--libbindgen/tests/headers/empty_template_param_name.hpp4
-rw-r--r--libbindgen/tests/headers/enum.h9
-rw-r--r--libbindgen/tests/headers/enum_alias.hpp7
-rw-r--r--libbindgen/tests/headers/enum_and_vtable_mangling.hpp11
-rw-r--r--libbindgen/tests/headers/enum_dupe.h4
-rw-r--r--libbindgen/tests/headers/enum_explicit_type.hpp28
-rw-r--r--libbindgen/tests/headers/enum_negative.h4
-rw-r--r--libbindgen/tests/headers/enum_packed.h14
-rw-r--r--libbindgen/tests/headers/extern.hpp3
-rw-r--r--libbindgen/tests/headers/float128.hpp13
-rw-r--r--libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp8
-rw-r--r--libbindgen/tests/headers/forward-inherit-struct.hpp5
-rw-r--r--libbindgen/tests/headers/forward_declared_struct.h11
-rw-r--r--libbindgen/tests/headers/func_proto.h1
-rw-r--r--libbindgen/tests/headers/func_ptr.h1
-rw-r--r--libbindgen/tests/headers/func_ptr_in_struct.h6
-rw-r--r--libbindgen/tests/headers/func_with_array_arg.h1
-rw-r--r--libbindgen/tests/headers/func_with_func_ptr_arg.h1
-rw-r--r--libbindgen/tests/headers/in_class_typedef.hpp10
-rw-r--r--libbindgen/tests/headers/inherit-namespaced.hpp4
-rw-r--r--libbindgen/tests/headers/inherit_named.hpp5
-rw-r--r--libbindgen/tests/headers/inherit_typedef.hpp5
-rw-r--r--libbindgen/tests/headers/inner_const.hpp6
-rw-r--r--libbindgen/tests/headers/inner_template_self.hpp10
-rw-r--r--libbindgen/tests/headers/int128_t.h7
-rw-r--r--libbindgen/tests/headers/jsval_layout_opaque.hpp424
-rw-r--r--libbindgen/tests/headers/keywords.h49
-rw-r--r--libbindgen/tests/headers/macro-expr-basic.h14
-rw-r--r--libbindgen/tests/headers/macro-redef.h5
-rw-r--r--libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp3
-rw-r--r--libbindgen/tests/headers/mutable.hpp14
-rw-r--r--libbindgen/tests/headers/namespace.hpp47
-rw-r--r--libbindgen/tests/headers/nested.hpp15
-rw-r--r--libbindgen/tests/headers/nested_vtable.hpp8
-rw-r--r--libbindgen/tests/headers/no-std.h5
-rw-r--r--libbindgen/tests/headers/no_copy.hpp6
-rw-r--r--libbindgen/tests/headers/nsStyleAutoArray.hpp57
-rw-r--r--libbindgen/tests/headers/only_bitfields.hpp5
-rw-r--r--libbindgen/tests/headers/opaque_in_struct.hpp10
-rw-r--r--libbindgen/tests/headers/opaque_pointer.hpp22
-rw-r--r--libbindgen/tests/headers/opaque_typedef.hpp17
-rw-r--r--libbindgen/tests/headers/overflowed_enum.hpp12
-rw-r--r--libbindgen/tests/headers/overloading.hpp9
-rw-r--r--libbindgen/tests/headers/private.hpp21
-rw-r--r--libbindgen/tests/headers/redeclaration.hpp7
-rw-r--r--libbindgen/tests/headers/ref_argument_array.hpp6
-rw-r--r--libbindgen/tests/headers/replace_template_alias.hpp23
-rw-r--r--libbindgen/tests/headers/replaces_double.hpp20
-rw-r--r--libbindgen/tests/headers/size_t_template.hpp8
-rw-r--r--libbindgen/tests/headers/struct_containing_forward_declared_struct.h7
-rw-r--r--libbindgen/tests/headers/struct_with_anon_struct.h6
-rw-r--r--libbindgen/tests/headers/struct_with_anon_struct_array.h10
-rw-r--r--libbindgen/tests/headers/struct_with_anon_struct_pointer.h6
-rw-r--r--libbindgen/tests/headers/struct_with_anon_union.h6
-rw-r--r--libbindgen/tests/headers/struct_with_anon_unnamed_struct.h6
-rw-r--r--libbindgen/tests/headers/struct_with_anon_unnamed_union.h6
-rw-r--r--libbindgen/tests/headers/struct_with_bitfields.h13
-rw-r--r--libbindgen/tests/headers/struct_with_derive_debug.h15
-rw-r--r--libbindgen/tests/headers/struct_with_nesting.h17
-rw-r--r--libbindgen/tests/headers/struct_with_packing.h4
-rw-r--r--libbindgen/tests/headers/struct_with_struct.h6
-rw-r--r--libbindgen/tests/headers/struct_with_typedef_template_arg.hpp4
-rw-r--r--libbindgen/tests/headers/template.hpp144
-rw-r--r--libbindgen/tests/headers/template_alias.hpp13
-rw-r--r--libbindgen/tests/headers/template_alias_basic.hpp4
-rw-r--r--libbindgen/tests/headers/template_alias_namespace.hpp13
-rw-r--r--libbindgen/tests/headers/template_typedef_transitive_param.hpp7
-rw-r--r--libbindgen/tests/headers/template_typedefs.hpp8
-rw-r--r--libbindgen/tests/headers/type_alias_empty.hpp10
-rw-r--r--libbindgen/tests/headers/typeref.hpp28
-rw-r--r--libbindgen/tests/headers/union_dtor.hpp5
-rw-r--r--libbindgen/tests/headers/union_fields.hpp5
-rw-r--r--libbindgen/tests/headers/union_template.hpp19
-rw-r--r--libbindgen/tests/headers/union_with_anon_struct.h6
-rw-r--r--libbindgen/tests/headers/union_with_anon_struct_bitfield.h8
-rw-r--r--libbindgen/tests/headers/union_with_anon_union.h6
-rw-r--r--libbindgen/tests/headers/union_with_anon_unnamed_struct.h9
-rw-r--r--libbindgen/tests/headers/union_with_anon_unnamed_union.h7
-rw-r--r--libbindgen/tests/headers/union_with_big_member.h14
-rw-r--r--libbindgen/tests/headers/union_with_nesting.h14
-rw-r--r--libbindgen/tests/headers/unknown_attr.h6
-rw-r--r--libbindgen/tests/headers/use-core.h8
-rw-r--r--libbindgen/tests/headers/using.hpp11
-rw-r--r--libbindgen/tests/headers/vector.hpp3
-rw-r--r--libbindgen/tests/headers/virtual_dtor.hpp3
-rw-r--r--libbindgen/tests/headers/virtual_overloaded.hpp5
-rw-r--r--libbindgen/tests/headers/vtable_recursive_sig.hpp11
-rw-r--r--libbindgen/tests/headers/weird_bitfields.hpp35
-rw-r--r--libbindgen/tests/headers/what_is_going_on.hpp19
-rw-r--r--libbindgen/tests/headers/whitelist_basic.hpp16
-rw-r--r--libbindgen/tests/headers/whitelist_vars.h4
121 files changed, 1927 insertions, 0 deletions
diff --git a/libbindgen/tests/headers/accessors.hpp b/libbindgen/tests/headers/accessors.hpp
new file mode 100644
index 00000000..4c23e35d
--- /dev/null
+++ b/libbindgen/tests/headers/accessors.hpp
@@ -0,0 +1,46 @@
+struct SomeAccessors {
+ int mNoAccessor;
+ /** <div rustbindgen accessor></div> */
+ int mBothAccessors;
+ /** <div rustbindgen accessor="unsafe"></div> */
+ int mUnsafeAccessors;
+ /** <div rustbindgen accessor="immutable"></div> */
+ int mImmutableAccessor;
+};
+
+/** <div rustbindgen accessor></div> */
+struct AllAccessors {
+ int mBothAccessors;
+ int mAlsoBothAccessors;
+};
+
+/** <div rustbindgen accessor="unsafe"></div> */
+struct AllUnsafeAccessors {
+ int mBothAccessors;
+ int mAlsoBothAccessors;
+};
+
+/** <div rustbindgen accessor></div> */
+struct ContradictAccessors {
+ int mBothAccessors;
+ /** <div rustbindgen accessor="false"></div> */
+ int mNoAccessors;
+ /** <div rustbindgen accessor="unsafe"></div> */
+ int mUnsafeAccessors;
+ /** <div rustbindgen accessor="immutable"></div> */
+ int mImmutableAccessor;
+};
+
+/** <div rustbindgen accessor replaces="Replaced"></div> */
+struct Replacing {
+ int mAccessor;
+};
+
+struct Replaced {
+ int noOp;
+};
+
+/** <div rustbindgen accessor></div> */
+struct Wrapper {
+ Replaced mReplaced;
+};
diff --git a/libbindgen/tests/headers/annotation_hide.hpp b/libbindgen/tests/headers/annotation_hide.hpp
new file mode 100644
index 00000000..3c82c9a2
--- /dev/null
+++ b/libbindgen/tests/headers/annotation_hide.hpp
@@ -0,0 +1,16 @@
+
+/**
+ * <div rustbindgen="true" hide="true"></div>
+ */
+struct C;
+
+/**
+ * <div rustbindgen opaque></div>
+ */
+struct D {
+ int a;
+};
+
+struct NotAnnotated {
+ int f;
+};
diff --git a/libbindgen/tests/headers/anon_enum.hpp b/libbindgen/tests/headers/anon_enum.hpp
new file mode 100644
index 00000000..c7405202
--- /dev/null
+++ b/libbindgen/tests/headers/anon_enum.hpp
@@ -0,0 +1,5 @@
+struct Test {
+ int foo;
+ float bar;
+ enum { T_NONE };
+};
diff --git a/libbindgen/tests/headers/anon_enum_whitelist.h b/libbindgen/tests/headers/anon_enum_whitelist.h
new file mode 100644
index 00000000..15cda6b1
--- /dev/null
+++ b/libbindgen/tests/headers/anon_enum_whitelist.h
@@ -0,0 +1,6 @@
+// bindgen-flags: --whitelist-var NODE_.*
+
+enum {
+ NODE_FLAG_FOO,
+ NODE_FLAG_BAR,
+};
diff --git a/libbindgen/tests/headers/anon_union.hpp b/libbindgen/tests/headers/anon_union.hpp
new file mode 100644
index 00000000..126f6a6e
--- /dev/null
+++ b/libbindgen/tests/headers/anon_union.hpp
@@ -0,0 +1,20 @@
+template<typename T>
+struct TErrorResult {
+ enum UnionState {
+ HasMessage,
+ HasException,
+ };
+ int mResult;
+ struct Message;
+ struct DOMExceptionInfo;
+ union {
+ Message* mMessage;
+ DOMExceptionInfo* mDOMExceptionInfo;
+ };
+
+ bool mMightHaveUnreported;
+ UnionState mUnionState;
+};
+
+struct ErrorResult : public TErrorResult<int> {
+};
diff --git a/libbindgen/tests/headers/arg_keyword.hpp b/libbindgen/tests/headers/arg_keyword.hpp
new file mode 100644
index 00000000..9f0af850
--- /dev/null
+++ b/libbindgen/tests/headers/arg_keyword.hpp
@@ -0,0 +1 @@
+void foo(const char* type);
diff --git a/libbindgen/tests/headers/base-to-derived.hpp b/libbindgen/tests/headers/base-to-derived.hpp
new file mode 100644
index 00000000..ea31e0f2
--- /dev/null
+++ b/libbindgen/tests/headers/base-to-derived.hpp
@@ -0,0 +1,19 @@
+// bindgen-flags: -- -std=c++11
+
+struct false_type {};
+
+template<typename _From, typename _To, bool>
+struct __is_base_to_derived_ref;
+
+template<typename _From, typename _To>
+struct __is_base_to_derived_ref<_From, _To, true>
+{
+ typedef _To type;
+
+ static constexpr bool value = type::value;
+};
+
+template<typename _From, typename _To>
+struct __is_base_to_derived_ref<_From, _To, false>
+: public false_type
+{ };
diff --git a/libbindgen/tests/headers/bitfield-enum-basic.h b/libbindgen/tests/headers/bitfield-enum-basic.h
new file mode 100644
index 00000000..364bebf2
--- /dev/null
+++ b/libbindgen/tests/headers/bitfield-enum-basic.h
@@ -0,0 +1,27 @@
+// bindgen-flags: --bitfield-enum "Foo|Buz|NS_.*|DUMMY_.*" -- -std=c++11
+
+enum Foo {
+ Bar = 1 << 1,
+ Baz = 1 << 2,
+ Duplicated = 1 << 2,
+ Negative = -3,
+};
+
+enum class Buz : signed char {
+ Bar = 1 << 1,
+ Baz = 1 << 2,
+ Duplicated = 1 << 2,
+ Negative = -3,
+};
+
+enum {
+ NS_FOO = 1 << 0,
+ NS_BAR = 1 << 1,
+};
+
+class Dummy {
+ enum {
+ DUMMY_FOO = 1 << 0,
+ DUMMY_BAR = 1 << 1,
+ };
+};
diff --git a/libbindgen/tests/headers/blocks.h b/libbindgen/tests/headers/blocks.h
new file mode 100644
index 00000000..80420e6e
--- /dev/null
+++ b/libbindgen/tests/headers/blocks.h
@@ -0,0 +1,3 @@
+// bindgen-flags: -- -fblocks
+
+void atexit_b(void (^)(void));
diff --git a/libbindgen/tests/headers/class.hpp b/libbindgen/tests/headers/class.hpp
new file mode 100644
index 00000000..e753f186
--- /dev/null
+++ b/libbindgen/tests/headers/class.hpp
@@ -0,0 +1,29 @@
+class C {
+ int a;
+ // More than rust limits (32)
+ char big_array[33];
+};
+
+class WithDtor {
+ int b;
+
+ ~WithDtor() {}
+};
+
+union Union {
+ float d;
+ int i;
+};
+
+class WithUnion {
+ Union data;
+};
+
+class RealAbstractionWithTonsOfMethods {
+ void foo();
+public:
+ void bar() const;
+ void bar();
+ void bar(int foo);
+ static void sta();
+};
diff --git a/libbindgen/tests/headers/class_nested.hpp b/libbindgen/tests/headers/class_nested.hpp
new file mode 100644
index 00000000..ab38d500
--- /dev/null
+++ b/libbindgen/tests/headers/class_nested.hpp
@@ -0,0 +1,24 @@
+class A {
+public:
+ int member_a;
+ class B {
+ int member_b;
+ };
+};
+
+A::B var;
+
+class D {
+ A::B member;
+};
+
+template<typename T>
+class Templated {
+ T member;
+
+ class Templated_inner {
+ public:
+ T* member_ptr;
+ void get() {}
+ };
+};
diff --git a/libbindgen/tests/headers/class_no_members.hpp b/libbindgen/tests/headers/class_no_members.hpp
new file mode 100644
index 00000000..a4483558
--- /dev/null
+++ b/libbindgen/tests/headers/class_no_members.hpp
@@ -0,0 +1,16 @@
+// bindgen-flags: -- -std=c++11
+
+class whatever {
+};
+
+class whatever_child: public whatever {
+};
+
+class whatever_child_with_member: public whatever {
+public:
+ int m_member;
+};
+
+static_assert(sizeof(whatever) == 1, "Testing!");
+static_assert(sizeof(whatever_child) == 1, "Testing!");
+static_assert(sizeof(whatever_child_with_member) == 4, "Testing!");
diff --git a/libbindgen/tests/headers/class_static.hpp b/libbindgen/tests/headers/class_static.hpp
new file mode 100644
index 00000000..21ab2321
--- /dev/null
+++ b/libbindgen/tests/headers/class_static.hpp
@@ -0,0 +1,7 @@
+class MyClass {
+public:
+ static const int* example;
+ static const int* example_check_no_collision;
+};
+
+static const int* example_check_no_collision;
diff --git a/libbindgen/tests/headers/class_static_const.hpp b/libbindgen/tests/headers/class_static_const.hpp
new file mode 100644
index 00000000..150afe8b
--- /dev/null
+++ b/libbindgen/tests/headers/class_static_const.hpp
@@ -0,0 +1,8 @@
+using int32_t = int;
+typedef unsigned int uint32_t;
+
+class A {
+ static const int a = 0;
+ static const int32_t b = 077;
+ static const uint32_t c = 0xff;
+};
diff --git a/libbindgen/tests/headers/class_use_as.hpp b/libbindgen/tests/headers/class_use_as.hpp
new file mode 100644
index 00000000..a4e36ded
--- /dev/null
+++ b/libbindgen/tests/headers/class_use_as.hpp
@@ -0,0 +1,15 @@
+
+/**
+ * <div rustbindgen="true" replaces="whatever"></div>
+ */
+struct whatever_replacement {
+ int replacement;
+};
+
+struct whatever {
+ int b;
+};
+
+struct container {
+ whatever c;
+};
diff --git a/libbindgen/tests/headers/class_with_dtor.hpp b/libbindgen/tests/headers/class_with_dtor.hpp
new file mode 100644
index 00000000..b9bf74e1
--- /dev/null
+++ b/libbindgen/tests/headers/class_with_dtor.hpp
@@ -0,0 +1,13 @@
+
+
+template <typename T>
+class HandleWithDtor {
+ T* ptr;
+ ~HandleWithDtor() {}
+};
+
+typedef HandleWithDtor<int> HandleValue;
+
+class WithoutDtor {
+ HandleValue shouldBeWithDtor;
+};
diff --git a/libbindgen/tests/headers/class_with_inner_struct.hpp b/libbindgen/tests/headers/class_with_inner_struct.hpp
new file mode 100644
index 00000000..ec729fe6
--- /dev/null
+++ b/libbindgen/tests/headers/class_with_inner_struct.hpp
@@ -0,0 +1,43 @@
+// bindgen-flags: -- -std=c++11
+
+class A {
+ unsigned c;
+ struct Segment { int begin, end; };
+ union {
+ int f;
+ } named_union;
+ union {
+ int d;
+ };
+};
+
+class B {
+ unsigned d;
+ struct Segment { int begin, end; };
+};
+
+
+enum class StepSyntax {
+ Keyword, // step-start and step-end
+ FunctionalWithoutKeyword, // steps(...)
+ FunctionalWithStartKeyword, // steps(..., start)
+ FunctionalWithEndKeyword, // steps(..., end)
+};
+
+class C {
+ unsigned d;
+ union {
+ struct {
+ float mX1;
+ float mY1;
+ float mX2;
+ float mY2;
+ } mFunc;
+ struct {
+ StepSyntax mStepSyntax;
+ unsigned int mSteps;
+ };
+ };
+ // To ensure it doesn't collide
+ struct Segment { int begin, end; };
+};
diff --git a/libbindgen/tests/headers/class_with_typedef.hpp b/libbindgen/tests/headers/class_with_typedef.hpp
new file mode 100644
index 00000000..8707cffe
--- /dev/null
+++ b/libbindgen/tests/headers/class_with_typedef.hpp
@@ -0,0 +1,22 @@
+typedef int AnotherInt;
+
+class C {
+public:
+ typedef int MyInt;
+ typedef const char* Lookup;
+ MyInt c;
+ MyInt* ptr;
+ MyInt arr[10];
+ AnotherInt d;
+ AnotherInt* other_ptr;
+
+ void method(MyInt c);
+ void methodRef(MyInt& c);
+ void complexMethodRef(Lookup& c);
+ void anotherMethod(AnotherInt c);
+};
+
+class D: public C {
+public:
+ MyInt* ptr;
+};
diff --git a/libbindgen/tests/headers/complex.h b/libbindgen/tests/headers/complex.h
new file mode 100644
index 00000000..04877a4e
--- /dev/null
+++ b/libbindgen/tests/headers/complex.h
@@ -0,0 +1,16 @@
+
+#define COMPLEX_TEST(ty_, name_) \
+ struct Test##name_ { \
+ ty_ _Complex mMember; \
+ \
+ }; \
+ struct Test##name_##Ptr { \
+ ty_ _Complex* mMember; \
+ };
+
+COMPLEX_TEST(double, Double)
+COMPLEX_TEST(float, Float)
+
+// FIXME: 128-byte-aligned in some machines
+// which we can't support right now in Rust.
+// COMPLEX_TEST(long double, LongDouble)
diff --git a/libbindgen/tests/headers/complex_global.h b/libbindgen/tests/headers/complex_global.h
new file mode 100644
index 00000000..d9f9fb01
--- /dev/null
+++ b/libbindgen/tests/headers/complex_global.h
@@ -0,0 +1,3 @@
+float _Complex globalValueFloat;
+double _Complex globalValueDouble;
+long double _Complex globalValueLongDouble;
diff --git a/libbindgen/tests/headers/const_enum_unnamed.hpp b/libbindgen/tests/headers/const_enum_unnamed.hpp
new file mode 100644
index 00000000..eb139434
--- /dev/null
+++ b/libbindgen/tests/headers/const_enum_unnamed.hpp
@@ -0,0 +1,9 @@
+
+enum {
+ FOO_BAR,
+ FOO_BAZ,
+};
+
+class Foo {
+ enum { FOO_BAR = 10 };
+};
diff --git a/libbindgen/tests/headers/const_ptr.hpp b/libbindgen/tests/headers/const_ptr.hpp
new file mode 100644
index 00000000..66744f8b
--- /dev/null
+++ b/libbindgen/tests/headers/const_ptr.hpp
@@ -0,0 +1,3 @@
+extern "C" {
+ void foo(const void* bar);
+}
diff --git a/libbindgen/tests/headers/const_resolved_ty.h b/libbindgen/tests/headers/const_resolved_ty.h
new file mode 100644
index 00000000..2521e61c
--- /dev/null
+++ b/libbindgen/tests/headers/const_resolved_ty.h
@@ -0,0 +1,3 @@
+typedef unsigned char uint8_t;
+
+void foo(const uint8_t* foo);
diff --git a/libbindgen/tests/headers/const_tparam.hpp b/libbindgen/tests/headers/const_tparam.hpp
new file mode 100644
index 00000000..05f26e4a
--- /dev/null
+++ b/libbindgen/tests/headers/const_tparam.hpp
@@ -0,0 +1,5 @@
+template<typename T>
+class C {
+ const T* const foo;
+ const T* bar;
+};
diff --git a/libbindgen/tests/headers/convert-floats.h b/libbindgen/tests/headers/convert-floats.h
new file mode 100644
index 00000000..08d9fe0b
--- /dev/null
+++ b/libbindgen/tests/headers/convert-floats.h
@@ -0,0 +1,9 @@
+// bindgen-flags: --no-convert-floats
+
+struct foo {
+ float bar, baz;
+ double bazz;
+ long double* bazzz;
+ float _Complex complexFloat;
+ double _Complex complexDouble;
+};
diff --git a/libbindgen/tests/headers/crtp.hpp b/libbindgen/tests/headers/crtp.hpp
new file mode 100644
index 00000000..a5477c54
--- /dev/null
+++ b/libbindgen/tests/headers/crtp.hpp
@@ -0,0 +1,12 @@
+template<class T>
+class Base {};
+
+class Derived : public Base<Derived> {};
+
+template<class T>
+class BaseWithDestructor {
+ ~BaseWithDestructor();
+};
+
+class DerivedFromBaseWithDestructor :
+ public BaseWithDestructor<DerivedFromBaseWithDestructor> {};
diff --git a/libbindgen/tests/headers/decl_extern_int_twice.h b/libbindgen/tests/headers/decl_extern_int_twice.h
new file mode 100644
index 00000000..06f80e87
--- /dev/null
+++ b/libbindgen/tests/headers/decl_extern_int_twice.h
@@ -0,0 +1,2 @@
+extern int foo;
+extern int foo;
diff --git a/libbindgen/tests/headers/decl_ptr_to_array.h b/libbindgen/tests/headers/decl_ptr_to_array.h
new file mode 100644
index 00000000..3222cbd4
--- /dev/null
+++ b/libbindgen/tests/headers/decl_ptr_to_array.h
@@ -0,0 +1 @@
+int (*foo)[1];
diff --git a/libbindgen/tests/headers/duplicated_constants_in_ns.hpp b/libbindgen/tests/headers/duplicated_constants_in_ns.hpp
new file mode 100644
index 00000000..bb343641
--- /dev/null
+++ b/libbindgen/tests/headers/duplicated_constants_in_ns.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: --enable-cxx-namespaces
+namespace foo {
+ const int FOO = 4;
+}
+namespace bar {
+ const int FOO = 5;
+}
diff --git a/libbindgen/tests/headers/elaborated.hpp b/libbindgen/tests/headers/elaborated.hpp
new file mode 100644
index 00000000..4bfbff23
--- /dev/null
+++ b/libbindgen/tests/headers/elaborated.hpp
@@ -0,0 +1,5 @@
+namespace whatever {
+ typedef int whatever_t;
+}
+
+void something(const whatever::whatever_t *wat);
diff --git a/libbindgen/tests/headers/empty_template_param_name.hpp b/libbindgen/tests/headers/empty_template_param_name.hpp
new file mode 100644
index 00000000..b3360bc9
--- /dev/null
+++ b/libbindgen/tests/headers/empty_template_param_name.hpp
@@ -0,0 +1,4 @@
+template<typename...> using __void_t = void;
+
+template<typename _Iterator, typename = __void_t<>>
+ struct __iterator_traits { };
diff --git a/libbindgen/tests/headers/enum.h b/libbindgen/tests/headers/enum.h
new file mode 100644
index 00000000..f2d301e7
--- /dev/null
+++ b/libbindgen/tests/headers/enum.h
@@ -0,0 +1,9 @@
+enum Foo {
+ Bar = 0,
+ Qux
+};
+
+enum Neg {
+ MinusOne = -1,
+ One = 1,
+};
diff --git a/libbindgen/tests/headers/enum_alias.hpp b/libbindgen/tests/headers/enum_alias.hpp
new file mode 100644
index 00000000..658f8fde
--- /dev/null
+++ b/libbindgen/tests/headers/enum_alias.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: -- -std=c++11
+
+typedef unsigned char uint8_t;
+
+enum Bar : uint8_t {
+ VAL
+};
diff --git a/libbindgen/tests/headers/enum_and_vtable_mangling.hpp b/libbindgen/tests/headers/enum_and_vtable_mangling.hpp
new file mode 100644
index 00000000..3abd6a29
--- /dev/null
+++ b/libbindgen/tests/headers/enum_and_vtable_mangling.hpp
@@ -0,0 +1,11 @@
+
+enum {
+ match,
+ whatever_else,
+};
+
+class C {
+ int i;
+public:
+ virtual void match() { };
+};
diff --git a/libbindgen/tests/headers/enum_dupe.h b/libbindgen/tests/headers/enum_dupe.h
new file mode 100644
index 00000000..6d3591d5
--- /dev/null
+++ b/libbindgen/tests/headers/enum_dupe.h
@@ -0,0 +1,4 @@
+enum Foo {
+ Bar = 1,
+ Dupe = 1
+};
diff --git a/libbindgen/tests/headers/enum_explicit_type.hpp b/libbindgen/tests/headers/enum_explicit_type.hpp
new file mode 100644
index 00000000..78eadd40
--- /dev/null
+++ b/libbindgen/tests/headers/enum_explicit_type.hpp
@@ -0,0 +1,28 @@
+// bindgen-flags: -- -std=c++11
+
+enum Foo: unsigned char {
+ Bar = 0,
+ Qux
+};
+
+enum Neg: char {
+ MinusOne = -1,
+ One = 1,
+};
+
+enum Bigger: unsigned short {
+ Much = 255,
+ Larger
+};
+
+enum MuchLong: long {
+ MuchLow = -4294967296,
+};
+
+enum MuchLongLong: long long {
+ I64_MIN = 1ll << 63,
+};
+
+enum MuchULongLong: unsigned long long {
+ MuchHigh = 4294967296,
+};
diff --git a/libbindgen/tests/headers/enum_negative.h b/libbindgen/tests/headers/enum_negative.h
new file mode 100644
index 00000000..6cbdfe04
--- /dev/null
+++ b/libbindgen/tests/headers/enum_negative.h
@@ -0,0 +1,4 @@
+enum Foo {
+ Bar = -2,
+ Qux = 1,
+};
diff --git a/libbindgen/tests/headers/enum_packed.h b/libbindgen/tests/headers/enum_packed.h
new file mode 100644
index 00000000..8654d110
--- /dev/null
+++ b/libbindgen/tests/headers/enum_packed.h
@@ -0,0 +1,14 @@
+enum __attribute__((packed)) Foo {
+ Bar = 0,
+ Qux
+};
+
+enum __attribute__((packed)) Neg {
+ MinusOne = -1,
+ One = 1,
+};
+
+enum __attribute__((packed)) Bigger {
+ Much = 255,
+ Larger
+};
diff --git a/libbindgen/tests/headers/extern.hpp b/libbindgen/tests/headers/extern.hpp
new file mode 100644
index 00000000..0779e038
--- /dev/null
+++ b/libbindgen/tests/headers/extern.hpp
@@ -0,0 +1,3 @@
+extern "C" {
+#include "func_proto.h"
+}
diff --git a/libbindgen/tests/headers/float128.hpp b/libbindgen/tests/headers/float128.hpp
new file mode 100644
index 00000000..f554e88e
--- /dev/null
+++ b/libbindgen/tests/headers/float128.hpp
@@ -0,0 +1,13 @@
+// FIXME: libclang < 3.9 does not expose `__float128` in its interface, so this
+// test will fail. Once we remove support for `--features llvm_stable` and
+// require libclang >= 3.9, we can reenable this test.
+//
+// static __float128 global = 1.0;
+
+// FIXME: We have no way to get 128 bit aligned structs in Rust at the moment,
+// and therefore the generated layout tests for this struct will fail. When we
+// can enforce 128 bit alignment, we can re-enable this test.
+//
+// struct A {
+// __float128 f;
+// };
diff --git a/libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp b/libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp
new file mode 100644
index 00000000..437fff5d
--- /dev/null
+++ b/libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp
@@ -0,0 +1,8 @@
+template <typename> class Rooted;
+namespace js {
+ template <typename T> class RootedBase {
+ T* foo;
+ Rooted<T>* next;
+ };
+}
+template <typename T> class Rooted : js::RootedBase<T> {};
diff --git a/libbindgen/tests/headers/forward-inherit-struct.hpp b/libbindgen/tests/headers/forward-inherit-struct.hpp
new file mode 100644
index 00000000..ac7aef5e
--- /dev/null
+++ b/libbindgen/tests/headers/forward-inherit-struct.hpp
@@ -0,0 +1,5 @@
+template <typename> class Rooted;
+namespace js {
+ template <typename T> class RootedBase {};
+}
+template <typename T> class Rooted : js::RootedBase<T> {};
diff --git a/libbindgen/tests/headers/forward_declared_struct.h b/libbindgen/tests/headers/forward_declared_struct.h
new file mode 100644
index 00000000..2a69450c
--- /dev/null
+++ b/libbindgen/tests/headers/forward_declared_struct.h
@@ -0,0 +1,11 @@
+struct a;
+
+struct a {
+ int b;
+};
+
+struct c {
+ int d;
+};
+
+struct c; \ No newline at end of file
diff --git a/libbindgen/tests/headers/func_proto.h b/libbindgen/tests/headers/func_proto.h
new file mode 100644
index 00000000..51139ca9
--- /dev/null
+++ b/libbindgen/tests/headers/func_proto.h
@@ -0,0 +1 @@
+typedef int foo(int bar);
diff --git a/libbindgen/tests/headers/func_ptr.h b/libbindgen/tests/headers/func_ptr.h
new file mode 100644
index 00000000..a4662f3d
--- /dev/null
+++ b/libbindgen/tests/headers/func_ptr.h
@@ -0,0 +1 @@
+int (*foo) (int x, int y);
diff --git a/libbindgen/tests/headers/func_ptr_in_struct.h b/libbindgen/tests/headers/func_ptr_in_struct.h
new file mode 100644
index 00000000..988db5b3
--- /dev/null
+++ b/libbindgen/tests/headers/func_ptr_in_struct.h
@@ -0,0 +1,6 @@
+
+enum baz;
+
+struct Foo {
+ enum baz (*bar) (int x, int y);
+};
diff --git a/libbindgen/tests/headers/func_with_array_arg.h b/libbindgen/tests/headers/func_with_array_arg.h
new file mode 100644
index 00000000..1b81702b
--- /dev/null
+++ b/libbindgen/tests/headers/func_with_array_arg.h
@@ -0,0 +1 @@
+void f(int x[2]);
diff --git a/libbindgen/tests/headers/func_with_func_ptr_arg.h b/libbindgen/tests/headers/func_with_func_ptr_arg.h
new file mode 100644
index 00000000..629c84ab
--- /dev/null
+++ b/libbindgen/tests/headers/func_with_func_ptr_arg.h
@@ -0,0 +1 @@
+void foo(void (*bar)());
diff --git a/libbindgen/tests/headers/in_class_typedef.hpp b/libbindgen/tests/headers/in_class_typedef.hpp
new file mode 100644
index 00000000..dda7472d
--- /dev/null
+++ b/libbindgen/tests/headers/in_class_typedef.hpp
@@ -0,0 +1,10 @@
+
+template<typename T>
+class Foo {
+ typedef T elem_type;
+ typedef T* ptr_type;
+
+ typedef struct Bar {
+ int x, y;
+ } Bar;
+};
diff --git a/libbindgen/tests/headers/inherit-namespaced.hpp b/libbindgen/tests/headers/inherit-namespaced.hpp
new file mode 100644
index 00000000..61eafd5a
--- /dev/null
+++ b/libbindgen/tests/headers/inherit-namespaced.hpp
@@ -0,0 +1,4 @@
+namespace js {
+ template <typename T> class RootedBase {};
+}
+template <typename T> class Rooted : js::RootedBase<T> {};
diff --git a/libbindgen/tests/headers/inherit_named.hpp b/libbindgen/tests/headers/inherit_named.hpp
new file mode 100644
index 00000000..9881d1b6
--- /dev/null
+++ b/libbindgen/tests/headers/inherit_named.hpp
@@ -0,0 +1,5 @@
+template<typename T>
+class Wohoo {};
+
+template<typename T>
+class Weeee : public T {};
diff --git a/libbindgen/tests/headers/inherit_typedef.hpp b/libbindgen/tests/headers/inherit_typedef.hpp
new file mode 100644
index 00000000..8d699e82
--- /dev/null
+++ b/libbindgen/tests/headers/inherit_typedef.hpp
@@ -0,0 +1,5 @@
+struct Foo {};
+
+typedef Foo TypedefedFoo;
+
+struct Bar: public TypedefedFoo {};
diff --git a/libbindgen/tests/headers/inner_const.hpp b/libbindgen/tests/headers/inner_const.hpp
new file mode 100644
index 00000000..25c2e603
--- /dev/null
+++ b/libbindgen/tests/headers/inner_const.hpp
@@ -0,0 +1,6 @@
+
+class Foo {
+ static int BOO;
+ static Foo whatever;
+ int bar;
+};
diff --git a/libbindgen/tests/headers/inner_template_self.hpp b/libbindgen/tests/headers/inner_template_self.hpp
new file mode 100644
index 00000000..1ae5af06
--- /dev/null
+++ b/libbindgen/tests/headers/inner_template_self.hpp
@@ -0,0 +1,10 @@
+
+template <typename T>
+class LinkedList {
+ LinkedList<T>* next;
+ LinkedList* prev;
+};
+
+class InstantiateIt {
+ LinkedList<int> m_list;
+};
diff --git a/libbindgen/tests/headers/int128_t.h b/libbindgen/tests/headers/int128_t.h
new file mode 100644
index 00000000..eece252c
--- /dev/null
+++ b/libbindgen/tests/headers/int128_t.h
@@ -0,0 +1,7 @@
+/**
+ * FIXME: Uncomment this once we can generate the proper alignment for the type,
+ * i.e., when we use u128/i128.
+struct Foo {
+ __int128 foo;
+};
+ */
diff --git a/libbindgen/tests/headers/jsval_layout_opaque.hpp b/libbindgen/tests/headers/jsval_layout_opaque.hpp
new file mode 100644
index 00000000..85c5be63
--- /dev/null
+++ b/libbindgen/tests/headers/jsval_layout_opaque.hpp
@@ -0,0 +1,424 @@
+// bindgen-flags: --no-unstable-rust -- -std=c++11
+
+/**
+ * These typedefs are hacky, but keep our tests consistent across 64-bit
+ * platforms, otherwise the id's change and our CI is unhappy.
+ */
+typedef unsigned char uint8_t;
+typedef int int32_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+typedef unsigned long long size_t;
+typedef unsigned long long uintptr_t;
+
+
+#define JS_PUNBOX64
+#define IS_LITTLE_ENDIAN
+
+/*
+ * Try to get jsvals 64-bit aligned. We could almost assert that all values are
+ * aligned, but MSVC and GCC occasionally break alignment.
+ */
+#if defined(__GNUC__) || defined(__xlc__) || defined(__xlC__)
+# define JSVAL_ALIGNMENT __attribute__((aligned (8)))
+#elif defined(_MSC_VER)
+ /*
+ * Structs can be aligned with MSVC, but not if they are used as parameters,
+ * so we just don't try to align.
+ */
+# define JSVAL_ALIGNMENT
+#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+# define JSVAL_ALIGNMENT
+#elif defined(__HP_cc) || defined(__HP_aCC)
+# define JSVAL_ALIGNMENT
+#endif
+
+#if defined(JS_PUNBOX64)
+# define JSVAL_TAG_SHIFT 47
+#endif
+
+/*
+ * We try to use enums so that printing a jsval_layout in the debugger shows
+ * nice symbolic type tags, however we can only do this when we can force the
+ * underlying type of the enum to be the desired size.
+ */
+#if !defined(__SUNPRO_CC) && !defined(__xlC__)
+
+#if defined(_MSC_VER)
+# define JS_ENUM_HEADER(id, type) enum id : type
+# define JS_ENUM_FOOTER(id)
+#else
+# define JS_ENUM_HEADER(id, type) enum id
+# define JS_ENUM_FOOTER(id) __attribute__((packed))
+#endif
+
+/* Remember to propagate changes to the C defines below. */
+JS_ENUM_HEADER(JSValueType, uint8_t)
+{
+ JSVAL_TYPE_DOUBLE = 0x00,
+ JSVAL_TYPE_INT32 = 0x01,
+ JSVAL_TYPE_UNDEFINED = 0x02,
+ JSVAL_TYPE_BOOLEAN = 0x03,
+ JSVAL_TYPE_MAGIC = 0x04,
+ JSVAL_TYPE_STRING = 0x05,
+ JSVAL_TYPE_SYMBOL = 0x06,
+ JSVAL_TYPE_NULL = 0x07,
+ JSVAL_TYPE_OBJECT = 0x08,
+
+ /* These never appear in a jsval; they are only provided as an out-of-band value. */
+ JSVAL_TYPE_UNKNOWN = 0x20,
+ JSVAL_TYPE_MISSING = 0x21
+} JS_ENUM_FOOTER(JSValueType);
+
+static_assert(sizeof(JSValueType) == 1,
+ "compiler typed enum support is apparently buggy");
+
+#if defined(JS_NUNBOX32)
+
+/* Remember to propagate changes to the C defines below. */
+JS_ENUM_HEADER(JSValueTag, uint32_t)
+{
+ JSVAL_TAG_CLEAR = 0xFFFFFF80,
+ JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32,
+ JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED,
+ JSVAL_TAG_STRING = JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING,
+ JSVAL_TAG_SYMBOL = JSVAL_TAG_CLEAR | JSVAL_TYPE_SYMBOL,
+ JSVAL_TAG_BOOLEAN = JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN,
+ JSVAL_TAG_MAGIC = JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC,
+ JSVAL_TAG_NULL = JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL,
+ JSVAL_TAG_OBJECT = JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT
+} JS_ENUM_FOOTER(JSValueTag);
+
+static_assert(sizeof(JSValueTag) == sizeof(uint32_t),
+ "compiler typed enum support is apparently buggy");
+
+#elif defined(JS_PUNBOX64)
+
+/* Remember to propagate changes to the C defines below. */
+JS_ENUM_HEADER(JSValueTag, uint32_t)
+{
+ JSVAL_TAG_MAX_DOUBLE = 0x1FFF0,
+ JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32,
+ JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED,
+ JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING,
+ JSVAL_TAG_SYMBOL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_SYMBOL,
+ JSVAL_TAG_BOOLEAN = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN,
+ JSVAL_TAG_MAGIC = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC,
+ JSVAL_TAG_NULL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL,
+ JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT
+} JS_ENUM_FOOTER(JSValueTag);
+
+static_assert(sizeof(JSValueTag) == sizeof(uint32_t),
+ "compiler typed enum support is apparently buggy");
+
+JS_ENUM_HEADER(JSValueShiftedTag, uint64_t)
+{
+ JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF),
+ JSVAL_SHIFTED_TAG_INT32 = (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_STRING = (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_SYMBOL = (((uint64_t)JSVAL_TAG_SYMBOL) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_MAGIC = (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_NULL = (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_OBJECT = (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT)
+} JS_ENUM_FOOTER(JSValueShiftedTag);
+
+static_assert(sizeof(JSValueShiftedTag) == sizeof(uint64_t),
+ "compiler typed enum support is apparently buggy");
+
+#endif
+
+/*
+ * All our supported compilers implement C++11 |enum Foo : T| syntax, so don't
+ * expose these macros. (This macro exists *only* because gcc bug 51242
+ * <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242> makes bit-fields of
+ * typed enums trigger a warning that can't be turned off. Don't expose it
+ * beyond this file!)
+ */
+#undef JS_ENUM_HEADER
+#undef JS_ENUM_FOOTER
+
+#else /* !defined(__SUNPRO_CC) && !defined(__xlC__) */
+
+typedef uint8_t JSValueType;
+#define JSVAL_TYPE_DOUBLE ((uint8_t)0x00)
+#define JSVAL_TYPE_INT32 ((uint8_t)0x01)
+#define JSVAL_TYPE_UNDEFINED ((uint8_t)0x02)
+#define JSVAL_TYPE_BOOLEAN ((uint8_t)0x03)
+#define JSVAL_TYPE_MAGIC ((uint8_t)0x04)
+#define JSVAL_TYPE_STRING ((uint8_t)0x05)
+#define JSVAL_TYPE_SYMBOL ((uint8_t)0x06)
+#define JSVAL_TYPE_NULL ((uint8_t)0x07)
+#define JSVAL_TYPE_OBJECT ((uint8_t)0x08)
+#define JSVAL_TYPE_UNKNOWN ((uint8_t)0x20)
+
+#if defined(JS_NUNBOX32)
+
+typedef uint32_t JSValueTag;
+#define JSVAL_TAG_CLEAR ((uint32_t)(0xFFFFFF80))
+#define JSVAL_TAG_INT32 ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32))
+#define JSVAL_TAG_UNDEFINED ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED))
+#define JSVAL_TAG_STRING ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING))
+#define JSVAL_TAG_SYMBOL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_SYMBOL))
+#define JSVAL_TAG_BOOLEAN ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN))
+#define JSVAL_TAG_MAGIC ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC))
+#define JSVAL_TAG_NULL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL))
+#define JSVAL_TAG_OBJECT ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT))
+
+#elif defined(JS_PUNBOX64)
+
+typedef uint32_t JSValueTag;
+#define JSVAL_TAG_MAX_DOUBLE ((uint32_t)(0x1FFF0))
+#define JSVAL_TAG_INT32 (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32)
+#define JSVAL_TAG_UNDEFINED (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED)
+#define JSVAL_TAG_STRING (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING)
+#define JSVAL_TAG_SYMBOL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_SYMBOL)
+#define JSVAL_TAG_BOOLEAN (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN)
+#define JSVAL_TAG_MAGIC (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC)
+#define JSVAL_TAG_NULL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL)
+#define JSVAL_TAG_OBJECT (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT)
+
+typedef uint64_t JSValueShiftedTag;
+#define JSVAL_SHIFTED_TAG_MAX_DOUBLE ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF)
+#define JSVAL_SHIFTED_TAG_INT32 (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_UNDEFINED (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_STRING (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_SYMBOL (((uint64_t)JSVAL_TAG_SYMBOL) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_BOOLEAN (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_MAGIC (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_NULL (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_OBJECT (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT)
+
+#endif /* JS_PUNBOX64 */
+#endif /* !defined(__SUNPRO_CC) && !defined(__xlC__) */
+
+#if defined(JS_NUNBOX32)
+
+#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_CLEAR | (type)))
+
+#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL
+#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT
+#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32
+#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING
+
+#elif defined(JS_PUNBOX64)
+
+#define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL
+#define JSVAL_TAG_MASK 0xFFFF800000000000LL
+#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type)))
+#define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64_t)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT)
+
+#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL
+#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT
+#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32
+#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING
+
+#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET JSVAL_SHIFTED_TAG_NULL
+#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET JSVAL_SHIFTED_TAG_OBJECT
+#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET JSVAL_SHIFTED_TAG_UNDEFINED
+#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET JSVAL_SHIFTED_TAG_STRING
+
+#endif /* JS_PUNBOX64 */
+
+typedef enum JSWhyMagic
+{
+ /** a hole in a native object's elements */
+ JS_ELEMENTS_HOLE,
+
+ /** there is not a pending iterator value */
+ JS_NO_ITER_VALUE,
+
+ /** exception value thrown when closing a generator */
+ JS_GENERATOR_CLOSING,
+
+ /** compiler sentinel value */
+ JS_NO_CONSTANT,
+
+ /** used in debug builds to catch tracing errors */
+ JS_THIS_POISON,
+
+ /** used in debug builds to catch tracing errors */
+ JS_ARG_POISON,
+
+ /** an empty subnode in the AST serializer */
+ JS_SERIALIZE_NO_NODE,
+
+ /** lazy arguments value on the stack */
+ JS_LAZY_ARGUMENTS,
+
+ /** optimized-away 'arguments' value */
+ JS_OPTIMIZED_ARGUMENTS,
+
+ /** magic value passed to natives to indicate construction */
+ JS_IS_CONSTRUCTING,
+
+ /** arguments.callee has been overwritten */
+ JS_OVERWRITTEN_CALLEE,
+
+ /** value of static block object slot */
+ JS_BLOCK_NEEDS_CLONE,
+
+ /** see class js::HashableValue */
+ JS_HASH_KEY_EMPTY,
+
+ /** error while running Ion code */
+ JS_ION_ERROR,
+
+ /** missing recover instruction result */
+ JS_ION_BAILOUT,
+
+ /** optimized out slot */
+ JS_OPTIMIZED_OUT,
+
+ /** uninitialized lexical bindings that produce ReferenceError on touch. */
+ JS_UNINITIALIZED_LEXICAL,
+
+ /** for local use */
+ JS_GENERIC_MAGIC,
+
+ JS_WHY_MAGIC_COUNT
+} JSWhyMagic;
+
+#if defined(IS_LITTLE_ENDIAN)
+# if defined(JS_NUNBOX32)
+typedef union jsval_layout
+{
+ uint64_t asBits;
+ struct {
+ union {
+ int32_t i32;
+ uint32_t u32;
+ uint32_t boo; // Don't use |bool| -- it must be four bytes.
+ JSString* str;
+ JS::Symbol* sym;
+ JSObject* obj;
+ js::gc::Cell* cell;
+ void* ptr;
+ JSWhyMagic why;
+ size_t word;
+ uintptr_t uintptr;
+ } payload;
+ JSValueTag tag;
+ } s;
+ double asDouble;
+ void* asPtr;
+} JSVAL_ALIGNMENT jsval_layout;
+# elif defined(JS_PUNBOX64)
+typedef union jsval_layout
+{
+ uint64_t asBits;
+#if !defined(_WIN64)
+ /* MSVC does not pack these correctly :-( */
+ struct {
+ uint64_t payload47 : 47;
+ JSValueTag tag : 17;
+ } debugView;
+#endif
+ struct {
+ union {
+ int32_t i32;
+ uint32_t u32;
+ JSWhyMagic why;
+ } payload;
+ } s;
+ double asDouble;
+ void* asPtr;
+ size_t asWord;
+ uintptr_t asUIntPtr;
+} JSVAL_ALIGNMENT jsval_layout;
+# endif /* JS_PUNBOX64 */
+#else /* defined(IS_LITTLE_ENDIAN) */
+# if defined(JS_NUNBOX32)
+typedef union jsval_layout
+{
+ uint64_t asBits;
+ struct {
+ JSValueTag tag;
+ union {
+ int32_t i32;
+ uint32_t u32;
+ uint32_t boo; // Don't use |bool| -- it must be four bytes.
+ JSString* str;
+ JS::Symbol* sym;
+ JSObject* obj;
+ js::gc::Cell* cell;
+ void* ptr;
+ JSWhyMagic why;
+ size_t word;
+ uintptr_t uintptr;
+ } payload;
+ } s;
+ double asDouble;
+ void* asPtr;
+} JSVAL_ALIGNMENT jsval_layout;
+# elif defined(JS_PUNBOX64)
+typedef union jsval_layout
+{
+ uint64_t asBits;
+ struct {
+ JSValueTag tag : 17;
+ uint64_t payload47 : 47;
+ } debugView;
+ struct {
+ uint32_t padding;
+ union {
+ int32_t i32;
+ uint32_t u32;
+ JSWhyMagic why;
+ } payload;
+ } s;
+ double asDouble;
+ void* asPtr;
+ size_t asWord;
+ uintptr_t asUIntPtr;
+} JSVAL_ALIGNMENT jsval_layout;
+# endif /* JS_PUNBOX64 */
+#endif /* defined(IS_LITTLE_ENDIAN) */
+
+/*
+ * For codesize purposes on some platforms, it's important that the
+ * compiler know that JS::Values constructed from constant values can be
+ * folded to constant bit patterns at compile time, rather than
+ * constructed at runtime. Doing this requires a fair amount of C++11
+ * features, which are not supported on all of our compilers. Set up
+ * some defines and helper macros in an attempt to confine the ugliness
+ * here, rather than scattering it all about the file. The important
+ * features are:
+ *
+ * - constexpr;
+ * - defaulted functions;
+ * - C99-style designated initializers.
+ */
+#if defined(__clang__)
+# if __has_feature(cxx_constexpr) && __has_feature(cxx_defaulted_functions)
+# define JS_VALUE_IS_CONSTEXPR
+# endif
+#elif defined(__GNUC__)
+/*
+ * We need 4.5 for defaulted functions, 4.6 for constexpr, 4.7 because 4.6
+ * doesn't understand |(X) { .field = ... }| syntax, and 4.7.3 because
+ * versions prior to that have bugs in the C++ front-end that cause crashes.
+ */
+# if MOZ_GCC_VERSION_AT_LEAST(4, 7, 3)
+# define JS_VALUE_IS_CONSTEXPR
+# endif
+#endif
+
+#if defined(JS_VALUE_IS_CONSTEXPR)
+# define JS_RETURN_LAYOUT_FROM_BITS(BITS) \
+ return (jsval_layout) { .asBits = (BITS) }
+# define JS_VALUE_CONSTEXPR MOZ_CONSTEXPR
+# define JS_VALUE_CONSTEXPR_VAR MOZ_CONSTEXPR_VAR
+#else
+# define JS_RETURN_LAYOUT_FROM_BITS(BITS) \
+ jsval_layout l; \
+ l.asBits = (BITS); \
+ return l;
+# define JS_VALUE_CONSTEXPR
+# define JS_VALUE_CONSTEXPR_VAR const
+#endif
+
+struct Value {
+ jsval_layout data;
+};
diff --git a/libbindgen/tests/headers/keywords.h b/libbindgen/tests/headers/keywords.h
new file mode 100644
index 00000000..8699ce5f
--- /dev/null
+++ b/libbindgen/tests/headers/keywords.h
@@ -0,0 +1,49 @@
+int u8;
+int u16;
+int u32;
+int u64;
+int i8;
+int i16;
+int i32;
+int i64;
+int f32;
+int f64;
+int usize;
+int isize;
+int as;
+int box;
+int crate;
+int false;
+int fn;
+int impl;
+int in;
+int let;
+int loop;
+int match;
+int mod;
+int move;
+int mut;
+int pub;
+int ref;
+int self;
+int Self;
+int super;
+int trait;
+int true;
+int type;
+int unsafe;
+int use;
+int where;
+int abstract;
+int alignof;
+int become;
+int final;
+int macro;
+int offsetof;
+int override;
+int priv;
+int proc;
+int pure;
+int unsized;
+int virtual;
+int yield;
diff --git a/libbindgen/tests/headers/macro-expr-basic.h b/libbindgen/tests/headers/macro-expr-basic.h
new file mode 100644
index 00000000..d2de7fdf
--- /dev/null
+++ b/libbindgen/tests/headers/macro-expr-basic.h
@@ -0,0 +1,14 @@
+#define FOO 1
+#define BAR 4
+#define BAZ (FOO + BAR)
+
+#define MIN (1 << 63)
+
+#define BARR (1 << 0)
+#define BAZZ ((1 << 1) + BAZ)
+#define I_RAN_OUT_OF_DUMB_NAMES (BARR | BAZZ)
+
+/* I haz a comment */
+#define HAZ_A_COMMENT BARR
+
+#define HAZ_A_COMMENT_INSIDE (/* comment for real */ BARR + FOO)
diff --git a/libbindgen/tests/headers/macro-redef.h b/libbindgen/tests/headers/macro-redef.h
new file mode 100644
index 00000000..0180d2ab
--- /dev/null
+++ b/libbindgen/tests/headers/macro-redef.h
@@ -0,0 +1,5 @@
+#define FOO 4
+#define BAR (1 + FOO)
+#undef FOO
+#define FOO 5
+#define BAZ (1 + FOO)
diff --git a/libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp b/libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp
new file mode 100644
index 00000000..1e2b133a
--- /dev/null
+++ b/libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp
@@ -0,0 +1,3 @@
+struct Foo {};
+struct Bar {};
+struct Baz : public Foo, public Bar {};
diff --git a/libbindgen/tests/headers/mutable.hpp b/libbindgen/tests/headers/mutable.hpp
new file mode 100644
index 00000000..b61a1031
--- /dev/null
+++ b/libbindgen/tests/headers/mutable.hpp
@@ -0,0 +1,14 @@
+class C {
+ mutable int m_member;
+ int m_other;
+};
+
+class NonCopiable {
+ mutable int m_member;
+
+ ~NonCopiable() {};
+};
+
+class NonCopiableWithNonCopiableMutableMember {
+ mutable NonCopiable m_member;
+};
diff --git a/libbindgen/tests/headers/namespace.hpp b/libbindgen/tests/headers/namespace.hpp
new file mode 100644
index 00000000..65788539
--- /dev/null
+++ b/libbindgen/tests/headers/namespace.hpp
@@ -0,0 +1,47 @@
+// bindgen-flags: --enable-cxx-namespaces
+
+void top_level();
+
+namespace whatever {
+ typedef int whatever_int_t;
+
+ void in_whatever();
+}
+
+namespace {
+ namespace empty {}
+
+ void foo();
+ struct A {
+ whatever::whatever_int_t b;
+ public:
+ int lets_hope_this_works();
+ };
+}
+
+template<typename T>
+class C: public A {
+ T m_c;
+ T* m_c_ptr;
+ T m_c_arr[10];
+};
+
+
+template<>
+class C<int>;
+
+
+namespace w {
+ typedef unsigned int whatever_int_t;
+
+ template<typename T>
+ class D {
+ C<T> m_c;
+ };
+
+ whatever_int_t heh(); // this should return w::whatever_int_t, and not whatever::whatever_int_t
+
+ C<int> foo();
+
+ C<float> barr(); // <- This is the problematic one
+}
diff --git a/libbindgen/tests/headers/nested.hpp b/libbindgen/tests/headers/nested.hpp
new file mode 100644
index 00000000..299e1768
--- /dev/null
+++ b/libbindgen/tests/headers/nested.hpp
@@ -0,0 +1,15 @@
+
+class Calc {
+ int w;
+};
+
+class Test {
+public:
+ struct Size;
+ friend struct Size;
+ struct Size {
+ struct Dimension : public Calc {
+ };
+ Dimension mWidth, mHeight;
+ };
+};
diff --git a/libbindgen/tests/headers/nested_vtable.hpp b/libbindgen/tests/headers/nested_vtable.hpp
new file mode 100644
index 00000000..87d6ce1f
--- /dev/null
+++ b/libbindgen/tests/headers/nested_vtable.hpp
@@ -0,0 +1,8 @@
+class nsISupports {
+public:
+ virtual nsISupports* QueryInterface();
+};
+
+class nsIRunnable : public nsISupports {};
+
+class Runnable : public nsIRunnable {};
diff --git a/libbindgen/tests/headers/no-std.h b/libbindgen/tests/headers/no-std.h
new file mode 100644
index 00000000..7bee9657
--- /dev/null
+++ b/libbindgen/tests/headers/no-std.h
@@ -0,0 +1,5 @@
+// bindgen-flags: --ctypes-prefix "libc" --use-core --raw-line "#![no_std]" --raw-line "mod libc { pub type c_int = i32; pub enum c_void {} }"
+struct foo {
+ int a, b;
+ void* bar;
+};
diff --git a/libbindgen/tests/headers/no_copy.hpp b/libbindgen/tests/headers/no_copy.hpp
new file mode 100644
index 00000000..349e428e
--- /dev/null
+++ b/libbindgen/tests/headers/no_copy.hpp
@@ -0,0 +1,6 @@
+
+/** <div rustbindgen nocopy></div> */
+template<typename T>
+class CopiableButWait {
+ int whatever;
+};
diff --git a/libbindgen/tests/headers/nsStyleAutoArray.hpp b/libbindgen/tests/headers/nsStyleAutoArray.hpp
new file mode 100644
index 00000000..950152c0
--- /dev/null
+++ b/libbindgen/tests/headers/nsStyleAutoArray.hpp
@@ -0,0 +1,57 @@
+
+template<typename T>
+class nsTArray {
+ T* mBuff;
+};
+
+template<typename T>
+class nsStyleAutoArray
+{
+public:
+ // This constructor places a single element in mFirstElement.
+ enum WithSingleInitialElement { WITH_SINGLE_INITIAL_ELEMENT };
+ explicit nsStyleAutoArray(WithSingleInitialElement) {}
+ nsStyleAutoArray(const nsStyleAutoArray& aOther) { *this = aOther; }
+ nsStyleAutoArray& operator=(const nsStyleAutoArray& aOther) {
+ mFirstElement = aOther.mFirstElement;
+ mOtherElements = aOther.mOtherElements;
+ return *this;
+ }
+
+ bool operator==(const nsStyleAutoArray& aOther) const {
+ return Length() == aOther.Length() &&
+ mFirstElement == aOther.mFirstElement &&
+ mOtherElements == aOther.mOtherElements;
+ }
+ bool operator!=(const nsStyleAutoArray& aOther) const {
+ return !(*this == aOther);
+ }
+
+ unsigned long Length() const {
+ return mOtherElements.Length() + 1;
+ }
+ const T& operator[](unsigned long aIndex) const {
+ return aIndex == 0 ? mFirstElement : mOtherElements[aIndex - 1];
+ }
+ T& operator[](unsigned long aIndex) {
+ return aIndex == 0 ? mFirstElement : mOtherElements[aIndex - 1];
+ }
+
+ void EnsureLengthAtLeast(unsigned long aMinLen) {
+ if (aMinLen > 0) {
+ mOtherElements.EnsureLengthAtLeast(aMinLen - 1);
+ }
+ }
+
+ void SetLengthNonZero(unsigned long aNewLen) {
+ mOtherElements.SetLength(aNewLen - 1);
+ }
+
+ void TruncateLengthNonZero(unsigned long aNewLen) {
+ mOtherElements.TruncateLength(aNewLen - 1);
+ }
+
+private:
+ T mFirstElement;
+ nsTArray<T> mOtherElements;
+};
diff --git a/libbindgen/tests/headers/only_bitfields.hpp b/libbindgen/tests/headers/only_bitfields.hpp
new file mode 100644
index 00000000..84db0586
--- /dev/null
+++ b/libbindgen/tests/headers/only_bitfields.hpp
@@ -0,0 +1,5 @@
+// bindgen-flags: --no-unstable-rust
+class C {
+ bool a: 1;
+ bool b: 7;
+};
diff --git a/libbindgen/tests/headers/opaque_in_struct.hpp b/libbindgen/tests/headers/opaque_in_struct.hpp
new file mode 100644
index 00000000..3cffeb20
--- /dev/null
+++ b/libbindgen/tests/headers/opaque_in_struct.hpp
@@ -0,0 +1,10 @@
+
+
+/** <div rustbindgen opaque> */
+typedef struct opaque {
+ int waht;
+} opaque;
+
+struct container {
+ opaque contained;
+};
diff --git a/libbindgen/tests/headers/opaque_pointer.hpp b/libbindgen/tests/headers/opaque_pointer.hpp
new file mode 100644
index 00000000..53f8ce1f
--- /dev/null
+++ b/libbindgen/tests/headers/opaque_pointer.hpp
@@ -0,0 +1,22 @@
+
+/**
+ * <div rustbindgen opaque></div>
+ */
+struct OtherOpaque {
+ int c;
+};
+
+/**
+ * <div rustbindgen opaque></div>
+ */
+template <typename T>
+struct Opaque {
+ T whatever;
+};
+
+struct WithOpaquePtr {
+ Opaque<int>* whatever;
+ Opaque<float> other;
+ OtherOpaque t;
+};
+
diff --git a/libbindgen/tests/headers/opaque_typedef.hpp b/libbindgen/tests/headers/opaque_typedef.hpp
new file mode 100644
index 00000000..25640738
--- /dev/null
+++ b/libbindgen/tests/headers/opaque_typedef.hpp
@@ -0,0 +1,17 @@
+// bindgen-flags: -- -std=c++11
+template<typename T>
+class RandomTemplate;
+
+template<int i>
+class Wat;
+
+template<int i>
+class Wat3;
+
+template<>
+class Wat3<3>;
+
+/** <div rustbindgen opaque></div> */
+typedef RandomTemplate<int> ShouldBeOpaque;
+
+typedef RandomTemplate<float> ShouldNotBeOpaque;
diff --git a/libbindgen/tests/headers/overflowed_enum.hpp b/libbindgen/tests/headers/overflowed_enum.hpp
new file mode 100644
index 00000000..1f2075a5
--- /dev/null
+++ b/libbindgen/tests/headers/overflowed_enum.hpp
@@ -0,0 +1,12 @@
+// bindgen-flags: -- -std=c++11 -Wno-narrowing
+
+enum Foo {
+ BAP_ARM = 0x93fcb9,
+ BAP_X86 = 0xb67eed,
+ BAP_X86_64 = 0xba7b274f,
+};
+
+enum Bar: unsigned short {
+ One = 1,
+ Big = 65538,
+};
diff --git a/libbindgen/tests/headers/overloading.hpp b/libbindgen/tests/headers/overloading.hpp
new file mode 100644
index 00000000..3c2b0487
--- /dev/null
+++ b/libbindgen/tests/headers/overloading.hpp
@@ -0,0 +1,9 @@
+extern bool Evaluate(char r);
+extern bool Evaluate(int x, int y);
+
+namespace foo {
+ extern void MyFunction();
+}
+namespace bar {
+ extern void MyFunction();
+}
diff --git a/libbindgen/tests/headers/private.hpp b/libbindgen/tests/headers/private.hpp
new file mode 100644
index 00000000..c0f3ce7f
--- /dev/null
+++ b/libbindgen/tests/headers/private.hpp
@@ -0,0 +1,21 @@
+
+struct HasPrivate {
+ int mNotPrivate;
+ /** <div rustbindgen private></div> */
+ int mIsPrivate;
+};
+
+
+/** <div rustbindgen private></div> */
+struct VeryPrivate {
+ int mIsPrivate;
+ int mIsAlsoPrivate;
+};
+
+
+/** <div rustbindgen private></div> */
+struct ContradictPrivate {
+ /** <div rustbindgen private="false"></div> */
+ int mNotPrivate;
+ int mIsPrivate;
+};
diff --git a/libbindgen/tests/headers/redeclaration.hpp b/libbindgen/tests/headers/redeclaration.hpp
new file mode 100644
index 00000000..d536b158
--- /dev/null
+++ b/libbindgen/tests/headers/redeclaration.hpp
@@ -0,0 +1,7 @@
+extern "C" {
+ void foo();
+}
+
+extern "C" {
+ void foo();
+}
diff --git a/libbindgen/tests/headers/ref_argument_array.hpp b/libbindgen/tests/headers/ref_argument_array.hpp
new file mode 100644
index 00000000..dc73fd62
--- /dev/null
+++ b/libbindgen/tests/headers/ref_argument_array.hpp
@@ -0,0 +1,6 @@
+
+#define NSID_LENGTH 10
+class nsID {
+public:
+ virtual void ToProvidedString(char (&aDest)[NSID_LENGTH]) = 0;
+};
diff --git a/libbindgen/tests/headers/replace_template_alias.hpp b/libbindgen/tests/headers/replace_template_alias.hpp
new file mode 100644
index 00000000..6ceae4e5
--- /dev/null
+++ b/libbindgen/tests/headers/replace_template_alias.hpp
@@ -0,0 +1,23 @@
+// bindgen-flags: -- --std=c++14
+
+namespace JS {
+namespace detail {
+
+/// Notice how this doesn't use T.
+template <typename T>
+using MaybeWrapped = int;
+
+}
+
+template <typename T>
+class Rooted {
+ detail::MaybeWrapped<T> ptr;
+};
+
+}
+
+/// But the replacement type does use T!
+///
+/// <div rustbindgen replaces="MaybeWrapped" />
+template <typename T>
+using replaces_MaybeWrapped = T;
diff --git a/libbindgen/tests/headers/replaces_double.hpp b/libbindgen/tests/headers/replaces_double.hpp
new file mode 100644
index 00000000..1a78b0d9
--- /dev/null
+++ b/libbindgen/tests/headers/replaces_double.hpp
@@ -0,0 +1,20 @@
+// bindgen-flags: --blacklist-type Wrapper -- --std=c++11
+
+template<typename T>
+struct Wrapper {
+ struct Wrapped {
+ T t;
+ };
+ using Type = Wrapped;
+};
+
+template<typename T>
+class Rooted {
+ using MaybeWrapped = typename Wrapper<T>::Type;
+ MaybeWrapped ptr;
+
+ /**
+ * <div rustbindgen replaces="Rooted_MaybeWrapped"></div>
+ */
+ using MaybeWrapped_simple = T;
+};
diff --git a/libbindgen/tests/headers/size_t_template.hpp b/libbindgen/tests/headers/size_t_template.hpp
new file mode 100644
index 00000000..6045c698
--- /dev/null
+++ b/libbindgen/tests/headers/size_t_template.hpp
@@ -0,0 +1,8 @@
+template<typename T, unsigned long N>
+class Array {
+ T inner[N];
+};
+
+class C {
+ Array<int, 3> arr;
+};
diff --git a/libbindgen/tests/headers/struct_containing_forward_declared_struct.h b/libbindgen/tests/headers/struct_containing_forward_declared_struct.h
new file mode 100644
index 00000000..d38aca2f
--- /dev/null
+++ b/libbindgen/tests/headers/struct_containing_forward_declared_struct.h
@@ -0,0 +1,7 @@
+struct a {
+ struct b* val_a;
+};
+
+struct b {
+ int val_b;
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_struct.h b/libbindgen/tests/headers/struct_with_anon_struct.h
new file mode 100644
index 00000000..1617d7a8
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_struct.h
@@ -0,0 +1,6 @@
+struct foo {
+ struct {
+ int a;
+ int b;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_struct_array.h b/libbindgen/tests/headers/struct_with_anon_struct_array.h
new file mode 100644
index 00000000..9ea977e8
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_struct_array.h
@@ -0,0 +1,10 @@
+struct foo {
+ struct {
+ int a;
+ int b;
+ } bar[2];
+ struct {
+ int a;
+ int b;
+ } baz[2][3][4];
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_struct_pointer.h b/libbindgen/tests/headers/struct_with_anon_struct_pointer.h
new file mode 100644
index 00000000..0c486d84
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_struct_pointer.h
@@ -0,0 +1,6 @@
+struct foo {
+ struct {
+ int a;
+ int b;
+ } *bar;
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_union.h b/libbindgen/tests/headers/struct_with_anon_union.h
new file mode 100644
index 00000000..3a92b940
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_union.h
@@ -0,0 +1,6 @@
+struct foo {
+ union {
+ unsigned int a;
+ unsigned short b;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_unnamed_struct.h b/libbindgen/tests/headers/struct_with_anon_unnamed_struct.h
new file mode 100644
index 00000000..f8ac4225
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_unnamed_struct.h
@@ -0,0 +1,6 @@
+struct foo {
+ struct {
+ unsigned int a;
+ unsigned int b;
+ };
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_unnamed_union.h b/libbindgen/tests/headers/struct_with_anon_unnamed_union.h
new file mode 100644
index 00000000..7158e727
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_unnamed_union.h
@@ -0,0 +1,6 @@
+struct foo {
+ union {
+ unsigned int a;
+ unsigned short b;
+ };
+};
diff --git a/libbindgen/tests/headers/struct_with_bitfields.h b/libbindgen/tests/headers/struct_with_bitfields.h
new file mode 100644
index 00000000..107fb136
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_bitfields.h
@@ -0,0 +1,13 @@
+// bindgen-flags: --no-unstable-rust
+struct bitfield {
+ unsigned short
+ a :1,
+ b :1,
+ c :1,
+ :1,
+ :2,
+ d :2;
+ int e;
+ unsigned int f : 2;
+ unsigned int g : 32;
+};
diff --git a/libbindgen/tests/headers/struct_with_derive_debug.h b/libbindgen/tests/headers/struct_with_derive_debug.h
new file mode 100644
index 00000000..98ba1b3d
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_derive_debug.h
@@ -0,0 +1,15 @@
+struct LittleArray {
+ int a[32];
+};
+
+struct BigArray{
+ int a[33];
+};
+
+struct WithLittleArray {
+ struct LittleArray a;
+};
+
+struct WithBigArray {
+ struct BigArray a;
+};
diff --git a/libbindgen/tests/headers/struct_with_nesting.h b/libbindgen/tests/headers/struct_with_nesting.h
new file mode 100644
index 00000000..9d7fa176
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_nesting.h
@@ -0,0 +1,17 @@
+struct foo {
+ unsigned int a;
+ union {
+ unsigned int b;
+ struct {
+ unsigned short c1;
+ unsigned short c2;
+ };
+
+ struct {
+ unsigned char d1;
+ unsigned char d2;
+ unsigned char d3;
+ unsigned char d4;
+ };
+ };
+};
diff --git a/libbindgen/tests/headers/struct_with_packing.h b/libbindgen/tests/headers/struct_with_packing.h
new file mode 100644
index 00000000..1b9fe131
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_packing.h
@@ -0,0 +1,4 @@
+struct a {
+ char b;
+ short c;
+} __attribute__((packed));
diff --git a/libbindgen/tests/headers/struct_with_struct.h b/libbindgen/tests/headers/struct_with_struct.h
new file mode 100644
index 00000000..78b1cc81
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_struct.h
@@ -0,0 +1,6 @@
+struct foo {
+ struct {
+ unsigned int x;
+ unsigned int y;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/struct_with_typedef_template_arg.hpp b/libbindgen/tests/headers/struct_with_typedef_template_arg.hpp
new file mode 100644
index 00000000..7fed21ab
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_typedef_template_arg.hpp
@@ -0,0 +1,4 @@
+template<typename T, typename ...Args>
+struct Proxy {
+ typedef void (*foo)(T* bar);
+};
diff --git a/libbindgen/tests/headers/template.hpp b/libbindgen/tests/headers/template.hpp
new file mode 100644
index 00000000..c13643c3
--- /dev/null
+++ b/libbindgen/tests/headers/template.hpp
@@ -0,0 +1,144 @@
+template<typename T, typename U> class Foo {
+ T m_member;
+ T* m_member_ptr;
+ T m_member_arr[1];
+};
+
+void bar(Foo<int, int> foo);
+
+template<typename T>
+class D {
+ typedef Foo<int, int> MyFoo;
+
+ MyFoo m_foo;
+
+ template<typename Z>
+ class U {
+ MyFoo m_nested_foo;
+ Z m_baz;
+ };
+};
+
+template<typename T>
+class Rooted {
+ T* prev;
+ Rooted<void*>* next;
+ T ptr;
+};
+
+class RootedContainer {
+ Rooted<void*> root;
+};
+
+template<typename T>
+class WithDtor;
+
+typedef WithDtor<int> WithDtorIntFwd;
+
+template<typename T>
+class WithDtor {
+ T member;
+ ~WithDtor() {}
+};
+
+class PODButContainsDtor {
+ WithDtorIntFwd member;
+};
+
+
+/** <div rustbindgen opaque> */
+template<typename T>
+class Opaque {
+ T member;
+};
+
+class POD {
+ Opaque<int> opaque_member;
+};
+
+/**
+ * <div rustbindgen replaces="NestedReplaced"></div>
+ */
+template<typename T>
+class Nested {
+ T* buff;
+};
+
+template<typename T, typename U>
+class NestedBase {
+ T* buff;
+};
+
+template<typename T>
+class NestedReplaced: public NestedBase<T, int> {
+};
+
+template<typename T>
+class Incomplete;
+
+template<typename T>
+class NestedContainer {
+ T c;
+private:
+ NestedReplaced<T> nested;
+ Incomplete<T> inc;
+};
+
+template<typename T>
+class Incomplete {
+ T d;
+};
+
+class Untemplated {};
+
+template<typename T>
+class Templated {
+ Untemplated m_untemplated;
+};
+
+/**
+ * If the replacement doesn't happen at the parse level the container would be
+ * copy and the replacement wouldn't, so this wouldn't compile.
+ *
+ * <div rustbindgen replaces="ReplacedWithoutDestructor"></div>
+ */
+template<typename T>
+class ReplacedWithDestructor {
+ T* buff;
+ ~ReplacedWithDestructor() {};
+};
+
+template<typename T>
+class ReplacedWithoutDestructor {
+ T* buff;
+};
+
+template<typename T>
+class ReplacedWithoutDestructorFwd;
+
+template<typename T>
+class ShouldNotBeCopiable {
+ ReplacedWithoutDestructor<T> m_member;
+};
+
+template<typename U>
+class ShouldNotBeCopiableAsWell {
+ ReplacedWithoutDestructorFwd<U> m_member;
+};
+
+/**
+ * If the replacement doesn't happen at the parse level the container would be
+ * copy and the replacement wouldn't, so this wouldn't compile.
+ *
+ * <div rustbindgen replaces="ReplacedWithoutDestructorFwd"></div>
+ */
+template<typename T>
+class ReplacedWithDestructorDeclaredAfter {
+ T* buff;
+ ~ReplacedWithDestructorDeclaredAfter() {};
+};
+
+template<typename T>
+class TemplateWithVar {
+ static T var = 0;
+};
diff --git a/libbindgen/tests/headers/template_alias.hpp b/libbindgen/tests/headers/template_alias.hpp
new file mode 100644
index 00000000..646d9f40
--- /dev/null
+++ b/libbindgen/tests/headers/template_alias.hpp
@@ -0,0 +1,13 @@
+// bindgen-flags: -- -std=c++14
+
+namespace JS {
+namespace detail {
+ template <typename T>
+ using Wrapped = T;
+}
+
+template <typename T>
+struct Rooted {
+ detail::Wrapped<T> ptr;
+};
+}
diff --git a/libbindgen/tests/headers/template_alias_basic.hpp b/libbindgen/tests/headers/template_alias_basic.hpp
new file mode 100644
index 00000000..964f6e27
--- /dev/null
+++ b/libbindgen/tests/headers/template_alias_basic.hpp
@@ -0,0 +1,4 @@
+// bindgen-flags: -- -std=c++11
+
+template<typename T>
+using Wrapped = T;
diff --git a/libbindgen/tests/headers/template_alias_namespace.hpp b/libbindgen/tests/headers/template_alias_namespace.hpp
new file mode 100644
index 00000000..bd637166
--- /dev/null
+++ b/libbindgen/tests/headers/template_alias_namespace.hpp
@@ -0,0 +1,13 @@
+// bindgen-flags: --enable-cxx-namespaces -- -std=c++14
+
+namespace JS {
+namespace detail {
+ template <typename T>
+ using Wrapped = T;
+}
+
+template <typename T>
+struct Rooted {
+ detail::Wrapped<T> ptr;
+};
+}
diff --git a/libbindgen/tests/headers/template_typedef_transitive_param.hpp b/libbindgen/tests/headers/template_typedef_transitive_param.hpp
new file mode 100644
index 00000000..2269ac36
--- /dev/null
+++ b/libbindgen/tests/headers/template_typedef_transitive_param.hpp
@@ -0,0 +1,7 @@
+template<typename T>
+struct Wrapper {
+ struct Wrapped {
+ T t;
+ };
+ using Type = Wrapped;
+};
diff --git a/libbindgen/tests/headers/template_typedefs.hpp b/libbindgen/tests/headers/template_typedefs.hpp
new file mode 100644
index 00000000..5e13dcd8
--- /dev/null
+++ b/libbindgen/tests/headers/template_typedefs.hpp
@@ -0,0 +1,8 @@
+typedef void (*foo)(int);
+
+template<typename T, typename U>
+class Foo {
+ typedef T Char;
+ typedef Char* FooPtrTypedef;
+ typedef bool (*nsCOMArrayEnumFunc)(T* aElement, void* aData);
+};
diff --git a/libbindgen/tests/headers/type_alias_empty.hpp b/libbindgen/tests/headers/type_alias_empty.hpp
new file mode 100644
index 00000000..f0760c8f
--- /dev/null
+++ b/libbindgen/tests/headers/type_alias_empty.hpp
@@ -0,0 +1,10 @@
+// bindgen-flags: --whitelist-type bool_constant -- -std=c++11
+
+// NB: The --whitelist-type is done to trigger the traversal of the types on
+// codegen in order to trigger #67.
+
+template<typename T, T Val>
+struct integral_constant {};
+
+template<bool B>
+using bool_constant = integral_constant<bool, B>;
diff --git a/libbindgen/tests/headers/typeref.hpp b/libbindgen/tests/headers/typeref.hpp
new file mode 100644
index 00000000..b94c98ef
--- /dev/null
+++ b/libbindgen/tests/headers/typeref.hpp
@@ -0,0 +1,28 @@
+struct nsFoo;
+
+namespace mozilla {
+
+struct FragmentOrURL { bool mIsLocalRef; };
+struct Position { };
+
+} // namespace mozilla
+
+class Bar {
+ nsFoo* mFoo;
+};
+
+namespace mozilla {
+
+template<typename ReferenceBox>
+struct StyleShapeSource {
+ union {
+ Position* mPosition;
+ FragmentOrURL* mFragmentOrURL;
+ };
+};
+
+} // namespace mozilla
+
+struct nsFoo {
+ mozilla::StyleShapeSource<int> mBar;
+};
diff --git a/libbindgen/tests/headers/union_dtor.hpp b/libbindgen/tests/headers/union_dtor.hpp
new file mode 100644
index 00000000..399dc89d
--- /dev/null
+++ b/libbindgen/tests/headers/union_dtor.hpp
@@ -0,0 +1,5 @@
+union UnionWithDtor {
+ ~UnionWithDtor();
+ int mFoo;
+ void* mBar;
+};
diff --git a/libbindgen/tests/headers/union_fields.hpp b/libbindgen/tests/headers/union_fields.hpp
new file mode 100644
index 00000000..aec3a7fd
--- /dev/null
+++ b/libbindgen/tests/headers/union_fields.hpp
@@ -0,0 +1,5 @@
+typedef union {
+ int mInt;
+ float mFloat;
+ void* mPointer;
+} nsStyleUnion;
diff --git a/libbindgen/tests/headers/union_template.hpp b/libbindgen/tests/headers/union_template.hpp
new file mode 100644
index 00000000..0d0a9bb3
--- /dev/null
+++ b/libbindgen/tests/headers/union_template.hpp
@@ -0,0 +1,19 @@
+template<typename T>
+struct NastyStruct {
+ bool mIsSome;
+ union {
+ void* mFoo;
+ unsigned long mDummy;
+ } mStorage;
+
+ union {
+ short wat;
+ int* wut;
+ };
+};
+
+template<typename T>
+union Whatever {
+ void* mTPtr;
+ int mInt;
+};
diff --git a/libbindgen/tests/headers/union_with_anon_struct.h b/libbindgen/tests/headers/union_with_anon_struct.h
new file mode 100644
index 00000000..7f8dec95
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_struct.h
@@ -0,0 +1,6 @@
+union foo {
+ struct {
+ unsigned int a;
+ unsigned int b;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/union_with_anon_struct_bitfield.h b/libbindgen/tests/headers/union_with_anon_struct_bitfield.h
new file mode 100644
index 00000000..24c7dce8
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_struct_bitfield.h
@@ -0,0 +1,8 @@
+// bindgen-flags: --no-unstable-rust
+union foo {
+ int a;
+ struct {
+ int b : 7;
+ int c : 25;
+ };
+};
diff --git a/libbindgen/tests/headers/union_with_anon_union.h b/libbindgen/tests/headers/union_with_anon_union.h
new file mode 100644
index 00000000..212431b8
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_union.h
@@ -0,0 +1,6 @@
+union foo {
+ union {
+ unsigned int a;
+ unsigned short b;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/union_with_anon_unnamed_struct.h b/libbindgen/tests/headers/union_with_anon_unnamed_struct.h
new file mode 100644
index 00000000..79558049
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_unnamed_struct.h
@@ -0,0 +1,9 @@
+union pixel {
+ unsigned int rgba;
+ struct {
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+ unsigned char a;
+ };
+};
diff --git a/libbindgen/tests/headers/union_with_anon_unnamed_union.h b/libbindgen/tests/headers/union_with_anon_unnamed_union.h
new file mode 100644
index 00000000..7580771a
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_unnamed_union.h
@@ -0,0 +1,7 @@
+union foo {
+ unsigned int a;
+ union {
+ unsigned short b;
+ unsigned char c;
+ };
+};
diff --git a/libbindgen/tests/headers/union_with_big_member.h b/libbindgen/tests/headers/union_with_big_member.h
new file mode 100644
index 00000000..6347d6ca
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_big_member.h
@@ -0,0 +1,14 @@
+union WithBigArray {
+ int a;
+ int b[33];
+};
+
+union WithBigArray2 {
+ int a;
+ char b[33];
+};
+
+union WithBigMember {
+ int a;
+ union WithBigArray b;
+};
diff --git a/libbindgen/tests/headers/union_with_nesting.h b/libbindgen/tests/headers/union_with_nesting.h
new file mode 100644
index 00000000..cd907d57
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_nesting.h
@@ -0,0 +1,14 @@
+union foo {
+ unsigned int a;
+ struct {
+ union {
+ unsigned short b1;
+ unsigned short b2;
+ };
+
+ union {
+ unsigned short c1;
+ unsigned short c2;
+ };
+ };
+};
diff --git a/libbindgen/tests/headers/unknown_attr.h b/libbindgen/tests/headers/unknown_attr.h
new file mode 100644
index 00000000..f87e9f0b
--- /dev/null
+++ b/libbindgen/tests/headers/unknown_attr.h
@@ -0,0 +1,6 @@
+typedef struct {
+ long long __clang_max_align_nonce1
+ __attribute__((__aligned__(__alignof__(long long))));
+ long double __clang_max_align_nonce2
+ __attribute__((__aligned__(__alignof__(long double))));
+} max_align_t;
diff --git a/libbindgen/tests/headers/use-core.h b/libbindgen/tests/headers/use-core.h
new file mode 100644
index 00000000..42bb10d9
--- /dev/null
+++ b/libbindgen/tests/headers/use-core.h
@@ -0,0 +1,8 @@
+// bindgen-flags: --use-core --raw-line "extern crate core;"
+
+struct foo {
+ int a, b;
+ void* bar;
+};
+
+typedef void (*fooFunction)(int bar);
diff --git a/libbindgen/tests/headers/using.hpp b/libbindgen/tests/headers/using.hpp
new file mode 100644
index 00000000..ba07b9c8
--- /dev/null
+++ b/libbindgen/tests/headers/using.hpp
@@ -0,0 +1,11 @@
+// bindgen-flags: -- -std=c++11
+
+template<typename T>
+class Point {
+ T x;
+ T y;
+};
+
+typedef Point<int> IntPoint2D;
+
+using IntVec2D = Point<int>;
diff --git a/libbindgen/tests/headers/vector.hpp b/libbindgen/tests/headers/vector.hpp
new file mode 100644
index 00000000..4707f77f
--- /dev/null
+++ b/libbindgen/tests/headers/vector.hpp
@@ -0,0 +1,3 @@
+struct foo {
+ __attribute__((__vector_size__(1 * sizeof(long long)))) long long mMember;
+};
diff --git a/libbindgen/tests/headers/virtual_dtor.hpp b/libbindgen/tests/headers/virtual_dtor.hpp
new file mode 100644
index 00000000..c35dcab1
--- /dev/null
+++ b/libbindgen/tests/headers/virtual_dtor.hpp
@@ -0,0 +1,3 @@
+struct nsSlots {
+ virtual ~nsSlots();
+};
diff --git a/libbindgen/tests/headers/virtual_overloaded.hpp b/libbindgen/tests/headers/virtual_overloaded.hpp
new file mode 100644
index 00000000..8aea8a19
--- /dev/null
+++ b/libbindgen/tests/headers/virtual_overloaded.hpp
@@ -0,0 +1,5 @@
+class C {
+public:
+ virtual void do_thing(char) { };
+ virtual void do_thing(int) { };
+};
diff --git a/libbindgen/tests/headers/vtable_recursive_sig.hpp b/libbindgen/tests/headers/vtable_recursive_sig.hpp
new file mode 100644
index 00000000..8729be00
--- /dev/null
+++ b/libbindgen/tests/headers/vtable_recursive_sig.hpp
@@ -0,0 +1,11 @@
+// bindgen-flags: -- -std=c++11
+
+class Derived;
+class Base {
+public:
+ virtual Derived* AsDerived() { return nullptr; }
+};
+
+class Derived final : public Base {
+ virtual Derived* AsDerived() override { return this; }
+};
diff --git a/libbindgen/tests/headers/weird_bitfields.hpp b/libbindgen/tests/headers/weird_bitfields.hpp
new file mode 100644
index 00000000..755681c1
--- /dev/null
+++ b/libbindgen/tests/headers/weird_bitfields.hpp
@@ -0,0 +1,35 @@
+// bindgen-flags: --no-unstable-rust
+// You can guess where this is taken from...
+enum nsStyleSVGOpacitySource {
+ eStyleSVGOpacitySource_Normal,
+ eStyleSVGOpacitySource_ContextFillOpacity,
+ eStyleSVGOpacitySource_ContextStrokeOpacity
+};
+
+class Weird {
+ unsigned int mStrokeDasharrayLength;
+ unsigned int bitTest: 16;
+ unsigned int bitTest2: 15;
+ unsigned char mClipRule; // [inherited]
+ unsigned char mColorInterpolation; // [inherited] see nsStyleConsts.h
+ unsigned char mColorInterpolationFilters; // [inherited] see nsStyleConsts.h
+ unsigned char mFillRule; // [inherited] see nsStyleConsts.h
+ unsigned char mImageRendering; // [inherited] see nsStyleConsts.h
+ unsigned char mPaintOrder; // [inherited] see nsStyleConsts.h
+ unsigned char mShapeRendering; // [inherited] see nsStyleConsts.h
+ unsigned char mStrokeLinecap; // [inherited] see nsStyleConsts.h
+ unsigned char mStrokeLinejoin; // [inherited] see nsStyleConsts.h
+ unsigned char mTextAnchor; // [inherited] see nsStyleConsts.h
+ unsigned char mTextRendering; // [inherited] see nsStyleConsts.h
+
+ // In SVG glyphs, whether we inherit fill or stroke opacity from the outer
+ // text object.
+ // Use 3 bits to avoid signedness problems in MSVC.
+ nsStyleSVGOpacitySource mFillOpacitySource : 3;
+ nsStyleSVGOpacitySource mStrokeOpacitySource : 3;
+
+ // SVG glyph outer object inheritance for other properties
+ bool mStrokeDasharrayFromObject : 1;
+ bool mStrokeDashoffsetFromObject : 1;
+ bool mStrokeWidthFromObject : 1;
+};
diff --git a/libbindgen/tests/headers/what_is_going_on.hpp b/libbindgen/tests/headers/what_is_going_on.hpp
new file mode 100644
index 00000000..078c1ad5
--- /dev/null
+++ b/libbindgen/tests/headers/what_is_going_on.hpp
@@ -0,0 +1,19 @@
+
+struct UnknownUnits {};
+typedef float Float;
+
+template<class units, class F = Float>
+struct PointTyped {
+ F x;
+ F y;
+
+ static PointTyped<units, F> FromUnknownPoint(const PointTyped<UnknownUnits, F>& aPoint) {
+ return PointTyped<units, F>(aPoint.x, aPoint.y);
+ }
+
+ PointTyped<UnknownUnits, F> ToUnknownPoint() const {
+ return PointTyped<UnknownUnits, F>(this->x, this->y);
+ }
+};
+
+typedef PointTyped<UnknownUnits> IntPoint;
diff --git a/libbindgen/tests/headers/whitelist_basic.hpp b/libbindgen/tests/headers/whitelist_basic.hpp
new file mode 100644
index 00000000..8424f75a
--- /dev/null
+++ b/libbindgen/tests/headers/whitelist_basic.hpp
@@ -0,0 +1,16 @@
+// bindgen-flags: --whitelist-type WhitelistMe
+
+template<typename T>
+class WhitelistMe {
+ class Inner {
+ T bar;
+ };
+
+ int foo;
+ Inner bar;
+};
+
+struct DontWhitelistMe {
+ void* foo;
+ double _Complex noComplexGenerated;
+};
diff --git a/libbindgen/tests/headers/whitelist_vars.h b/libbindgen/tests/headers/whitelist_vars.h
new file mode 100644
index 00000000..07fa2815
--- /dev/null
+++ b/libbindgen/tests/headers/whitelist_vars.h
@@ -0,0 +1,4 @@
+#define NONE 0
+#define FOO 5
+#define FOOB -2
+#define FOOBAR (-10)