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