mirror of
https://github.com/holub/mame
synced 2025-04-20 15:32:45 +03:00
luaengine: safer (nw)
This commit is contained in:
parent
06363cf65a
commit
431f8d3611
@ -125,7 +125,7 @@ namespace sol
|
||||
struct checker<sol::buffer *>
|
||||
{
|
||||
template <typename Handler>
|
||||
static bool check ( lua_State* L, int index, Handler&& handler, record& tracking )
|
||||
static bool check (lua_State* L, int index, Handler&& handler, record& tracking)
|
||||
{
|
||||
return stack::check<int>(L, index, handler);
|
||||
}
|
||||
|
@ -89,15 +89,15 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
// this will also check if a returned table contains type T
|
||||
// this can also check if a returned table contains type T
|
||||
template<typename T, typename U>
|
||||
bool call_plugin_check(const std::string &name, const U in)
|
||||
bool call_plugin_check(const std::string &name, const U in, bool table = false)
|
||||
{
|
||||
bool ret = false;
|
||||
sol::object outobj = call_plugin(name, sol::make_object(sol(), in));
|
||||
if(outobj.is<T>())
|
||||
if(outobj.is<T>() && !table)
|
||||
ret = true;
|
||||
else if(outobj.is<sol::table>())
|
||||
else if(outobj.is<sol::table>() && table)
|
||||
{
|
||||
// check just one entry, checking the whole thing shouldn't be necessary as this only supports homogeneous tables
|
||||
if(outobj.as<sol::table>().begin().operator*().second.template is<T>())
|
||||
|
@ -130,7 +130,7 @@ void menu_main::populate()
|
||||
item_append(_("Plugin Options"), "", 0, (void *)PLUGINS);
|
||||
|
||||
// add dats menu
|
||||
if (mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", ""))
|
||||
if (mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", "", true))
|
||||
item_append(_("External DAT View"), "", 0, (void *)EXTERNAL_DATS);
|
||||
|
||||
item_append(menu_item_type::SEPARATOR);
|
||||
|
@ -347,7 +347,7 @@ void menu_select_game::handle()
|
||||
if (!isfavorite())
|
||||
{
|
||||
const game_driver *driver = (const game_driver *)menu_event->itemref;
|
||||
if ((uintptr_t)driver > skip_main_items && mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", driver->name))
|
||||
if ((uintptr_t)driver > skip_main_items && mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", driver->name, true))
|
||||
menu::stack_push<menu_dats_view>(ui(), container(), driver);
|
||||
}
|
||||
else
|
||||
@ -356,7 +356,7 @@ void menu_select_game::handle()
|
||||
|
||||
if ((uintptr_t)ui_swinfo > skip_main_items)
|
||||
{
|
||||
if (ui_swinfo->startempty == 1 && mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", ui_swinfo->driver->name))
|
||||
if (ui_swinfo->startempty == 1 && mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", ui_swinfo->driver->name, true))
|
||||
menu::stack_push<menu_dats_view>(ui(), container(), ui_swinfo->driver);
|
||||
else if (mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", std::string(ui_swinfo->shortname).append(1, ',').append(ui_swinfo->listname).c_str()) || !ui_swinfo->usage.empty())
|
||||
menu::stack_push<menu_dats_view>(ui(), container(), ui_swinfo);
|
||||
|
@ -247,7 +247,7 @@ void menu_select_software::handle()
|
||||
// handle UI_DATS
|
||||
ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref;
|
||||
|
||||
if (ui_swinfo->startempty == 1 && mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", ui_swinfo->driver->name))
|
||||
if (ui_swinfo->startempty == 1 && mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", ui_swinfo->driver->name, true))
|
||||
menu::stack_push<menu_dats_view>(ui(), container(), ui_swinfo->driver);
|
||||
else if (mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", std::string(ui_swinfo->shortname).append(1, ',').append(ui_swinfo->listname).c_str()) || !ui_swinfo->usage.empty())
|
||||
menu::stack_push<menu_dats_view>(ui(), container(), ui_swinfo);
|
||||
|
Loading…
Reference in New Issue
Block a user