From 416f0c25e62041a1e942d28440b3a649cf9ef776 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 31 Oct 2020 13:00:50 +0100 Subject: Remove use of cassert and type_traits Losing assertions is unfortunate, but these slow down compile times, and in this case the scope of error is small enough that the risk is minimal. --- bindings/cxx/include/pugl/pugl.hpp | 66 ++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/bindings/cxx/include/pugl/pugl.hpp b/bindings/cxx/include/pugl/pugl.hpp index ec9ca20..bcf4e6e 100644 --- a/bindings/cxx/include/pugl/pugl.hpp +++ b/bindings/cxx/include/pugl/pugl.hpp @@ -24,10 +24,8 @@ #include "pugl/pugl.h" -#include #include #include -#include namespace pugl { @@ -574,16 +572,6 @@ public: const PuglView* cobj() const { return Wrapper::cobj(); } private: - template - static const Typed& typedEventRef(const Base& base) - { - const auto& event = static_cast(base); - static_assert(sizeof(event) == sizeof(typename Typed::BaseEvent), ""); - static_assert(std::is_standard_layout::value, ""); - assert(event.type == Typed::type); - return event; - } - static PuglStatus dispatchEvent(PuglView* view, const PuglEvent* event) noexcept { @@ -603,73 +591,73 @@ private: return PUGL_SUCCESS; case PUGL_CREATE: return static_cast( - onCreate(typedEventRef(event->any))); + onCreate(static_cast(event->any))); case PUGL_DESTROY: return static_cast( - onDestroy(typedEventRef(event->any))); + onDestroy(static_cast(event->any))); case PUGL_CONFIGURE: - return static_cast( - onConfigure(typedEventRef(event->configure))); + return static_cast(onConfigure( + static_cast(event->configure))); case PUGL_MAP: return static_cast( - onMap(typedEventRef(event->any))); + onMap(static_cast(event->any))); case PUGL_UNMAP: return static_cast( - onUnmap(typedEventRef(event->any))); + onUnmap(static_cast(event->any))); case PUGL_UPDATE: return static_cast( - onUpdate(typedEventRef(event->any))); + onUpdate(static_cast(event->any))); case PUGL_EXPOSE: return static_cast( - onExpose(typedEventRef(event->expose))); + onExpose(static_cast(event->expose))); case PUGL_CLOSE: return static_cast( - onClose(typedEventRef(event->any))); + onClose(static_cast(event->any))); case PUGL_FOCUS_IN: return static_cast( - onFocusIn(typedEventRef(event->focus))); + onFocusIn(static_cast(event->focus))); case PUGL_FOCUS_OUT: return static_cast( - onFocusOut(typedEventRef(event->focus))); + onFocusOut(static_cast(event->focus))); case PUGL_KEY_PRESS: return static_cast( - onKeyPress(typedEventRef(event->key))); + onKeyPress(static_cast(event->key))); case PUGL_KEY_RELEASE: return static_cast( - onKeyRelease(typedEventRef(event->key))); + onKeyRelease(static_cast(event->key))); case PUGL_TEXT: return static_cast( - onText(typedEventRef(event->text))); + onText(static_cast(event->text))); case PUGL_POINTER_IN: - return static_cast( - onPointerIn(typedEventRef(event->crossing))); + return static_cast(onPointerIn( + static_cast(event->crossing))); case PUGL_POINTER_OUT: - return static_cast( - onPointerOut(typedEventRef(event->crossing))); + return static_cast(onPointerOut( + static_cast(event->crossing))); case PUGL_BUTTON_PRESS: - return static_cast( - onButtonPress(typedEventRef(event->button))); + return static_cast(onButtonPress( + static_cast(event->button))); case PUGL_BUTTON_RELEASE: return static_cast(onButtonRelease( - typedEventRef(event->button))); + static_cast(event->button))); case PUGL_MOTION: return static_cast( - onMotion(typedEventRef(event->motion))); + onMotion(static_cast(event->motion))); case PUGL_SCROLL: return static_cast( - onScroll(typedEventRef(event->scroll))); + onScroll(static_cast(event->scroll))); case PUGL_CLIENT: return static_cast( - onClient(typedEventRef(event->client))); + onClient(static_cast(event->client))); case PUGL_TIMER: return static_cast( - onTimer(typedEventRef(event->timer))); + onTimer(static_cast(event->timer))); case PUGL_LOOP_ENTER: return static_cast( - onLoopEnter(typedEventRef(event->any))); + onLoopEnter(static_cast(event->any))); case PUGL_LOOP_LEAVE: return static_cast( - onLoopLeave(typedEventRef(event->any))); + onLoopLeave(static_cast(event->any))); } return PUGL_FAILURE; -- cgit v1.2.1