summaryrefslogtreecommitdiff
path: root/lib/luacd.cpp
diff options
context:
space:
mode:
authorpixel <pixel>2003-12-10 02:59:30 +0000
committerpixel <pixel>2003-12-10 02:59:30 +0000
commit5695a4b1e91154f8b9bae6d62eb9313b973fc6bd (patch)
tree071dff4a418b445451954efb04d0c1286b315387 /lib/luacd.cpp
parent0b266c95523f944e62acf9251eb27450a8d73a04 (diff)
LUALUALUALUALUALUALUALUALUA
Diffstat (limited to 'lib/luacd.cpp')
-rw-r--r--lib/luacd.cpp116
1 files changed, 86 insertions, 30 deletions
diff --git a/lib/luacd.cpp b/lib/luacd.cpp
index 47cb05b..68b3028 100644
--- a/lib/luacd.cpp
+++ b/lib/luacd.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: luacd.cpp,v 1.3 2003-12-08 15:12:57 pixel Exp $ */
+/* $Id: luacd.cpp,v 1.4 2003-12-10 02:59:32 pixel Exp $ */
#include "luacd.h"
@@ -57,14 +57,14 @@ enum cdutils_functions_t {
struct lua_functypes_t cdutils_methods[] = {
{ CDUTILS_SETISOW, "set_iso_w", 1, 1, {LUA_OBJECT} },
- { CDUTILS_GUESSTYPE, "guesstype", 0, 1, {LUA_NUMBER} },
+ { CDUTILS_GUESSTYPE, "guessmode", 0, 1, {LUA_NUMBER} },
{ CDUTILS_SECTORSEEK, "sectorseek", 1, 1, {LUA_NUMBER} },
{ CDUTILS_READSECTOR, "readsector", 0, 2, {LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_READDATAS, "readdatas", 3, 3, {LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_READFILE, "readfile", 4, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_READDATAS, "readdatas", 1, 3, {LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_READFILE, "readfile", 2, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ CDUTILS_WRITESECTOR, "writesector", 1, 3, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_WRITEDATAS, "writedatas", 4, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_WRITEFILE, "writefile", 1, 3, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_WRITEDATAS, "writedatas", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_WRITEFILE, "writefile", 1, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ CDUTILS_GETISOINFOS, "getisoinfos", 0, 0, 0 },
{ CDUTILS_GETPTINFOS, "getptinfos", 0, 0, 0 },
{ CDUTILS_FINDPATH, "findpath", 1, 1, {LUA_STRING} },
@@ -204,7 +204,7 @@ void Luacdutils::pushstatics(Lua * L) throw (GeneralException) {
}
int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
- int r = 0, sect = -1, mode = GUESS, size, i;
+ int r = 0, sect = -1, mode = GUESS, size = -1, i;
Handle * h;
Byte sdatas[2352], * datas;
String path;
@@ -241,11 +241,13 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
r = 1;
break;
case CDUTILS_READDATAS:
- mode = L->tonumber(2);
- sect = L->tonumber(3);
- size = L->tonumber(4);
+ size = L->tonumber(2);
+ if (n >= 2)
+ mode = L->tonumber(3);
+ if (n == 3)
+ sect = L->tonumber(3);
datas = (Byte *) malloc(size);
- cd->read_datas(datas, mode, sect, size);
+ cd->read_datas(datas, size, mode, sect);
L->newtable();
for (i = 0; i < size; i++) {
L->push((lua_Number) i);
@@ -257,10 +259,12 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
break;
case CDUTILS_READFILE:
h = (Handle *) LuaObject::getme(L, 2);
- mode = L->tonumber(3);
- sect = L->tonumber(4);
size = L->tonumber(5);
- cd->read_file(h, mode, sect, size);
+ if (n >= 3)
+ mode = L->tonumber(4);
+ if (n == 4)
+ sect = L->tonumber(5);
+ cd->read_file(h, size, mode, sect);
break;
case CDUTILS_WRITESECTOR:
if (n >= 2)
@@ -276,9 +280,11 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
cd->write_sector(datas, mode, sect);
break;
case CDUTILS_WRITEDATAS:
- mode = L->tonumber(3);
- sect = L->tonumber(4);
- size = L->tonumber(5);
+ size = L->tonumber(3);
+ if (n >= 3)
+ mode = L->tonumber(4);
+ if (n == 4)
+ sect = L->tonumber(5);
datas = (Byte *) malloc(size);
for (i = 0; i < size; i++) {
@@ -287,16 +293,18 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
sdatas[i] = L->tonumber();
L->pop();
}
- cd->write_datas(datas, mode, sect, size);
+ cd->write_datas(datas, size, mode, sect);
free(datas);
break;
case CDUTILS_WRITEFILE:
h = (Handle *) LuaObject::getme(L, 2);
if (n >= 2)
- mode = L->tonumber(3);
- if (n == 3)
- sect = L->tonumber(4);
- cd->write_file(h, mode, sect);
+ size = L->tonumber(3);
+ if (n >= 3)
+ mode = L->tonumber(4);
+ if (n == 4)
+ sect = L->tonumber(5);
+ cd->write_file(h, size, mode, sect);
break;
case CDUTILS_GETISOINFOS:
L->push((lua_Number) cd->get_iso_infos());
@@ -519,6 +527,8 @@ Luadirentry::Luadirentry(cdutils::DirEntry * _dir) : dir(_dir) { }
enum direntry_methods_t {
DIRENTRY_INDEX = 0,
+ DIRENTRY_ISHIDDEN,
+ DIRENTRY_ISDIR,
DIRENTRY_HASXA,
DIRENTRY_ISXADIR,
DIRENTRY_ISXAAUDIO,
@@ -529,6 +539,8 @@ enum direntry_methods_t {
struct lua_functypes_t direntry_methods[] = {
{ DIRENTRY_INDEX, "index", 1, 1, {LUA_STRING} },
+ { DIRENTRY_ISHIDDEN, "ishidden", 0, 0, 0 },
+ { DIRENTRY_ISDIR, "isdir", 0, 0, 0 },
{ DIRENTRY_HASXA, "hasxa", 0, 0, 0 },
{ DIRENTRY_ISXADIR, "isxadir", 0, 0, 0 },
{ DIRENTRY_ISXAAUDIO, "isxaaudio", 0, 0, 0 },
@@ -541,6 +553,8 @@ struct lua_functypes_t direntry_methods[] = {
class sLua_direntry : public Base {
public:
DECLARE_METHOD(direntry, DIRENTRY_INDEX);
+ DECLARE_METHOD(direntry, DIRENTRY_ISHIDDEN);
+ DECLARE_METHOD(direntry, DIRENTRY_ISDIR);
DECLARE_METHOD(direntry, DIRENTRY_HASXA);
DECLARE_METHOD(direntry, DIRENTRY_ISXADIR);
DECLARE_METHOD(direntry, DIRENTRY_ISXAAUDIO);
@@ -555,6 +569,8 @@ void Luadirentry::pushmembers(Lua * L) {
pushme(L, dir);
PUSH_METAMETHOD(direntry, DIRENTRY_INDEX);
+ PUSH_METHOD(direntry, DIRENTRY_ISHIDDEN);
+ PUSH_METHOD(direntry, DIRENTRY_ISDIR);
PUSH_METHOD(direntry, DIRENTRY_HASXA);
PUSH_METHOD(direntry, DIRENTRY_ISXADIR);
PUSH_METHOD(direntry, DIRENTRY_ISXAAUDIO);
@@ -590,6 +606,14 @@ int sLua_direntry::direntry_proceed(Lua * L, int n, direntry * dir, int caller)
L->push(has_xa);
r = 1;
break;
+ case DIRENTRY_ISHIDDEN:
+ L->push(dir->Flags & 1 ? true : false);
+ r = 1;
+ break;
+ case DIRENTRY_ISDIR:
+ L->push(dir->Flags & 2 ? true : false);
+ r = 1;
+ break;
case DIRENTRY_ISXADIR:
L->push(p[4] & 0x80 ? true : false);
r = 1;
@@ -672,18 +696,29 @@ enum cddate_methods_t {
CDDATE_NEWINDEX,
};
+enum cddate_functions_t {
+ CDDATE_NEWCDDATE = 0,
+};
+
struct lua_functypes_t cddate_methods[] = {
{ CDDATE_INDEX, "index", 1, 1, {LUA_STRING} },
{ CDDATE_NEWINDEX, "newindex", 2, 2, {LUA_STRING, LUA_NUMBER} },
{ -1, 0, 0, 0, 0 }
};
+struct lua_functypes_t cddate_functions[] = {
+ { CDDATE_NEWCDDATE, "cddate", 0, 0, 0 },
+ { -1, 0, 0, 0, 0 }
+};
+
class sLua_cddate : public Base {
public:
DECLARE_METHOD(cddate, CDDATE_INDEX);
DECLARE_METHOD(cddate, CDDATE_NEWINDEX);
+ DECLARE_FUNCTION(cddate, CDDATE_NEWCDDATE);
private:
static int cddate_proceed(Lua * L, int n, cddate * obj, int caller);
+ static int cddate_proceed_statics(Lua * L, int n, int caller);
};
void Luacddate::pushmembers(Lua * L) {
@@ -693,6 +728,13 @@ void Luacddate::pushmembers(Lua * L) {
PUSH_METAMETHOD(cddate, CDDATE_NEWINDEX);
}
+void Luacddate::pushstatics(Lua * L) throw (GeneralException) {
+ CHECK_METHODS(cddate);
+ CHECK_FUNCTIONS(cddate);
+
+ PUSH_FUNCTION(cddate, CDDATE_NEWCDDATE);
+}
+
int sLua_cddate::cddate_proceed(Lua * L, int n, cddate * date, int caller) {
int r, value;
String key;
@@ -701,7 +743,7 @@ int sLua_cddate::cddate_proceed(Lua * L, int n, cddate * date, int caller) {
case CDDATE_INDEX:
key = L->tostring(2);
r = 1;
- if (key == "year") {
+ if (key == "year") {
L->push((lua_Number) date->year);
} else if (key == "month") {
L->push((lua_Number) date->month);
@@ -749,6 +791,19 @@ int sLua_cddate::cddate_proceed(Lua * L, int n, cddate * date, int caller) {
return r;
}
+int sLua_cddate::cddate_proceed_statics(Lua * L, int n, int caller) {
+ int r = 0;
+
+ switch (caller) {
+ case CDDATE_NEWCDDATE:
+ {
+ Luacddate t(new cddate());
+ t.pushdestruct(L);
+ }
+ }
+
+ return r;
+}
/**********************\
|** class PVD exports **|
@@ -1124,6 +1179,8 @@ int sLua_DirTree::DirTree_proceed(Lua * L, int n, DirTree * dir, int caller) {
} else if (key == "brother") {
LuaDirTree tdir(dir->Brother());
tdir.push(L);
+ } else if (key == "isdir") {
+ L->push(dir->isdir());
} else {
invalid = true;
}
@@ -1298,7 +1355,7 @@ struct lua_functypes_t isobuilder_methods[] = {
{ ISOBUILDER_SETBASICS, "setbasics", 1, 5, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ ISOBUILDER_CREATEDIR, "createdir", 2, 5, {LUA_OBJECT, LUA_STRING, LUA_NUMBER, LUA_OBJECT, LUA_NUMBER} },
{ ISOBUILDER_CREATEFILE, "createfile", 3, 5, {LUA_OBJECT, LUA_OBJECT, LUA_STRING, LUA_OBJECT, LUA_NUMBER} },
- { ISOBUILDER_COPYDIR, "copydir", 4, 5, {LUA_OBJECT, LUA_STRING, LUA_OBJECT, LUA_OBJECT, LUA_NUMBER} },
+ { ISOBUILDER_COPYDIR, "copydir", 3, 4, {LUA_OBJECT, LUA_OBJECT, LUA_OBJECT, LUA_NUMBER} },
{ ISOBUILDER_CLOSE, "close", 0, 2, {LUA_OBJECT, LUA_NUMBER} },
{ -1, 0, 0, 0, 0 }
};
@@ -1505,12 +1562,11 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca
break;
case ISOBUILDER_COPYDIR:
dirt = (DirTree *) LuaObject::getme(L, 2);
- name = L->tostring(3);
- cd = (cdutils *) LuaObject::getme(L, 4);
- dire = (direntry *) LuaObject::getme(L, 5);
- if (n >= 5)
- mode = L->tonumber(6);
- iso->copydir(dirt, name, cd, dire, mode);
+ cd = (cdutils *) LuaObject::getme(L, 3);
+ dire = (direntry *) LuaObject::getme(L, 4);
+ if (n >= 4)
+ mode = L->tonumber(5);
+ iso->copydir(dirt, cd, dire, mode);
break;
case ISOBUILDER_CLOSE:
if (n >= 1)