Sync with 5.1.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;
73} struct_field;
74
75/** Structure (record, set, union, anytype) descriptor for code generation */
76typedef struct {
77 const char *name; /**< C++ name for code generation */
78 const char *dispname; /**< Display name (user-visible) */
79 struct_def_kind_enum kind; /**< is it a record or a set */
80 boolean isASN1; /**< Originating from an ASN.1 module */
81 boolean hasRaw;
82 boolean hasText;
83 boolean hasXer;
84 boolean hasJson;
85 boolean xerUntagged;
86 boolean xerUntaggedOne; /**< from Type::u.secho.has_single_charenc */
87 boolean xerUseNilPossible; /* for sequence */
88 boolean xerUseOrderPossible; /* for sequence */
89 boolean xerUseQName; /* for sequence */
90 boolean xerUseTypeAttr; /* for choice */
91 boolean xerUseUnion; /* for choice */
92 boolean xerHasNamespaces; /* from the module */
93 boolean xerEmbedValuesPossible; /* for sequence */
94 boolean jsonAsValue; /* for choice */
95 /** The index of the last field which can generate empty XML, or -1 */
96 int exerMaybeEmptyIndex; /* for union */
97 const char * control_ns_prefix;
98 raw_attrib_struct raw;
99 size_t nElements; /**< Number of fields for this class */
100 size_t totalElements; /**< Real number of elements; may include
101 fields from the last component when USE-NIL and USE-ORDER are both set */
102 struct_field *elements;
103 boolean has_opentypes;
104 boolean opentype_outermost;
105 Opentype_t *ot;
106} struct_def;
107
108/** record of, set of descriptor for code generation */
109typedef struct {
110 const char *name; /**< C++ name for code generation */
111 const char *dispname; /**< Display name (user-visible) */
112 struct_of_def_kind_enum kind; /**< is it a record-of or a set-of */
113 boolean isASN1;
114 boolean hasRaw;
115 boolean hasText;
116 boolean hasXer;
117 boolean hasJson;
118 /** true if this is a record-of BOOLEAN, ENUMERATED or NULL */
119 boolean xmlValueList;
120 /* * true if this record-of has the LIST encoding instruction */
121 /*boolean xerList;*/
122 /** true if this record-of has the ATTRIBUTE encoding instruction */
123 boolean xerAttribute;
124 /** true if this record-of has the ANY-ATTRIBUTE or ANY-ELEMENT encoding instruction */
125 boolean xerAnyAttrElem;
126 raw_attrib_struct raw;
127 boolean has_opentypes;
128 const char *type; /**< Type of the elements */
129 const char *oftypedescrname; /**< Type descr. variable of the elements */
130 size_t nFollowers; /**< number of optional fields following the record-of */
131 struct_field *followers; /**< information about following optional siblings */
132} struct_of_def;
133
134/* for processing enumerated type definitions */
135
136typedef struct {
137 const char *name; /* identifier name */
138 const char *dispname; /* identifier TTCN-3 name */
139 const char *text; /* modified by TEXT */
140 int value;
141} enum_field;
142
143typedef struct {
144 const char *name;
145 const char *dispname; /* fullname */
146 boolean isASN1;
147 boolean hasRaw;
148 boolean hasText;
149 boolean hasXer;
150 boolean hasJson;
151 boolean xerUseNumber;
152 boolean xerText; /* A component has the TEXT encoding instruction */
153 size_t nElements;
154 enum_field *elements;
155 int firstUnused, secondUnused;
156} enum_def;
157
158/* for function, altstep, testcase reference types */
159
160typedef enum { FUNCTION, ALTSTEP, TESTCASE } fat_type;
161
162typedef struct {
163 const char *name;
164 const char *dispname;
165 char *return_type;
166 fat_type type;
167 boolean runs_on_self;
168 boolean is_startable;
169 char *formal_par_list;
170 char *actual_par_list;
171 size_t nElements;
172 const char** parameters;
173} funcref_def;
174
175/** for template restrictions */
176typedef enum {
177 TR_NONE, /* no restriction was given */
178 TR_OMIT,
179 TR_VALUE,
180 TR_PRESENT
181} template_restriction_t;
182
183#endif /* DATATYPES_H */
This page took 0.028893 seconds and 5 git commands to generate.