Mir

Merge lp:~alan-griffiths/mir/cleaner-dimensions into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 2519
Proposed branch: lp:~alan-griffiths/mir/cleaner-dimensions
Merge into: lp:mir
Diff against target: 88 lines (+15/-17)
1 file modified
include/common/mir/geometry/dimensions.h (+15/-17)
To merge this branch: bzr merge lp:~alan-griffiths/mir/cleaner-dimensions
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Approve
Andreas Pokorny (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+257459@code.launchpad.net

Commit message

geometry: use a simpler technique for distinguishing dimensions (that gives better error messages)

Description of the change

geometry: use a simpler technique for distinguishing dimensions (that gives better error messages)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

oh I did not realize that you can fwd declare structs and use them in typedef right away

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/common/mir/geometry/dimensions.h'
2--- include/common/mir/geometry/dimensions.h 2015-04-16 18:50:58 +0000
3+++ include/common/mir/geometry/dimensions.h 2015-04-25 12:05:21 +0000
4@@ -32,9 +32,7 @@
5
6 namespace detail
7 {
8-enum DimensionTag { width, height, x, y, dx, dy, stride };
9-
10-template<DimensionTag Tag>
11+template<typename Tag>
12 class IntWrapper
13 {
14 public:
15@@ -61,59 +59,59 @@
16 ValueType value;
17 };
18
19-template<DimensionTag Tag>
20+template<typename Tag>
21 std::ostream& operator<<(std::ostream& out, IntWrapper<Tag> const& value)
22 {
23 out << value.as_int();
24 return out;
25 }
26
27-template<DimensionTag Tag>
28+template<typename Tag>
29 inline bool operator == (IntWrapper<Tag> const& lhs, IntWrapper<Tag> const& rhs)
30 {
31 return lhs.as_int() == rhs.as_int();
32 }
33
34-template<DimensionTag Tag>
35+template<typename Tag>
36 inline bool operator != (IntWrapper<Tag> const& lhs, IntWrapper<Tag> const& rhs)
37 {
38 return lhs.as_int() != rhs.as_int();
39 }
40
41-template<DimensionTag Tag>
42+template<typename Tag>
43 inline bool operator <= (IntWrapper<Tag> const& lhs, IntWrapper<Tag> const& rhs)
44 {
45 return lhs.as_int() <= rhs.as_int();
46 }
47
48-template<DimensionTag Tag>
49+template<typename Tag>
50 inline bool operator >= (IntWrapper<Tag> const& lhs, IntWrapper<Tag> const& rhs)
51 {
52 return lhs.as_int() >= rhs.as_int();
53 }
54
55-template<DimensionTag Tag>
56+template<typename Tag>
57 inline bool operator < (IntWrapper<Tag> const& lhs, IntWrapper<Tag> const& rhs)
58 {
59 return lhs.as_int() < rhs.as_int();
60 }
61
62-template<DimensionTag Tag>
63+template<typename Tag>
64 inline bool operator > (IntWrapper<Tag> const& lhs, IntWrapper<Tag> const& rhs)
65 {
66 return lhs.as_int() > rhs.as_int();
67 }
68 } // namespace detail
69
70-typedef detail::IntWrapper<detail::width> Width;
71-typedef detail::IntWrapper<detail::height> Height;
72+typedef detail::IntWrapper<struct WidthTag> Width;
73+typedef detail::IntWrapper<struct HeightTag> Height;
74 // Just to be clear, mir::geometry::Stride is the stride of the buffer in bytes
75-typedef detail::IntWrapper<detail::stride> Stride;
76+typedef detail::IntWrapper<struct StrideTag> Stride;
77
78-typedef detail::IntWrapper<detail::x> X;
79-typedef detail::IntWrapper<detail::y> Y;
80-typedef detail::IntWrapper<detail::dx> DeltaX;
81-typedef detail::IntWrapper<detail::dy> DeltaY;
82+typedef detail::IntWrapper<struct XTag> X;
83+typedef detail::IntWrapper<struct YTag> Y;
84+typedef detail::IntWrapper<struct DeltaXTag> DeltaX;
85+typedef detail::IntWrapper<struct DeltaYTag> DeltaY;
86
87 // Adding deltas is fine
88 inline DeltaX operator+(DeltaX lhs, DeltaX rhs) { return DeltaX(lhs.as_int() + rhs.as_int()); }

Subscribers

People subscribed via source and target branches