| 1 |
#if 0 |
| 2 |
''' ' |
| 3 |
#endif |
| 4 |
|
| 5 |
#ifdef __cplusplus |
| 6 |
template <typename T> |
| 7 |
using Box = T*; |
| 8 |
#endif |
| 9 |
|
| 10 |
#if 0 |
| 11 |
' ''' |
| 12 |
#endif |
| 13 |
|
| 14 |
|
| 15 |
#include <cstdarg> |
| 16 |
#include <cstdint> |
| 17 |
#include <cstdlib> |
| 18 |
#include <ostream> |
| 19 |
#include <new> |
| 20 |
|
| 21 |
enum class A : uint64_t { |
| 22 |
a1 = 0, |
| 23 |
a2 = 2, |
| 24 |
a3, |
| 25 |
a4 = 5, |
| 26 |
}; |
| 27 |
|
| 28 |
enum class B : uint32_t { |
| 29 |
b1 = 0, |
| 30 |
b2 = 2, |
| 31 |
b3, |
| 32 |
b4 = 5, |
| 33 |
}; |
| 34 |
|
| 35 |
enum class C : uint16_t { |
| 36 |
c1 = 0, |
| 37 |
c2 = 2, |
| 38 |
c3, |
| 39 |
c4 = 5, |
| 40 |
}; |
| 41 |
|
| 42 |
enum class D : uint8_t { |
| 43 |
d1 = 0, |
| 44 |
d2 = 2, |
| 45 |
d3, |
| 46 |
d4 = 5, |
| 47 |
}; |
| 48 |
|
| 49 |
enum class E : uintptr_t { |
| 50 |
e1 = 0, |
| 51 |
e2 = 2, |
| 52 |
e3, |
| 53 |
e4 = 5, |
| 54 |
}; |
| 55 |
|
| 56 |
enum class F : intptr_t { |
| 57 |
f1 = 0, |
| 58 |
f2 = 2, |
| 59 |
f3, |
| 60 |
f4 = 5, |
| 61 |
}; |
| 62 |
|
| 63 |
enum class L { |
| 64 |
l1, |
| 65 |
l2, |
| 66 |
l3, |
| 67 |
l4, |
| 68 |
}; |
| 69 |
|
| 70 |
enum class M : int8_t { |
| 71 |
m1 = -1, |
| 72 |
m2 = 0, |
| 73 |
m3 = 1, |
| 74 |
}; |
| 75 |
|
| 76 |
enum N { |
| 77 |
n1, |
| 78 |
n2, |
| 79 |
n3, |
| 80 |
n4, |
| 81 |
}; |
| 82 |
|
| 83 |
enum O : int8_t { |
| 84 |
o1, |
| 85 |
o2, |
| 86 |
o3, |
| 87 |
o4, |
| 88 |
}; |
| 89 |
|
| 90 |
struct J; |
| 91 |
|
| 92 |
struct K; |
| 93 |
|
| 94 |
struct Opaque; |
| 95 |
|
| 96 |
union G { |
| 97 |
enum class Tag : uint8_t { |
| 98 |
Foo, |
| 99 |
Bar, |
| 100 |
Baz, |
| 101 |
}; |
| 102 |
|
| 103 |
struct Foo_Body { |
| 104 |
Tag tag; |
| 105 |
int16_t _0; |
| 106 |
}; |
| 107 |
|
| 108 |
struct Bar_Body { |
| 109 |
Tag tag; |
| 110 |
uint8_t x; |
| 111 |
int16_t y; |
| 112 |
}; |
| 113 |
|
| 114 |
struct { |
| 115 |
Tag tag; |
| 116 |
}; |
| 117 |
Foo_Body foo; |
| 118 |
Bar_Body bar; |
| 119 |
}; |
| 120 |
|
| 121 |
struct H { |
| 122 |
enum class Tag { |
| 123 |
H_Foo, |
| 124 |
H_Bar, |
| 125 |
H_Baz, |
| 126 |
}; |
| 127 |
|
| 128 |
struct H_Foo_Body { |
| 129 |
int16_t _0; |
| 130 |
}; |
| 131 |
|
| 132 |
struct H_Bar_Body { |
| 133 |
uint8_t x; |
| 134 |
int16_t y; |
| 135 |
}; |
| 136 |
|
| 137 |
Tag tag; |
| 138 |
union { |
| 139 |
H_Foo_Body foo; |
| 140 |
H_Bar_Body bar; |
| 141 |
}; |
| 142 |
}; |
| 143 |
|
| 144 |
struct ExI { |
| 145 |
enum class Tag : uint8_t { |
| 146 |
ExI_Foo, |
| 147 |
ExI_Bar, |
| 148 |
ExI_Baz, |
| 149 |
}; |
| 150 |
|
| 151 |
struct ExI_Foo_Body { |
| 152 |
int16_t _0; |
| 153 |
}; |
| 154 |
|
| 155 |
struct ExI_Bar_Body { |
| 156 |
uint8_t x; |
| 157 |
int16_t y; |
| 158 |
}; |
| 159 |
|
| 160 |
Tag tag; |
| 161 |
union { |
| 162 |
ExI_Foo_Body foo; |
| 163 |
ExI_Bar_Body bar; |
| 164 |
}; |
| 165 |
}; |
| 166 |
|
| 167 |
struct P { |
| 168 |
enum class Tag : uint8_t { |
| 169 |
P0, |
| 170 |
P1, |
| 171 |
}; |
| 172 |
|
| 173 |
struct P0_Body { |
| 174 |
uint8_t _0; |
| 175 |
}; |
| 176 |
|
| 177 |
struct P1_Body { |
| 178 |
uint8_t _0; |
| 179 |
uint8_t _1; |
| 180 |
uint8_t _2; |
| 181 |
}; |
| 182 |
|
| 183 |
Tag tag; |
| 184 |
union { |
| 185 |
P0_Body p0; |
| 186 |
P1_Body p1; |
| 187 |
}; |
| 188 |
}; |
| 189 |
|
| 190 |
struct Q { |
| 191 |
enum class Tag { |
| 192 |
Ok, |
| 193 |
Err, |
| 194 |
}; |
| 195 |
|
| 196 |
struct Ok_Body { |
| 197 |
Box<uint32_t> _0; |
| 198 |
}; |
| 199 |
|
| 200 |
struct Err_Body { |
| 201 |
uint32_t _0; |
| 202 |
}; |
| 203 |
|
| 204 |
Tag tag; |
| 205 |
union { |
| 206 |
Ok_Body ok; |
| 207 |
Err_Body err; |
| 208 |
}; |
| 209 |
}; |
| 210 |
|
| 211 |
struct R { |
| 212 |
enum class Tag { |
| 213 |
IRFoo, |
| 214 |
IRBar, |
| 215 |
IRBaz, |
| 216 |
}; |
| 217 |
|
| 218 |
struct IRFoo_Body { |
| 219 |
int16_t _0; |
| 220 |
}; |
| 221 |
|
| 222 |
struct IRBar_Body { |
| 223 |
uint8_t x; |
| 224 |
int16_t y; |
| 225 |
}; |
| 226 |
|
| 227 |
Tag tag; |
| 228 |
union { |
| 229 |
IRFoo_Body IRFoo; |
| 230 |
IRBar_Body IRBar; |
| 231 |
}; |
| 232 |
}; |
| 233 |
|
| 234 |
extern "C" { |
| 235 |
|
| 236 |
void root(Opaque *opaque, |
| 237 |
A a, |
| 238 |
B b, |
| 239 |
C c, |
| 240 |
D d, |
| 241 |
E e, |
| 242 |
F f, |
| 243 |
G g, |
| 244 |
H h, |
| 245 |
ExI i, |
| 246 |
J j, |
| 247 |
K k, |
| 248 |
L l, |
| 249 |
M m, |
| 250 |
N n, |
| 251 |
O o, |
| 252 |
P p, |
| 253 |
Q q, |
| 254 |
R r); |
| 255 |
|
| 256 |
} // extern "C" |
| 257 |
|
| 258 |
#if 0 |
| 259 |
''' ' |
| 260 |
#endif |
| 261 |
|
| 262 |
#include <stddef.h> |
| 263 |
#include "testing-helpers.h" |
| 264 |
static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); |
| 265 |
static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); |
| 266 |
static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); |
| 267 |
static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); |
| 268 |
|
| 269 |
#if 0 |
| 270 |
' ''' |
| 271 |
#endif |