diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2009-12-17 01:11:47 +0100 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2009-12-17 01:11:47 +0100 |
commit | 6ff9cbf815122663ba8b0018321dd1307781f811 (patch) | |
tree | 73225080c92a7429a7660074a71e04ed2aba73c8 /include | |
parent | cdf245a8d0f0cea8665e51946aee69052f798e3e (diff) |
Finally adding the HandleLua object, plus a few minor tweaks to the Lua VM.
Diffstat (limited to 'include')
-rw-r--r-- | include/BLua.h | 4 | ||||
-rw-r--r-- | include/LuaHandle.h | 14 |
2 files changed, 17 insertions, 1 deletions
diff --git a/include/BLua.h b/include/BLua.h index 5d61dc1..f1401fd 100644 --- a/include/BLua.h +++ b/include/BLua.h @@ -70,6 +70,8 @@ class Lua : public Base { Lua(const Lua &) throw (GeneralException); virtual ~Lua(); typedef int (*lua_CallWrapper)(lua_State *, lua_CFunction); + int ref(int t = -2) { luaL_ref(L, t); } + void unref(int ref, int t = -1) { luaL_unref(L, t, ref); } void open_base(); void open_table(); void open_io(bool safe = true); @@ -102,6 +104,8 @@ class Lua : public Base { void * newuser(size_t s) { checkstack(); return lua_newuserdata(L, s); } void settable(int = -3, bool raw = false); void gettable(int = -2, bool raw = false); + void rawseti(int i, int t = -2) { lua_rawseti(L, t, i); } + void rawgeti(int i, int t = -1) { lua_rawgeti(L, t, i); } void setvar() { lua_settable(L, LUA_GLOBALSINDEX); } int gettop() { return lua_gettop(L); } void getglobal(const String &) throw (GeneralException); diff --git a/include/LuaHandle.h b/include/LuaHandle.h index 3ee7cc6..82dfc8c 100644 --- a/include/LuaHandle.h +++ b/include/LuaHandle.h @@ -61,7 +61,7 @@ class LuaBuffer : public LuaHandle { class HandleLua : public Handle { public: - HandleLua(); + HandleLua(Lua *, int t = -1); virtual ~HandleLua(); virtual ssize_t read(void * buf, size_t count) throw (GeneralException); virtual ssize_t write(const void * buf, size_t count) throw (GeneralException); @@ -75,6 +75,18 @@ class HandleLua : public Handle { virtual time_t GetModif() const; virtual bool CanWatch() const; virtual void Flush(); + private: + void GetObj() const; + int ref; + mutable Lua * L; +}; + +class LuaHandleLua : public LuaHandle { + public: + static void pushconstruct(Lua *); + LuaHandleLua(HandleLua *); + protected: + virtual void pushmembers(Lua *); }; #endif |