[wesnoth-commits] [wesnoth/wesnoth] 0b4536: GUI2: finished refactoring out usage of boost::mpl

GitHub noreply at github.com
Tue Apr 17 10:52:54 UTC 2018


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 0b45363c9589c14984eed393305b3a5ac59b71ec
      https://github.com/wesnoth/wesnoth/commit/0b45363c9589c14984eed393305b3a5ac59b71ec
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2018-04-17 (Tue, 17 Apr 2018)

  Changed paths:
    M src/gui/core/event/dispatcher.cpp
    M src/gui/core/event/dispatcher.hpp
    M src/gui/core/event/dispatcher_private.hpp
    M src/gui/core/event/handler.cpp
    M src/gui/core/event/handler.hpp

  Log Message:
  -----------
  GUI2: finished refactoring out usage of boost::mpl

dispatcher::has_event called the private find() function, which after a whole bunch of
jumping around essentially checked that the signal queue for the given event was not
empty. This was a run-time op, yet the code was set up using SFINAE in order to for
has_handler::oper() to call the event_signal function corresponding to the event's queue
(ie, the mouse queue for a mouse-type event).

Since this code was written before the era of constexpr, event type validation was done
using boost::mpl, which, in this case, resulted in a monstrous amalgamation of build-time
template specialization for a run-time check. I'm not certain, but I believe it might
have resulted in an specialization of find() (or at least, implementation::find()) for
every single event type (each member of the ui_event enum).

This converts the code to a purely run-time check and throws out all the template stuff.
It also removes the relevant event_signal overload dealing with events in a set. The
version dealing with function types is preserved as it's used in the fire_event()
implementation and is a fairly standard usecase of SFINAE.

The has_handler class has also been converted to a static function since it's no longer
needed for template specializations in find().

And finally, is_raw_event had to be renamed to is_raw_event_event to allow simple name
completion in IMPLEMENT_RUNTIME_EVENT_SIGNAL_CHECK. I could have also renamed the raw event
queue to signal_raw_queue but I figured keeping the name as signal_raw_event_queue made
its purpose clearer.




More information about the Commits mailing list