How to access C pointers in Lua -
i have array of elements (dynamic) in c return pointer.
using pointer need read value of array elements.
is there function access pointers c , retrieve value in lua.?
you can wrap pointer userdata , write accessor methods (complexity: high). easier solution convert array regular lua table.
size_t arr_size = 10; int arr[10] = { 0 }; lua_getglobal(l, "testfunc"); lua_createtable(l, arr_size, 0); (size_t = 0; < arr_size; i++) { lua_pushinteger(l, arr[i]); lua_rawseti(l, -2, i+1); } // table @ top of stack lua_call(l, 1, 0); // call testfunc(t)
Comments
Post a Comment