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