|
And still I'm looking for a way to use both OOP style (my_array:length()) and array-style (my_array[1] = 0)
static int get (lua_State *L) {
array* a = check_array (L);
if (lua_isnumber (L, 2)) {
int index = lua_tointeger (L, 2);<... array access here ...>return 1;
}
else {
lua_getglobal (L, "array");
lua_pushvalue (L, 2);
lua_gettable (L, -2);
lua_remove (L, -2);
return 1;
}
}