I just replaced Lua with LuaJIT for my project and I got the error saying
Use of undeclared identifier 'lua_len'
How can I change lua_len
so it is compatible with Lua 5.1 and LuaJIT?
Here's my code that uses lua_len
from the SWIG binding. (In case it helps)
%typemap(in) (int argc, t_atom *argv)
{
if (!lua_istable(L, $input)) {
SWIG_exception(SWIG_RuntimeError, "argument mismatch: table expected");
}
lua_len(L, $input);
$1 = lua_tointeger(L, -1);
if (!$1) {
SWIG_exception(SWIG_RuntimeError, "table is empty");
}
$2 = (t_atom *)getbytes($1 * sizeof(t_atom));
for (int i=0; i<$1; ++i) {
lua_pushinteger(L, i+1);
lua_gettable(L, $input);
if (lua_isnumber(L, -1)) {
$2[i].a_type = A_FLOAT;
$2[i].a_w.w_float = lua_tonumber(L, -1);
}
else if (lua_isstring(L, -1)) {
$2[i].a_type = A_SYMBOL;
$2[i].a_w.w_symbol = gensym(lua_tostring(L, -1));
}
else {
SWIG_exception(SWIG_RuntimeError, "unhandled argument type");
}
}
}