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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // Ex. MaybeHandle<JSArray> can be passed when Handle<Object> is expected. | 199 // Ex. MaybeHandle<JSArray> can be passed when Handle<Object> is expected. |
200 template <typename S> | 200 template <typename S> |
201 V8_INLINE MaybeHandle(MaybeHandle<S> maybe_handle) | 201 V8_INLINE MaybeHandle(MaybeHandle<S> maybe_handle) |
202 : location_(reinterpret_cast<T**>(maybe_handle.location_)) { | 202 : location_(reinterpret_cast<T**>(maybe_handle.location_)) { |
203 T* a = nullptr; | 203 T* a = nullptr; |
204 S* b = nullptr; | 204 S* b = nullptr; |
205 a = b; // Fake assignment to enforce type checks. | 205 a = b; // Fake assignment to enforce type checks. |
206 USE(a); | 206 USE(a); |
207 } | 207 } |
208 | 208 |
| 209 template <typename S> |
| 210 V8_INLINE MaybeHandle(S* object, Isolate* isolate) |
| 211 : MaybeHandle(handle(object, isolate)) {} |
| 212 |
209 V8_INLINE void Assert() const { DCHECK_NOT_NULL(location_); } | 213 V8_INLINE void Assert() const { DCHECK_NOT_NULL(location_); } |
210 V8_INLINE void Check() const { CHECK_NOT_NULL(location_); } | 214 V8_INLINE void Check() const { CHECK_NOT_NULL(location_); } |
211 | 215 |
212 V8_INLINE Handle<T> ToHandleChecked() const { | 216 V8_INLINE Handle<T> ToHandleChecked() const { |
213 Check(); | 217 Check(); |
214 return Handle<T>(location_); | 218 return Handle<T>(location_); |
215 } | 219 } |
216 | 220 |
217 // Convert to a Handle with a type that can be upcasted to. | 221 // Convert to a Handle with a type that can be upcasted to. |
218 template <typename S> | 222 template <typename S> |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 next = limit = NULL; | 411 next = limit = NULL; |
408 sealed_level = level = 0; | 412 sealed_level = level = 0; |
409 canonical_scope = NULL; | 413 canonical_scope = NULL; |
410 } | 414 } |
411 }; | 415 }; |
412 | 416 |
413 } // namespace internal | 417 } // namespace internal |
414 } // namespace v8 | 418 } // namespace v8 |
415 | 419 |
416 #endif // V8_HANDLES_H_ | 420 #endif // V8_HANDLES_H_ |
OLD | NEW |