From 58b06d12b0e09958e58a404a9b56dbca7bab1e73 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 29 Sep 2015 10:55:08 -0700 Subject: [PATCH] feat(library/kernel_bindings): expose get_ios in the Lua API It gives access to the global io_state object. --- src/library/kernel_bindings.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/library/kernel_bindings.cpp b/src/library/kernel_bindings.cpp index 4e892d6f5..13a7e1db2 100644 --- a/src/library/kernel_bindings.cpp +++ b/src/library/kernel_bindings.cpp @@ -1283,6 +1283,10 @@ static const struct luaL_Reg io_state_m[] = { {0, 0} }; +static int get_global_io_state(lua_State * L) { + return push_io_state(L, get_io_state(L)); +} + void open_io_state(lua_State * L) { luaL_newmetatable(L, io_state_mt); lua_pushvalue(L, -1); @@ -1292,6 +1296,8 @@ void open_io_state(lua_State * L) { SET_GLOBAL_FUN(io_state_pred, "is_io_state"); SET_GLOBAL_FUN(mk_io_state, "io_state"); SET_GLOBAL_FUN(print, "print"); + SET_GLOBAL_FUN(get_global_io_state, "get_io_state"); + SET_GLOBAL_FUN(get_global_io_state, "get_ios"); } static char g_set_state_key;