Skip to content

Port code skeleton generated with missing reference

Not a huge deal, but when generating a test port skeleton from the following ttcn code, a reference is not added to the port header file for the message type IP used by port PCOType.

A forward declaration needs to be added at the start of the generated PCOType.hh:

namespace MyExample { class IP; }

You cant #include MyExample.hh as that messes up the ordering of declarations.

This problem seems specific to the use of translation port types.

MyExample.ttcn:

// TTCN-3 version of "Hello, world!"
module MyExample
{
type record UDP {
  integer x
}

type record IP {
  integer Y,
  UDP u
}

function ip_to_udp(in IP x, out UDP y) {
  y := x.u;
  port.setstate(0, "Translated");
}
with {
  extension "prototype(fast)"
}

function ip_to_ip(in IP x, out IP y) {
  y := x;
  port.setstate(0, "Translated");
}
with {
  extension "prototype(fast)"
}

function udp_to_ip(in UDP x, out IP y) {
  y.u := x;
  y.Y := 0;
  port.setstate(0, "Translated");
}
with {
  extension "prototype(fast)"
}

type charstring address;

type port PCOType message 
{
  map param(charstring prm);
  inout IP;
}
with {
  extension "address"
  extension "provider"
}

type port UserPort message map to PCOType {
    in UDP from IP with ip_to_udp()
    out UDP to IP with udp_to_ip()
    in IP from IP with ip_to_ip();
    out IP to IP with ip_to_ip();
}with {
    extension "internal"
}


type component MTCType
{
	var charstring vc_pp;
	port UserPort MyUser_PT;
}

type component SysType
{
	port PCOType MyPCO_PT;
}

template IP m_anyIP := {
	Y := ?,
	u := ?
}

template UDP m_anyUDP := {
    x := ?
}

testcase tc_ReceiveIP() runs on MTCType system SysType
{
    map(mtc:MyUser_PT, system:MyPCO_PT) param ("Hello");
    var IP i := {0,{5}};
    MyUser_PT.send(i) //to "me";
    timer t
    t.start(1.0);
    alt {
		[]MyUser_PT.receive(m_anyIP) {
			setverdict(pass);	
		}
		[] t.timeout {
		    setverdict(fail);
		}
	}
}

testcase tc_ReceiveUDP() runs on MTCType system SysType
{
    map(mtc:MyUser_PT, system:MyPCO_PT) param ("Fred");
    var UDP u := {0};
    MyUser_PT.send(u) //to "me";
    timer t;
    t.start(1.0);
    alt {
		[]MyUser_PT.receive(m_anyUDP) {
			setverdict(pass);	
		}
		[] t.timeout {
		    setverdict(fail);
		}
    }
}

control
{
  execute(tc_ReceiveIP());
  execute(tc_ReceiveUDP());
}

}
```
`
Edited by Ashley Duncan