diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/BLua.h | 51 | ||||
-rw-r--r-- | include/Exceptions.h | 1 | ||||
-rw-r--r-- | include/Handle.h | 6 | ||||
-rw-r--r-- | include/LuaHandle.h | 33 |
4 files changed, 87 insertions, 4 deletions
diff --git a/include/BLua.h b/include/BLua.h index 476ac0a..fb62b14 100644 --- a/include/BLua.h +++ b/include/BLua.h @@ -11,19 +11,66 @@ class Lua : public Base { 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(double);
+ 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 *) throw (GeneralException) ;
Lua * thread();
- static Lua * find(lua_State *);
+ 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<lua_State *, Lua *> 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
diff --git a/include/Exceptions.h b/include/Exceptions.h index 17fe093..d37cd5a 100644 --- a/include/Exceptions.h +++ b/include/Exceptions.h @@ -21,6 +21,7 @@ struct ugly_string; class Base { public: + virtual ~Base() {}; static char * strdup(const char * s); static void * malloc(ssize_t s); static void * realloc(void * p, size_t s); diff --git a/include/Handle.h b/include/Handle.h index 6e0fcbc..763a34b 100644 --- a/include/Handle.h +++ b/include/Handle.h @@ -13,14 +13,16 @@ class Handle : public Base { public: Handle(const Handle &); virtual ~Handle(); - virtual ssize_t read(void *buf, size_t count) throw (GeneralException); - virtual ssize_t write(const void *buf, size_t count) throw (GeneralException); + virtual ssize_t read(void * buf, size_t count) throw (GeneralException); + virtual ssize_t write(const void * buf, size_t count) throw (GeneralException); Uint8 readU8(); Uint16 readU16(); Uint32 readU32(); void writeU8(Uint8); void writeU16(Uint16); void writeU32(Uint32); + void copyto(Handle *, ssize_t = -1); + void copyfrom(Handle *, ssize_t = -1); bool IsClosed(void) const; bool IsNonBlock(void) const; void SetNonBlock(void); diff --git a/include/LuaHandle.h b/include/LuaHandle.h new file mode 100644 index 0000000..629b57f --- /dev/null +++ b/include/LuaHandle.h @@ -0,0 +1,33 @@ +#ifndef __LUAHANDLE_H__
+#define __LUAHANDLE_H__
+
+#include <Exceptions.h>
+#include <Input.h>
+#include <Output.h>
+#include <BLua.h>
+
+class LuaHandle : public LuaObject {
+ public:
+ LuaHandle(Handle *);
+ protected:
+ virtual void pushmembers(Lua *);
+ Handle * h;
+};
+
+class LuaInput : public LuaHandle {
+ public:
+ static void pushconstruct(Lua *);
+ LuaInput(Input *);
+ protected:
+ virtual void pushmembers(Lua *);
+};
+
+class LuaOutput : public LuaHandle {
+ public:
+ static void pushconstruct(Lua *);
+ LuaOutput(Output *);
+ protected:
+ virtual void pushmembers(Lua *);
+};
+
+#endif
|