Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: src/handles.h

Issue 2622503002: include fixing: api.h shouldn't include objects-inl.h (Closed)
Patch Set: static type check Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/global-handles.cc ('k') | src/i18n.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <type_traits>
9
8 #include "include/v8.h" 10 #include "include/v8.h"
9 #include "src/base/functional.h" 11 #include "src/base/functional.h"
10 #include "src/base/macros.h" 12 #include "src/base/macros.h"
11 #include "src/checks.h" 13 #include "src/checks.h"
12 #include "src/globals.h" 14 #include "src/globals.h"
13 #include "src/zone/zone.h" 15 #include "src/zone/zone.h"
14 16
15 namespace v8 { 17 namespace v8 {
16 namespace internal { 18 namespace internal {
17 19
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // 86 //
85 // Also note that Handles do not provide default equality comparison or hashing 87 // Also note that Handles do not provide default equality comparison or hashing
86 // operators on purpose. Such operators would be misleading, because intended 88 // operators on purpose. Such operators would be misleading, because intended
87 // semantics is ambiguous between Handle location and object identity. Instead 89 // semantics is ambiguous between Handle location and object identity. Instead
88 // use either {is_identical_to} or {location} explicitly. 90 // use either {is_identical_to} or {location} explicitly.
89 template <typename T> 91 template <typename T>
90 class Handle final : public HandleBase { 92 class Handle final : public HandleBase {
91 public: 93 public:
92 V8_INLINE explicit Handle(T** location = nullptr) 94 V8_INLINE explicit Handle(T** location = nullptr)
93 : HandleBase(reinterpret_cast<Object**>(location)) { 95 : HandleBase(reinterpret_cast<Object**>(location)) {
94 Object* a = nullptr; 96 // Type check:
95 T* b = nullptr; 97 static_assert(std::is_base_of<Object, T>::value, "static type violation");
96 a = b; // Fake assignment to enforce type checks.
97 USE(a);
98 } 98 }
99
99 V8_INLINE explicit Handle(T* object) : Handle(object, object->GetIsolate()) {} 100 V8_INLINE explicit Handle(T* object) : Handle(object, object->GetIsolate()) {}
100 V8_INLINE Handle(T* object, Isolate* isolate) : HandleBase(object, isolate) {} 101 V8_INLINE Handle(T* object, Isolate* isolate) : HandleBase(object, isolate) {}
101 102
102 // Allocate a new handle for the object, do not canonicalize. 103 // Allocate a new handle for the object, do not canonicalize.
103 V8_INLINE static Handle<T> New(T* object, Isolate* isolate); 104 V8_INLINE static Handle<T> New(T* object, Isolate* isolate);
104 105
105 // Constructor for handling automatic up casting. 106 // Constructor for handling automatic up casting.
106 // Ex. Handle<JSFunction> can be passed when Handle<Object> is expected. 107 // Ex. Handle<JSFunction> can be passed when Handle<Object> is expected.
107 template <typename S> 108 template <typename S>
108 V8_INLINE Handle(Handle<S> handle) 109 V8_INLINE Handle(Handle<S> handle)
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 next = limit = NULL; 414 next = limit = NULL;
414 sealed_level = level = 0; 415 sealed_level = level = 0;
415 canonical_scope = NULL; 416 canonical_scope = NULL;
416 } 417 }
417 }; 418 };
418 419
419 } // namespace internal 420 } // namespace internal
420 } // namespace v8 421 } // namespace v8
421 422
422 #endif // V8_HANDLES_H_ 423 #endif // V8_HANDLES_H_
OLDNEW
« no previous file with comments | « src/global-handles.cc ('k') | src/i18n.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698