/* * luautil.hpp * * Copyright 2007 Julian Moore * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ bool isError(lua_State* L) { if (lua_isstring(L,-1)) { return true; }else{ return false; } } const char* getError(lua_State* L) { if (isError(L)) { const char* err = lua_tostring(L,-1); lua_pop(L,1); return err; }else{ return ""; } } void printError(lua_State* L,const char* msg) { if (isError(L)) { std::cerr << msg << getError(L) << std::endl; } } void DoString(lua_State* L,const char* str) { luaL_dostring(L,str); printError(L,"[C++ STRING]: "); } void DoFile(lua_State* L,const char* str) { luaL_dofile(L,str); printError(L,"[C++ FILE]: "); } #include "ircluautil.hpp"