diff options
author | Nicolas Noble <pixel@nobis-crew.org> | 2014-08-11 11:53:25 -0700 |
---|---|---|
committer | Nicolas Noble <pixel@nobis-crew.org> | 2014-08-11 11:53:25 -0700 |
commit | 2a2c2e97a9be9fc4db30842ad61e46a1fd7cd125 (patch) | |
tree | 843518e97789df9b85ac2fcc32417e1ec59b1656 /includes/LuaHandle.h | |
parent | 3664fe8db6a88e2aed5bc9425dfae92828851a42 (diff) |
Bugs fixing in Lua - we really can't afford to have destructors throwing exceptions, and also making sure we're using the proper types for Handles.
Diffstat (limited to 'includes/LuaHandle.h')
-rw-r--r-- | includes/LuaHandle.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/includes/LuaHandle.h b/includes/LuaHandle.h index fcde496..b67d084 100644 --- a/includes/LuaHandle.h +++ b/includes/LuaHandle.h @@ -6,23 +6,33 @@ namespace Balau { +class LuaIO { + public: + LuaIO(IO<Handle> h) : m_h(h) { } + LuaIO(const LuaIO & lio) : m_h(lio.m_h) { } + IO<Handle> getIO() { return m_h; } + void cleanup() { m_h->close(); } + private: + IO<Handle> m_h; +}; + class LuaHandleFactory : public LuaObjectFactory { public: - LuaHandleFactory(IO<Handle> h) : m_obj(new IO<Handle>(h)) { } + LuaHandleFactory(IO<Handle> h) : m_obj(new LuaIO(h)) { } static void pushStatics(Lua & L); protected: - LuaHandleFactory(IO<Handle> * h) : m_obj(h) { } - void pushObjectAndMembers(Lua & L); + LuaHandleFactory(LuaIO * h) : m_obj(h) { } + virtual void pushObjectAndMembers(Lua & L) override; private: - IO<Handle> * m_obj; + LuaIO * m_obj; }; class LuaInputFactory : public LuaHandleFactory { public: - LuaInputFactory(IO<Input> h) : LuaHandleFactory(new IO<Handle>(h)) { } + LuaInputFactory(IO<Input> h) : LuaHandleFactory(h) { } static void pushStatics(Lua & L); private: - void pushObjectAndMembers(Lua & L); + virtual void pushObjectAndMembers(Lua & L) override; }; void registerLuaHandle(Lua &); |