From a18509185569b8e637c7e129caab5eb75e4adff9 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sat, 12 Feb 2022 04:10:39 +1100 Subject: Addressed some Lua scripting pitfalls. (#9294) Addressed pure virtual function call crash on end of emulation session if you haven't explicitly removed all address space taps, memory corruption on end of emulation session if you haven't explicitly removed all address space change notifiers, and symbol being garbage-collected out from under you while you have parsed expressions or other symbol tables that depend on them. Removed the copy constructor for parsed expressions as the underlying C++ copy constructor appears to be broken, and simplified symbol table constructors. Also made symbol table add methods return the new entry to avoid the need for an extra lookup. Fixed breakpoint/watchpoint objects being inappropriately copied into the tables returned by bplist() and wplist(), allowing the enabled property to be modifiable for breakpoint and watchpoint objects in Lua. Fixed drivers and devices causing a new memory pass-through handler to be allocated on each soft reset, and fixed multiple instances of taps being installed in the event the machine is reset before the tap is removed. Added classes for managing broadcast subscriptions, and adapted address spaces to use this for change notifications. --- src/frontend/mame/luaengine.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/frontend/mame/luaengine.cpp') diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 4798d7ca9d4..831f445faa5 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -28,6 +28,7 @@ #include "uiinput.h" #include "corestr.h" +#include "notifier.h" #include #include @@ -741,6 +742,10 @@ void lua_engine::initialize() [] (device_t &dev, int maxdepth) { return devenum(dev, maxdepth); }); + auto notifier_subscription_type = sol().registry().new_usertype("notifier_subscription", sol::no_constructor); + notifier_subscription_type["unsubscribe"] = &util::notifier_subscription::reset; + notifier_subscription_type["is_active"] = sol::property(&util::notifier_subscription::operator bool); + auto attotime_type = emu.new_usertype( "attotime", sol::call_constructor, sol::constructors()); -- cgit v1.2.3-70-g09d2