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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc
diff --git a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc
index 700368e83eaee928a7e4cba14e26fb03ecb734b0..93a2f62736cab3b239a9da9974306caea4806c45 100644
--- a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc
+++ b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc
@@ -7,17 +7,40 @@
namespace mojo {
// static
+bool StructTraits<test::NestedStructWithTraits,
+ test::NestedStructWithTraitsImpl>::
+ Read(test::NestedStructWithTraitsDataView data,
+ test::NestedStructWithTraitsImpl* output) {
+ output->value = data.value();
+ return true;
+}
+
+// static
bool StructTraits<test::StructWithTraits, test::StructWithTraitsImpl>::Read(
test::StructWithTraitsDataView data,
test::StructWithTraitsImpl* out) {
out->set_bool(data.f_bool());
out->set_uint32(data.f_uint32());
out->set_uint64(data.f_uint64());
- base::StringPiece f_string, f_string2;
- if (!data.ReadFString(&f_string) || !data.ReadFString2(&f_string2))
+
+ base::StringPiece f_string;
+ std::string f_string2;
+ if (!data.ReadFString(&f_string) || !data.ReadFString2(&f_string2) ||
+ f_string != f_string2) {
+ return false;
+ }
+ out->set_string(f_string2);
+
+ if (!data.ReadFStringArray(&out->get_mutable_string_array()))
return false;
- out->set_string(f_string.as_string());
- return f_string == f_string2;
+
+ if (!data.ReadFStruct(&out->get_mutable_struct()))
+ return false;
+
+ if (!data.ReadFStructArray(&out->get_mutable_struct_array()))
+ return false;
+
+ return true;
}
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698