I'm trying to wrap a C++ function that can receive Lua table of strings and use it as an array of strings in C++ function.
I could successfully do this using float type instead of string.
Here's my function.
static void readTable(float values[], int len) {
for (int i=0; i<len; ++i)
printf("VALUE : %g", values[i]);
}
And here's the typemaps part from SWIG interface (.i) file
// using typemaps
%include <typemaps.i>
%apply (float INPUT[], int) {(float values[], int len)};
It works fine when I call this function in Lua.
However, if I change the type to std::string
instead of float
and pass table of strings to the function, I get the following error in Lua.
Error in readTable expected 2..2 args, got 1
I don't know what this means and how to fix this. Maybe I have to add something more to the SWIG interface (.i) file?
I would appreciate any help. Thanks!