luaengine: remove now unnecessary stuff since a copy of searchpath is made and it won't be garbage collected from underneath us (nw)

This commit is contained in:
cracyc 2016-08-19 10:56:31 -05:00
parent 7d5ee75620
commit 53962aff61
3 changed files with 14 additions and 25 deletions

View File

@ -14,7 +14,7 @@ local function xml_parse(data)
local arr = {} local arr = {}
while str ~= "" do while str ~= "" do
local tag, attr, stop local tag, attr, stop
tag, attr, stop, str = str:match("<([%w!-]+) ?(.-)(/?)[ -]->(.*)") tag, attr, stop, str = str:match("<([%w!%-]+) ?(.-)(/?)[ %-]->(.*)")
if not tag then if not tag then
return arr return arr
@ -26,7 +26,7 @@ local function xml_parse(data)
nest, str = str:match("(.-)</ *" .. tag .. " *>(.*)") nest, str = str:match("(.-)</ *" .. tag .. " *>(.*)")
local children = get_tags(nest) local children = get_tags(nest)
if not next(children) then if not next(children) then
nest = nest:gsub("<!--.--->", "") nest = nest:gsub("<!--.-%-%->", "")
nest = nest:gsub("^%s*(.-)%s*$", "%1") nest = nest:gsub("^%s*(.-)%s*$", "%1")
block["text"] = nest block["text"] = nest
else else

View File

@ -1724,12 +1724,12 @@ int lua_engine::lua_screen::l_draw_text(lua_State *L)
int lua_engine::lua_emu_file::l_emu_file_read(lua_State *L) int lua_engine::lua_emu_file::l_emu_file_read(lua_State *L)
{ {
lua_emu_file *file = luabridge::Stack<lua_emu_file *>::get(L, 1); emu_file *file = luabridge::Stack<emu_file *>::get(L, 1);
luaL_argcheck(L, lua_isnumber(L, 2), 2, "length (integer) expected"); luaL_argcheck(L, lua_isnumber(L, 2), 2, "length (integer) expected");
int ret, len = lua_tonumber(L, 2); int ret, len = lua_tonumber(L, 2);
luaL_Buffer buff; luaL_Buffer buff;
char *ptr = luaL_buffinitsize(L, &buff, len); char *ptr = luaL_buffinitsize(L, &buff, len);
ret = file->file.read(ptr, len); ret = file->read(ptr, len);
luaL_pushresultsize(&buff, ret); luaL_pushresultsize(&buff, ret);
return 1; return 1;
} }
@ -2675,15 +2675,17 @@ void lua_engine::initialize()
.addProperty <bool> ("is_creatable", &device_image_interface::is_creatable) .addProperty <bool> ("is_creatable", &device_image_interface::is_creatable)
.addProperty <bool> ("is_reset_on_load", &device_image_interface::is_reset_on_load) .addProperty <bool> ("is_reset_on_load", &device_image_interface::is_reset_on_load)
.endClass() .endClass()
.beginClass <lua_emu_file> ("file") .beginClass <lua_emu_file> ("lua_file")
.addConstructor <void (*)(const char *, UINT32)> ()
.addCFunction ("read", &lua_emu_file::l_emu_file_read) .addCFunction ("read", &lua_emu_file::l_emu_file_read)
.addFunction ("open", &lua_emu_file::open) .endClass()
.addFunction ("open_next", &lua_emu_file::open_next) .deriveClass <emu_file, lua_emu_file> ("file")
.addFunction ("seek", &lua_emu_file::seek) .addConstructor <void (*)(const char *, UINT32)> ()
.addFunction ("size", &lua_emu_file::size) .addFunction ("open", static_cast<osd_file::error (emu_file::*)(const std::string &)>(&emu_file::open))
.addFunction ("filename", &lua_emu_file::filename) .addFunction ("open_next", &emu_file::open_next)
.addFunction ("fullpath", &lua_emu_file::fullpath) .addFunction ("seek", &emu_file::seek)
.addFunction ("size", &emu_file::size)
.addFunction ("filename", &emu_file::filename)
.addFunction ("fullpath", &emu_file::fullpath)
.endClass() .endClass()
.beginClass <lua_item> ("item") .beginClass <lua_item> ("item")
.addConstructor <void (*)(int)> () .addConstructor <void (*)(int)> ()

View File

@ -226,20 +226,7 @@ private:
}; };
struct lua_emu_file { struct lua_emu_file {
lua_emu_file(const char *searchpath, UINT32 openflags) :
path(searchpath),
file(path.c_str(), openflags) {}
int l_emu_file_read(lua_State *L); int l_emu_file_read(lua_State *L);
osd_file::error open(const std::string &name) {return file.open(name);}
osd_file::error open_next() {return file.open_next();}
int seek(INT64 offset, int whence) {return file.seek(offset, whence);}
UINT64 size() {return file.size();}
const char *filename() {return file.filename();}
const char *fullpath() {return file.fullpath();}
std::string path;
emu_file file;
}; };
struct lua_item { struct lua_item {