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

Unified Diff: mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h

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.h
diff --git a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h
index 0cfc5e7a520fe76c7127ee00aa9b26f0f1c8bc77..6b3acf69b4c385648037a95d7ffee51c13bae944 100644
--- a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h
+++ b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <string>
+#include <vector>
#include "base/strings/string_piece.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
@@ -17,13 +18,23 @@
namespace mojo {
template <>
+struct StructTraits<test::NestedStructWithTraits,
+ test::NestedStructWithTraitsImpl> {
+ static bool Read(test::NestedStructWithTraitsDataView data,
+ test::NestedStructWithTraitsImpl* output);
+ static int32_t value(const test::NestedStructWithTraitsImpl& input) {
+ return input.value;
+ }
+};
+
+template <>
struct StructTraits<test::StructWithTraits, test::StructWithTraitsImpl> {
// Deserialization to test::StructTraitsImpl.
static bool Read(test::StructWithTraitsDataView data,
test::StructWithTraitsImpl* out);
// Fields in test::StructWithTraits.
- // See src/mojo/public/interfaces/bindings/tests/test_native_types.mojom.
+ // See src/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom.
static bool f_bool(const test::StructWithTraitsImpl& value) {
return value.get_bool();
}
@@ -37,12 +48,27 @@ struct StructTraits<test::StructWithTraits, test::StructWithTraitsImpl> {
}
static base::StringPiece f_string(const test::StructWithTraitsImpl& value) {
- return value.get_string();
+ return value.get_string_as_string_piece();
}
- static base::StringPiece f_string2(const test::StructWithTraitsImpl& value) {
+ static const std::string& f_string2(const test::StructWithTraitsImpl& value) {
return value.get_string();
}
+
+ static const std::vector<std::string>& f_string_array(
+ const test::StructWithTraitsImpl& value) {
+ return value.get_string_array();
+ }
+
+ static const test::NestedStructWithTraitsImpl& f_struct(
+ const test::StructWithTraitsImpl& value) {
+ return value.get_struct();
+ }
+
+ static const std::vector<test::NestedStructWithTraitsImpl>& f_struct_array(
+ const test::StructWithTraitsImpl& value) {
+ return value.get_struct_array();
+ }
};
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698