OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_TRAITS_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_TRAITS_H_ |
| 7 |
| 8 #include "mojo/public/cpp/bindings/struct_traits.h" |
| 9 #include "mojo/public/cpp/bindings/tests/rect_chromium.h" |
| 10 #include "mojo/public/interfaces/bindings/tests/rect.mojom-chromium.h" |
| 11 |
| 12 namespace mojo { |
| 13 |
| 14 template <> |
| 15 struct StructTraits<test::chromium::TypemappedRect, test::RectChromium> { |
| 16 static int x(const test::RectChromium& r) { return r.x(); } |
| 17 static int y(const test::RectChromium& r) { return r.y(); } |
| 18 static int width(const test::RectChromium& r) { return r.width(); } |
| 19 static int height(const test::RectChromium& r) { return r.height(); } |
| 20 |
| 21 static bool Read(test::chromium::TypemappedRect::Reader r, |
| 22 test::RectChromium* out) { |
| 23 if (r.width() < 0 || r.height() < 0) |
| 24 return false; |
| 25 out->set_x(r.x()); |
| 26 out->set_y(r.y()); |
| 27 out->set_width(r.width()); |
| 28 out->set_height(r.height()); |
| 29 return true; |
| 30 } |
| 31 }; |
| 32 |
| 33 } // namespace mojo |
| 34 |
| 35 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_CHROMIUM_TRAITS_H_ |
OLD | NEW |