feat(library/kernel_bindings): add to_io_state_ext helper function

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-05-29 13:35:11 -07:00
parent f8e71f711f
commit fc7d5461b1
2 changed files with 8 additions and 0 deletions

View file

@ -1280,6 +1280,13 @@ static void open_environment(lua_State * L) {
// IO state // IO state
DECL_UDATA(io_state) DECL_UDATA(io_state)
io_state to_io_state_ext(lua_State * L, int idx) {
if (idx <= lua_gettop(L))
return to_io_state(L, idx);
else
return get_io_state(L);
}
int mk_io_state(lua_State * L) { int mk_io_state(lua_State * L) {
int nargs = lua_gettop(L); int nargs = lua_gettop(L);
if (nargs == 0) if (nargs == 0)

View file

@ -76,5 +76,6 @@ public:
*/ */
io_state * get_io_state_ptr(lua_State * L); io_state * get_io_state_ptr(lua_State * L);
io_state get_io_state(lua_State * L); io_state get_io_state(lua_State * L);
io_state to_io_state_ext(lua_State * L, int idx);
void open_io_state(lua_State * L); void open_io_state(lua_State * L);
} }