File: encode_SE.ttcn

package info (click to toggle)
eclipse-titan 8.2.0-1
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 103,544 kB
  • sloc: cpp: 271,008; ansic: 33,683; yacc: 23,419; makefile: 15,483; lex: 9,204; java: 4,848; perl: 4,555; sh: 2,242; xml: 1,378; javascript: 85; awk: 48; php: 32; python: 13
file content (161 lines) | stat: -rw-r--r-- 6,929 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
/******************************************************************************
 * Copyright (c) 2000-2021 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:
 *   Baranyi, Botond
 *
 ******************************************************************************/

module encode_SE { //^In TTCN-3 module//

type record Rec1 { //^In type definition//
  integer f1
}
with {
  variant "name as uncapitalized"; //No encoding rules defined for type//
}

type record Rec2 { //^In type definition//
  integer f1
}
with {
  encode "XML";
  variant "name as uncapitalizeded"; //in variant attribute, at or before token `uncapitalizeded'\: syntax error, unexpected XIdentifier//
}

type record Rec3 { //^In type definition//
  integer f1
}
with {
  encode "JSON";
  variant "attribute"; //Variant attribute is not related to JSON encoding//
  variant "name as uncapitalized"; //Variant attribute is not related to JSON encoding// //This format is not supported for the JSON codec//
}

type record Rec4 { //^In type definition//
  charstring f1,
  Rec2 f2,
  Rec3 f3
}
with {
  encode "XML";
  variant "name as uncapitalized";
  variant (f1) "16 bit"; //Variant attribute is not related to XER encoding//
  encode (f2) "RAW";
  encode (f2) "JSON";
  variant (f2) "FIELDLENGTH(16)"; //The encoding reference is mandatory for variant attributes of type `@encode_SE.Rec2', which has multiple encodings//
  variant (f2) "RAW"."ALIGN(left)";
  variant (f2) "JSON"."untagged"; //Variant attribute is not related to JSON encoding//
  variant (f2) "XML"."name as 'abc'"; //Type `@encode_SE.Rec2' does not support XER encoding//
  variant (f3) "untagged"; //Variant attribute is not related to JSON encoding//
}

type record Rec5 { //^In type definition// //Invalid attribute, 'as value' is only allowed for unions, the anytype, or records or sets with one mandatory field//
  integer f1, //Invalid attribute, 'omit as null' requires optional field of a record or set.//
  Rec4 f2, //USE-UNION can only be applied to a CHOICE/union type//
  record of Rec3 f3 //Invalid attribute, 'name as ...' requires field of a record, set or union.// //^In JSON default value \(legacy\)// //Invalid JSON default value for type `@encode_SE.Rec5.f3'. Only the empty array is allowed.//
}
with {
  encode "RAW";
  encode "JSON";
  variant "RAW"."FIELDLENGTH(50)";
  variant "JSON"."JSON: as value";
  variant (f1) "RAW"."COMP(nosign)";
  variant (f1) "JSON"."JSON: omit as null";
  variant (f2) "useUnion";
  variant (f3) "RAW"."BYTEORDER(first)";
  variant (f3) "JSON"."JSON: default(30)";
  variant (f3[-]) "JSON: name as def";
  encode (f3[-].f1) "TEXT"; //Encode attribute is ignored, because it refers to a type from a different type definition//
  variant (f3[-].f1) "TEXT_CODING(length=5;leading0=true)"; //Variant attribute is ignored, because it refers to a type from a different type definition//
}

type set of integer SetOf1 //^In type definition//
with {
  encode "abc";
  encode "XML";
  variant "abc"."some variant"; //Variant attributes related to custom encoding are ignored//
  variant ([-]) "abc"."FIELDLENGTH(20)"; //Variant attributes related to custom encoding are ignored//
  variant ([-]) "xyz"."some other variant"; //Type `integer' does not support custom encoding `xyz'//
}

external function f_enc_xy1(in SetOf2 x) return bitstring
  with { extension "prototype(convert) encode(xy)" }

type set of Rec3 SetOf2
with {
  encode "xy";
}

external function f_enc_xy2(in SetOf2 x) return bitstring
  with { extension "prototype(convert) encode(xy)" }

external function f_dec_xy1(inout bitstring x, out SetOf2 y) return integer
  with { extension "prototype(sliding) decode(xy)" }
  
type set of SetOf2 SetOf3
with {
  encode "xy";
}

external function f_dec_xy2(inout bitstring x, out SetOf3[-] y) return integer
  with { extension "prototype(sliding) decode(xy)" }

function f1() { //^In function definition// 
  var bitstring bs;
  var universal charstring ucs;
  var integer i;
  var Rec3 r3;
  var Rec4 r4;
  var SetOf2 so2; //Multiple `xy' encoder functions defined for type//
  var SetOf3 so3; //No `xy' decoder function defined for type//
  const universal charstring c_enc := "JSON";
  bs := encvalue(Rec1: { 1 }, "", "XML"); //^In variable assignment// //^In the first parameter of encvalue// //No coding rule specified for type//
  ucs := encvalue_unichar(Rec2: { 2 }, "UTF-8", "qqqqqqqqq", c_enc); //^In variable assignment// //In the fourth operand of encvalue_unichar// //The encoding string does not match any encodings of type//
  i := decvalue(bs, r3, i, "abc"); //^In variable assignment// //^In the third parameter of decvalue// //Third operand of operation `decvalue' should be \(universal\) charstring value// //In the fourth operand of decvalue// //The encoding string does not match any encodings of type//
  i := decvalue_unichar(ucs, r4, "UTF-8", "...", r3); //^In variable assignment// //^In the fifth operand of decvalue_unichar// //Fifth operand of operation `decvalue_unichar' should be \(universal\) charstring value//
  bs := encvalue(so2);
  i := decvalue(bs, so3[-]);
  var template charstring dm := decmatch so3;
}

external function f_enc_xy3(in SetOf2 x) return bitstring
  with { extension "prototype(convert) encode(xy)" }
  
external function f_dec_xy3(inout bitstring x, out SetOf2 y) return integer
  with { extension "prototype(sliding) decode(xy)" }
  
type component CT {}

function f2() runs on CT { //^In function definition//
  self.setencode(Rec1, "BER:2002"); //^In setencode statement// //The type argument has no encoding rules defined//
  self.setencode(Rec2, "RAW"); //^In setencode statement// //The type argument has only one encoding rule defined. The 'setencode' statement will be ignored// //^In the second argument// //The encoding string does not match any encodings of type//
  self.setencode(Rec3, 12); //^In setencode statement// //The type argument has only one encoding rule defined. The 'setencode' statement will be ignored// //^In the second argument// //character string value was expected//
  self.setencode(Rec4.f2, "TEXT"); //^In setencode statement// //^In the second argument// //The encoding string does not match any encodings of type//
}

type record Rec6 { //^In type definition// //Type `@encode_SE.Rec6' cannot have RAW encoding. Encode attribute ignored.// //Type `@encode_SE.Rec6' cannot have TEXT encoding. Encode attribute ignored.//
  Int f1,
  Rec1 f2,
  Rec6 f3 optional,
  SetOf2 f4,
  record of Rec6 f5,
  bitstring f6,
  objid f7
}
with {
  encode "XML";
  encode "JSON";
  encode "RAW";
  encode "TEXT";
  variant (f3) "JSON"."JSON: name as ff1";
  variant (f5) "XML"."list";
}

type integer Int;

}