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

Side by Side Diff: src/handles.h

Issue 2632713003: Remove ~MaybeHandle and statically assert that handles are trivially copyable
Patch Set: 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 | « no previous file | src/handles.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> 8 #include <type_traits>
9 9
10 #include "include/v8.h" 10 #include "include/v8.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // into a Handle requires checking that it does not point to NULL. This 178 // into a Handle requires checking that it does not point to NULL. This
179 // ensures NULL checks before use. 179 // ensures NULL checks before use.
180 // 180 //
181 // Also note that Handles do not provide default equality comparison or hashing 181 // Also note that Handles do not provide default equality comparison or hashing
182 // operators on purpose. Such operators would be misleading, because intended 182 // operators on purpose. Such operators would be misleading, because intended
183 // semantics is ambiguous between Handle location and object identity. 183 // semantics is ambiguous between Handle location and object identity.
184 template <typename T> 184 template <typename T>
185 class MaybeHandle final { 185 class MaybeHandle final {
186 public: 186 public:
187 V8_INLINE MaybeHandle() {} 187 V8_INLINE MaybeHandle() {}
188 V8_INLINE ~MaybeHandle() {}
189 188
190 // Constructor for handling automatic up casting from Handle. 189 // Constructor for handling automatic up casting from Handle.
191 // Ex. Handle<JSArray> can be passed when MaybeHandle<Object> is expected. 190 // Ex. Handle<JSArray> can be passed when MaybeHandle<Object> is expected.
192 template <typename S> 191 template <typename S>
193 V8_INLINE MaybeHandle(Handle<S> handle) 192 V8_INLINE MaybeHandle(Handle<S> handle)
194 : location_(reinterpret_cast<T**>(handle.location_)) { 193 : location_(reinterpret_cast<T**>(handle.location_)) {
195 T* a = nullptr; 194 T* a = nullptr;
196 S* b = nullptr; 195 S* b = nullptr;
197 a = b; // Fake assignment to enforce type checks. 196 a = b; // Fake assignment to enforce type checks.
198 USE(a); 197 USE(a);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 next = limit = NULL; 413 next = limit = NULL;
415 sealed_level = level = 0; 414 sealed_level = level = 0;
416 canonical_scope = NULL; 415 canonical_scope = NULL;
417 } 416 }
418 }; 417 };
419 418
420 } // namespace internal 419 } // namespace internal
421 } // namespace v8 420 } // namespace v8
422 421
423 #endif // V8_HANDLES_H_ 422 #endif // V8_HANDLES_H_
OLDNEW
« no previous file with comments | « no previous file | src/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698