Mir

Merge lp:~brandontschaefer/mir/capnproto-assert-structures-align into lp:mir

Proposed by Brandon Schaefer on 2016-04-01
Status: Work in progress
Proposed branch: lp:~brandontschaefer/mir/capnproto-assert-structures-align
Merge into: lp:mir
Prerequisite: lp:~brandontschaefer/mir/mir-event-capnproto
Diff against target: 98 lines (+83/-0)
2 files modified
src/common/events/CMakeLists.txt (+1/-0)
src/common/events/capnp_enums_aligned_asserts.cpp (+82/-0)
To merge this branch: bzr merge lp:~brandontschaefer/mir/capnproto-assert-structures-align
Reviewer Review Type Date Requested Status
Chris Halse Rogers Approve on 2016-05-04
Mir CI Bot continuous-integration Needs Fixing on 2016-04-06
Cemil Azizoglu (community) 2016-04-01 Approve on 2016-04-04
Review via email: mp+290764@code.launchpad.net

This proposal supersedes a proposal from 2016-04-01.

Commit message

Assert our capnproto generated structures align with the public C API enums so we can static cast between them.

Capnproto only generates enum classes, so we've to static cast if we want to name our types in capnproto.

Description of the change

Assert our capnproto generated structures align with the public C API enums so we can static cast between them.

Capnproto only generates enum classes, so we've to static cast if we want to name our types in capnproto.

To post a comment you must log in.
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3415
https://mir-jenkins.ubuntu.com/job/mir-ci/737/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/706/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/743
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/734
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/734
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/715/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/715
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/715/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/715/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/715/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/715
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/715/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/737/rebuild

review: Needs Fixing (continuous-integration)
3416. By Brandon Schaefer on 2016-04-04

* Merge parent

Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3416
https://mir-jenkins.ubuntu.com/job/mir-ci/746/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/720/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/757
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/748
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/748
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/729/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/729
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/729/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/729/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/729/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/729
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/729/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/746/rebuild

review: Needs Fixing (continuous-integration)
Cemil Azizoglu (cemil-azizoglu) wrote :

ok

review: Approve
3417. By Brandon Schaefer on 2016-04-06

* Merge parent

3418. By Brandon Schaefer on 2016-04-06

* Switch from MotionEventSet to MotionSetEvent

Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3418
https://mir-jenkins.ubuntu.com/job/mir-ci/775/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/765/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/802
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/793
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/793
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/774/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/774
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/774/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/774/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/774/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/774
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/774/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/775/rebuild

review: Needs Fixing (continuous-integration)
Chris Halse Rogers (raof) wrote :

Sure

review: Approve

Unmerged revisions

3418. By Brandon Schaefer on 2016-04-06

* Switch from MotionEventSet to MotionSetEvent

3417. By Brandon Schaefer on 2016-04-06

* Merge parent

3416. By Brandon Schaefer on 2016-04-04

* Merge parent

3415. By Brandon Schaefer on 2016-04-01

