rttlua getOperation failing to construct a 'string const& const&' type

Dear All,

I recently fixed up TaskContext:provides() to produce more useful
output by printing the full Operations similar to printing a
TaskContext. I stumbled upon the following problem in the case that a
port has been added to the TC.

"Operation.call: can't create return value DSB of type 'string const& const&'"

The Operation in question is "name", defined in PortInterface.hpp:77
as
const std::string& getName() const { return name; }

and added in PortInterface.cpp:80.

The relevant rttlua (~ line 1656) code is here:

if(oip->resultType() != "void"){
ti = types::TypeInfoRepository::Instance()->type(oip->resultType());
if(!ti)
luaL_error(L, "Operation.call: can't create return value DSB of type '%s'", oip->resultType().c_str());
...

oip is a OperationInterfacePart *

The following rttlua fourliner triggers the problem

require "rttlib"
tc=rtt.getTC()
tc:addPort(rtt.InputPort("int", "myport"))
print=tc:provides("myport"):getOperation("name")

Any ideas why this type can't be constructed? What is a
"string const& const&" supposed to be anyway?

Thanks in advance.

Markus

rttlua getOperation failing to construct a 'string const& const&

On Thu, Jun 7, 2012 at 12:27 PM, Markus Klotzbuecher <
markus [dot] klotzbuecher [..] ...> wrote:

> Dear All,
>
> I recently fixed up TaskContext:provides() to produce more useful
> output by printing the full Operations similar to printing a
> TaskContext. I stumbled upon the following problem in the case that a
> port has been added to the TC.
>
> "Operation.call: can't create return value DSB of type 'string const&
> const&'"
>
> The Operation in question is "name", defined in PortInterface.hpp:77
> as
> const std::string& getName() const { return name; }
>
> and added in PortInterface.cpp:80.
>
>
> The relevant rttlua (~ line 1656) code is here:
>
> if(oip->resultType() != "void"){
> ti = types::TypeInfoRepository::Instance()->type(oip->resultType());
> if(!ti)
> luaL_error(L, "Operation.call: can't create return value DSB of
> type '%s'", oip->resultType().c_str());
> ...
>
> oip is a OperationInterfacePart *
>
>
> The following rttlua fourliner triggers the problem
>
> require "rttlib"
> tc=rtt.getTC()
> tc:addPort(rtt.InputPort("int", "myport"))
> print=tc:provides("myport"):getOperation("name")
>
> Any ideas why this type can't be constructed? What is a
> "string const& const&" supposed to be anyway?
>

It's a bug in 'resultType()' afaikt. It should return 'string const&'. In
addition there's a bug in your code. You should have used:

ti = oip->getArgumentType(0); // 0 == return type

Instead of relying on a string name, which you know, may return rubbish in
many different cases.

Peter

rttlua getOperation failing to construct a 'string const& const&

On Sat, Jun 16, 2012 at 10:35:42PM +0100, Peter Soetens wrote:
> On Thu, Jun 7, 2012 at 12:27 PM, Markus Klotzbuecher <
> markus [dot] klotzbuecher [..] ...> wrote:
>
> Dear All,
>
> I recently fixed up TaskContext:provides() to produce more useful
> output by printing the full Operations similar to printing a
> TaskContext. I stumbled upon the following problem in the case that a
> port has been added to the TC.
>
> "Operation.call: can't create return value DSB of type 'string const&
> const&'"
>
> The Operation in question is "name", defined in PortInterface.hpp:77
> as
> const std::string& getName() const { return name; }
>
> and added in PortInterface.cpp:80.
>
>
> The relevant rttlua (~ line 1656) code is here:
>
> if(oip->resultType() != "void"){
> ti = types::TypeInfoRepository::Instance()->type(oip->resultType());
> if(!ti)
> luaL_error(L, "Operation.call: can't create return value DSB of
> type '%s'", oip->resultType().c_str());
> ...
>
> oip is a OperationInterfacePart *
>
>
> The following rttlua fourliner triggers the problem
>
> require "rttlib"
> tc=rtt.getTC()
> tc:addPort(rtt.InputPort("int", "myport"))
> print=tc:provides("myport"):getOperation("name")
>
> Any ideas why this type can't be constructed? What is a
> "string const& const&" supposed to be anyway?
>
>
> It's a bug in 'resultType()' afaikt. It should return 'string const&'. In
> addition there's a bug in your code. You should have used:
>
> ti = oip->getArgumentType(0); // 0 == return type
>
> Instead of relying on a string name, which you know, may return rubbish in many
> different cases.

Thanks, yes that fixed the lua problem, now I just get the wrong output:

string const& const& name() // Returns the port name.

Are you taking care of the resultType bug?

Markus