NativeEnumerated.c vars NULL init and check
[com/asn1c.git] / tests / tests-asn1c-compiler / 110-param-3-OK.asn1.-Pfcompound-names
1
2 /*** <<< INCLUDES [Flag] >>> ***/
3
4 #include <NativeInteger.h>
5 #include <constr_SEQUENCE.h>
6 #include <NativeEnumerated.h>
7
8 /*** <<< DEPS [Flag] >>> ***/
9
10 typedef enum Flag_15P0__field {
11         Flag_15P0__field_red    = 0,
12         Flag_15P0__field_green  = 1,
13         Flag_15P0__field_blue   = 5
14 } e_Flag_15P0__field;
15 typedef enum Flag_15P1__field {
16         Flag_15P1__field_red    = 3,
17         Flag_15P1__field_green  = 4,
18         Flag_15P1__field_blue   = 5
19 } e_Flag_15P1__field;
20
21 /*** <<< TYPE-DECLS [Flag] >>> ***/
22
23 typedef struct Flag_15P0 {
24         long    *field; /* DEFAULT 5 */
25         
26         /* Context for parsing across buffer boundaries */
27         asn_struct_ctx_t _asn_ctx;
28 } Flag_15P0_t;
29 typedef struct Flag_15P1 {
30         long    *field; /* DEFAULT 5 */
31         
32         /* Context for parsing across buffer boundaries */
33         asn_struct_ctx_t _asn_ctx;
34 } Flag_15P1_t;
35
36 /*** <<< FUNC-DECLS [Flag] >>> ***/
37
38 extern asn_TYPE_descriptor_t asn_DEF_Flag_15P0;
39 extern asn_SEQUENCE_specifics_t asn_SPC_Flag_15P0_specs_1;
40 extern asn_TYPE_member_t asn_MBR_Flag_15P0_1[1];
41 /* extern asn_TYPE_descriptor_t asn_DEF_field_7;        // (Use -fall-defs-global to expose) */
42 extern asn_TYPE_descriptor_t asn_DEF_Flag_15P1;
43 extern asn_SEQUENCE_specifics_t asn_SPC_Flag_15P1_specs_6;
44 extern asn_TYPE_member_t asn_MBR_Flag_15P1_6[1];
45
46 /*** <<< CODE [Flag] >>> ***/
47
48 /*
49  * This type is implemented using NativeEnumerated,
50  * so here we adjust the DEF accordingly.
51  */
52
53 /*** <<< STAT-DEFS [Flag] >>> ***/
54
55 static int asn_DFL_2_cmp_5(const void *sptr) {
56         const long *st = sptr;
57         
58         if(!st) {
59                 return -1; /* No value is not a default value */
60         }
61         
62         /* Test default value 5 */
63         return (*st != 5);
64 }
65 static int asn_DFL_2_set_5(void **sptr) {
66         long *st = *sptr;
67         
68         if(!st) {
69                 st = (*sptr = CALLOC(1, sizeof(*st)));
70                 if(!st) return -1;
71         }
72         
73         /* Install default value 5 */
74         *st = 5;
75         return 0;
76 }
77 asn_TYPE_member_t asn_MBR_Flag_15P0_1[] = {
78         { ATF_POINTER, 1, offsetof(struct Flag_15P0, field),
79                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
80                 .tag_mode = 0,
81                 .type = &asn_DEF_NativeInteger,
82                 .type_selector = 0,
83                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
84                 .default_value_cmp = &asn_DFL_2_cmp_5,  /* Compare DEFAULT 5 */
85                 .default_value_set = &asn_DFL_2_set_5,  /* Set DEFAULT 5 */
86                 .name = "field"
87                 },
88 };
89 static const ber_tlv_tag_t asn_DEF_Flag_15P0_tags_1[] = {
90         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
91 };
92 static const asn_TYPE_tag2member_t asn_MAP_Flag_15P0_tag2el_1[] = {
93     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* field */
94 };
95 asn_SEQUENCE_specifics_t asn_SPC_Flag_15P0_specs_1 = {
96         sizeof(struct Flag_15P0),
97         offsetof(struct Flag_15P0, _asn_ctx),
98         .tag2el = asn_MAP_Flag_15P0_tag2el_1,
99         .tag2el_count = 1,      /* Count of tags in the map */
100         0, 0, 0,        /* Optional elements (not needed) */
101         -1,     /* First extension addition */
102 };
103 asn_TYPE_descriptor_t asn_DEF_Flag_15P0 = {
104         "Flag",
105         "Flag",
106         &asn_OP_SEQUENCE,
107         asn_DEF_Flag_15P0_tags_1,
108         sizeof(asn_DEF_Flag_15P0_tags_1)
109                 /sizeof(asn_DEF_Flag_15P0_tags_1[0]), /* 1 */
110         asn_DEF_Flag_15P0_tags_1,       /* Same as above */
111         sizeof(asn_DEF_Flag_15P0_tags_1)
112                 /sizeof(asn_DEF_Flag_15P0_tags_1[0]), /* 1 */
113         { 0, 0, SEQUENCE_constraint },
114         asn_MBR_Flag_15P0_1,
115         1,      /* Elements count */
116         &asn_SPC_Flag_15P0_specs_1      /* Additional specs */
117 };
118
119 static int asn_DFL_7_cmp_5(const void *sptr) {
120         const long *st = sptr;
121         
122         if(!st) {
123                 return -1; /* No value is not a default value */
124         }
125         
126         /* Test default value 5 */
127         return (*st != 5);
128 }
129 static int asn_DFL_7_set_5(void **sptr) {
130         long *st = *sptr;
131         
132         if(!st) {
133                 st = (*sptr = CALLOC(1, sizeof(*st)));
134                 if(!st) return -1;
135         }
136         
137         /* Install default value 5 */
138         *st = 5;
139         return 0;
140 }
141 static const asn_INTEGER_enum_map_t asn_MAP_field_value2enum_7[] = {
142         { 3,    3,      "red" },
143         { 4,    5,      "green" },
144         { 5,    4,      "blue" }
145 };
146 static const unsigned int asn_MAP_field_enum2value_7[] = {
147         2,      /* blue(5) */
148         1,      /* green(4) */
149         0       /* red(3) */
150 };
151 static const asn_INTEGER_specifics_t asn_SPC_field_specs_7 = {
152         asn_MAP_field_value2enum_7,     /* "tag" => N; sorted by tag */
153         asn_MAP_field_enum2value_7,     /* N => "tag"; sorted by N */
154         3,      /* Number of elements in the maps */
155         0,      /* Enumeration is not extensible */
156         1,      /* Strict enumeration */
157         0,      /* Native long size */
158         0
159 };
160 static const ber_tlv_tag_t asn_DEF_field_tags_7[] = {
161         (ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
162 };
163 static /* Use -fall-defs-global to expose */
164 asn_TYPE_descriptor_t asn_DEF_field_7 = {
165         "field",
166         "field",
167         &asn_OP_NativeEnumerated,
168         asn_DEF_field_tags_7,
169         sizeof(asn_DEF_field_tags_7)
170                 /sizeof(asn_DEF_field_tags_7[0]), /* 1 */
171         asn_DEF_field_tags_7,   /* Same as above */
172         sizeof(asn_DEF_field_tags_7)
173                 /sizeof(asn_DEF_field_tags_7[0]), /* 1 */
174         { 0, 0, NativeEnumerated_constraint },
175         0, 0,   /* Defined elsewhere */
176         &asn_SPC_field_specs_7  /* Additional specs */
177 };
178
179 asn_TYPE_member_t asn_MBR_Flag_15P1_6[] = {
180         { ATF_POINTER, 1, offsetof(struct Flag_15P1, field),
181                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
182                 .tag_mode = 0,
183                 .type = &asn_DEF_field_7,
184                 .type_selector = 0,
185                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
186                 .default_value_cmp = &asn_DFL_7_cmp_5,  /* Compare DEFAULT 5 */
187                 .default_value_set = &asn_DFL_7_set_5,  /* Set DEFAULT 5 */
188                 .name = "field"
189                 },
190 };
191 static const ber_tlv_tag_t asn_DEF_Flag_15P1_tags_6[] = {
192         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
193 };
194 static const asn_TYPE_tag2member_t asn_MAP_Flag_15P1_tag2el_6[] = {
195     { (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)), 0, 0, 0 } /* field */
196 };
197 asn_SEQUENCE_specifics_t asn_SPC_Flag_15P1_specs_6 = {
198         sizeof(struct Flag_15P1),
199         offsetof(struct Flag_15P1, _asn_ctx),
200         .tag2el = asn_MAP_Flag_15P1_tag2el_6,
201         .tag2el_count = 1,      /* Count of tags in the map */
202         0, 0, 0,        /* Optional elements (not needed) */
203         -1,     /* First extension addition */
204 };
205 asn_TYPE_descriptor_t asn_DEF_Flag_15P1 = {
206         "Flag",
207         "Flag",
208         &asn_OP_SEQUENCE,
209         asn_DEF_Flag_15P1_tags_6,
210         sizeof(asn_DEF_Flag_15P1_tags_6)
211                 /sizeof(asn_DEF_Flag_15P1_tags_6[0]), /* 1 */
212         asn_DEF_Flag_15P1_tags_6,       /* Same as above */
213         sizeof(asn_DEF_Flag_15P1_tags_6)
214                 /sizeof(asn_DEF_Flag_15P1_tags_6[0]), /* 1 */
215         { 0, 0, SEQUENCE_constraint },
216         asn_MBR_Flag_15P1_6,
217         1,      /* Elements count */
218         &asn_SPC_Flag_15P1_specs_6      /* Additional specs */
219 };
220
221
222 /*** <<< INCLUDES [IntegerColorFlag] >>> ***/
223
224 #include "Flag.h"
225
226 /*** <<< TYPE-DECLS [IntegerColorFlag] >>> ***/
227
228 typedef Flag_15P0_t      IntegerColorFlag_t;
229
230 /*** <<< FUNC-DECLS [IntegerColorFlag] >>> ***/
231
232 extern asn_TYPE_descriptor_t asn_DEF_IntegerColorFlag;
233 asn_struct_free_f IntegerColorFlag_free;
234 asn_struct_print_f IntegerColorFlag_print;
235 asn_constr_check_f IntegerColorFlag_constraint;
236 ber_type_decoder_f IntegerColorFlag_decode_ber;
237 der_type_encoder_f IntegerColorFlag_encode_der;
238 xer_type_decoder_f IntegerColorFlag_decode_xer;
239 xer_type_encoder_f IntegerColorFlag_encode_xer;
240
241 /*** <<< CODE [IntegerColorFlag] >>> ***/
242
243 /*
244  * This type is implemented using Flag_15P0,
245  * so here we adjust the DEF accordingly.
246  */
247
248 /*** <<< STAT-DEFS [IntegerColorFlag] >>> ***/
249
250 static const ber_tlv_tag_t asn_DEF_IntegerColorFlag_tags_1[] = {
251         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
252 };
253 asn_TYPE_descriptor_t asn_DEF_IntegerColorFlag = {
254         "IntegerColorFlag",
255         "IntegerColorFlag",
256         &asn_OP_SEQUENCE,
257         asn_DEF_IntegerColorFlag_tags_1,
258         sizeof(asn_DEF_IntegerColorFlag_tags_1)
259                 /sizeof(asn_DEF_IntegerColorFlag_tags_1[0]), /* 1 */
260         asn_DEF_IntegerColorFlag_tags_1,        /* Same as above */
261         sizeof(asn_DEF_IntegerColorFlag_tags_1)
262                 /sizeof(asn_DEF_IntegerColorFlag_tags_1[0]), /* 1 */
263         { 0, 0, SEQUENCE_constraint },
264         asn_MBR_Flag_15P0_1,
265         1,      /* Elements count */
266         &asn_SPC_Flag_15P0_specs_1      /* Additional specs */
267 };
268
269
270 /*** <<< INCLUDES [EnumeratedColorFlag] >>> ***/
271
272 #include "Flag.h"
273
274 /*** <<< TYPE-DECLS [EnumeratedColorFlag] >>> ***/
275
276 typedef Flag_15P1_t      EnumeratedColorFlag_t;
277
278 /*** <<< FUNC-DECLS [EnumeratedColorFlag] >>> ***/
279
280 extern asn_TYPE_descriptor_t asn_DEF_EnumeratedColorFlag;
281 asn_struct_free_f EnumeratedColorFlag_free;
282 asn_struct_print_f EnumeratedColorFlag_print;
283 asn_constr_check_f EnumeratedColorFlag_constraint;
284 ber_type_decoder_f EnumeratedColorFlag_decode_ber;
285 der_type_encoder_f EnumeratedColorFlag_encode_der;
286 xer_type_decoder_f EnumeratedColorFlag_decode_xer;
287 xer_type_encoder_f EnumeratedColorFlag_encode_xer;
288
289 /*** <<< CODE [EnumeratedColorFlag] >>> ***/
290
291 /*
292  * This type is implemented using Flag_15P1,
293  * so here we adjust the DEF accordingly.
294  */
295
296 /*** <<< STAT-DEFS [EnumeratedColorFlag] >>> ***/
297
298 static const ber_tlv_tag_t asn_DEF_EnumeratedColorFlag_tags_1[] = {
299         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
300 };
301 asn_TYPE_descriptor_t asn_DEF_EnumeratedColorFlag = {
302         "EnumeratedColorFlag",
303         "EnumeratedColorFlag",
304         &asn_OP_SEQUENCE,
305         asn_DEF_EnumeratedColorFlag_tags_1,
306         sizeof(asn_DEF_EnumeratedColorFlag_tags_1)
307                 /sizeof(asn_DEF_EnumeratedColorFlag_tags_1[0]), /* 1 */
308         asn_DEF_EnumeratedColorFlag_tags_1,     /* Same as above */
309         sizeof(asn_DEF_EnumeratedColorFlag_tags_1)
310                 /sizeof(asn_DEF_EnumeratedColorFlag_tags_1[0]), /* 1 */
311         { 0, 0, SEQUENCE_constraint },
312         asn_MBR_Flag_15P1_6,
313         1,      /* Elements count */
314         &asn_SPC_Flag_15P1_specs_6      /* Additional specs */
315 };
316