| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_STRUCT_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ |
| 7 | 7 |
| 8 #include <new> | 8 #include <new> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/type_converter.h" | 10 #include "mojo/public/cpp/bindings/type_converter.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 bool is_null() const { return is_null_; } | 143 bool is_null() const { return is_null_; } |
| 144 | 144 |
| 145 Struct& operator*() const { | 145 Struct& operator*() const { |
| 146 MOJO_DCHECK(!is_null_); | 146 MOJO_DCHECK(!is_null_); |
| 147 return value_; | 147 return value_; |
| 148 } | 148 } |
| 149 Struct* operator->() const { | 149 Struct* operator->() const { |
| 150 MOJO_DCHECK(!is_null_); | 150 MOJO_DCHECK(!is_null_); |
| 151 return &value_; | 151 return &value_; |
| 152 } | 152 } |
| 153 Struct* get() const { return &value_; } | 153 Struct* get() const { return is_null() ? nullptr : &value_; } |
| 154 | 154 |
| 155 void Swap(InlinedStructPtr* other) { | 155 void Swap(InlinedStructPtr* other) { |
| 156 std::swap(value_, other->value_); | 156 std::swap(value_, other->value_); |
| 157 std::swap(is_null_, other->is_null_); | 157 std::swap(is_null_, other->is_null_); |
| 158 } | 158 } |
| 159 | 159 |
| 160 InlinedStructPtr Clone() const { | 160 InlinedStructPtr Clone() const { |
| 161 return is_null() ? InlinedStructPtr() : value_.Clone(); | 161 return is_null() ? InlinedStructPtr() : value_.Clone(); |
| 162 } | 162 } |
| 163 bool Equals(const InlinedStructPtr& other) const { | 163 bool Equals(const InlinedStructPtr& other) const { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 181 Swap(other); | 181 Swap(other); |
| 182 } | 182 } |
| 183 | 183 |
| 184 mutable Struct value_; | 184 mutable Struct value_; |
| 185 bool is_null_; | 185 bool is_null_; |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 } // namespace mojo | 188 } // namespace mojo |
| 189 | 189 |
| 190 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ | 190 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ |
| OLD | NEW |