#ifndef __BLUA_H__ #define __BLUA_H__ #include #include #include #include class Lua : public Base { public: Lua(); Lua(const Lua &) throw (GeneralException); virtual ~Lua(); void open_base(); void open_table(); void open_io(); void open_string(); void open_math(); void open_debug(); void declarefunc(const String &, lua_CFunction, int = LUA_GLOBALSINDEX); void call(const String &, int = LUA_GLOBALSINDEX, int = 0, int = 0); void call(int = 0, int = 0); void push(); void push(lua_Number); void push(const String &); void push(bool); void push(void *); void push(lua_CFunction, int = 0); void pop(int = 1); void newtable(); void settable(int = -3); void gettable(int = -2); int gettop(); void error(const String &); int type(int = -1); bool isnil(int = -1); bool isboolean(int = -1); bool isnumber(int = -1); bool isstring(int = -1); bool istable(int = -1); bool isfunction(int = -1); bool iscfunction(int = -1); bool isuserdata(int = -1); bool islightuserdata(int = -1); bool toboolean(int = -1); lua_Number tonumber(int = -1); String tostring(int = -1); lua_CFunction tocfunction(int = -1); void * touserdata(int = -1); Lua * tothread(int = -1); void load(Handle *, bool = true) throw (GeneralException); void dump(Handle *, bool = true); Lua * thread(); static Lua * find(lua_State *) throw (GeneralException); void showerror(); int getmetatable(int = -1); int setmetatable(int = -2); private: Lua(lua_State *); lua_State * L; static std::map lualist; }; class LuaObject : public Base { public: LuaObject() : wantdestruct(false), pushed(false) {} virtual void push(Lua *) throw (GeneralException); static void * getme(Lua *, int = 1) throw (GeneralException); void pushdestruct(Lua *) throw (GeneralException); protected: virtual void pushmembers(Lua *) = 0; void pushme(Lua *, void *); static void pushit(Lua *, const String &, lua_CFunction); bool wantdestruct, pushed; }; #endif