NativeEnumerated.c vars NULL init and check
[com/asn1c.git] / tests / tests-asn1c-compiler / 95-choice-per-order-OK.asn1.-Pgen-PER
1
2 /*** <<< INCLUDES [Choice] >>> ***/
3
4 #include <RELATIVE-OID.h>
5 #include <BIT_STRING.h>
6 #include <BOOLEAN.h>
7 #include <NULL.h>
8 #include <NativeInteger.h>
9 #include <constr_CHOICE.h>
10
11 /*** <<< DEPS [Choice] >>> ***/
12
13 typedef enum Choice_PR {
14         Choice_PR_NOTHING,      /* No components present */
15         Choice_PR_roid,
16         Choice_PR_bitstr,
17         Choice_PR_ch,
18         /* Extensions may appear below */
19         Choice_PR_bool
20 } Choice_PR;
21 typedef enum ch_PR {
22         ch_PR_NOTHING,  /* No components present */
23         ch_PR_null,
24         ch_PR_int
25 } ch_PR;
26
27 /*** <<< TYPE-DECLS [Choice] >>> ***/
28
29 typedef struct Choice {
30         Choice_PR present;
31         union Choice_u {
32                 RELATIVE_OID_t   roid;
33                 BIT_STRING_t     bitstr;
34                 struct ch {
35                         ch_PR present;
36                         union Choice__ch_u {
37                                 NULL_t   null;
38                                 long     Int;
39                         } choice;
40                         
41                         /* Context for parsing across buffer boundaries */
42                         asn_struct_ctx_t _asn_ctx;
43                 } ch;
44                 /*
45                  * This type is extensible,
46                  * possible extensions are below.
47                  */
48                 BOOLEAN_t        Bool;
49         } choice;
50         
51         /* Context for parsing across buffer boundaries */
52         asn_struct_ctx_t _asn_ctx;
53 } Choice_t;
54
55 /*** <<< FUNC-DECLS [Choice] >>> ***/
56
57 extern asn_TYPE_descriptor_t asn_DEF_Choice;
58
59 /*** <<< CTDEFS [Choice] >>> ***/
60
61 static asn_per_constraints_t asn_PER_type_ch_constr_4 CC_NOTUSED = {
62         { APC_CONSTRAINED,       1,  1,  0,  1 }        /* (0..1) */,
63         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
64         0, 0    /* No PER value map */
65 };
66 static asn_per_constraints_t asn_PER_type_Choice_constr_1 CC_NOTUSED = {
67         { APC_CONSTRAINED | APC_EXTENSIBLE,  2,  2,  0,  2 }    /* (0..2,...) */,
68         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
69         0, 0    /* No PER value map */
70 };
71
72 /*** <<< STAT-DEFS [Choice] >>> ***/
73
74 static asn_TYPE_member_t asn_MBR_ch_4[] = {
75         { ATF_NOFLAGS, 0, offsetof(struct ch, choice.null),
76                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (5 << 2)),
77                 .tag_mode = 0,
78                 .type = &asn_DEF_NULL,
79                 .type_selector = 0,
80                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
81                 0, 0, /* No default value */
82                 .name = "null"
83                 },
84         { ATF_NOFLAGS, 0, offsetof(struct ch, choice.Int),
85                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
86                 .tag_mode = 0,
87                 .type = &asn_DEF_NativeInteger,
88                 .type_selector = 0,
89                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
90                 0, 0, /* No default value */
91                 .name = "int"
92                 },
93 };
94 static const unsigned asn_MAP_ch_to_canonical_4[] = { 1, 0 };
95 static const unsigned asn_MAP_ch_from_canonical_4[] = { 1, 0 };
96 static const asn_TYPE_tag2member_t asn_MAP_ch_tag2el_4[] = {
97     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* int */
98     { (ASN_TAG_CLASS_UNIVERSAL | (5 << 2)), 0, 0, 0 } /* null */
99 };
100 static asn_CHOICE_specifics_t asn_SPC_ch_specs_4 = {
101         sizeof(struct ch),
102         offsetof(struct ch, _asn_ctx),
103         offsetof(struct ch, present),
104         sizeof(((struct ch *)0)->present),
105         .tag2el = asn_MAP_ch_tag2el_4,
106         .tag2el_count = 2,      /* Count of tags in the map */
107         .to_canonical_order = asn_MAP_ch_to_canonical_4,
108         .from_canonical_order = asn_MAP_ch_from_canonical_4,
109         .first_extension = -1   /* Extensions start */
110 };
111 static /* Use -fall-defs-global to expose */
112 asn_TYPE_descriptor_t asn_DEF_ch_4 = {
113         "ch",
114         "ch",
115         &asn_OP_CHOICE,
116         0,      /* No effective tags (pointer) */
117         0,      /* No effective tags (count) */
118         0,      /* No tags (pointer) */
119         0,      /* No tags (count) */
120         { 0, &asn_PER_type_ch_constr_4, CHOICE_constraint },
121         asn_MBR_ch_4,
122         2,      /* Elements count */
123         &asn_SPC_ch_specs_4     /* Additional specs */
124 };
125
126 static asn_TYPE_member_t asn_MBR_Choice_1[] = {
127         { ATF_NOFLAGS, 0, offsetof(struct Choice, choice.roid),
128                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (13 << 2)),
129                 .tag_mode = 0,
130                 .type = &asn_DEF_RELATIVE_OID,
131                 .type_selector = 0,
132                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
133                 0, 0, /* No default value */
134                 .name = "roid"
135                 },
136         { ATF_NOFLAGS, 0, offsetof(struct Choice, choice.bitstr),
137                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)),
138                 .tag_mode = 0,
139                 .type = &asn_DEF_BIT_STRING,
140                 .type_selector = 0,
141                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
142                 0, 0, /* No default value */
143                 .name = "bitstr"
144                 },
145         { ATF_NOFLAGS, 0, offsetof(struct Choice, choice.ch),
146                 .tag = -1 /* Ambiguous tag (CHOICE?) */,
147                 .tag_mode = 0,
148                 .type = &asn_DEF_ch_4,
149                 .type_selector = 0,
150                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
151                 0, 0, /* No default value */
152                 .name = "ch"
153                 },
154         { ATF_NOFLAGS, 0, offsetof(struct Choice, choice.Bool),
155                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
156                 .tag_mode = 0,
157                 .type = &asn_DEF_BOOLEAN,
158                 .type_selector = 0,
159                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
160                 0, 0, /* No default value */
161                 .name = "bool"
162                 },
163 };
164 static const unsigned asn_MAP_Choice_to_canonical_1[] = { 2, 1, 0, 3 };
165 static const unsigned asn_MAP_Choice_from_canonical_1[] = { 2, 1, 0, 3 };
166 static const asn_TYPE_tag2member_t asn_MAP_Choice_tag2el_1[] = {
167     { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 3, 0, 0 }, /* bool */
168     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 2, 0, 0 }, /* int */
169     { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), 1, 0, 0 }, /* bitstr */
170     { (ASN_TAG_CLASS_UNIVERSAL | (5 << 2)), 2, 0, 0 }, /* null */
171     { (ASN_TAG_CLASS_UNIVERSAL | (13 << 2)), 0, 0, 0 } /* roid */
172 };
173 static asn_CHOICE_specifics_t asn_SPC_Choice_specs_1 = {
174         sizeof(struct Choice),
175         offsetof(struct Choice, _asn_ctx),
176         offsetof(struct Choice, present),
177         sizeof(((struct Choice *)0)->present),
178         .tag2el = asn_MAP_Choice_tag2el_1,
179         .tag2el_count = 5,      /* Count of tags in the map */
180         .to_canonical_order = asn_MAP_Choice_to_canonical_1,
181         .from_canonical_order = asn_MAP_Choice_from_canonical_1,
182         .first_extension = 3    /* Extensions start */
183 };
184 asn_TYPE_descriptor_t asn_DEF_Choice = {
185         "Choice",
186         "Choice",
187         &asn_OP_CHOICE,
188         0,      /* No effective tags (pointer) */
189         0,      /* No effective tags (count) */
190         0,      /* No tags (pointer) */
191         0,      /* No tags (count) */
192         { 0, &asn_PER_type_Choice_constr_1, CHOICE_constraint },
193         asn_MBR_Choice_1,
194         4,      /* Elements count */
195         &asn_SPC_Choice_specs_1 /* Additional specs */
196 };
197
198
199 /*** <<< INCLUDES [Choice2] >>> ***/
200
201 #include <BIT_STRING.h>
202 #include <RELATIVE-OID.h>
203 #include <constr_CHOICE.h>
204
205 /*** <<< DEPS [Choice2] >>> ***/
206
207 typedef enum Choice2_PR {
208         Choice2_PR_NOTHING,     /* No components present */
209         Choice2_PR_bitstr,
210         Choice2_PR_roid
211 } Choice2_PR;
212
213 /*** <<< TYPE-DECLS [Choice2] >>> ***/
214
215 typedef struct Choice2 {
216         Choice2_PR present;
217         union Choice2_u {
218                 BIT_STRING_t     bitstr;
219                 RELATIVE_OID_t   roid;
220         } choice;
221         
222         /* Context for parsing across buffer boundaries */
223         asn_struct_ctx_t _asn_ctx;
224 } Choice2_t;
225
226 /*** <<< FUNC-DECLS [Choice2] >>> ***/
227
228 extern asn_TYPE_descriptor_t asn_DEF_Choice2;
229
230 /*** <<< CTDEFS [Choice2] >>> ***/
231
232 static asn_per_constraints_t asn_PER_type_Choice2_constr_1 CC_NOTUSED = {
233         { APC_CONSTRAINED,       1,  1,  0,  1 }        /* (0..1) */,
234         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
235         0, 0    /* No PER value map */
236 };
237
238 /*** <<< STAT-DEFS [Choice2] >>> ***/
239
240 static asn_TYPE_member_t asn_MBR_Choice2_1[] = {
241         { ATF_NOFLAGS, 0, offsetof(struct Choice2, choice.bitstr),
242                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
243                 .tag_mode = +1, /* EXPLICIT tag at current level */
244                 .type = &asn_DEF_BIT_STRING,
245                 .type_selector = 0,
246                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
247                 0, 0, /* No default value */
248                 .name = "bitstr"
249                 },
250         { ATF_NOFLAGS, 0, offsetof(struct Choice2, choice.roid),
251                 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
252                 .tag_mode = +1, /* EXPLICIT tag at current level */
253                 .type = &asn_DEF_RELATIVE_OID,
254                 .type_selector = 0,
255                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
256                 0, 0, /* No default value */
257                 .name = "roid"
258                 },
259 };
260 static const asn_TYPE_tag2member_t asn_MAP_Choice2_tag2el_1[] = {
261     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* bitstr */
262     { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* roid */
263 };
264 static asn_CHOICE_specifics_t asn_SPC_Choice2_specs_1 = {
265         sizeof(struct Choice2),
266         offsetof(struct Choice2, _asn_ctx),
267         offsetof(struct Choice2, present),
268         sizeof(((struct Choice2 *)0)->present),
269         .tag2el = asn_MAP_Choice2_tag2el_1,
270         .tag2el_count = 2,      /* Count of tags in the map */
271         0, 0,
272         .first_extension = -1   /* Extensions start */
273 };
274 asn_TYPE_descriptor_t asn_DEF_Choice2 = {
275         "Choice2",
276         "Choice2",
277         &asn_OP_CHOICE,
278         0,      /* No effective tags (pointer) */
279         0,      /* No effective tags (count) */
280         0,      /* No tags (pointer) */
281         0,      /* No tags (count) */
282         { 0, &asn_PER_type_Choice2_constr_1, CHOICE_constraint },
283         asn_MBR_Choice2_1,
284         2,      /* Elements count */
285         &asn_SPC_Choice2_specs_1        /* Additional specs */
286 };
287