OLD | NEW |
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_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
13 #include "mojo/public/cpp/bindings/struct_traits.h" | 13 #include "mojo/public/cpp/bindings/struct_traits.h" |
14 #include "mojo/public/cpp/bindings/tests/struct_with_traits_impl.h" | 14 #include "mojo/public/cpp/bindings/tests/struct_with_traits_impl.h" |
| 15 #include "mojo/public/interfaces/bindings/tests/struct_with_traits.mojom.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 namespace test { | |
18 class StructWithTraits; | |
19 class StructWithTraits_Reader; | |
20 } | |
21 | 18 |
22 template <> | 19 template <> |
23 struct StructTraits<test::StructWithTraits, test::StructWithTraitsImpl> { | 20 struct StructTraits<test::StructWithTraits, test::StructWithTraitsImpl> { |
24 // Deserialization to test::StructTraitsImpl. | 21 // Deserialization to test::StructTraitsImpl. |
25 static bool Read(test::StructWithTraits_Reader r, | 22 static bool Read(test::StructWithTraitsDataView data, |
26 test::StructWithTraitsImpl* out); | 23 test::StructWithTraitsImpl* out); |
27 | 24 |
28 // Fields in test::StructWithTraits. | 25 // Fields in test::StructWithTraits. |
29 // See src/mojo/public/interfaces/bindings/tests/test_native_types.mojom. | 26 // See src/mojo/public/interfaces/bindings/tests/test_native_types.mojom. |
30 static bool f_bool(const test::StructWithTraitsImpl& value) { | 27 static bool f_bool(const test::StructWithTraitsImpl& value) { |
31 return value.get_bool(); | 28 return value.get_bool(); |
32 } | 29 } |
33 | 30 |
34 static uint32_t f_uint32(const test::StructWithTraitsImpl& value) { | 31 static uint32_t f_uint32(const test::StructWithTraitsImpl& value) { |
35 return value.get_uint32(); | 32 return value.get_uint32(); |
36 } | 33 } |
37 | 34 |
38 static uint64_t f_uint64(const test::StructWithTraitsImpl& value) { | 35 static uint64_t f_uint64(const test::StructWithTraitsImpl& value) { |
39 return value.get_uint64(); | 36 return value.get_uint64(); |
40 } | 37 } |
41 | 38 |
42 static base::StringPiece f_string(const test::StructWithTraitsImpl& value) { | 39 static base::StringPiece f_string(const test::StructWithTraitsImpl& value) { |
43 return value.get_string(); | 40 return value.get_string(); |
44 } | 41 } |
45 | 42 |
46 static base::StringPiece f_string2(const test::StructWithTraitsImpl& value) { | 43 static base::StringPiece f_string2(const test::StructWithTraitsImpl& value) { |
47 return value.get_string(); | 44 return value.get_string(); |
48 } | 45 } |
49 }; | 46 }; |
50 | 47 |
51 } // namespace mojo | 48 } // namespace mojo |
52 | 49 |
53 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ | 50 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ |
OLD | NEW |