/****************************************************************************** * Copyright (c) 2000-2015 Ericsson Telecom AB * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ module SemanticCheck { // Recursive type checks (type Inner doesn't have JSON encoding explicitly, // but it can be encoded as part of Outer1) type union Inner { integer num, charstring str } type record Outer1 { octetstring bytes, Inner rec } with { encode "JSON"; } external function f_enc1(in Outer1 x) return octetstring with { extension "prototype(convert) encode(JSON)" } // Same thing, but Outer2 only has a JSON variant attribute to specify the encoding (no 'encode' attribute) type record Outer2 { octetstring bytes, Inner rec } with { variant(rec) "JSON : name as stuff"; } external function f_enc2(in Outer2 x) return octetstring with { extension "prototype(convert) encode(JSON)" } // Embedded union with the "as value" attribute type record HasUnion { charstring str, EmbeddedUnion val } with { encode "JSON"; } type union EmbeddedUnion { integer num, octetstring bytes } with { variant "JSON: as value"; } }