1d2ee812e6c7310997dc2b381fb76042ccf1135f
[com/asn1c.git] / tests / tests-asn1c-compiler / 142-anonymous-types-deco-OK.asn1.-Pfcompound-names
1
2 /*** <<< INCLUDES [CommonType] >>> ***/
3
4 #include "Type1.h"
5 #include "Type2.h"
6 #include <constr_CHOICE.h>
7
8 /*** <<< DEPS [CommonType] >>> ***/
9
10 typedef enum CommonType_PR {
11         CommonType_PR_NOTHING,  /* No components present */
12         CommonType_PR_t1,
13         CommonType_PR_t2
14 } CommonType_PR;
15
16 /*** <<< TYPE-DECLS [CommonType] >>> ***/
17
18 typedef struct CommonType {
19         CommonType_PR present;
20         union CommonType_u {
21                 Type1_t  t1;
22                 Type2_t  t2;
23         } choice;
24         
25         /* Context for parsing across buffer boundaries */
26         asn_struct_ctx_t _asn_ctx;
27 } CommonType_t;
28
29 /*** <<< FUNC-DECLS [CommonType] >>> ***/
30
31 extern asn_TYPE_descriptor_t asn_DEF_CommonType;
32
33 /*** <<< STAT-DEFS [CommonType] >>> ***/
34
35 static asn_TYPE_member_t asn_MBR_CommonType_1[] = {
36         { ATF_NOFLAGS, 0, offsetof(struct CommonType, choice.t1),
37                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
38                 .tag_mode = +1, /* EXPLICIT tag at current level */
39                 .type = &asn_DEF_Type1,
40                 .type_selector = 0,
41                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
42                 0, 0, /* No default value */
43                 .name = "t1"
44                 },
45         { ATF_NOFLAGS, 0, offsetof(struct CommonType, choice.t2),
46                 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
47                 .tag_mode = +1, /* EXPLICIT tag at current level */
48                 .type = &asn_DEF_Type2,
49                 .type_selector = 0,
50                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
51                 0, 0, /* No default value */
52                 .name = "t2"
53                 },
54 };
55 static const asn_TYPE_tag2member_t asn_MAP_CommonType_tag2el_1[] = {
56     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* t1 */
57     { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* t2 */
58 };
59 static asn_CHOICE_specifics_t asn_SPC_CommonType_specs_1 = {
60         sizeof(struct CommonType),
61         offsetof(struct CommonType, _asn_ctx),
62         offsetof(struct CommonType, present),
63         sizeof(((struct CommonType *)0)->present),
64         .tag2el = asn_MAP_CommonType_tag2el_1,
65         .tag2el_count = 2,      /* Count of tags in the map */
66         0, 0,
67         .first_extension = -1   /* Extensions start */
68 };
69 asn_TYPE_descriptor_t asn_DEF_CommonType = {
70         "CommonType",
71         "CommonType",
72         &asn_OP_CHOICE,
73         0,      /* No effective tags (pointer) */
74         0,      /* No effective tags (count) */
75         0,      /* No tags (pointer) */
76         0,      /* No tags (count) */
77         { 0, 0, CHOICE_constraint },
78         asn_MBR_CommonType_1,
79         2,      /* Elements count */
80         &asn_SPC_CommonType_specs_1     /* Additional specs */
81 };
82
83
84 /*** <<< INCLUDES [Type1] >>> ***/
85
86 #include <OCTET_STRING.h>
87 #include <constr_SEQUENCE.h>
88 #include <constr_CHOICE.h>
89
90 /*** <<< DEPS [Type1] >>> ***/
91
92 typedef enum Type1_PR {
93         Type1_PR_NOTHING,       /* No components present */
94         Type1_PR_anonType
95 } Type1_PR;
96
97 /*** <<< TYPE-DECLS [Type1] >>> ***/
98
99 typedef struct Type1 {
100         Type1_PR present;
101         union Type1_u {
102                 struct Type1__anonType {
103                         OCTET_STRING_t   x;
104                         OCTET_STRING_t   y;
105                         
106                         /* Context for parsing across buffer boundaries */
107                         asn_struct_ctx_t _asn_ctx;
108                 } anonType;
109         } choice;
110         
111         /* Context for parsing across buffer boundaries */
112         asn_struct_ctx_t _asn_ctx;
113 } Type1_t;
114
115 /*** <<< FUNC-DECLS [Type1] >>> ***/
116
117 extern asn_TYPE_descriptor_t asn_DEF_Type1;
118 extern asn_CHOICE_specifics_t asn_SPC_Type1_specs_1;
119 extern asn_TYPE_member_t asn_MBR_Type1_1[1];
120
121 /*** <<< CODE [Type1] >>> ***/
122
123 static int
124 memb_x_constraint_2(const asn_TYPE_descriptor_t *td, const void *sptr,
125                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
126         const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
127         size_t size;
128         
129         if(!sptr) {
130                 ASN__CTFAIL(app_key, td, sptr,
131                         "%s: value not given (%s:%d)",
132                         td->name, __FILE__, __LINE__);
133                 return -1;
134         }
135         
136         size = st->size;
137         
138         if((size == 32)) {
139                 /* Constraint check succeeded */
140                 return 0;
141         } else {
142                 ASN__CTFAIL(app_key, td, sptr,
143                         "%s: constraint failed (%s:%d)",
144                         td->name, __FILE__, __LINE__);
145                 return -1;
146         }
147 }
148
149 static int
150 memb_y_constraint_2(const asn_TYPE_descriptor_t *td, const void *sptr,
151                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
152         const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
153         size_t size;
154         
155         if(!sptr) {
156                 ASN__CTFAIL(app_key, td, sptr,
157                         "%s: value not given (%s:%d)",
158                         td->name, __FILE__, __LINE__);
159                 return -1;
160         }
161         
162         size = st->size;
163         
164         if((size == 32)) {
165                 /* Constraint check succeeded */
166                 return 0;
167         } else {
168                 ASN__CTFAIL(app_key, td, sptr,
169                         "%s: constraint failed (%s:%d)",
170                         td->name, __FILE__, __LINE__);
171                 return -1;
172         }
173 }
174
175
176 /*** <<< STAT-DEFS [Type1] >>> ***/
177
178 static asn_TYPE_member_t asn_MBR_anonType_2[] = {
179         { ATF_NOFLAGS, 0, offsetof(struct Type1__anonType, x),
180                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
181                 .tag_mode = -1, /* IMPLICIT tag at current level */
182                 .type = &asn_DEF_OCTET_STRING,
183                 .type_selector = 0,
184                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_x_constraint_2 },
185                 0, 0, /* No default value */
186                 .name = "x"
187                 },
188         { ATF_NOFLAGS, 0, offsetof(struct Type1__anonType, y),
189                 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
190                 .tag_mode = -1, /* IMPLICIT tag at current level */
191                 .type = &asn_DEF_OCTET_STRING,
192                 .type_selector = 0,
193                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_y_constraint_2 },
194                 0, 0, /* No default value */
195                 .name = "y"
196                 },
197 };
198 static const ber_tlv_tag_t asn_DEF_anonType_tags_2[] = {
199         (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
200         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
201 };
202 static const asn_TYPE_tag2member_t asn_MAP_anonType_tag2el_2[] = {
203     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* x */
204     { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* y */
205 };
206 static asn_SEQUENCE_specifics_t asn_SPC_anonType_specs_2 = {
207         sizeof(struct Type1__anonType),
208         offsetof(struct Type1__anonType, _asn_ctx),
209         .tag2el = asn_MAP_anonType_tag2el_2,
210         .tag2el_count = 2,      /* Count of tags in the map */
211         0, 0, 0,        /* Optional elements (not needed) */
212         -1,     /* First extension addition */
213 };
214 static /* Use -fall-defs-global to expose */
215 asn_TYPE_descriptor_t asn_DEF_anonType_2 = {
216         "anonType",
217         "anonType",
218         &asn_OP_SEQUENCE,
219         asn_DEF_anonType_tags_2,
220         sizeof(asn_DEF_anonType_tags_2)
221                 /sizeof(asn_DEF_anonType_tags_2[0]) - 1, /* 1 */
222         asn_DEF_anonType_tags_2,        /* Same as above */
223         sizeof(asn_DEF_anonType_tags_2)
224                 /sizeof(asn_DEF_anonType_tags_2[0]), /* 2 */
225         { 0, 0, SEQUENCE_constraint },
226         asn_MBR_anonType_2,
227         2,      /* Elements count */
228         &asn_SPC_anonType_specs_2       /* Additional specs */
229 };
230
231 asn_TYPE_member_t asn_MBR_Type1_1[] = {
232         { ATF_NOFLAGS, 0, offsetof(struct Type1, choice.anonType),
233                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
234                 .tag_mode = 0,
235                 .type = &asn_DEF_anonType_2,
236                 .type_selector = 0,
237                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
238                 0, 0, /* No default value */
239                 .name = "anonType"
240                 },
241 };
242 static const asn_TYPE_tag2member_t asn_MAP_Type1_tag2el_1[] = {
243     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* anonType */
244 };
245 asn_CHOICE_specifics_t asn_SPC_Type1_specs_1 = {
246         sizeof(struct Type1),
247         offsetof(struct Type1, _asn_ctx),
248         offsetof(struct Type1, present),
249         sizeof(((struct Type1 *)0)->present),
250         .tag2el = asn_MAP_Type1_tag2el_1,
251         .tag2el_count = 1,      /* Count of tags in the map */
252         0, 0,
253         .first_extension = -1   /* Extensions start */
254 };
255 asn_TYPE_descriptor_t asn_DEF_Type1 = {
256         "Type1",
257         "Type1",
258         &asn_OP_CHOICE,
259         0,      /* No effective tags (pointer) */
260         0,      /* No effective tags (count) */
261         0,      /* No tags (pointer) */
262         0,      /* No tags (count) */
263         { 0, 0, CHOICE_constraint },
264         asn_MBR_Type1_1,
265         1,      /* Elements count */
266         &asn_SPC_Type1_specs_1  /* Additional specs */
267 };
268
269
270 /*** <<< INCLUDES [Type2] >>> ***/
271
272 #include <OCTET_STRING.h>
273 #include <constr_SEQUENCE.h>
274 #include <constr_CHOICE.h>
275
276 /*** <<< DEPS [Type2] >>> ***/
277
278 typedef enum Type2_PR {
279         Type2_PR_NOTHING,       /* No components present */
280         Type2_PR_anonType
281 } Type2_PR;
282
283 /*** <<< TYPE-DECLS [Type2] >>> ***/
284
285 typedef struct Type2 {
286         Type2_PR present;
287         union Type2_u {
288                 struct Type2__anonType {
289                         OCTET_STRING_t   x;
290                         OCTET_STRING_t   y;
291                         
292                         /* Context for parsing across buffer boundaries */
293                         asn_struct_ctx_t _asn_ctx;
294                 } anonType;
295         } choice;
296         
297         /* Context for parsing across buffer boundaries */
298         asn_struct_ctx_t _asn_ctx;
299 } Type2_t;
300
301 /*** <<< FUNC-DECLS [Type2] >>> ***/
302
303 extern asn_TYPE_descriptor_t asn_DEF_Type2;
304 extern asn_CHOICE_specifics_t asn_SPC_Type2_specs_1;
305 extern asn_TYPE_member_t asn_MBR_Type2_1[1];
306
307 /*** <<< CODE [Type2] >>> ***/
308
309 static int
310 memb_x_constraint_2(const asn_TYPE_descriptor_t *td, const void *sptr,
311                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
312         const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
313         size_t size;
314         
315         if(!sptr) {
316                 ASN__CTFAIL(app_key, td, sptr,
317                         "%s: value not given (%s:%d)",
318                         td->name, __FILE__, __LINE__);
319                 return -1;
320         }
321         
322         size = st->size;
323         
324         if((size == 48)) {
325                 /* Constraint check succeeded */
326                 return 0;
327         } else {
328                 ASN__CTFAIL(app_key, td, sptr,
329                         "%s: constraint failed (%s:%d)",
330                         td->name, __FILE__, __LINE__);
331                 return -1;
332         }
333 }
334
335 static int
336 memb_y_constraint_2(const asn_TYPE_descriptor_t *td, const void *sptr,
337                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
338         const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
339         size_t size;
340         
341         if(!sptr) {
342                 ASN__CTFAIL(app_key, td, sptr,
343                         "%s: value not given (%s:%d)",
344                         td->name, __FILE__, __LINE__);
345                 return -1;
346         }
347         
348         size = st->size;
349         
350         if((size == 48)) {
351                 /* Constraint check succeeded */
352                 return 0;
353         } else {
354                 ASN__CTFAIL(app_key, td, sptr,
355                         "%s: constraint failed (%s:%d)",
356                         td->name, __FILE__, __LINE__);
357                 return -1;
358         }
359 }
360
361
362 /*** <<< STAT-DEFS [Type2] >>> ***/
363
364 static asn_TYPE_member_t asn_MBR_anonType_2[] = {
365         { ATF_NOFLAGS, 0, offsetof(struct Type2__anonType, x),
366                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
367                 .tag_mode = -1, /* IMPLICIT tag at current level */
368                 .type = &asn_DEF_OCTET_STRING,
369                 .type_selector = 0,
370                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_x_constraint_2 },
371                 0, 0, /* No default value */
372                 .name = "x"
373                 },
374         { ATF_NOFLAGS, 0, offsetof(struct Type2__anonType, y),
375                 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
376                 .tag_mode = -1, /* IMPLICIT tag at current level */
377                 .type = &asn_DEF_OCTET_STRING,
378                 .type_selector = 0,
379                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_y_constraint_2 },
380                 0, 0, /* No default value */
381                 .name = "y"
382                 },
383 };
384 static const ber_tlv_tag_t asn_DEF_anonType_tags_2[] = {
385         (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
386         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
387 };
388 static const asn_TYPE_tag2member_t asn_MAP_anonType_tag2el_2[] = {
389     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* x */
390     { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* y */
391 };
392 static asn_SEQUENCE_specifics_t asn_SPC_anonType_specs_2 = {
393         sizeof(struct Type2__anonType),
394         offsetof(struct Type2__anonType, _asn_ctx),
395         .tag2el = asn_MAP_anonType_tag2el_2,
396         .tag2el_count = 2,      /* Count of tags in the map */
397         0, 0, 0,        /* Optional elements (not needed) */
398         -1,     /* First extension addition */
399 };
400 static /* Use -fall-defs-global to expose */
401 asn_TYPE_descriptor_t asn_DEF_anonType_2 = {
402         "anonType",
403         "anonType",
404         &asn_OP_SEQUENCE,
405         asn_DEF_anonType_tags_2,
406         sizeof(asn_DEF_anonType_tags_2)
407                 /sizeof(asn_DEF_anonType_tags_2[0]) - 1, /* 1 */
408         asn_DEF_anonType_tags_2,        /* Same as above */
409         sizeof(asn_DEF_anonType_tags_2)
410                 /sizeof(asn_DEF_anonType_tags_2[0]), /* 2 */
411         { 0, 0, SEQUENCE_constraint },
412         asn_MBR_anonType_2,
413         2,      /* Elements count */
414         &asn_SPC_anonType_specs_2       /* Additional specs */
415 };
416
417 asn_TYPE_member_t asn_MBR_Type2_1[] = {
418         { ATF_NOFLAGS, 0, offsetof(struct Type2, choice.anonType),
419                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
420                 .tag_mode = 0,
421                 .type = &asn_DEF_anonType_2,
422                 .type_selector = 0,
423                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
424                 0, 0, /* No default value */
425                 .name = "anonType"
426                 },
427 };
428 static const asn_TYPE_tag2member_t asn_MAP_Type2_tag2el_1[] = {
429     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* anonType */
430 };
431 asn_CHOICE_specifics_t asn_SPC_Type2_specs_1 = {
432         sizeof(struct Type2),
433         offsetof(struct Type2, _asn_ctx),
434         offsetof(struct Type2, present),
435         sizeof(((struct Type2 *)0)->present),
436         .tag2el = asn_MAP_Type2_tag2el_1,
437         .tag2el_count = 1,      /* Count of tags in the map */
438         0, 0,
439         .first_extension = -1   /* Extensions start */
440 };
441 asn_TYPE_descriptor_t asn_DEF_Type2 = {
442         "Type2",
443         "Type2",
444         &asn_OP_CHOICE,
445         0,      /* No effective tags (pointer) */
446         0,      /* No effective tags (count) */
447         0,      /* No tags (pointer) */
448         0,      /* No tags (count) */
449         { 0, 0, CHOICE_constraint },
450         asn_MBR_Type2_1,
451         1,      /* Elements count */
452         &asn_SPC_Type2_specs_1  /* Additional specs */
453 };
454