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

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

Issue 1967703004: Mojo C++ bindings: add StringTraits and ArrayTraits for STL types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@27_update_users
Patch Set: Created 4 years, 7 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 #include "mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h" 5 #include "mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h"
6 6
7 namespace mojo { 7 namespace mojo {
8 8
9 // static 9 // static
10 bool StructTraits<test::NestedStructWithTraits,
11 test::NestedStructWithTraitsImpl>::
12 Read(test::NestedStructWithTraitsDataView data,
13 test::NestedStructWithTraitsImpl* output) {
14 output->value = data.value();
15 return true;
16 }
17
18 // static
10 bool StructTraits<test::StructWithTraits, test::StructWithTraitsImpl>::Read( 19 bool StructTraits<test::StructWithTraits, test::StructWithTraitsImpl>::Read(
11 test::StructWithTraitsDataView data, 20 test::StructWithTraitsDataView data,
12 test::StructWithTraitsImpl* out) { 21 test::StructWithTraitsImpl* out) {
13 out->set_bool(data.f_bool()); 22 out->set_bool(data.f_bool());
14 out->set_uint32(data.f_uint32()); 23 out->set_uint32(data.f_uint32());
15 out->set_uint64(data.f_uint64()); 24 out->set_uint64(data.f_uint64());
16 base::StringPiece f_string, f_string2; 25
17 if (!data.ReadFString(&f_string) || !data.ReadFString2(&f_string2)) 26 base::StringPiece f_string;
27 std::string f_string2;
28 if (!data.ReadFString(&f_string) || !data.ReadFString2(&f_string2) ||
29 f_string != f_string2) {
18 return false; 30 return false;
19 out->set_string(f_string.as_string()); 31 }
20 return f_string == f_string2; 32 out->set_string(f_string2);
33
34 if (!data.ReadFStringArray(&out->get_mutable_string_array()))
35 return false;
36
37 if (!data.ReadFStruct(&out->get_mutable_struct()))
38 return false;
39
40 if (!data.ReadFStructArray(&out->get_mutable_struct_array()))
41 return false;
42
43 return true;
21 } 44 }
22 45
23 } // namespace mojo 46 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698