From b3b4fd468cb4703ceed95ed78a567bb759cdb338 Mon Sep 17 00:00:00 2001 From: pixel Date: Sun, 7 Dec 2003 04:44:37 +0000 Subject: LUA work work work --- cd-tool.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'cd-tool.cpp') diff --git a/cd-tool.cpp b/cd-tool.cpp index bf3d879..fd123a2 100644 --- a/cd-tool.cpp +++ b/cd-tool.cpp @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: cd-tool.cpp,v 1.16 2003-12-06 04:26:16 pixel Exp $ */ +/* $Id: cd-tool.cpp,v 1.17 2003-12-07 04:44:38 pixel Exp $ */ #include #include @@ -38,6 +38,14 @@ #include "isobuilder.h" #include "luacd.h" +static int myprint(lua_State * L) { + const char * t = lua_tostring(L, -1); + + Base::printm(M_INFO, "From LUA: %s\n", t); + + return 0; +} + int lga = 0; struct option long_options[] = { {"help", 0, NULL, 'h'}, @@ -330,14 +338,22 @@ virtual int startup() throw (GeneralException) { } arg1 = argv[optind]; Lua * L = new Lua(); + L->open_math(); + L->open_string(); LuaInput::pushconstruct(L); LuaOutput::pushconstruct(L); LuaBuffer::pushconstruct(L); - L->push("cdutil"); + Luacdutils::pushstatics(L); + Luacdfile::pushstatics(L); + L->push("print"); + L->push(myprint); + L->settable(LUA_GLOBALSINDEX); Luacdutils lcdutil(cdutil); + L->push("cdutil"); lcdutil.push(L); L->settable(LUA_GLOBALSINDEX); L->load(&Input(arg1)); + getchar(); } else { showhelp(); printm(M_ERROR, "Command %s unknow.\n", argv[optind]); -- cgit v1.2.3