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

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

Issue 2007813004: Mojo C++ bindings: support attaching context object for StructTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 93a2f62736cab3b239a9da9974306caea4806c45..45c57ec3971b39a590c007fd90f81f050b1b4fc4 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
@@ -5,6 +5,41 @@
#include "mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h"
namespace mojo {
+namespace {
+
+struct Context {
+ int32_t value;
+};
+
+} // namespace
+
+// static
+void* StructTraits<test::NestedStructWithTraits,
+ test::NestedStructWithTraitsImpl>::
+ SetUpContext(const test::NestedStructWithTraitsImpl& input) {
+ Context* context = new Context;
+ context->value = input.value;
+ return context;
+}
+
+// static
+void StructTraits<test::NestedStructWithTraits,
+ test::NestedStructWithTraitsImpl>::
+ TearDownContext(const test::NestedStructWithTraitsImpl& input,
+ void* context) {
+ Context* context_obj = static_cast<Context*>(context);
+ CHECK_EQ(context_obj->value, input.value);
+ delete context_obj;
+}
+
+// static
+int32_t StructTraits<test::NestedStructWithTraits,
+ test::NestedStructWithTraitsImpl>::
+ value(const test::NestedStructWithTraitsImpl& input, void* context) {
+ Context* context_obj = static_cast<Context*>(context);
+ CHECK_EQ(context_obj->value, input.value);
+ return input.value;
+}
// static
bool StructTraits<test::NestedStructWithTraits,

Powered by Google App Engine
This is Rietveld 408576698