Replaced unbound record elements with null pointers in record-ofs (bug 494614)
[deliverable/titan.core.git] / compiler2 / datatypes.h
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Baranyi, Botond
11 * Cserveni, Akos
12 * Delic, Adam
13 * Forstner, Matyas
14 * Kremer, Peter
15 * Raduly, Csaba
16 * Szabados, Kristof
17 * Szabo, Janos Zoltan – initial implementation
18 * Szalai, Gabor
19 *
20 ******************************************************************************/
21 #ifndef DATATYPES_H
22 #define DATATYPES_H
23
24 #include "asn1/asn1p_old.h"
25 #include "ttcn3/rawASTspec.h"
26 /* Common types */
27
28 typedef int boolean;
29 #define TRUE 1
30 #define FALSE 0
31
32 /* C structures for representing TTCN-3 and ASN.1 types */
33
34 typedef enum { RECORD, SET, UNION, ANYTYPE } struct_def_kind_enum;
35
36 typedef enum { RECORD_OF, SET_OF } struct_of_def_kind_enum;
37
38 typedef enum {
39 ANY_ATTRIB_BIT = 1,
40 ANY_ELEM_BIT = 2,
41 ANY_FROM_BIT = 4,
42 ANY_EXCEPT_BIT = 8
43 } any_kind;
44 /* bit fields, use one of {ANY_ATTRIB_BIT,ANY_ELEM_BIT} and
45 * one of {ANY_FROM_BIT, ANY_EXCEPT_BIT} */
46
47 /** Flags that determine the type(s) of value an object or field will be encoded
48 * as in JSON code */
49 typedef enum {
50 JSON_NONE = 0x00, // no value type set (default)
51 JSON_NUMBER = 0x01, // integer and float
52 JSON_STRING = 0x02, // all string types, the objid type, the verdict type and enumerated values
53 JSON_BOOLEAN = 0x04, // boolean (true or false)
54 JSON_OBJECT = 0x08, // records, sets, unions and the anytype
55 JSON_ARRAY = 0x10, // record of, set of and array
56 JSON_NULL = 0x20, // ASN.1 null type
57 JSON_ANY_VALUE = 0x3F // unions with the "as value" coding instruction
58 } json_value_t;
59
60 /* Compound type definitions */
61
62 /* record, set, union */
63
64 /** Structure field descriptor for code generation */
65 typedef struct {
66 const char *type; /**< The C++ type name of the field */
67 const char *typegen; /**< XER descriptor name */
68 const char *typedescrname; /**< The name of the TTCN_descriptor variable */
69 const char *name; /**< The C++ name of the field (without the prefix) */
70 const char *dispname; /**< Display name (user-visible name) */
71 boolean isOptional;
72 boolean isDefault; /**< does it have a default value */
73 boolean of_type; /**< true if the field is a sequence-of or set-of */
74 boolean hasRaw;
75 raw_attrib_struct raw;
76 const char *defvalname; /**< the constant containing the default value */
77 size_t xerAnyNum;
78 char ** xerAnyUris;
79 /** Conflated field for anyAttributes and anyElement. Use one of
80 * {ANY_ATTRIB_BIT,ANY_ELEM_BIT} + one of {ANY_FROM_BIT, ANY_EXCEPT_BIT} */
81 unsigned short xerAnyKind;
82 unsigned short jsonValueType;
83 boolean xerAttribute;
84 boolean jsonOmitAsNull;
85 boolean jsonMetainfoUnbound;
86 const char* jsonAlias;
87 const char* jsonDefaultValue;
88 /** true if the field is a record-of or set-of with optimized memory allocation */
89 boolean optimizedMemAlloc;
90 } struct_field;
91
92 /** Structure (record, set, union, anytype) descriptor for code generation */
93 typedef struct {
94 const char *name; /**< C++ name for code generation */
95 const char *dispname; /**< Display name (user-visible) */
96 struct_def_kind_enum kind; /**< is it a record or a set */
97 boolean isASN1; /**< Originating from an ASN.1 module */
98 boolean hasRaw;
99 boolean hasText;
100 boolean hasXer;
101 boolean hasJson;
102 boolean xerUntagged;
103 boolean xerUntaggedOne; /**< from Type::u.secho.has_single_charenc */
104 boolean xerUseNilPossible; /* for sequence */
105 boolean xerUseOrderPossible; /* for sequence */
106 boolean xerUseQName; /* for sequence */
107 boolean xerUseTypeAttr; /* for choice */
108 boolean xerUseUnion; /* for choice */
109 boolean xerHasNamespaces; /* from the module */
110 boolean xerEmbedValuesPossible; /* for sequence */
111 boolean jsonAsValue; /* for choice */
112 /** The index of the last field which can generate empty XML, or -1 */
113 int exerMaybeEmptyIndex; /* for union */
114 const char * control_ns_prefix;
115 raw_attrib_struct raw;
116 size_t nElements; /**< Number of fields for this class */
117 size_t totalElements; /**< Real number of elements; may include
118 fields from the last component when USE-NIL and USE-ORDER are both set */
119 struct_field *elements;
120 boolean has_opentypes;
121 boolean opentype_outermost;
122 Opentype_t *ot;
123 boolean isOptional; /**< this structure is an optional field in a record/set */
124 } struct_def;
125
126 /** record of, set of descriptor for code generation */
127 typedef struct {
128 const char *name; /**< C++ name for code generation */
129 const char *dispname; /**< Display name (user-visible) */
130 struct_of_def_kind_enum kind; /**< is it a record-of or a set-of */
131 boolean isASN1;
132 boolean hasRaw;
133 boolean hasText;
134 boolean hasXer;
135 boolean hasJson;
136 /** true if this is a record-of BOOLEAN, ENUMERATED or NULL */
137 boolean xmlValueList;
138 /* * true if this record-of has the LIST encoding instruction */
139 /*boolean xerList;*/
140 /** true if this record-of has the ATTRIBUTE encoding instruction */
141 boolean xerAttribute;
142 /** true if this record-of has the ANY-ATTRIBUTE or ANY-ELEMENT encoding instruction */
143 boolean xerAnyAttrElem;
144 raw_attrib_struct raw;
145 boolean has_opentypes;
146 const char *type; /**< Type of the elements */
147 const char *oftypedescrname; /**< Type descr. variable of the elements */
148 size_t nFollowers; /**< number of optional fields following the record-of */
149 struct_field *followers; /**< information about following optional siblings */
150 } struct_of_def;
151
152 /* for processing enumerated type definitions */
153
154 typedef struct {
155 const char *name; /* identifier name */
156 const char *dispname; /* identifier TTCN-3 name */
157 const char *text; /* modified by TEXT */
158 int value;
159 } enum_field;
160
161 typedef struct {
162 const char *name;
163 const char *dispname; /* fullname */
164 boolean isASN1;
165 boolean hasRaw;
166 boolean hasText;
167 boolean hasXer;
168 boolean hasJson;
169 boolean xerUseNumber;
170 boolean xerText; /* A component has the TEXT encoding instruction */
171 size_t nElements;
172 enum_field *elements;
173 int firstUnused, secondUnused;
174 } enum_def;
175
176 /* for function, altstep, testcase reference types */
177
178 typedef enum { FUNCTION, ALTSTEP, TESTCASE } fat_type;
179
180 typedef struct {
181 const char *name;
182 const char *dispname;
183 char *return_type;
184 fat_type type;
185 boolean runs_on_self;
186 boolean is_startable;
187 char *formal_par_list;
188 char *actual_par_list;
189 size_t nElements;
190 const char** parameters;
191 } funcref_def;
192
193 /** for template restrictions */
194 typedef enum {
195 TR_NONE, /* no restriction was given */
196 TR_OMIT,
197 TR_VALUE,
198 TR_PRESENT
199 } template_restriction_t;
200
201 #endif /* DATATYPES_H */
This page took 0.03703 seconds and 5 git commands to generate.