| 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 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 14 #include "mojo/public/cpp/bindings/struct_traits.h" | 14 #include "mojo/public/cpp/bindings/struct_traits.h" |
| 15 #include "mojo/public/cpp/bindings/tests/struct_with_traits_impl.h" | 15 #include "mojo/public/cpp/bindings/tests/struct_with_traits_impl.h" |
| 16 #include "mojo/public/interfaces/bindings/tests/struct_with_traits.mojom.h" | 16 #include "mojo/public/interfaces/bindings/tests/struct_with_traits.mojom.h" |
| 17 | 17 |
| 18 namespace mojo { | 18 namespace mojo { |
| 19 | 19 |
| 20 template <> | 20 template <> |
| 21 struct StructTraits<test::NestedStructWithTraits, | 21 struct StructTraits<test::NestedStructWithTraits, |
| 22 test::NestedStructWithTraitsImpl> { | 22 test::NestedStructWithTraitsImpl> { |
| 23 static void* SetUpContext(const test::NestedStructWithTraitsImpl& input); |
| 24 static void TearDownContext(const test::NestedStructWithTraitsImpl& input, |
| 25 void* context); |
| 26 |
| 27 static int32_t value(const test::NestedStructWithTraitsImpl& input, |
| 28 void* context); |
| 29 |
| 23 static bool Read(test::NestedStructWithTraitsDataView data, | 30 static bool Read(test::NestedStructWithTraitsDataView data, |
| 24 test::NestedStructWithTraitsImpl* output); | 31 test::NestedStructWithTraitsImpl* output); |
| 25 static int32_t value(const test::NestedStructWithTraitsImpl& input) { | |
| 26 return input.value; | |
| 27 } | |
| 28 }; | 32 }; |
| 29 | 33 |
| 30 template <> | 34 template <> |
| 31 struct StructTraits<test::StructWithTraits, test::StructWithTraitsImpl> { | 35 struct StructTraits<test::StructWithTraits, test::StructWithTraitsImpl> { |
| 32 // Deserialization to test::StructTraitsImpl. | 36 // Deserialization to test::StructTraitsImpl. |
| 33 static bool Read(test::StructWithTraitsDataView data, | 37 static bool Read(test::StructWithTraitsDataView data, |
| 34 test::StructWithTraitsImpl* out); | 38 test::StructWithTraitsImpl* out); |
| 35 | 39 |
| 36 // Fields in test::StructWithTraits. | 40 // Fields in test::StructWithTraits. |
| 37 // See src/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom. | 41 // See src/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 67 | 71 |
| 68 static const std::vector<test::NestedStructWithTraitsImpl>& f_struct_array( | 72 static const std::vector<test::NestedStructWithTraitsImpl>& f_struct_array( |
| 69 const test::StructWithTraitsImpl& value) { | 73 const test::StructWithTraitsImpl& value) { |
| 70 return value.get_struct_array(); | 74 return value.get_struct_array(); |
| 71 } | 75 } |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 } // namespace mojo | 78 } // namespace mojo |
| 75 | 79 |
| 76 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ | 80 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ |
| OLD | NEW |