| OLD | NEW |
| 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 namespace { |
| 9 |
| 10 struct Context { |
| 11 int32_t value; |
| 12 }; |
| 13 |
| 14 } // namespace |
| 15 |
| 16 // static |
| 17 void* StructTraits<test::NestedStructWithTraits, |
| 18 test::NestedStructWithTraitsImpl>:: |
| 19 SetUpContext(const test::NestedStructWithTraitsImpl& input) { |
| 20 Context* context = new Context; |
| 21 context->value = input.value; |
| 22 return context; |
| 23 } |
| 24 |
| 25 // static |
| 26 void StructTraits<test::NestedStructWithTraits, |
| 27 test::NestedStructWithTraitsImpl>:: |
| 28 TearDownContext(const test::NestedStructWithTraitsImpl& input, |
| 29 void* context) { |
| 30 Context* context_obj = static_cast<Context*>(context); |
| 31 CHECK_EQ(context_obj->value, input.value); |
| 32 delete context_obj; |
| 33 } |
| 34 |
| 35 // static |
| 36 int32_t StructTraits<test::NestedStructWithTraits, |
| 37 test::NestedStructWithTraitsImpl>:: |
| 38 value(const test::NestedStructWithTraitsImpl& input, void* context) { |
| 39 Context* context_obj = static_cast<Context*>(context); |
| 40 CHECK_EQ(context_obj->value, input.value); |
| 41 return input.value; |
| 42 } |
| 8 | 43 |
| 9 // static | 44 // static |
| 10 bool StructTraits<test::NestedStructWithTraits, | 45 bool StructTraits<test::NestedStructWithTraits, |
| 11 test::NestedStructWithTraitsImpl>:: | 46 test::NestedStructWithTraitsImpl>:: |
| 12 Read(test::NestedStructWithTraitsDataView data, | 47 Read(test::NestedStructWithTraitsDataView data, |
| 13 test::NestedStructWithTraitsImpl* output) { | 48 test::NestedStructWithTraitsImpl* output) { |
| 14 output->value = data.value(); | 49 output->value = data.value(); |
| 15 return true; | 50 return true; |
| 16 } | 51 } |
| 17 | 52 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 37 if (!data.ReadFStruct(&out->get_mutable_struct())) | 72 if (!data.ReadFStruct(&out->get_mutable_struct())) |
| 38 return false; | 73 return false; |
| 39 | 74 |
| 40 if (!data.ReadFStructArray(&out->get_mutable_struct_array())) | 75 if (!data.ReadFStructArray(&out->get_mutable_struct_array())) |
| 41 return false; | 76 return false; |
| 42 | 77 |
| 43 return true; | 78 return true; |
| 44 } | 79 } |
| 45 | 80 |
| 46 } // namespace mojo | 81 } // namespace mojo |
| OLD | NEW |