Merge pull request #24 from BenceJanosSzabo/master
[deliverable/titan.core.git] / regression_test / json / SemanticCheck.ttcn
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 *
12 ******************************************************************************/
13 module SemanticCheck {
14
15 // Recursive type checks (type Inner doesn't have JSON encoding explicitly,
16 // but it can be encoded as part of Outer1)
17 type union Inner {
18 integer num,
19 charstring str
20 }
21
22 type record Outer1 {
23 octetstring bytes,
24 Inner rec
25 } with {
26 encode "JSON";
27 }
28
29 external function f_enc1(in Outer1 x) return octetstring
30 with { extension "prototype(convert) encode(JSON)" }
31
32 // Same thing, but Outer2 only has a JSON variant attribute to specify the encoding (no 'encode' attribute)
33 type record Outer2 {
34 octetstring bytes,
35 Inner rec
36 } with {
37 variant(rec) "JSON : name as stuff";
38 }
39
40 external function f_enc2(in Outer2 x) return octetstring
41 with { extension "prototype(convert) encode(JSON)" }
42
43 // Embedded union with the "as value" attribute
44 type record HasUnion
45 {
46 charstring str,
47 EmbeddedUnion val
48 }
49 with {
50 encode "JSON";
51 }
52
53
54
55 type union EmbeddedUnion
56 {
57 integer num,
58 octetstring bytes
59 }
60 with {
61 variant "JSON: as value";
62 }
63
64 }
This page took 0.044872 seconds and 5 git commands to generate.