lua-users home
lua-l archive

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


I'm having difficulty with the Lua bindings output by SWIG with C++
and thought this might be a good place to post after finding some
previous posts about SWIG and Lua.

In a SWIG interface file you may explicitly tag function parameters as
INPUT, OUTPUT, or INOUT.  If I have a function

void foo(int a, int* OUTPUT)

where OUTPUT is an output parameter, then the generated Lua binding to
the function has one input of type number and one return value of type
number.  Good.  But if I have a C++ function

void foo(int a, int& OUTPUT)

(int reference) then the generated Lua binding has *two* inputs, one
of type number and the other of type SWIGTYPE_p_int (pointer to int),
with *no* return value.  I would expect one input of type number and
one return value of type number.

However for an INOUT parameter

void foo(int a, int& INOUT)

the generated Lua binding has two inputs of type number and one return
value of type number, which is correct.

I'm guessing that the Lua SWIG typemaps for OUTPUT parameters don't
know how to handle references to primitive types.  They should be
treated as pointers as far as I can tell.

Does anyone have any insight into the deep magic of SWIG typemaps for Lua?

Thanks,

.. Adam