summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/BLua.h3
-rw-r--r--includes/BigInt.h2
-rw-r--r--includes/LuaHandle.h22
3 files changed, 20 insertions, 7 deletions
diff --git a/includes/BLua.h b/includes/BLua.h
index b5c147a..d0541f6 100644
--- a/includes/BLua.h
+++ b/includes/BLua.h
@@ -35,8 +35,9 @@ class DeferredCollector : public StacklessTask {
virtual const char * getName() const override { return "DeferredCollector"; }
virtual void Do() override {
StacklessBegin();
- StacklessOperation(delete m_obj);
+ StacklessOperation(m_obj->cleanup());
StacklessEnd();
+ delete m_obj;
}
private:
T * m_obj;
diff --git a/includes/BigInt.h b/includes/BigInt.h
index 3a31b2e..bc956bd 100644
--- a/includes/BigInt.h
+++ b/includes/BigInt.h
@@ -118,6 +118,8 @@ class BigInt {
String toString(int radix = 10) const;
char * makeString(int radix = 10) const;
+ void cleanup() { }
+
private:
void * m_bi = NULL;
};
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 &);