| 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 |
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t |
| 16 |
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t |
| 17 |
cdef extern from *: |
| 18 |
ctypedef bint bool |
| 19 |
ctypedef struct va_list |
| 20 |
|
| 21 |
cdef extern from *: |
| 22 |
|
| 23 |
cdef enum: |
| 24 |
a1 # = 0, |
| 25 |
a2 # = 2, |
| 26 |
a3, |
| 27 |
a4 # = 5, |
| 28 |
ctypedef uint64_t A; |
| 29 |
|
| 30 |
cdef enum: |
| 31 |
b1 # = 0, |
| 32 |
b2 # = 2, |
| 33 |
b3, |
| 34 |
b4 # = 5, |
| 35 |
ctypedef uint32_t B; |
| 36 |
|
| 37 |
cdef enum: |
| 38 |
c1 # = 0, |
| 39 |
c2 # = 2, |
| 40 |
c3, |
| 41 |
c4 # = 5, |
| 42 |
ctypedef uint16_t C; |
| 43 |
|
| 44 |
cdef enum: |
| 45 |
d1 # = 0, |
| 46 |
d2 # = 2, |
| 47 |
d3, |
| 48 |
d4 # = 5, |
| 49 |
ctypedef uint8_t D; |
| 50 |
|
| 51 |
cdef enum: |
| 52 |
e1 # = 0, |
| 53 |
e2 # = 2, |
| 54 |
e3, |
| 55 |
e4 # = 5, |
| 56 |
ctypedef uintptr_t E; |
| 57 |
|
| 58 |
cdef enum: |
| 59 |
f1 # = 0, |
| 60 |
f2 # = 2, |
| 61 |
f3, |
| 62 |
f4 # = 5, |
| 63 |
ctypedef intptr_t F; |
| 64 |
|
| 65 |
ctypedef enum L: |
| 66 |
l1, |
| 67 |
l2, |
| 68 |
l3, |
| 69 |
l4, |
| 70 |
|
| 71 |
cdef enum: |
| 72 |
m1 # = -1, |
| 73 |
m2 # = 0, |
| 74 |
m3 # = 1, |
| 75 |
ctypedef int8_t M; |
| 76 |
|
| 77 |
ctypedef enum N: |
| 78 |
n1, |
| 79 |
n2, |
| 80 |
n3, |
| 81 |
n4, |
| 82 |
|
| 83 |
cdef enum: |
| 84 |
o1, |
| 85 |
o2, |
| 86 |
o3, |
| 87 |
o4, |
| 88 |
ctypedef int8_t O; |
| 89 |
|
| 90 |
ctypedef struct J: |
| 91 |
pass |
| 92 |
|
| 93 |
ctypedef struct K: |
| 94 |
pass |
| 95 |
|
| 96 |
ctypedef struct Opaque: |
| 97 |
pass |
| 98 |
|
| 99 |
cdef enum: |
| 100 |
Foo, |
| 101 |
Bar, |
| 102 |
Baz, |
| 103 |
ctypedef uint8_t G_Tag; |
| 104 |
|
| 105 |
ctypedef struct Bar_Body: |
| 106 |
G_Tag tag; |
| 107 |
uint8_t x; |
| 108 |
int16_t y; |
| 109 |
|
| 110 |
ctypedef union G: |
| 111 |
G_Tag tag; |
| 112 |
int16_t foo; |
| 113 |
Bar_Body bar; |
| 114 |
|
| 115 |
ctypedef enum H_Tag: |
| 116 |
H_Foo, |
| 117 |
H_Bar, |
| 118 |
H_Baz, |
| 119 |
|
| 120 |
ctypedef struct H_Bar_Body: |
| 121 |
uint8_t x; |
| 122 |
int16_t y; |
| 123 |
|
| 124 |
ctypedef struct H: |
| 125 |
H_Tag tag; |
| 126 |
int16_t foo; |
| 127 |
H_Bar_Body bar; |
| 128 |
|
| 129 |
cdef enum: |
| 130 |
ExI_Foo, |
| 131 |
ExI_Bar, |
| 132 |
ExI_Baz, |
| 133 |
ctypedef uint8_t ExI_Tag; |
| 134 |
|
| 135 |
ctypedef struct ExI_Bar_Body: |
| 136 |
uint8_t x; |
| 137 |
int16_t y; |
| 138 |
|
| 139 |
ctypedef struct ExI: |
| 140 |
ExI_Tag tag; |
| 141 |
int16_t foo; |
| 142 |
ExI_Bar_Body bar; |
| 143 |
|
| 144 |
cdef enum: |
| 145 |
P0, |
| 146 |
P1, |
| 147 |
ctypedef uint8_t P_Tag; |
| 148 |
|
| 149 |
ctypedef struct P1_Body: |
| 150 |
uint8_t _0; |
| 151 |
uint8_t _1; |
| 152 |
uint8_t _2; |
| 153 |
|
| 154 |
ctypedef struct P: |
| 155 |
P_Tag tag; |
| 156 |
uint8_t p0; |
| 157 |
P1_Body p1; |
| 158 |
|
| 159 |
ctypedef enum Q_Tag: |
| 160 |
Ok, |
| 161 |
Err, |
| 162 |
|
| 163 |
ctypedef struct Q: |
| 164 |
Q_Tag tag; |
| 165 |
uint32_t *ok; |
| 166 |
uint32_t err; |
| 167 |
|
| 168 |
ctypedef enum R_Tag: |
| 169 |
IRFoo, |
| 170 |
IRBar, |
| 171 |
IRBaz, |
| 172 |
|
| 173 |
ctypedef struct IRBar_Body: |
| 174 |
uint8_t x; |
| 175 |
int16_t y; |
| 176 |
|
| 177 |
ctypedef struct R: |
| 178 |
R_Tag tag; |
| 179 |
int16_t IRFoo; |
| 180 |
IRBar_Body IRBar; |
| 181 |
|
| 182 |
void root(Opaque *opaque, |
| 183 |
A a, |
| 184 |
B b, |
| 185 |
C c, |
| 186 |
D d, |
| 187 |
E e, |
| 188 |
F f, |
| 189 |
G g, |
| 190 |
H h, |
| 191 |
ExI i, |
| 192 |
J j, |
| 193 |
K k, |
| 194 |
L l, |
| 195 |
M m, |
| 196 |
N n, |
| 197 |
O o, |
| 198 |
P p, |
| 199 |
Q q, |
| 200 |
R r); |
| 201 |
|
| 202 |
#if 0 |
| 203 |
''' ' |
| 204 |
#endif |
| 205 |
|
| 206 |
#include <stddef.h> |
| 207 |
#include "testing-helpers.h" |
| 208 |
static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag"); |
| 209 |
static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0"); |
| 210 |
static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1"); |
| 211 |
static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); |
| 212 |
|
| 213 |
#if 0 |
| 214 |
' ''' |
| 215 |
#endif |