From e76bc2b8b3ebe01872fecd4f5f2344ee9b998f6d Mon Sep 17 00:00:00 2001 From: pixel Date: Sat, 6 Dec 2003 04:26:16 +0000 Subject: Having LUA now in cd-tool! Yay! --- lib/LuaHandle.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc index c332b0a..487470d 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.5 2003-12-04 04:09:02 pixel Exp $ */ +/* $Id: LuaHandle.cc,v 1.6 2003-12-06 04:26:17 pixel Exp $ */ #include "LuaHandle.h" @@ -30,6 +30,7 @@ class sLuaHandle : public Base { public: static int newinput(lua_State * L); static int newoutput(lua_State * L); + static int newbuffer(lua_State * L); static int read(lua_State * L); static int readstring(lua_State * L); static int readU8(lua_State * L); @@ -89,6 +90,10 @@ void LuaOutput::pushconstruct(Lua * L) { L->declarefunc("Output", sLuaHandle::newoutput); } +void LuaBuffer::pushconstruct(Lua * L) { + L->declarefunc("Buffer", sLuaHandle::newbuffer); +} + int sLuaHandle::newinput(lua_State * _L) { Lua * L = Lua::find(_L); int n = L->gettop(); @@ -117,6 +122,24 @@ int sLuaHandle::newoutput(lua_State * _L) { return 1; } +int sLuaHandle::newbuffer(lua_State * _L) { + Lua * L = Lua::find(_L); + int n = L->gettop(); + bool seekable = false; + + if ((n > 1) || ((n == 1) && (!L->isboolean()))) { + L->error("Incorrect arguments to constructor `Buffer'"); + } + + if (n == 1) + seekable = L->toboolean(); + + LuaBuffer o(new Buffer(seekable)); + o.pushdestruct(L); + + return 1; +} + int sLuaHandle::read(lua_State * _L) { Lua * L = Lua::find(_L); int n = L->gettop(), i; -- cgit v1.2.3