/******************************************************************************
 * 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:
 *   Szabo, Bence Janos
 *
 ******************************************************************************/

// Test that internal ports can be the data layer of translation ports.
module PortTranslateInternal {


	type port InternalP1 message {
		in integer
	} with {
		extension "provider"
	}

	type port InternalPT1 message map to InternalP1 {
		in integer from charstring with str_to_int() : charstring with str_to_int() : octetstring with oct_to_int()
	} with {
		extension "internal"
	}

	type port InternalPT2 message map to InternalP1 {
		in integer from charstring with str_to_int() : charstring with str_to_int() : octetstring with oct_to_int()
		in charstring from integer with int_to_str() : integer with int_to_str() : octetstring with oct_to_str()
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP1_ message {
		in integer, hexstring
	} with {
		extension "provider"
	}

	type port InternalP2_ message {
		in charstring, octetstring
	} with {
		extension "provider"
	}
	
	type port InternalPT2_ message map to InternalP1_, InternalP2_ {
		in integer from octetstring with oct_to_int() : hexstring with hex_to_int() : charstring with str_to_int()
		in charstring from octetstring with oct_to_str() : hexstring with hex_to_str() : integer with int_to_str()
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type component MyComp {
		port InternalPT1 pt1
		port InternalPT2 pt2
		port InternalPT2_ pt2_
	}

	type component MySystem {
		port InternalP1 p1
		port InternalP1_ p1_
		port InternalP2 p2
		port InternalP2_ p2_
	}

	// Check that mapping is possible
	testcase tc_map() runs on MyComp system MySystem {
		map(self:pt1, system:p1);
		map(self:pt2, system:p1);
		map(self:pt2_, system:p1_);
		map(self:pt2_, system:p2_);
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP2 message {
		in integer , charstring
	} with {
		extension "provider"
	}

	type port InternalPT3 message map to InternalP2 {
		in integer from charstring with str_to_int()
		in charstring from integer with int_to_str()
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP3 message {
		in integer, charstring
		inout octetstring
	} with {
		extension "provider"
	}

	type port InternalPT4 message map to InternalP3 {
		in integer
		in charstring
		inout octetstring
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP4 message {
		in integer, charstring
		in octetstring
		out octetstring
	} with {
		extension "provider"
	}

	type port InternalPT5 message map to InternalP4 {
		in integer
		in charstring
		inout octetstring
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP5 message {
		in integer, charstring
		in octetstring
		out octetstring
	} with {
		extension "provider"
	}

	type port InternalPT6 message map to InternalP5 {
		in integer
		in charstring
		in octetstring
		out octetstring
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP6 message {
		in integer, charstring
		in octetstring
		out octetstring, integer
	} with {
		extension "provider"
	}

	type port InternalPT7 message map to InternalP6 {
		in integer
		in charstring
		in octetstring
		out octetstring to hexstring with oct_to_hex() : hexstring with oct_to_hex(), integer to hexstring with int_to_hex() : hexstring with int_to_hex()
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP7 message {
		in integer
	} with {
		extension "provider"
	}

	type port InternalP8 message {
		in integer
	} with {
		extension "provider"
	}

	type port InternalPT9 message map to InternalP7, InternalP8 {
		in integer
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP9 message {
		in integer
		out charstring, octetstring
	} with {
		extension "provider"
	}

	type port InternalP10 message {
		in integer
		out octetstring, charstring
	} with {
		extension "provider"
	}

	type port InternalPT10 message map to InternalP9, InternalP10 {
		in integer
		out charstring to octetstring with str_to_oct(), octetstring to charstring with oct_to_str()
	} with {
		extension "internal"
	}


///////////////////////////////////////////////////////////////////////////////

	type port InternalP13 message {
		in integer, hexstring
		out charstring, octetstring
	} with {
		extension "provider"
	}

	type port InternalP14 message {
		in integer
		out octetstring, charstring
	} with {
		extension "provider"
	}

	type port InternalPT12 message map to InternalP13, InternalP14 {
		in integer, hexstring
		out charstring, octetstring
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP15 message {
		in integer, hexstring
		out charstring, octetstring
		inout bitstring
	} with {
		extension "provider"
	}

	type port InternalP16 message {
		in integer, bitstring
		out octetstring, charstring, bitstring
	} with {
		extension "provider"
	}

	type port InternalPT13 message map to InternalP15, InternalP16 {
		in integer, hexstring
		out charstring, octetstring
		inout bitstring
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP17 message {
		out integer, hexstring, charstring
	} with {
		extension "provider"
	}

	type port InternalP18 message {
		out charstring, octetstring, integer
	} with {
		extension "provider"
	}
	
	type port InternalPT14 message map to InternalP17, InternalP18 {
		out integer to bitstring with int_to_bit() : hexstring with int_to_hex()
		out charstring to bitstring with str_to_bit() : hexstring with str_to_hex()
	} with {
		extension "internal"
	}


///////////////////////////////////////////////////////////////////////////////

	type port InternalP19 message {
		inout integer
	} with {
		extension "provider"
	}
	
	type port InternalPT15 message map to InternalP19 {
		out integer
		in integer
	} with {
		extension "internal"
	}

///////////////////////////////////////////////////////////////////////////////

	type port InternalP20 message {
		out charstring
		out bitstring
	} with {
		extension "provider"
	}

	type port InternalP21 message {
		out integer
		out hexstring
	} with {
		extension "provider"
	}

	type port InternalP22 message {
		out octetstring
		out hexstring
	} with {
		extension "provider"
	}

	type port InternalPT16 message map to InternalP20, InternalP21, InternalP22 {
		out integer to charstring with int_to_str() : octetstring with int_to_oct()
		out bitstring to hexstring with bit_to_hex()
	} with {
		extension "internal"
	}


	type component Comp1 {
		port InternalPT16 pt16[4][5][5];
		port InternalP22  p22[3][5][6];
	}

	testcase tc_port_arr() runs on Comp1 {
		map(self:pt16[1][2][3], system:p22[1][2][3]);
	}

	/* Conversion functions */

	function int_to_str(in integer i, out charstring j) {

	} with {
		extension "prototype(fast)";
	}

	function int_to_oct(in integer i, out octetstring j) {

	} with {
		extension "prototype(fast)";
	}

	function int_to_bit(in integer i, out bitstring j) {

	} with {
		extension "prototype(fast)";
	}

	function int_to_hex(in integer i, out hexstring j) {

	} with {
		extension "prototype(fast)";
	}

	/////////////////////////////////////////////////////

	function str_to_int(in charstring i, out integer j) {

	} with {
		extension "prototype(fast)";
	}

	function str_to_oct(in charstring i, out octetstring j) {

	} with {
		extension "prototype(fast)";
	}

	function str_to_bit(in charstring i, out bitstring j) {

	} with {
		extension "prototype(fast)";
	}

	function str_to_hex(in charstring i, out hexstring j) {

	} with {
		extension "prototype(fast)";
	}

	/////////////////////////////////////////////////////

	function oct_to_int(in octetstring i, out integer j) {

	} with {
		extension "prototype(fast)";
	}

	function oct_to_str(in octetstring i, out charstring j) {

	} with {
		extension "prototype(fast)";
	}

	function oct_to_bit(in octetstring i, out bitstring j) {

	} with {
		extension "prototype(fast)";
	}

	function oct_to_hex(in octetstring i, out hexstring j) {

	} with {
		extension "prototype(fast)";
	}

	/////////////////////////////////////////////////////

	function bit_to_int(in bitstring i, out integer j) {

	} with {
		extension "prototype(fast)";
	}

	function bit_to_str(in bitstring i, out charstring j) {

	} with {
		extension "prototype(fast)";
	}

	function bit_to_oct(in bitstring i, out octetstring j) {

	} with {
		extension "prototype(fast)";
	}

	function bit_to_hex(in bitstring i, out hexstring j) {

	} with {
		extension "prototype(fast)";
	}

	/////////////////////////////////////////////////////

	function hex_to_int(in hexstring i, out integer j) {

	} with {
		extension "prototype(fast)";
	}

	function hex_to_str(in hexstring i, out charstring j) {

	} with {
		extension "prototype(fast)";
	}

	function hex_to_oct(in hexstring i, out octetstring j) {

	} with {
		extension "prototype(fast)";
	}

	function hex_to_bit(in hexstring i, out bitstring j) {

	} with {
		extension "prototype(fast)";
	}



}