lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello. I am a new user here at Nabble.

I wonder if anybody has an answer to Sebs question? Its really hard finding
documentation
about this.

/Robert



Sebastian Wolff wrote:
> 
> Dear Lua community,
> 
> I hope someone already encountered the following problem and may assist 
> finding a solution.
> 
> I have an own object class type MyClass and want to wrap a C++ library 
> using SWIG 1.3.39 to be used by Lua. Using this library I often have to 
> wrap methods of the form
> 
> void foo1(const MyClass & a, MyClass & b)
> {
>     b.assign_and_action(a);
> }
> void foo2(const MyClass & a, MyClass & b)
> {
>     b.modify(a);
> }
> void foo2b(const int &a, int &b)
> {
>     b += a;
> }
> 
> 'foo1' simply returns 'b' reading 'a'. foo2 and foo2b modify 'b' using 
> 'a'. Therefore, in Lua I want to call them by
> 
> b = foo1(a)
> b = foo2(a,c)
> b = foo2b(a,c)
> 
> To let SWIG know about the parameter types one has to specify which is 
> INPUT, OUTPUT or both:
> 
> void foo1(const MyClass & INPUT, MyClass & OUPUT);
> void foo2(const MyClass & INPUT, MyClass & INOUT);
> void foo2b(const int & INPUT, int & INOUT);
> 
> For 'foo2b' this is working fine. Somehow it does not work for 'foo1' 
> and 'foo2'. In the latter, all parameters are considered being input 
> variables.
> 
> Any ideas what went wrong?
> 
> Best regards
> Seb
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Lua-SWIG-output-parameters-of-custom-types-as-references-tp2740991p3565721.html
Sent from the Lua list mailing list archive at Nabble.com.