Skip to content

Commit

Permalink
Added getfd method to io objects
Browse files Browse the repository at this point in the history
  • Loading branch information
daurnimator authored and Brian Maher committed Nov 30, 2010
1 parent be4b11c commit e5bb88d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions io_lua_ev.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static int create_io_mt(lua_State *L) {
static luaL_reg fns[] = {
{ "stop", io_stop },
{ "start", io_start },
{ "getfd" , io_getfd },
{ NULL, NULL }
};
luaL_newmetatable(L, IO_MT);
Expand Down Expand Up @@ -99,3 +100,18 @@ static int io_start(lua_State *L) {

return 0;
}

/**
* Returns the original file descriptor
* Usage:
* io:getfd ( )
*
* [+1, -0, e]
*/
static int io_getfd(lua_State *L) {
ev_io* io = check_io(L, 1);

lua_pushinteger ( L , io->fd );

return 1;
}
1 change: 1 addition & 0 deletions lua_ev.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static int io_new(lua_State* L);
static void io_cb(struct ev_loop* loop, ev_io* io, int revents);
static int io_stop(lua_State *L);
static int io_start(lua_State *L);
static int io_getfd(lua_State *L);

/**
* Signal functions:
Expand Down

0 comments on commit e5bb88d

Please sign in to comment.