* Assert out capnproto enums are aligned with the C API

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/common/events/CMakeLists.txt'
2--- src/common/events/CMakeLists.txt 2016-04-06 19:10:13 +0000
3+++ src/common/events/CMakeLists.txt 2016-04-06 19:10:13 +0000
4@@ -15,6 +15,7 @@
5 # Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
6
7 set(EVENT_SOURCES
8+ capnp_enums_aligned_asserts.cpp
9 close_surface_event.cpp
10 event.cpp
11 input_configuration_event.cpp
12
13=== added file 'src/common/events/capnp_enums_aligned_asserts.cpp'
14--- src/common/events/capnp_enums_aligned_asserts.cpp 1970-01-01 00:00:00 +0000
15+++ src/common/events/capnp_enums_aligned_asserts.cpp 2016-04-06 19:10:13 +0000
16@@ -0,0 +1,82 @@
17+/*
18+ * Copyright © 2016 Canonical Ltd.
19+ *
20+ * This program is free software: you can redistribute it and/or modify it
21+ * under the terms of the GNU Lesser General Public License version 3,
22+ * as published by the Free Software Foundation.
23+ *
24+ * This program is distributed in the hope that it will be useful,
25+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
26+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+ * GNU Lesser General Public License for more details.
28+ *
29+ * You should have received a copy of the GNU Lesser General Public License
30+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
31+ *
32+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
33+ */
34+
35+#include "mir/events/event_private.h"
36+#include "mir_event.capnp.h"
37+
38+namespace mcap = mir::capnp;
39+
40+/* Static asserts that our capnp enums are equal to the c api enums.
41+ This way we can tell on compile time if any of the enums are incorrect.
42+*/
43+namespace
44+{
45+static_assert(static_cast<MirKeyboardAction>(mcap::KeyboardEvent::Action::UP) ==
46+ mir_keyboard_action_up, "");
47+static_assert(static_cast<MirKeyboardAction>(mcap::KeyboardEvent::Action::DOWN) ==
48+ mir_keyboard_action_down, "");
49+static_assert(static_cast<MirKeyboardAction>(mcap::KeyboardEvent::Action::REPEAT) ==
50+ mir_keyboard_action_repeat, "");
51+
52+static_assert(static_cast<MirTouchTooltype>(mcap::MotionSetEvent::Motion::ToolType::UNKNOWN) ==
53+ mir_touch_tooltype_unknown, "");
54+static_assert(static_cast<MirTouchTooltype>(mcap::MotionSetEvent::Motion::ToolType::FINGER) ==
55+ mir_touch_tooltype_finger, "");
56+static_assert(static_cast<MirTouchTooltype>(mcap::MotionSetEvent::Motion::ToolType::STYLUS) ==
57+ mir_touch_tooltype_stylus, "");
58+
59+static_assert(static_cast<MirInputConfigurationAction>(mcap::InputConfigurationEvent::Action::CONFIGURATION_CHANGED) ==
60+ mir_input_configuration_action_configuration_changed, "");
61+static_assert(static_cast<MirInputConfigurationAction>(mcap::InputConfigurationEvent::Action::DEVICE_RESET) ==
62+ mir_input_configuration_action_device_reset, "");
63+
64+static_assert(static_cast<MirSurfaceAttrib>(mcap::SurfaceEvent::Attrib::TYPE) ==
65+ mir_surface_attrib_type, "");
66+static_assert(static_cast<MirSurfaceAttrib>(mcap::SurfaceEvent::Attrib::STATE) ==
67+ mir_surface_attrib_state, "");
68+static_assert(static_cast<MirSurfaceAttrib>(mcap::SurfaceEvent::Attrib::SWAP_INTERVAL) ==
69+ mir_surface_attrib_swapinterval, "");
70+static_assert(static_cast<MirSurfaceAttrib>(mcap::SurfaceEvent::Attrib::FOCUS) ==
71+ mir_surface_attrib_focus, "");
72+static_assert(static_cast<MirSurfaceAttrib>(mcap::SurfaceEvent::Attrib::DPI) ==
73+ mir_surface_attrib_dpi, "");
74+static_assert(static_cast<MirSurfaceAttrib>(mcap::SurfaceEvent::Attrib::VISIBILITY) ==
75+ mir_surface_attrib_visibility, "");
76+static_assert(static_cast<MirSurfaceAttrib>(mcap::SurfaceEvent::Attrib::PREFERRED_ORIENTATION) ==
77+ mir_surface_attrib_preferred_orientation, "");
78+
79+static_assert(static_cast<MirPromptSessionState>(mcap::PromptSessionEvent::State::STOPPED) ==
80+ mir_prompt_session_state_stopped, "");
81+static_assert(static_cast<MirPromptSessionState>(mcap::PromptSessionEvent::State::STARTED) ==
82+ mir_prompt_session_state_started, "");
83+static_assert(static_cast<MirPromptSessionState>(mcap::PromptSessionEvent::State::SUSPENDED) ==
84+ mir_prompt_session_state_suspended, "");
85+
86+static_assert(static_cast<MirFormFactor>(mcap::SurfaceOutputEvent::FormFactor::UNKNOWN) ==
87+ mir_form_factor_unknown, "");
88+static_assert(static_cast<MirFormFactor>(mcap::SurfaceOutputEvent::FormFactor::PHONE) ==
89+ mir_form_factor_phone, "");
90+static_assert(static_cast<MirFormFactor>(mcap::SurfaceOutputEvent::FormFactor::TABLET) ==
91+ mir_form_factor_tablet, "");
92+static_assert(static_cast<MirFormFactor>(mcap::SurfaceOutputEvent::FormFactor::MONITOR) ==
93+ mir_form_factor_monitor, "");
94+static_assert(static_cast<MirFormFactor>(mcap::SurfaceOutputEvent::FormFactor::TV) ==
95+ mir_form_factor_tv, "");
96+static_assert(static_cast<MirFormFactor>(mcap::SurfaceOutputEvent::FormFactor::PROJECTOR) ==
97+ mir_form_factor_projector, "");
98+}

Subscribers

People subscribed via source and target branches