summaryrefslogtreecommitdiffstats
path: root/src/frontend/mame/luaengine_debug.cpp
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2022-03-23 20:27:30 +1100
committer GitHub <noreply@github.com>2022-03-23 20:27:30 +1100
commite6588480c477a8132676abbbb32bfc42287d8c6d (patch)
treeb483f8b9e049a280f68ae7b0af9c57372676f5df /src/frontend/mame/luaengine_debug.cpp
parentbb3f3e5abd7051ed371fe7fbdd0f49a56cc03f1f (diff)
Lua engine improvements (#9453)
Made auto-boot script errors and plugin bootstrap errors fatal. Run auto-boot scripts in a sandbox. Globals can be accessed, but not set. The sandbox is cleared on hard reset, but not on soft reset. Added (hopefully) useful to string metafunctions to device_t and address space that show short names and tags. Fixed issues in plugins that surface when strict type checking is enabled, as this means numbers and nil are not automatically converted to strings. Plugins should be tested with debug builds to check for this. Made save item read_block raise an error on invalid arguments rather than returning an empty string, and made it use luaL_buffer directly rather than using the helper wrapper. Changed some more function bindings to use set_function to avoid issues related to ThePhD/sol2#608, and got rid of some unnecessary lambda captures.
Diffstat (limited to 'src/frontend/mame/luaengine_debug.cpp')
-rw-r--r--src/frontend/mame/luaengine_debug.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/frontend/mame/luaengine_debug.cpp b/src/frontend/mame/luaengine_debug.cpp
index 94748d5a897..e2c6713ff44 100644
--- a/src/frontend/mame/luaengine_debug.cpp
+++ b/src/frontend/mame/luaengine_debug.cpp
@@ -181,14 +181,14 @@ void lua_engine::initialize_debug(sol::table &emu)
{ "m", EXPSPACE_REGION }
};
- auto const do_add_symbol = [this] (symbol_table_wrapper &st, char const *name, sol::protected_function getter, std::optional<sol::protected_function> setter, std::optional<char const *> format) -> symbol_entry &
+ auto const do_add_symbol = [] (symbol_table_wrapper &st, char const *name, sol::protected_function getter, std::optional<sol::protected_function> setter, std::optional<char const *> format) -> symbol_entry &
{
symbol_table::setter_func setfun;
if (setter)
- setfun = [this, cbfunc = std::move(*setter)] (u64 value) { invoke(cbfunc, value); };
+ setfun = [cbfunc = std::move(*setter)] (u64 value) { invoke(cbfunc, value); };
return st.table().add(
name,
- [this, cbfunc = std::move(getter)] () -> u64
+ [cbfunc = std::move(getter)] () -> u64
{
auto result = invoke(cbfunc).get<sol::optional<u64> >();
if (result)
@@ -217,12 +217,12 @@ void lua_engine::initialize_debug(sol::table &emu)
[] (device_t &device)
{ return std::make_shared<symbol_table_wrapper>(device.machine(), nullptr, &device); }));
symbol_table_type.set_function("set_memory_modified_func",
- [this] (symbol_table_wrapper &st, sol::object cb)
+ [] (symbol_table_wrapper &st, sol::object cb)
{
if (cb == sol::lua_nil)
st.table().set_memory_modified_func(nullptr);
else if (cb.is<sol::protected_function>())
- st.table().set_memory_modified_func([this, cbfunc = cb.as<sol::protected_function>()] () { invoke(cbfunc); });
+ st.table().set_memory_modified_func([cbfunc = cb.as<sol::protected_function>()] () { invoke(cbfunc); });
else
osd_printf_error("[LUA ERROR] must call set_memory_modified_func with function or nil\n");
});
@@ -246,19 +246,19 @@ void lua_engine::initialize_debug(sol::table &emu)
{
return do_add_symbol(st, name, getter, std::nullopt, nullptr);
},
- [this] (symbol_table_wrapper &st, char const *name, int minparams, int maxparams, sol::protected_function execute) -> symbol_entry &
+ [] (symbol_table_wrapper &st, sol::this_state s, char const *name, int minparams, int maxparams, sol::protected_function execute) -> symbol_entry &
{
return st.table().add(
name,
minparams,
maxparams,
- [this, cbref = sol::reference(execute)] (int numparams, u64 const *paramlist) -> u64
+ [L = s.L, cbref = sol::reference(execute)] (int numparams, u64 const *paramlist) -> u64
{
- sol::stack_reference traceback(m_lua_state, -sol::stack::push(m_lua_state, sol::default_traceback_error_handler));
+ sol::stack_reference traceback(L, -sol::stack::push(L, sol::default_traceback_error_handler));
cbref.push();
- sol::stack_aligned_stack_handler_function func(m_lua_state, -1, traceback);
+ sol::stack_aligned_stack_handler_function func(L, -1, traceback);
for (int i = 0; numparams > i; ++i)
- lua_pushinteger(m_lua_state, paramlist[i]);
+ lua_pushinteger(L, paramlist[i]);
auto result = func(sol::stack_count(numparams)).get<sol::optional<u64> >();
traceback.pop();
return result ? *result : 0;