Re: rttlua does not support enum types as arguments for operations
Peter Soetens <[email protected]>
| Newsgroups | gmane.science.robotics.orocos.devel |
|---|---|
| Message-ID | <CAMYDobUa5E+TcJPT7HML1XiuCmkd=btQTy9ucHDmm=nF8w6LYw@mail.gmail.com> |
On Thu, Mar 14, 2013 at 4:53 PM, Ruben Smits <[email protected]> wrote: > Hi, > > I've got an enum type for which I created a typekit using typegen and an > extra plugin to add these enums to the GlobalTypeRepository of RTT. > > I have a component that uses this enum as an argument type. Everything goes > fine using the OCL Taskbrowser, I can call my operation using the enum taken > from the global repository. > > The same however fails using rttlua with the following error: > > ``` >> component.operation("string",rtt.globals.MYENUM) > > /home/rsmits/orocos_toolchain/ocl/bin/rttlua-gnulinux: > .../orocos_toolchain/ocl/lua/modules/rttlib.lua:716: Operation.call: > argument 2 is not assignable. > > ``` > > Does anyone have an idea why this happens? Is this due to the fact that I > take the value from the GlobalRepository? It's due to the fact that it accidentally worked for primitive types (int,float,...) and not for all other types. Patch in attachment that copies the constant over to a value data source and uses that down the road. Fine to push Markus ? Peter -- Orocos-Dev mailing list [email protected] http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev
0001-lua-make-copies-of-constant-variable-arguments-of-op.patch
(application/octet-stream, 1018 B)
From e0ca20f8e0128a5d1682df7e1f9742aac4a2a331 Mon Sep 17 00:00:00 2001 From: Peter Soetens <[email protected]> Date: Thu, 14 Mar 2013 16:58:45 +0100 Subject: [PATCH] lua: make copies of constant variable arguments of operations. Signed-off-by: Peter Soetens <[email protected]> --- lua/rtt.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/rtt.cpp b/lua/rtt.cpp index 2736887..c32c92d 100644 --- a/lua/rtt.cpp +++ b/lua/rtt.cpp @@ -1441,8 +1441,12 @@ static int __Operation_call(lua_State *L) OperationHandle def.): */ oh->dsb_store.push_back(dsb); } - if(!dsb->isAssignable()) - luaL_error(L, "Operation.call: argument %d is not assignable.", arg-1); + if(!dsb->isAssignable()) { + /* make a copy */ + base::DataSourceBase::shared_ptr copy = dsb->getTypeInfo()->buildValue(); + copy->update(dsb.get()); + dsb = copy; + } ret = oh->args[arg-2]->setReference(dsb); if (!ret) -- 1.7.9.5