8c053e40844ed0e75ec1b1d21b979a2faee53fde
[com/asn1c.git] / tests / tests-asn1c-compiler / 156-union-ios-OK.asn1.-Pgen-PER
1
2 /*** <<< INCLUDES [Message] >>> ***/
3
4 #include "SpecializedContent.h"
5 #include <constr_SEQUENCE.h>
6
7 /*** <<< TYPE-DECLS [Message] >>> ***/
8
9 typedef struct Message {
10         TotalRegionExtension_t   content;
11         
12         /* Context for parsing across buffer boundaries */
13         asn_struct_ctx_t _asn_ctx;
14 } Message_t;
15
16 /*** <<< FUNC-DECLS [Message] >>> ***/
17
18 extern asn_TYPE_descriptor_t asn_DEF_Message;
19
20 /*** <<< STAT-DEFS [Message] >>> ***/
21
22 static asn_TYPE_member_t asn_MBR_Message_1[] = {
23         { ATF_NOFLAGS, 0, offsetof(struct Message, content),
24                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
25                 .tag_mode = 0,
26                 .type = &asn_DEF_TotalRegionExtension,
27                 .type_selector = 0,
28                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
29                 0, 0, /* No default value */
30                 .name = "content"
31                 },
32 };
33 static const ber_tlv_tag_t asn_DEF_Message_tags_1[] = {
34         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
35 };
36 static const asn_TYPE_tag2member_t asn_MAP_Message_tag2el_1[] = {
37     { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* content */
38 };
39 static asn_SEQUENCE_specifics_t asn_SPC_Message_specs_1 = {
40         sizeof(struct Message),
41         offsetof(struct Message, _asn_ctx),
42         .tag2el = asn_MAP_Message_tag2el_1,
43         .tag2el_count = 1,      /* Count of tags in the map */
44         0, 0, 0,        /* Optional elements (not needed) */
45         -1,     /* First extension addition */
46 };
47 asn_TYPE_descriptor_t asn_DEF_Message = {
48         "Message",
49         "Message",
50         &asn_OP_SEQUENCE,
51         asn_DEF_Message_tags_1,
52         sizeof(asn_DEF_Message_tags_1)
53                 /sizeof(asn_DEF_Message_tags_1[0]), /* 1 */
54         asn_DEF_Message_tags_1, /* Same as above */
55         sizeof(asn_DEF_Message_tags_1)
56                 /sizeof(asn_DEF_Message_tags_1[0]), /* 1 */
57         { 0, 0, SEQUENCE_constraint },
58         asn_MBR_Message_1,
59         1,      /* Elements count */
60         &asn_SPC_Message_specs_1        /* Additional specs */
61 };
62
63
64 /*** <<< INCLUDES [SpecializedContent] >>> ***/
65
66 #include <NativeInteger.h>
67 #include <ANY.h>
68 #include <asn_ioc.h>
69 #include <BOOLEAN.h>
70 #include <OCTET_STRING.h>
71 #include <OPEN_TYPE.h>
72 #include <constr_CHOICE.h>
73 #include <constr_SEQUENCE.h>
74
75 /*** <<< DEPS [SpecializedContent] >>> ***/
76
77 typedef enum value_PR {
78         value_PR_NOTHING,       /* No components present */
79         value_PR_INTEGER,
80         value_PR_BOOLEAN,
81         value_PR_OCTET_STRING
82 } value_PR;
83
84 /*** <<< TYPE-DECLS [SpecializedContent] >>> ***/
85
86 typedef struct TotalRegionExtension {
87         long     id;
88         struct value {
89                 value_PR present;
90                 union TotalRegionExtension__value_u {
91                         long     INTEGER;
92                         BOOLEAN_t        BOOLEAN;
93                         OCTET_STRING_t   OCTET_STRING;
94                 } choice;
95                 
96                 /* Context for parsing across buffer boundaries */
97                 asn_struct_ctx_t _asn_ctx;
98         } value;
99         
100         /* Context for parsing across buffer boundaries */
101         asn_struct_ctx_t _asn_ctx;
102 } TotalRegionExtension_t;
103
104 /*** <<< FUNC-DECLS [SpecializedContent] >>> ***/
105
106 extern asn_TYPE_descriptor_t asn_DEF_TotalRegionExtension;
107 extern asn_SEQUENCE_specifics_t asn_SPC_TotalRegionExtension_specs_1;
108 extern asn_TYPE_member_t asn_MBR_TotalRegionExtension_1[2];
109
110 /*** <<< IOC-TABLES [SpecializedContent] >>> ***/
111
112 static const long asn_VAL_1_1 = 1;
113 static const long asn_VAL_2_2 = 2;
114 static const long asn_VAL_3_3 = 3;
115 static const long asn_VAL_4_1 = 1;
116 static const long asn_VAL_5_2 = 2;
117 static const long asn_VAL_6_3 = 3;
118 static const asn_ioc_cell_t asn_IOS_TotalRegionExtension_1_rows[] = {
119         { "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_1_1 },
120         { "&Type", aioc__type, &asn_DEF_NativeInteger },
121         { "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_2_2 },
122         { "&Type", aioc__type, &asn_DEF_BOOLEAN },
123         { "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_3_3 },
124         { "&Type", aioc__type, &asn_DEF_OCTET_STRING },
125         { "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_4_1 },
126         { "&Type", aioc__type, &asn_DEF_NativeInteger },
127         { "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_5_2 },
128         { "&Type", aioc__type, &asn_DEF_BOOLEAN },
129         { "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_6_3 },
130         { "&Type", aioc__type, &asn_DEF_OCTET_STRING }
131 };
132 static const asn_ioc_set_t asn_IOS_TotalRegionExtension_1[] = {
133         { 6, 2, asn_IOS_TotalRegionExtension_1_rows }
134 };
135
136 /*** <<< CODE [SpecializedContent] >>> ***/
137
138 static int
139 memb_id_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
140                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
141         
142         if(!sptr) {
143                 ASN__CTFAIL(app_key, td, sptr,
144                         "%s: value not given (%s:%d)",
145                         td->name, __FILE__, __LINE__);
146                 return -1;
147         }
148         
149         
150         if(1 /* No applicable constraints whatsoever */) {
151                 /* Nothing is here. See below */
152         }
153         
154         return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
155 }
156
157 static asn_type_selector_result_t
158 select_TotalRegionExtension_value_type(const asn_TYPE_descriptor_t *parent_type, const void *parent_sptr) {
159         asn_type_selector_result_t result = {0, 0};
160         const asn_ioc_set_t *itable = asn_IOS_TotalRegionExtension_1;
161         size_t constraining_column = 0; /* &id */
162         size_t for_column = 1; /* &Type */
163         size_t row, presence_index = 0;
164         const long *constraining_value = (const long *)((const char *)parent_sptr + offsetof(struct TotalRegionExtension, id));
165         
166         for(row=0; row < itable->rows_count; row++) {
167             const asn_ioc_cell_t *constraining_cell = &itable->rows[row * itable->columns_count + constraining_column];
168             const asn_ioc_cell_t *type_cell = &itable->rows[row * itable->columns_count + for_column];
169         
170             if(type_cell->cell_kind == aioc__undefined)
171                 continue;
172         
173             presence_index++;
174             if(constraining_cell->type_descriptor->op->compare_struct(constraining_cell->type_descriptor, constraining_value, constraining_cell->value_sptr) == 0) {
175                 result.type_descriptor = type_cell->type_descriptor;
176                 result.presence_index = presence_index;
177                 break;
178             }
179         }
180         
181         return result;
182 }
183
184 static int
185 memb_value_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
186                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
187         
188         if(!sptr) {
189                 ASN__CTFAIL(app_key, td, sptr,
190                         "%s: value not given (%s:%d)",
191                         td->name, __FILE__, __LINE__);
192                 return -1;
193         }
194         
195         
196         if(1 /* No applicable constraints whatsoever */) {
197                 /* Nothing is here. See below */
198         }
199         
200         return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
201 }
202
203
204 /*** <<< CTDEFS [SpecializedContent] >>> ***/
205
206 static asn_per_constraints_t asn_PER_memb_id_constr_2 CC_NOTUSED = {
207         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
208         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
209         0, 0    /* No PER value map */
210 };
211 static asn_per_constraints_t asn_PER_memb_value_constr_3 CC_NOTUSED = {
212         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
213         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
214         0, 0    /* No PER value map */
215 };
216
217 /*** <<< STAT-DEFS [SpecializedContent] >>> ***/
218
219 static asn_TYPE_member_t asn_MBR_value_3[] = {
220         { ATF_NOFLAGS, 0, offsetof(struct value, choice.INTEGER),
221                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
222                 .tag_mode = 0,
223                 .type = &asn_DEF_NativeInteger,
224                 .type_selector = 0,
225                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
226                 0, 0, /* No default value */
227                 .name = "INTEGER"
228                 },
229         { ATF_NOFLAGS, 0, offsetof(struct value, choice.BOOLEAN),
230                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
231                 .tag_mode = 0,
232                 .type = &asn_DEF_BOOLEAN,
233                 .type_selector = 0,
234                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
235                 0, 0, /* No default value */
236                 .name = "BOOLEAN"
237                 },
238         { ATF_NOFLAGS, 0, offsetof(struct value, choice.OCTET_STRING),
239                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)),
240                 .tag_mode = 0,
241                 .type = &asn_DEF_OCTET_STRING,
242                 .type_selector = 0,
243                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
244                 0, 0, /* No default value */
245                 .name = "OCTET STRING"
246                 },
247 };
248 static const unsigned asn_MAP_value_to_canonical_3[] = { 1, 0, 2 };
249 static const unsigned asn_MAP_value_from_canonical_3[] = { 1, 0, 2 };
250 static const asn_TYPE_tag2member_t asn_MAP_value_tag2el_3[] = {
251     { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 1, 0, 0 }, /* BOOLEAN */
252     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* INTEGER */
253     { (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), 2, 0, 0 } /* OCTET STRING */
254 };
255 static asn_CHOICE_specifics_t asn_SPC_value_specs_3 = {
256         sizeof(struct value),
257         offsetof(struct value, _asn_ctx),
258         offsetof(struct value, present),
259         sizeof(((struct value *)0)->present),
260         .tag2el = asn_MAP_value_tag2el_3,
261         .tag2el_count = 3,      /* Count of tags in the map */
262         .to_canonical_order = asn_MAP_value_to_canonical_3,
263         .from_canonical_order = asn_MAP_value_from_canonical_3,
264         .first_extension = -1   /* Extensions start */
265 };
266 static /* Use -fall-defs-global to expose */
267 asn_TYPE_descriptor_t asn_DEF_value_3 = {
268         "value",
269         "value",
270         &asn_OP_OPEN_TYPE,
271         0,      /* No effective tags (pointer) */
272         0,      /* No effective tags (count) */
273         0,      /* No tags (pointer) */
274         0,      /* No tags (count) */
275         { 0, 0, OPEN_TYPE_constraint },
276         asn_MBR_value_3,
277         3,      /* Elements count */
278         &asn_SPC_value_specs_3  /* Additional specs */
279 };
280
281 asn_TYPE_member_t asn_MBR_TotalRegionExtension_1[] = {
282         { ATF_NOFLAGS, 0, offsetof(struct TotalRegionExtension, id),
283                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
284                 .tag_mode = 0,
285                 .type = &asn_DEF_NativeInteger,
286                 .type_selector = 0,
287                 { .oer_constraints = 0, .per_constraints = &asn_PER_memb_id_constr_2, .general_constraints =  memb_id_constraint_1 },
288                 0, 0, /* No default value */
289                 .name = "id"
290                 },
291         { ATF_OPEN_TYPE | ATF_NOFLAGS, 0, offsetof(struct TotalRegionExtension, value),
292                 .tag = -1 /* Ambiguous tag (ANY?) */,
293                 .tag_mode = 0,
294                 .type = &asn_DEF_value_3,
295                 .type_selector = select_TotalRegionExtension_value_type,
296                 { .oer_constraints = 0, .per_constraints = &asn_PER_memb_value_constr_3, .general_constraints =  memb_value_constraint_1 },
297                 0, 0, /* No default value */
298                 .name = "value"
299                 },
300 };
301 static const ber_tlv_tag_t asn_DEF_TotalRegionExtension_tags_1[] = {
302         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
303 };
304 static const asn_TYPE_tag2member_t asn_MAP_TotalRegionExtension_tag2el_1[] = {
305     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* id */
306 };
307 asn_SEQUENCE_specifics_t asn_SPC_TotalRegionExtension_specs_1 = {
308         sizeof(struct TotalRegionExtension),
309         offsetof(struct TotalRegionExtension, _asn_ctx),
310         .tag2el = asn_MAP_TotalRegionExtension_tag2el_1,
311         .tag2el_count = 1,      /* Count of tags in the map */
312         0, 0, 0,        /* Optional elements (not needed) */
313         -1,     /* First extension addition */
314 };
315 asn_TYPE_descriptor_t asn_DEF_TotalRegionExtension = {
316         "TotalRegionExtension",
317         "TotalRegionExtension",
318         &asn_OP_SEQUENCE,
319         asn_DEF_TotalRegionExtension_tags_1,
320         sizeof(asn_DEF_TotalRegionExtension_tags_1)
321                 /sizeof(asn_DEF_TotalRegionExtension_tags_1[0]), /* 1 */
322         asn_DEF_TotalRegionExtension_tags_1,    /* Same as above */
323         sizeof(asn_DEF_TotalRegionExtension_tags_1)
324                 /sizeof(asn_DEF_TotalRegionExtension_tags_1[0]), /* 1 */
325         { 0, 0, SEQUENCE_constraint },
326         asn_MBR_TotalRegionExtension_1,
327         2,      /* Elements count */
328         &asn_SPC_TotalRegionExtension_specs_1   /* Additional specs */
329 };
330