Closed tpdickso closed 8 years ago
I think the principle of the change is ok.
However your code doesn't work if index is positive. You can either fix it if possible, or put an assert(index < 0);
to replace the assert you removed.
Interesting -- what do the positive indices in lua_read_at_position
represent? Are they offsets from the bottom of the stack, as opposed to the top? I don't know what would cause lua_read_at_position to receive a positive index, from my few days of playing with this library. Thanks!
Yes, positive indices are from the bottom of the stack.
Tables now have an index field, which keeps track of where they are in the lua stack, and the lua FFI functions are now offset relative to this index (when relevant.)
This is my first pull request on Github, and I know only as much about the Lua C API as I skimmed in the past hour or so, but I ran this through a small gauntlet of tests with Rust FFI functions accepting multiple user-data types that are pushed to and read from Lua as tables, and it seems to work. (My data types are all just vectors and matrices and such, though, so no nested tables. It may be worth giving a try with those if you have some on hand.)
Thanks!