File: datatypes.h

package info (click to toggle)
eclipse-titan 6.5.0-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 101,128 kB
  • sloc: cpp: 259,139; ansic: 47,560; yacc: 22,554; makefile: 14,074; sh: 12,630; lex: 9,101; xml: 5,362; java: 4,849; perl: 3,784; awk: 48; php: 32; python: 13
file content (217 lines) | stat: -rw-r--r-- 7,323 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/******************************************************************************
 * Copyright (c) 2000-2018 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Baranyi, Botond
 *   Cserveni, Akos
 *   Delic, Adam
 *   Forstner, Matyas
 *   Kremer, Peter
 *   Raduly, Csaba
 *   Szabados, Kristof
 *   Szabo, Janos Zoltan – initial implementation
 *   Szabo, Bence Janos
 *   Szalai, Gabor
 *
 ******************************************************************************/
#ifndef DATATYPES_H
#define DATATYPES_H

#include "asn1/asn1p_old.h"
#include "ttcn3/rawASTspec.h"
#include "XSD_Types.hh"
/* Common types */

typedef int boolean;
#define TRUE 1
#define FALSE 0

/* C structures for representing TTCN-3 and ASN.1 types */

typedef enum { RECORD, SET, UNION, ANYTYPE } struct_def_kind_enum;

typedef enum { RECORD_OF, SET_OF } struct_of_def_kind_enum;

typedef enum {
  ANY_ATTRIB_BIT = 1,
  ANY_ELEM_BIT   = 2,
  ANY_FROM_BIT   = 4,
  ANY_EXCEPT_BIT = 8
} any_kind;
/* bit fields, use one of {ANY_ATTRIB_BIT,ANY_ELEM_BIT} and
 * one of {ANY_FROM_BIT, ANY_EXCEPT_BIT} */

/** Flags that determine the type(s) of value an object or field will be encoded
  * as in JSON code */
typedef enum {
  JSON_NONE       = 0x00, // no value type set (default)
  JSON_NUMBER     = 0x01, // integer and float
  JSON_STRING     = 0x02, // all string types, the objid type, the verdict type and enumerated values
  JSON_BOOLEAN    = 0x04, // boolean (true or false)
  JSON_OBJECT     = 0x08, // records, sets, unions and the anytype
  JSON_ARRAY      = 0x10, // record of, set of and array
  JSON_NULL       = 0x20, // ASN.1 null type
  JSON_ANY_VALUE  = 0x3F  // unions with the "as value" coding instruction
} json_value_t;

/* Compound type definitions */

/* record, set, union */

/** Structure field descriptor for code generation */
typedef struct {
  const char *type; /**< The C++ type name of the field */
  const char *typegen; /**< XER descriptor name */
  const char *typedescrname; /**< The name of the TTCN_descriptor variable */
  const char *name; /**< The C++ name of the field (without the prefix) */
  const char *dispname; /**< Display name (user-visible name) */
  boolean isOptional;
  boolean isDefault; /**< does it have a default value */
  boolean of_type; /**< true if the field is a sequence-of or set-of */
  boolean hasRaw;
  raw_attrib_struct raw;
  const char *defvalname; /**< the constant containing the default value */
  size_t   xerAnyNum;
  char **  xerAnyUris;
  /** Conflated field for anyAttributes and anyElement. Use one of
   * {ANY_ATTRIB_BIT,ANY_ELEM_BIT} + one of {ANY_FROM_BIT, ANY_EXCEPT_BIT} */
  unsigned short xerAnyKind;
  unsigned short jsonValueType;
  boolean xerAttribute;
  boolean jsonOmitAsNull;
  boolean jsonMetainfoUnbound;
  const char* jsonAlias;
  const char* jsonDefaultValue;
  rawAST_coding_taglist_list* jsonChosen;
  /** true if the field is a record-of or set-of with optimized memory allocation */
  boolean optimizedMemAlloc;
  XSD_types xsd_type;
  boolean xerUseUnion;
} struct_field;

