diff options
author | pixel <pixel> | 2008-07-18 14:01:13 +0000 |
---|---|---|
committer | pixel <pixel> | 2008-07-18 14:01:13 +0000 |
commit | f2b61730a78987ad8738822372a5ec0fac4b56b3 (patch) | |
tree | cf5ab92bd5bfb964c25f04d7877205412572cdc9 /lib | |
parent | d1d512080aafbf9a271c13cd3eb04815baeebadc (diff) |
Adding time() function.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/BLua.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/BLua.cc b/lib/BLua.cc index a8751be..9f33284 100644 --- a/lib/BLua.cc +++ b/lib/BLua.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: BLua.cc,v 1.61 2008-07-05 06:24:05 pixel Exp $ */ +/* $Id: BLua.cc,v 1.62 2008-07-18 14:01:13 pixel Exp $ */ #include <stdlib.h> #include "BLua.h" @@ -85,6 +85,7 @@ class LuaStatics : public Base { static int iconv(lua_State *); static int mkdir(lua_State *); + static int time(lua_State *); static int globalindex(lua_State *); @@ -319,6 +320,14 @@ int LuaStatics::mkdir(lua_State * _L) { return 0; } +int LuaStatics::time(lua_State * _L) { + Lua * L = Lua::find(_L); + + L->push((lua_Number) ::time(NULL)); + + return 1; +} + int LuaStatics::print(lua_State * _L) { Lua * L = Lua::find(_L); @@ -487,10 +496,16 @@ void Lua::open_base() { push("mkdir"); push(LuaStatics::mkdir); settable(); + push("time"); + push(LuaStatics::time); + settable(); lua_pop(L, 1); push("mkdir"); push(LuaStatics::mkdir); settable(LUA_GLOBALSINDEX); + push("time"); + push(LuaStatics::time); + settable(LUA_GLOBALSINDEX); } void Lua::open_table() { |