summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-05-16 21:43:21 +0000
committerPixel <pixel@nobis-crew.org>2009-05-16 21:43:21 +0000
commit4984ff4a7cdc181aa8d4ff913ddc4323e77f4bca (patch)
tree9346fd308d415fc1d0862b9d6b4a42a1b03650d9
parent78bc26257579e19892454e7ed81832d2388e28ee (diff)
Adding cd/dvdabstract classes to the lua exports.
-rw-r--r--includes/luacd.h20
-rw-r--r--lib/luacd.cpp102
2 files changed, 122 insertions, 0 deletions
diff --git a/includes/luacd.h b/includes/luacd.h
index 1f7768f..baa4929 100644
--- a/includes/luacd.h
+++ b/includes/luacd.h
@@ -27,6 +27,8 @@
#include <LuaHandle.h>
#include <cdutils.h>
#include <isobuilder.h>
+#include <cdabstract.h>
+#include <dvdabstract.h>
#define CD_PUSHSTATICS(L) { \
Luacdutils::pushstatics(L); \
@@ -34,6 +36,8 @@
LuaPVD::pushstatics(L); \
LuaDirTree::pushstatics(L); \
Luaisobuilder::pushstatics(L); \
+ Luacdabstract::pushconstruct(L); \
+ Luadvdabstract::pushconstruct(L); \
}
class Luacdutils : public LuaObject {
@@ -89,4 +93,20 @@ class Luaisobuilder : public LuaObject {
isobuilder * iso;
};
+class Luacdabstract : public LuaHandle {
+ public:
+ static void pushconstruct(Lua *);
+ Luacdabstract(Handle *);
+ protected:
+ virtual void pushmembers(Lua *);
+};
+
+class Luadvdabstract : public LuaHandle {
+ public:
+ static void pushconstruct(Lua *);
+ Luadvdabstract(dvdabstract *);
+ protected:
+ virtual void pushmembers(Lua *);
+};
+
#endif
diff --git a/lib/luacd.cpp b/lib/luacd.cpp
index b619905..881f5ae 100644
--- a/lib/luacd.cpp
+++ b/lib/luacd.cpp
@@ -30,6 +30,12 @@ Luacdutils::Luacdutils(cdutils * _cd) : cd(_cd) { }
class Luacdfile : public LuaHandle {
public:
Luacdfile(cdfile * h) : LuaHandle(h) {}
+ void pushmembers(Lua * L) {
+ LuaHandle::pushmembers(L);
+ L->push("__handletype");
+ L->push("cdfile");
+ L->settable(-3, true);
+ }
};
enum cdutils_methods_t {
@@ -1713,3 +1719,99 @@ int sLua_isobuilder::isobuilder_proceed_statics(Lua * L, int n, int caller) {
return r;
}
+
+
+ /********************************\
+|** the various abstract classes **|
+ \********************************/
+
+class sLuacdabstract : public Base {
+ public:
+ static int cdprobe(lua_State * L);
+ static int new_cdabstract(lua_State * L);
+};
+
+int sLuacdabstract::cdprobe(lua_State * __L) {
+ Lua * L = Lua::find(__L);
+
+ if (!cdabstract::canprobe())
+ return 0;
+
+ L->newtable();
+ std::vector<String> probed = cdabstract::probe();
+ int j = 1;
+
+ for (std::vector<String>::iterator i = probed.begin(); i != probed.end(); i++, j++) {
+ L->push((lua_Number) j);
+ L->push(*i);
+ L->settable();
+ }
+
+ return 1;
+}
+
+int sLuacdabstract::new_cdabstract(lua_State * __L) {
+ Lua * L = Lua::find(__L);
+ int n = L->gettop();
+
+ if ((n != 1) || !L->isstring()) {
+ L->error("Incorrect arguments to constructor `cdabstract'");
+ }
+
+ Luacdabstract m(cdabstract::open_cd(L->tostring()));
+ m.pushdestruct(L);
+
+ return 1;
+}
+
+Luacdabstract::Luacdabstract(Handle * h) : LuaHandle(h) { }
+
+void Luacdabstract::pushconstruct(Lua * L) {
+ L->declarefunc("cdprobe", sLuacdabstract::cdprobe);
+ L->declarefunc("cdabstract", sLuacdabstract::new_cdabstract);
+}
+
+void Luacdabstract::pushmembers(Lua * L) {
+ LuaHandle::pushmembers(L);
+ L->push("__handletype");
+ L->push("cdabstract");
+ L->settable(-3, true);
+}
+
+class sLuadvdabstract : public Base {
+ public:
+ static int new_dvdabstract(lua_State * L);
+};
+
+int sLuadvdabstract::new_dvdabstract(lua_State * __L) {
+ Lua * L = Lua::find(__L);
+ int n = L->gettop();
+ bool forwrite = false;
+ String fname;
+
+ if ((n > 2) || (n < 1) || !L->isstring(1)) {
+ L->error("Incorrect arguments to constructor `dvdabstract'");
+ }
+
+ if (n == 2)
+ forwrite = L->toboolean(2);
+ fname = L->tostring(1);
+
+ Luadvdabstract m(new dvdabstract(forwrite ? (Handle *) new Output(fname, 0, 0) : (Handle *) new Input(fname)));
+ m.pushdestruct(L);
+
+ return 1;
+}
+
+Luadvdabstract::Luadvdabstract(dvdabstract * h) : LuaHandle(h) { }
+
+void Luadvdabstract::pushconstruct(Lua * L) {
+ L->declarefunc("dvdabstract", sLuadvdabstract::new_dvdabstract);
+}
+
+void Luadvdabstract::pushmembers(Lua * L) {
+ LuaHandle::pushmembers(L);
+ L->push("__handletype");
+ L->push("dvdabstract");
+ L->settable(-3, true);
+}