diff options
Diffstat (limited to 'lib/LuaHandle.cc')
-rw-r--r-- | lib/LuaHandle.cc | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc index d4a204a..22c5036 100644 --- a/lib/LuaHandle.cc +++ b/lib/LuaHandle.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: LuaHandle.cc,v 1.25 2008-01-24 10:49:59 pixel Exp $ */ +/* $Id: LuaHandle.cc,v 1.26 2008-05-13 06:59:10 pixel Exp $ */ #include "LuaHandle.h" @@ -67,6 +67,8 @@ class sLuaHandle : public Base { static int get_nb_input(lua_State * L); static int get_nb_output(lua_State * L); static int get_nb_buffer(lua_State * L); + static int zlib_inflate(lua_State * L); + static int zlib_deflate(lua_State * L); private: static int read(lua_State * L, int); static int write(lua_State * L, int); @@ -516,6 +518,46 @@ int sLuaHandle::get_nb_buffer(lua_State * __L) { return 1; } +int sLuaHandle::zlib_inflate(lua_State * __L) { + Lua * L = Lua::find(__L); + int n = L->gettop(); + Handle * s, * d; + int r; + + if (n != 2) { + L->error("Incorrect arguments to method `Handle::zlib_inflate'"); + } + + s = (Handle *) LuaObject::getme(L, 1); + d = (Handle *) LuaObject::getme(L, 2); + + r = Handle::zlib_inflate(s, d); + + L->push((lua_Number) r); + + return 1; +} + +int sLuaHandle::zlib_deflate(lua_State * __L) { + Lua * L = Lua::find(__L); + int n = L->gettop(); + Handle * s, * d; + int r; + + if (n != 2) { + L->error("Incorrect arguments to method `Handle::zlib_deflate'"); + } + + s = (Handle *) LuaObject::getme(L, 1); + d = (Handle *) LuaObject::getme(L, 2); + + r = Handle::zlib_deflate(s, d); + + L->push((lua_Number) r); + + return 1; +} + int sLuaHandle::seek(lua_State * __L) { Lua * L = Lua::find(__L); int n = L->gettop(); @@ -732,4 +774,7 @@ void LuaHandle::pushconstruct(Lua * L) { L->declarefunc("get_nb_input", sLuaHandle::get_nb_input); L->declarefunc("get_nb_output", sLuaHandle::get_nb_output); L->declarefunc("get_nb_buffer", sLuaHandle::get_nb_buffer); + + L->declarefunc("zlib_inflate", sLuaHandle::zlib_inflate); + L->declarefunc("zlib_deflate", sLuaHandle::zlib_deflate); } |