ef85ab294756ef60fbf0beb929d43e4989f5cbb1
[com/asn1c.git] / tests / tests-asn1c-compiler / 146-ios-parameterization-per-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         RegionalExtension_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_RegionalExtension,
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 <OPEN_TYPE.h>
71 #include <constr_CHOICE.h>
72 #include <constr_SEQUENCE.h>
73
74 /*** <<< DEPS [SpecializedContent] >>> ***/
75
76 typedef enum value_PR {
77         value_PR_NOTHING,       /* No components present */
78         value_PR_INTEGER,
79         value_PR_BOOLEAN
80 } value_PR;
81
82 /*** <<< TYPE-DECLS [SpecializedContent] >>> ***/
83
84 typedef struct RegionalExtension {
85         long     id;
86         struct value {
87                 value_PR present;
88                 union RegionalExtension__value_u {
89                         long     INTEGER;
90                         BOOLEAN_t        BOOLEAN;
91                 } choice;
92                 
93                 /* Context for parsing across buffer boundaries */
94                 asn_struct_ctx_t _asn_ctx;
95         } value;
96         
97         /* Context for parsing across buffer boundaries */
98         asn_struct_ctx_t _asn_ctx;
99 } RegionalExtension_t;
100
101 /*** <<< FUNC-DECLS [SpecializedContent] >>> ***/
102
103 extern asn_TYPE_descriptor_t asn_DEF_RegionalExtension;
104 extern asn_SEQUENCE_specifics_t asn_SPC_RegionalExtension_specs_1;
105 extern asn_TYPE_member_t asn_MBR_RegionalExtension_1[2];
106
107 /*** <<< IOC-TABLES [SpecializedContent] >>> ***/
108
109 static const long asn_VAL_1_1 = 1;
110 static const long asn_VAL_2_2 = 2;
111 static const asn_ioc_cell_t asn_IOS_RegionalExtension_1_rows[] = {
112         { "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_1_1 },
113         { "&Type", aioc__type, &asn_DEF_NativeInteger },
114         { "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_2_2 },
115         { "&Type", aioc__type, &asn_DEF_BOOLEAN }
116 };
117 static const asn_ioc_set_t asn_IOS_RegionalExtension_1[] = {
118         { 2, 2, asn_IOS_RegionalExtension_1_rows }
119 };
120
121 /*** <<< CODE [SpecializedContent] >>> ***/
122
123 static int
124 memb_id_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
125                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
126         
127         if(!sptr) {
128                 ASN__CTFAIL(app_key, td, sptr,
129                         "%s: value not given (%s:%d)",
130                         td->name, __FILE__, __LINE__);
131                 return -1;
132         }
133         
134         
135         if(1 /* No applicable constraints whatsoever */) {
136                 /* Nothing is here. See below */
137         }
138         
139         return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
140 }
141
142 static asn_type_selector_result_t
143 select_RegionalExtension_value_type(const asn_TYPE_descriptor_t *parent_type, const void *parent_sptr) {
144         asn_type_selector_result_t result = {0, 0};
145         const asn_ioc_set_t *itable = asn_IOS_RegionalExtension_1;
146         size_t constraining_column = 0; /* &id */
147         size_t for_column = 1; /* &Type */
148         size_t row, presence_index = 0;
149         const long *constraining_value = (const long *)((const char *)parent_sptr + offsetof(struct RegionalExtension, id));
150         
151         for(row=0; row < itable->rows_count; row++) {
152             const asn_ioc_cell_t *constraining_cell = &itable->rows[row * itable->columns_count + constraining_column];
153             const asn_ioc_cell_t *type_cell = &itable->rows[row * itable->columns_count + for_column];
154         
155             if(type_cell->cell_kind == aioc__undefined)
156                 continue;
157         
158             presence_index++;
159             if(constraining_cell->type_descriptor->op->compare_struct(constraining_cell->type_descriptor, constraining_value, constraining_cell->value_sptr) == 0) {
160                 result.type_descriptor = type_cell->type_descriptor;
161                 result.presence_index = presence_index;
162                 break;
163             }
164         }
165         
166         return result;
167 }
168
169 static int
170 memb_value_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
171                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
172         
173         if(!sptr) {
174                 ASN__CTFAIL(app_key, td, sptr,
175                         "%s: value not given (%s:%d)",
176                         td->name, __FILE__, __LINE__);
177                 return -1;
178         }
179         
180         
181         if(1 /* No applicable constraints whatsoever */) {
182                 /* Nothing is here. See below */
183         }
184         
185         return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
186 }
187
188
189 /*** <<< CTDEFS [SpecializedContent] >>> ***/
190
191 static asn_per_constraints_t asn_PER_memb_id_constr_2 CC_NOTUSED = {
192         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
193         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
194         0, 0    /* No PER value map */
195 };
196 static asn_per_constraints_t asn_PER_memb_value_constr_3 CC_NOTUSED = {
197         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
198         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
199         0, 0    /* No PER value map */
200 };
201
202 /*** <<< STAT-DEFS [SpecializedContent] >>> ***/
203
204 static asn_TYPE_member_t asn_MBR_value_3[] = {
205         { ATF_NOFLAGS, 0, offsetof(struct value, choice.INTEGER),
206                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
207                 .tag_mode = 0,
208                 .type = &asn_DEF_NativeInteger,
209                 .type_selector = 0,
210                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
211                 0, 0, /* No default value */
212                 .name = "INTEGER"
213                 },
214         { ATF_NOFLAGS, 0, offsetof(struct value, choice.BOOLEAN),
215                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
216                 .tag_mode = 0,
217                 .type = &asn_DEF_BOOLEAN,
218                 .type_selector = 0,
219                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
220                 0, 0, /* No default value */
221                 .name = "BOOLEAN"
222                 },
223 };
224 static const unsigned asn_MAP_value_to_canonical_3[] = { 1, 0 };
225 static const unsigned asn_MAP_value_from_canonical_3[] = { 1, 0 };
226 static const asn_TYPE_tag2member_t asn_MAP_value_tag2el_3[] = {
227     { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 1, 0, 0 }, /* BOOLEAN */
228     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* INTEGER */
229 };
230 static asn_CHOICE_specifics_t asn_SPC_value_specs_3 = {
231         sizeof(struct value),
232         offsetof(struct value, _asn_ctx),
233         offsetof(struct value, present),
234         sizeof(((struct value *)0)->present),
235         .tag2el = asn_MAP_value_tag2el_3,
236         .tag2el_count = 2,      /* Count of tags in the map */
237         .to_canonical_order = asn_MAP_value_to_canonical_3,
238         .from_canonical_order = asn_MAP_value_from_canonical_3,
239         .first_extension = -1   /* Extensions start */
240 };
241 static /* Use -fall-defs-global to expose */
242 asn_TYPE_descriptor_t asn_DEF_value_3 = {
243         "value",
244         "value",
245         &asn_OP_OPEN_TYPE,
246         0,      /* No effective tags (pointer) */
247         0,      /* No effective tags (count) */
248         0,      /* No tags (pointer) */
249         0,      /* No tags (count) */
250         { 0, 0, OPEN_TYPE_constraint },
251         asn_MBR_value_3,
252         2,      /* Elements count */
253         &asn_SPC_value_specs_3  /* Additional specs */
254 };
255
256 asn_TYPE_member_t asn_MBR_RegionalExtension_1[] = {
257         { ATF_NOFLAGS, 0, offsetof(struct RegionalExtension, id),
258                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
259                 .tag_mode = 0,
260                 .type = &asn_DEF_NativeInteger,
261                 .type_selector = 0,
262                 { .oer_constraints = 0, .per_constraints = &asn_PER_memb_id_constr_2, .general_constraints =  memb_id_constraint_1 },
263                 0, 0, /* No default value */
264                 .name = "id"
265                 },
266         { ATF_OPEN_TYPE | ATF_NOFLAGS, 0, offsetof(struct RegionalExtension, value),
267                 .tag = -1 /* Ambiguous tag (ANY?) */,
268                 .tag_mode = 0,
269                 .type = &asn_DEF_value_3,
270                 .type_selector = select_RegionalExtension_value_type,
271                 { .oer_constraints = 0, .per_constraints = &asn_PER_memb_value_constr_3, .general_constraints =  memb_value_constraint_1 },
272                 0, 0, /* No default value */
273                 .name = "value"
274                 },
275 };
276 static const ber_tlv_tag_t asn_DEF_RegionalExtension_tags_1[] = {
277         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
278 };
279 static const asn_TYPE_tag2member_t asn_MAP_RegionalExtension_tag2el_1[] = {
280     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* id */
281 };
282 asn_SEQUENCE_specifics_t asn_SPC_RegionalExtension_specs_1 = {
283         sizeof(struct RegionalExtension),
284         offsetof(struct RegionalExtension, _asn_ctx),
285         .tag2el = asn_MAP_RegionalExtension_tag2el_1,
286         .tag2el_count = 1,      /* Count of tags in the map */
287         0, 0, 0,        /* Optional elements (not needed) */
288         -1,     /* First extension addition */
289 };
290 asn_TYPE_descriptor_t asn_DEF_RegionalExtension = {
291         "RegionalExtension",
292         "RegionalExtension",
293         &asn_OP_SEQUENCE,
294         asn_DEF_RegionalExtension_tags_1,
295         sizeof(asn_DEF_RegionalExtension_tags_1)
296                 /sizeof(asn_DEF_RegionalExtension_tags_1[0]), /* 1 */
297         asn_DEF_RegionalExtension_tags_1,       /* Same as above */
298         sizeof(asn_DEF_RegionalExtension_tags_1)
299                 /sizeof(asn_DEF_RegionalExtension_tags_1[0]), /* 1 */
300         { 0, 0, SEQUENCE_constraint },
301         asn_MBR_RegionalExtension_1,
302         2,      /* Elements count */
303         &asn_SPC_RegionalExtension_specs_1      /* Additional specs */
304 };
305