Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: mojo/public/cpp/bindings/tests/rect_blink_traits.h

Issue 1832703002: Mojo: Simplify typemap usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-bindings-variant-import
Patch Set: add missing mash dependency Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_TRAITS_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_TRAITS_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_TRAITS_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_TRAITS_H_
7 7
8 #include "mojo/public/cpp/bindings/struct_traits.h" 8 #include "mojo/public/cpp/bindings/struct_traits.h"
9 #include "mojo/public/cpp/bindings/tests/rect_blink.h" 9 #include "mojo/public/cpp/bindings/tests/rect_blink.h"
10 #include "mojo/public/interfaces/bindings/tests/rect.mojom-blink.h" 10 #include "mojo/public/interfaces/bindings/tests/rect.mojom-wtf.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 13
14 template <> 14 template <>
15 struct StructTraits<test::blink::TypemappedRect, test::RectBlink> { 15 struct StructTraits<test::wtf::TypemappedRect, test::RectBlink> {
16 static int x(const test::RectBlink& r) { return r.x(); } 16 static int x(const test::RectBlink& r) { return r.x(); }
17 static int y(const test::RectBlink& r) { return r.y(); } 17 static int y(const test::RectBlink& r) { return r.y(); }
18 static int width(const test::RectBlink& r) { return r.width(); } 18 static int width(const test::RectBlink& r) { return r.width(); }
19 static int height(const test::RectBlink& r) { return r.height(); } 19 static int height(const test::RectBlink& r) { return r.height(); }
20 20
21 static bool Read(test::blink::TypemappedRect::Reader r, 21 static bool Read(test::wtf::TypemappedRect::Reader r, test::RectBlink* out) {
22 test::RectBlink* out) {
23 if (r.x() < 0 || r.y() < 0 || r.width() < 0 || r.height() < 0) { 22 if (r.x() < 0 || r.y() < 0 || r.width() < 0 || r.height() < 0) {
24 return false; 23 return false;
25 } 24 }
26 out->setX(r.x()); 25 out->setX(r.x());
27 out->setY(r.y()); 26 out->setY(r.y());
28 out->setWidth(r.width()); 27 out->setWidth(r.width());
29 out->setHeight(r.height()); 28 out->setHeight(r.height());
30 return true; 29 return true;
31 } 30 }
32 }; 31 };
33 32
34 } // namespace mojo 33 } // namespace mojo
35 34
36 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_TRAITS_H_ 35 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_TRAITS_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/rect_blink.typemap ('k') | mojo/public/cpp/bindings/tests/rect_chromium.typemap » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698