/** Structure (record, set, union, anytype) descriptor for code generation */
typedef struct {
  const char *name; /**< C++ name for code generation */
  const char *dispname; /**< Display name (user-visible) */
  struct_def_kind_enum kind; /**< is it a record or a set */
  boolean isASN1; /**< Originating from an ASN.1 module */
  boolean hasRaw;
  boolean hasText;
  boolean hasXer;
  boolean hasJson;
  boolean hasOer;
  boolean oerExtendable;
  int oerNrOrRootcomps;
  int oerEagNum;
  int* oerEag;
  int oerPNum;
  int* oerP;
  boolean xerUntagged;
  boolean xerUntaggedOne; /**< from Type::u.secho.has_single_charenc */
  boolean xerUseNilPossible; /* for sequence */
  boolean xerUseOrderPossible; /* for sequence */
  boolean xerUseQName; /* for sequence */
  boolean xerUseTypeAttr; /* for choice */
  boolean xerUseUnion; /* for choice */
  boolean xerHasNamespaces; /* from the module */
  boolean xerEmbedValuesPossible; /* for sequence */
  boolean jsonAsValue; /* for both */
  boolean jsonAsMapPossible; /* for sequence */
  /** The index of the last field which can generate empty XML, or -1 */
  int exerMaybeEmptyIndex; /* for union */
  const char * control_ns_prefix;
  raw_attrib_struct raw;
  size_t nElements; /**< Number of fields for this class */
  size_t totalElements; /**< Real number of elements; may include
  fields from the last component when USE-NIL and USE-ORDER are both set */
  struct_field *elements;
  boolean has_opentypes;
  boolean opentype_outermost;
  Opentype_t *ot;
  boolean isOptional; /**< this structure is an optional field in a record/set */
} struct_def;

/** record of, set of descriptor for code generation */
typedef struct {
  const char *name; /**< C++ name for code generation */
  const char *dispname; /**< Display name (user-visible) */
  struct_of_def_kind_enum kind; /**< is it a record-of or a set-of */
  boolean isASN1;
  boolean hasRaw;
  boolean hasText;
  boolean hasXer;
  boolean hasJson;
  boolean hasOer;
  /** true if this is a record-of BOOLEAN, ENUMERATED or NULL */
  boolean xmlValueList;
  /* * true if this record-of has the LIST encoding instruction */
  /*boolean xerList;*/
  /** true if this record-of has the ATTRIBUTE encoding instruction */
  boolean xerAttribute;
  /** true if this record-of has the ANY-ATTRIBUTE or ANY-ELEMENT encoding instruction */
  boolean xerAnyAttrElem;
  raw_attrib_struct raw;
  boolean has_opentypes;
  const char *type; /**< Type of the elements */
  const char *oftypedescrname; /**< Type descr. variable of the elements */
  size_t nFollowers; /**< number of optional fields following the record-of */
  struct_field *followers; /**< information about following optional siblings */
} struct_of_def;

/* for processing enumerated type definitions */

typedef struct {
    const char *name; /* identifier name */
    const char *dispname; /* identifier TTCN-3 name */
    const char *text; /* modified by TEXT */
    const char *descaped_text; /* text but the escaped characters are descaped */
    int value;
} enum_field;

typedef struct {
    const char *name;
    const char *dispname; /* fullname */
    boolean isASN1;
    boolean hasRaw;
    boolean hasText;
    boolean hasXer;
    boolean hasJson;
    boolean hasOer;
    boolean xerUseNumber;
    boolean xerText; /* A component has the TEXT encoding instruction */
    size_t nElements;
    enum_field *elements;
    int firstUnused, secondUnused;
} enum_def;

/* for function, altstep, testcase reference types */

typedef enum { FUNCTION, ALTSTEP, TESTCASE } fat_type;

typedef struct {
  const char *name;
  const char *dispname;
  char *return_type;
  fat_type type;
  boolean runs_on_self;
  boolean is_startable;
  char *formal_par_list;
  char *actual_par_list;
  size_t nElements;
  const char** parameters;
} funcref_def;

/** for template restrictions */
typedef enum {
  TR_NONE, /* no restriction was given */
  TR_OMIT,
  TR_VALUE,
  TR_PRESENT
} template_restriction_t;

#endif /* DATATYPES_H */