diff options
author | 2021-09-21 01:02:11 +1000 | |
---|---|---|
committer | 2021-09-21 01:02:11 +1000 | |
commit | da1af2b0d6816a5da1544176b882407bd0dad2ee (patch) | |
tree | 9a7db16882a0fe937a1b2cbdcb6e78711f33dfa3 /src/frontend/mame/luaengine_render.cpp | |
parent | 362d859dc15384f98b97d37cb5e21c7798df3cab (diff) |
-delegates: Fixed structure return with MSVC C++ ABI.
* Automatically use delegate_mfp_compatible to generate an adaptor for
member functions that return non-scalar, non-reference types
(partially addresses #8597).
* Enabled the MSVC delegate implemenation for MSVC on AArch64.
* Switched back to neater delegate types for layout item bounds and
colour.
-docs: Updated the example layout links to point to 0.235 - this means
there's now an example of embedded SVG.
Diffstat (limited to 'src/frontend/mame/luaengine_render.cpp')
-rw-r--r-- | src/frontend/mame/luaengine_render.cpp | 66 |
1 files changed, 10 insertions, 56 deletions
diff --git a/src/frontend/mame/luaengine_render.cpp b/src/frontend/mame/luaengine_render.cpp index eab50d89a90..2cf8cc6878d 100644 --- a/src/frontend/mame/luaengine_render.cpp +++ b/src/frontend/mame/luaengine_render.cpp @@ -291,63 +291,17 @@ void lua_engine::initialize_render(sol::table &emu) "set_animation_state_callback", "animation state"); layout_view_item_type["set_bounds_callback"] = - [this] (layout_view::item &i, sol::object cb) - { - if (cb == sol::lua_nil) - { - i.set_bounds_callback(layout_view::item::bounds_delegate()); - } - else if (cb.is<sol::protected_function>()) - { - i.set_bounds_callback(layout_view::item::bounds_delegate( - [this, cbfunc = cb.as<sol::protected_function>()] (render_bounds &b) - { - auto result(invoke(cbfunc).get<sol::optional<render_bounds> >()); - if (result) - { - b = *result; - } - else - { - osd_printf_error("[LUA ERROR] invalid return from bounds callback\n"); - b = render_bounds{ 0.0, 0.0, 1.0, 1.0 }; - } - })); - } - else - { - osd_printf_error("[LUA ERROR] must call set_bounds_callback with function or nil\n"); - } - }; + make_simple_callback_setter<render_bounds>( + &layout_view::item::set_bounds_callback, + [] () { return render_bounds{ 0.0f, 0.0f, 1.0f, 1.0f }; }, + "set_bounds_callback", + "bounds"); layout_view_item_type["set_color_callback"] = - [this] (layout_view::item &i, sol::object cb) - { - if (cb == sol::lua_nil) - { - i.set_color_callback(layout_view::item::color_delegate()); - } - else if (cb.is<sol::protected_function>()) - { - i.set_color_callback(layout_view::item::color_delegate( - [this, cbfunc = cb.as<sol::protected_function>()] (render_color &c) - { - auto result(invoke(cbfunc).get<sol::optional<render_color> >()); - if (result) - { - c = *result; - } - else - { - osd_printf_error("[LUA ERROR] invalid return from color callback\n"); - c = render_color{ 1.0, 1.0, 1.0, 1.0 }; - } - })); - } - else - { - osd_printf_error("[LUA ERROR] must call set_bounds_callback with function or nil\n"); - } - }; + make_simple_callback_setter<render_color>( + &layout_view::item::set_color_callback, + [] () { return render_color{ 1.0f, 1.0f, 1.0f, 1.0f }; }, + "set_color_callback", + "color"); layout_view_item_type["id"] = sol::property( [] (layout_view::item &i, sol::this_state s) -> sol::object { |