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> |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 test::MoveOnlyStructWithTraitsImpl* out); | 117 test::MoveOnlyStructWithTraitsImpl* out); |
118 | 118 |
119 // Fields in test::MoveOnlyStructWithTraits. | 119 // Fields in test::MoveOnlyStructWithTraits. |
120 // See src/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom. | 120 // See src/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom. |
121 static ScopedHandle f_handle(test::MoveOnlyStructWithTraitsImpl& value) { | 121 static ScopedHandle f_handle(test::MoveOnlyStructWithTraitsImpl& value) { |
122 return std::move(value.get_mutable_handle()); | 122 return std::move(value.get_mutable_handle()); |
123 } | 123 } |
124 }; | 124 }; |
125 | 125 |
126 template <> | 126 template <> |
127 struct StructTraits<test::StructWithTraitsForUniquePtrTest, | 127 struct StructTraits<test::StructWithTraitsForUniquePtr, std::unique_ptr<int>> { |
128 std::unique_ptr<int>> { | 128 static bool IsNull(const std::unique_ptr<int>& data) { return !data; } |
| 129 static void SetToNull(std::unique_ptr<int>* data) { data->reset(); } |
| 130 |
129 static int f_int32(const std::unique_ptr<int>& data) { return *data; } | 131 static int f_int32(const std::unique_ptr<int>& data) { return *data; } |
130 | 132 |
131 static bool Read(test::StructWithTraitsForUniquePtrTest::DataView data, | 133 static bool Read(test::StructWithTraitsForUniquePtr::DataView data, |
132 std::unique_ptr<int>* out) { | 134 std::unique_ptr<int>* out) { |
133 out->reset(new int(data.f_int32())); | 135 out->reset(new int(data.f_int32())); |
134 return true; | 136 return true; |
135 } | 137 } |
136 }; | 138 }; |
137 | 139 |
138 } // namespace mojo | 140 } // namespace mojo |
139 | 141 |
140 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ | 142 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ |
OLD | NEW |