| 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 ScopedHandle& get_mutable_handle() { return handle_; } | 108 ScopedHandle& get_mutable_handle() { return handle_; } |
| 109 | 109 |
| 110 MoveOnlyStructWithTraitsImpl& operator=(MoveOnlyStructWithTraitsImpl&& other); | 110 MoveOnlyStructWithTraitsImpl& operator=(MoveOnlyStructWithTraitsImpl&& other); |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 ScopedHandle handle_; | 113 ScopedHandle handle_; |
| 114 DISALLOW_COPY_AND_ASSIGN(MoveOnlyStructWithTraitsImpl); | 114 DISALLOW_COPY_AND_ASSIGN(MoveOnlyStructWithTraitsImpl); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 class UnionWithTraitsBase { |
| 118 public: |
| 119 enum class Type { INT32, STRUCT }; |
| 120 |
| 121 virtual ~UnionWithTraitsBase() {} |
| 122 |
| 123 Type type() const { return type_; } |
| 124 |
| 125 protected: |
| 126 Type type_ = Type::INT32; |
| 127 }; |
| 128 |
| 129 class UnionWithTraitsInt32 : public UnionWithTraitsBase { |
| 130 public: |
| 131 UnionWithTraitsInt32() {} |
| 132 explicit UnionWithTraitsInt32(int32_t value) : value_(value) {} |
| 133 |
| 134 ~UnionWithTraitsInt32() override; |
| 135 |
| 136 int32_t value() const { return value_; } |
| 137 void set_value(int32_t value) { value_ = value; } |
| 138 |
| 139 private: |
| 140 int32_t value_ = 0; |
| 141 }; |
| 142 |
| 143 class UnionWithTraitsStruct : public UnionWithTraitsBase { |
| 144 public: |
| 145 UnionWithTraitsStruct() { type_ = Type::STRUCT; } |
| 146 explicit UnionWithTraitsStruct(int32_t value) : struct_(value) { |
| 147 type_ = Type::STRUCT; |
| 148 } |
| 149 ~UnionWithTraitsStruct() override; |
| 150 |
| 151 NestedStructWithTraitsImpl& get_mutable_struct() { return struct_; } |
| 152 const NestedStructWithTraitsImpl& get_struct() const { return struct_; } |
| 153 |
| 154 private: |
| 155 NestedStructWithTraitsImpl struct_; |
| 156 }; |
| 157 |
| 117 } // namespace test | 158 } // namespace test |
| 118 } // namespace mojo | 159 } // namespace mojo |
| 119 | 160 |
| 120 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ | 161 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_H_ |
| OLD | NEW |