003c11a8c882a9cec22d0ed5e3f5286d8c205c84
[com/asn1c.git] / tests / tests-asn1c-compiler / 44-choice-in-sequence-OK.asn1.-P
1
2 /*** <<< INCLUDES [T] >>> ***/
3
4 #include <NULL.h>
5 #include <constr_CHOICE.h>
6 #include <constr_SEQUENCE.h>
7
8 /*** <<< DEPS [T] >>> ***/
9
10 typedef enum b_PR {
11         b_PR_NOTHING,   /* No components present */
12         b_PR_c,
13         b_PR_d,
14         b_PR_e,
15         b_PR_h
16 } b_PR;
17 typedef enum e_PR {
18         e_PR_NOTHING,   /* No components present */
19         e_PR_f,
20         e_PR_g
21 } e_PR;
22 typedef enum h_PR {
23         h_PR_NOTHING,   /* No components present */
24         h_PR_i,
25         h_PR_j
26 } h_PR;
27
28 /*** <<< TYPE-DECLS [T] >>> ***/
29
30 typedef struct T {
31         NULL_t   a;
32         struct b {
33                 b_PR present;
34                 union T__b_u {
35                         NULL_t   c;
36                         NULL_t   d;
37                         struct e {
38                                 e_PR present;
39                                 union T__b__e_u {
40                                         NULL_t   f;
41                                         NULL_t   g;
42                                 } choice;
43                                 
44                                 /* Context for parsing across buffer boundaries */
45                                 asn_struct_ctx_t _asn_ctx;
46                         } e;
47                         struct h {
48                                 h_PR present;
49                                 union T__b__h_u {
50                                         NULL_t   i;
51                                         NULL_t   j;
52                                 } choice;
53                                 
54                                 /* Context for parsing across buffer boundaries */
55                                 asn_struct_ctx_t _asn_ctx;
56                         } h;
57                 } choice;
58                 
59                 /* Context for parsing across buffer boundaries */
60                 asn_struct_ctx_t _asn_ctx;
61         } b;
62         
63         /* Context for parsing across buffer boundaries */
64         asn_struct_ctx_t _asn_ctx;
65 } T_t;
66
67 /*** <<< FUNC-DECLS [T] >>> ***/
68
69 extern asn_TYPE_descriptor_t asn_DEF_T;
70
71 /*** <<< STAT-DEFS [T] >>> ***/
72
73 static asn_TYPE_member_t asn_MBR_e_6[] = {
74         { ATF_NOFLAGS, 0, offsetof(struct e, choice.f),
75                 .tag = (ASN_TAG_CLASS_PRIVATE | (7 << 2)),
76                 .tag_mode = -1, /* IMPLICIT tag at current level */
77                 .type = &asn_DEF_NULL,
78                 .type_selector = 0,
79                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
80                 0, 0, /* No default value */
81                 .name = "f"
82                 },
83         { ATF_NOFLAGS, 0, offsetof(struct e, choice.g),
84                 .tag = (ASN_TAG_CLASS_PRIVATE | (8 << 2)),
85                 .tag_mode = -1, /* IMPLICIT tag at current level */
86                 .type = &asn_DEF_NULL,
87                 .type_selector = 0,
88                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
89                 0, 0, /* No default value */
90                 .name = "g"
91                 },
92 };
93 static const asn_TYPE_tag2member_t asn_MAP_e_tag2el_6[] = {
94     { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 0, 0, 0 }, /* f */
95     { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 1, 0, 0 } /* g */
96 };
97 static asn_CHOICE_specifics_t asn_SPC_e_specs_6 = {
98         sizeof(struct e),
99         offsetof(struct e, _asn_ctx),
100         offsetof(struct e, present),
101         sizeof(((struct e *)0)->present),
102         .tag2el = asn_MAP_e_tag2el_6,
103         .tag2el_count = 2,      /* Count of tags in the map */
104         0, 0,
105         .first_extension = -1   /* Extensions start */
106 };
107 static /* Use -fall-defs-global to expose */
108 asn_TYPE_descriptor_t asn_DEF_e_6 = {
109         "e",
110         "e",
111         &asn_OP_CHOICE,
112         0,      /* No effective tags (pointer) */
113         0,      /* No effective tags (count) */
114         0,      /* No tags (pointer) */
115         0,      /* No tags (count) */
116         { 0, 0, CHOICE_constraint },
117         asn_MBR_e_6,
118         2,      /* Elements count */
119         &asn_SPC_e_specs_6      /* Additional specs */
120 };
121
122 static asn_TYPE_member_t asn_MBR_h_9[] = {
123         { ATF_NOFLAGS, 0, offsetof(struct h, choice.i),
124                 .tag = (ASN_TAG_CLASS_PRIVATE | (1 << 2)),
125                 .tag_mode = -1, /* IMPLICIT tag at current level */
126                 .type = &asn_DEF_NULL,
127                 .type_selector = 0,
128                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
129                 0, 0, /* No default value */
130                 .name = "i"
131                 },
132         { ATF_NOFLAGS, 0, offsetof(struct h, choice.j),
133                 .tag = (ASN_TAG_CLASS_PRIVATE | (2 << 2)),
134                 .tag_mode = -1, /* IMPLICIT tag at current level */
135                 .type = &asn_DEF_NULL,
136                 .type_selector = 0,
137                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
138                 0, 0, /* No default value */
139                 .name = "j"
140                 },
141 };
142 static const asn_TYPE_tag2member_t asn_MAP_h_tag2el_9[] = {
143     { (ASN_TAG_CLASS_PRIVATE | (1 << 2)), 0, 0, 0 }, /* i */
144     { (ASN_TAG_CLASS_PRIVATE | (2 << 2)), 1, 0, 0 } /* j */
145 };
146 static asn_CHOICE_specifics_t asn_SPC_h_specs_9 = {
147         sizeof(struct h),
148         offsetof(struct h, _asn_ctx),
149         offsetof(struct h, present),
150         sizeof(((struct h *)0)->present),
151         .tag2el = asn_MAP_h_tag2el_9,
152         .tag2el_count = 2,      /* Count of tags in the map */
153         0, 0,
154         .first_extension = -1   /* Extensions start */
155 };
156 static /* Use -fall-defs-global to expose */
157 asn_TYPE_descriptor_t asn_DEF_h_9 = {
158         "h",
159         "h",
160         &asn_OP_CHOICE,
161         0,      /* No effective tags (pointer) */
162         0,      /* No effective tags (count) */
163         0,      /* No tags (pointer) */
164         0,      /* No tags (count) */
165         { 0, 0, CHOICE_constraint },
166         asn_MBR_h_9,
167         2,      /* Elements count */
168         &asn_SPC_h_specs_9      /* Additional specs */
169 };
170
171 static asn_TYPE_member_t asn_MBR_b_3[] = {
172         { ATF_NOFLAGS, 0, offsetof(struct b, choice.c),
173                 .tag = (ASN_TAG_CLASS_PRIVATE | (5 << 2)),
174                 .tag_mode = -1, /* IMPLICIT tag at current level */
175                 .type = &asn_DEF_NULL,
176                 .type_selector = 0,
177                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
178                 0, 0, /* No default value */
179                 .name = "c"
180                 },
181         { ATF_NOFLAGS, 0, offsetof(struct b, choice.d),
182                 .tag = (ASN_TAG_CLASS_PRIVATE | (6 << 2)),
183                 .tag_mode = -1, /* IMPLICIT tag at current level */
184                 .type = &asn_DEF_NULL,
185                 .type_selector = 0,
186                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
187                 0, 0, /* No default value */
188                 .name = "d"
189                 },
190         { ATF_NOFLAGS, 0, offsetof(struct b, choice.e),
191                 .tag = -1 /* Ambiguous tag (CHOICE?) */,
192                 .tag_mode = 0,
193                 .type = &asn_DEF_e_6,
194                 .type_selector = 0,
195                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
196                 0, 0, /* No default value */
197                 .name = "e"
198                 },
199         { ATF_NOFLAGS, 0, offsetof(struct b, choice.h),
200                 .tag = (ASN_TAG_CLASS_PRIVATE | (9 << 2)),
201                 .tag_mode = +1, /* EXPLICIT tag at current level */
202                 .type = &asn_DEF_h_9,
203                 .type_selector = 0,
204                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
205                 0, 0, /* No default value */
206                 .name = "h"
207                 },
208 };
209 static const asn_TYPE_tag2member_t asn_MAP_b_tag2el_3[] = {
210     { (ASN_TAG_CLASS_PRIVATE | (5 << 2)), 0, 0, 0 }, /* c */
211     { (ASN_TAG_CLASS_PRIVATE | (6 << 2)), 1, 0, 0 }, /* d */
212     { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 2, 0, 0 }, /* f */
213     { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 2, 0, 0 }, /* g */
214     { (ASN_TAG_CLASS_PRIVATE | (9 << 2)), 3, 0, 0 } /* h */
215 };
216 static asn_CHOICE_specifics_t asn_SPC_b_specs_3 = {
217         sizeof(struct b),
218         offsetof(struct b, _asn_ctx),
219         offsetof(struct b, present),
220         sizeof(((struct b *)0)->present),
221         .tag2el = asn_MAP_b_tag2el_3,
222         .tag2el_count = 5,      /* Count of tags in the map */
223         0, 0,
224         .first_extension = -1   /* Extensions start */
225 };
226 static /* Use -fall-defs-global to expose */
227 asn_TYPE_descriptor_t asn_DEF_b_3 = {
228         "b",
229         "b",
230         &asn_OP_CHOICE,
231         0,      /* No effective tags (pointer) */
232         0,      /* No effective tags (count) */
233         0,      /* No tags (pointer) */
234         0,      /* No tags (count) */
235         { 0, 0, CHOICE_constraint },
236         asn_MBR_b_3,
237         4,      /* Elements count */
238         &asn_SPC_b_specs_3      /* Additional specs */
239 };
240
241 static asn_TYPE_member_t asn_MBR_T_1[] = {
242         { ATF_NOFLAGS, 0, offsetof(struct T, a),
243                 .tag = (ASN_TAG_CLASS_PRIVATE | (2 << 2)),
244                 .tag_mode = -1, /* IMPLICIT tag at current level */
245                 .type = &asn_DEF_NULL,
246                 .type_selector = 0,
247                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
248                 0, 0, /* No default value */
249                 .name = "a"
250                 },
251         { ATF_NOFLAGS, 0, offsetof(struct T, b),
252                 .tag = -1 /* Ambiguous tag (CHOICE?) */,
253                 .tag_mode = 0,
254                 .type = &asn_DEF_b_3,
255                 .type_selector = 0,
256                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
257                 0, 0, /* No default value */
258                 .name = "b"
259                 },
260 };
261 static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
262         (ASN_TAG_CLASS_PRIVATE | (1 << 2)),
263         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
264 };
265 static const asn_TYPE_tag2member_t asn_MAP_T_tag2el_1[] = {
266     { (ASN_TAG_CLASS_PRIVATE | (2 << 2)), 0, 0, 0 }, /* a */
267     { (ASN_TAG_CLASS_PRIVATE | (5 << 2)), 1, 0, 0 }, /* c */
268     { (ASN_TAG_CLASS_PRIVATE | (6 << 2)), 1, 0, 0 }, /* d */
269     { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 1, 0, 0 }, /* f */
270     { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 1, 0, 0 }, /* g */
271     { (ASN_TAG_CLASS_PRIVATE | (9 << 2)), 1, 0, 0 } /* h */
272 };
273 static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
274         sizeof(struct T),
275         offsetof(struct T, _asn_ctx),
276         .tag2el = asn_MAP_T_tag2el_1,
277         .tag2el_count = 6,      /* Count of tags in the map */
278         0, 0, 0,        /* Optional elements (not needed) */
279         -1,     /* First extension addition */
280 };
281 asn_TYPE_descriptor_t asn_DEF_T = {
282         "T",
283         "T",
284         &asn_OP_SEQUENCE,
285         asn_DEF_T_tags_1,
286         sizeof(asn_DEF_T_tags_1)
287                 /sizeof(asn_DEF_T_tags_1[0]) - 1, /* 1 */
288         asn_DEF_T_tags_1,       /* Same as above */
289         sizeof(asn_DEF_T_tags_1)
290                 /sizeof(asn_DEF_T_tags_1[0]), /* 2 */
291         { 0, 0, SEQUENCE_constraint },
292         asn_MBR_T_1,
293         2,      /* Elements count */
294         &asn_SPC_T_specs_1      /* Additional specs */
295 };
296