OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project 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 V8_HANDLES_H_ | 5 #ifndef V8_HANDLES_H_ |
6 #define V8_HANDLES_H_ | 6 #define V8_HANDLES_H_ |
7 | 7 |
8 #include "include/v8.h" | 8 #include "include/v8.h" |
9 #include "src/base/functional.h" | 9 #include "src/base/functional.h" |
10 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 V8_INLINE Handle<T> handle(T* object) { | 164 V8_INLINE Handle<T> handle(T* object) { |
165 return Handle<T>(object); | 165 return Handle<T>(object); |
166 } | 166 } |
167 | 167 |
168 | 168 |
169 // ---------------------------------------------------------------------------- | 169 // ---------------------------------------------------------------------------- |
170 // A Handle can be converted into a MaybeHandle. Converting a MaybeHandle | 170 // A Handle can be converted into a MaybeHandle. Converting a MaybeHandle |
171 // into a Handle requires checking that it does not point to NULL. This | 171 // into a Handle requires checking that it does not point to NULL. This |
172 // ensures NULL checks before use. | 172 // ensures NULL checks before use. |
173 // | 173 // |
174 // Do not use MaybeHandle as argument type. | |
175 // | |
176 // Also note that Handles do not provide default equality comparison or hashing | 174 // Also note that Handles do not provide default equality comparison or hashing |
177 // operators on purpose. Such operators would be misleading, because intended | 175 // operators on purpose. Such operators would be misleading, because intended |
178 // semantics is ambiguous between Handle location and object identity. | 176 // semantics is ambiguous between Handle location and object identity. |
179 template <typename T> | 177 template <typename T> |
180 class MaybeHandle final { | 178 class MaybeHandle final { |
181 public: | 179 public: |
182 V8_INLINE MaybeHandle() {} | 180 V8_INLINE MaybeHandle() {} |
183 V8_INLINE ~MaybeHandle() {} | 181 V8_INLINE ~MaybeHandle() {} |
184 | 182 |
185 // Constructor for handling automatic up casting from Handle. | 183 // Constructor for handling automatic up casting from Handle. |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 next = limit = NULL; | 399 next = limit = NULL; |
402 sealed_level = level = 0; | 400 sealed_level = level = 0; |
403 canonical_scope = NULL; | 401 canonical_scope = NULL; |
404 } | 402 } |
405 }; | 403 }; |
406 | 404 |
407 } // namespace internal | 405 } // namespace internal |
408 } // namespace v8 | 406 } // namespace v8 |
409 | 407 |
410 #endif // V8_HANDLES_H_ | 408 #endif // V8_HANDLES_H_ |
OLD | NEW |