• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq -- -std=c++11
2 //
3 template<typename T, typename U> class Foo {
4     T m_member;
5     T* m_member_ptr;
6     T m_member_arr[1];
7 };
8 
9 template<typename T> class B {
10     T m_member { 0 };
11 };
12 
13 void bar(Foo<int, int> foo);
14 
15 namespace mozilla {
16 class Foo;
17 };
18 
19 struct C {
20     B<unsigned int> mB;
21     B<const int*> mBConstPtr;
22     B<const mozilla::Foo*> mBConstStructPtr;
23     B<const mozilla::Foo*[1]> mBConstStructPtrArray;
24     B<const int> mBConst;
25     B<volatile int> mBVolatile;
26     B<const bool> mBConstBool;
27     B<const char16_t> mBConstChar;
28     B<int[1]> mBArray;
29     B<int*[1]> mBPtrArray;
30     B<int(*)[1]> mBArrayPtr;
31     B<int&> mBRef;
32     B<const int&> mBConstRef;
33     B<int*&> mPtrRef;
34     B<int(&)[1]> mArrayRef;
35     B<const int[1]> mBConstArray;
36 };
37 
38 template<typename T>
39 class D {
40     typedef Foo<int, int> MyFoo;
41 
42     MyFoo m_foo;
43 
44     template<typename Z>
45     class U {
46         MyFoo m_nested_foo;
47         Z m_baz;
48     };
49 };
50 
51 template<typename T>
52 class Rooted {
53     T* prev;
54     Rooted<void*>* next;
55     T ptr;
56 };
57 
58 class RootedContainer {
59     Rooted<void*> root;
60 };
61 
62 template<typename T>
63 class WithDtor;
64 
65 typedef WithDtor<int> WithDtorIntFwd;
66 
67 template<typename T>
68 class WithDtor {
69     T member;
~WithDtor()70     ~WithDtor() {}
71 };
72 
73 class PODButContainsDtor {
74     WithDtorIntFwd member;
75 };
76 
77 
78 /** <div rustbindgen opaque> */
79 template<typename T>
80 class Opaque {
81     T member;
82 };
83 
84 class POD {
85     Opaque<int> opaque_member;
86 };
87 
88 /**
89  * <div rustbindgen replaces="NestedReplaced"></div>
90  */
91 template<typename T>
92 class Nested {
93     T* buff;
94 };
95 
96 template<typename T, typename U>
97 class NestedBase {
98     T* buff;
99 };
100 
101 template<typename T>
102 class NestedReplaced: public NestedBase<T, int> {
103 };
104 
105 template<typename T>
106 class Incomplete;
107 
108 template<typename T>
109 class NestedContainer {
110     T c;
111 private:
112     NestedReplaced<T> nested;
113     Incomplete<T> inc;
114 };
115 
116 template<typename T>
117 class Incomplete {
118     T d;
119 };
120 
121 class Untemplated {};
122 
123 template<typename T>
124 class Templated {
125     Untemplated m_untemplated;
126 };
127 
128 /**
129  * If the replacement doesn't happen at the parse level the container would be
130  * copy and the replacement wouldn't, so this wouldn't compile.
131  *
132  * <div rustbindgen replaces="ReplacedWithoutDestructor"></div>
133  */
134 template<typename T>
135 class ReplacedWithDestructor {
136     T* buff;
~ReplacedWithDestructor()137     ~ReplacedWithDestructor() {};
138 };
139 
140 template<typename T>
141 class ReplacedWithoutDestructor {
142     T* buff;
143 };
144 
145 template<typename T>
146 class ReplacedWithoutDestructorFwd;
147 
148 template<typename T>
149 class ShouldNotBeCopiable {
150     ReplacedWithoutDestructor<T> m_member;
151 };
152 
153 template<typename U>
154 class ShouldNotBeCopiableAsWell {
155     ReplacedWithoutDestructorFwd<U> m_member;
156 };
157 
158 /**
159  * If the replacement doesn't happen at the parse level the container would be
160  * copy and the replacement wouldn't, so this wouldn't compile.
161  *
162  * <div rustbindgen replaces="ReplacedWithoutDestructorFwd"></div>
163  */
164 template<typename T>
165 class ReplacedWithDestructorDeclaredAfter {
166     T* buff;
~ReplacedWithDestructorDeclaredAfter()167     ~ReplacedWithDestructorDeclaredAfter() {};
168 };
169