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

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

Issue 2179273002: Mojo C++ bindings: support mapping T and T? differently. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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_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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698