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

Side by Side Diff: include/v8.h

Issue 1017663002: add missing dcheck to ToLocalChecked (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/api.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 422 }
423 423
424 V8_INLINE bool IsEmpty() const { return val_ == nullptr; } 424 V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
425 425
426 template <class S> 426 template <class S>
427 V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const { 427 V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const {
428 out->val_ = IsEmpty() ? nullptr : this->val_; 428 out->val_ = IsEmpty() ? nullptr : this->val_;
429 return !IsEmpty(); 429 return !IsEmpty();
430 } 430 }
431 431
432 V8_INLINE Local<T> ToLocalChecked() { 432 V8_INLINE Local<T> ToLocalChecked();
433 // TODO(dcarney): add DCHECK.
434 return Local<T>(val_);
435 }
436 433
437 template <class S> 434 template <class S>
438 V8_INLINE Local<S> FromMaybe(Local<S> default_value) const { 435 V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
439 return IsEmpty() ? default_value : Local<S>(val_); 436 return IsEmpty() ? default_value : Local<S>(val_);
440 } 437 }
441 438
442 private: 439 private:
443 T* val_; 440 T* val_;
444 }; 441 };
445 442
(...skipping 5440 matching lines...) Expand 10 before | Expand all | Expand 10 after
5886 // Must be 1 or -1. 5883 // Must be 1 or -1.
5887 int internal_field_index2, 5884 int internal_field_index2,
5888 WeakCallbackInfo<void>::Callback weak_callback); 5885 WeakCallbackInfo<void>::Callback weak_callback);
5889 static void* ClearWeak(internal::Object** global_handle); 5886 static void* ClearWeak(internal::Object** global_handle);
5890 static void Eternalize(Isolate* isolate, 5887 static void Eternalize(Isolate* isolate,
5891 Value* handle, 5888 Value* handle,
5892 int* index); 5889 int* index);
5893 static Local<Value> GetEternal(Isolate* isolate, int index); 5890 static Local<Value> GetEternal(Isolate* isolate, int index);
5894 5891
5895 static void CheckIsJust(bool is_just); 5892 static void CheckIsJust(bool is_just);
5893 static void ToLocalEmpty();
5896 5894
5897 template <class T> friend class Handle; 5895 template <class T> friend class Handle;
5898 template <class T> friend class Local; 5896 template <class T> friend class Local;
5899 template <class T> 5897 template <class T>
5898 friend class MaybeLocal;
5899 template <class T>
5900 friend class Maybe; 5900 friend class Maybe;
5901 template <class T> friend class Eternal; 5901 template <class T> friend class Eternal;
5902 template <class T> friend class PersistentBase; 5902 template <class T> friend class PersistentBase;
5903 template <class T, class M> friend class Persistent; 5903 template <class T, class M> friend class Persistent;
5904 friend class Context; 5904 friend class Context;
5905 }; 5905 };
5906 5906
5907 5907
5908 /** 5908 /**
5909 * A simple Maybe type, representing an object which may or may not have a 5909 * A simple Maybe type, representing an object which may or may not have a
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
6719 } 6719 }
6720 6720
6721 6721
6722 template<class T> 6722 template<class T>
6723 Local<T> Eternal<T>::Get(Isolate* isolate) { 6723 Local<T> Eternal<T>::Get(Isolate* isolate) {
6724 return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_))); 6724 return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_)));
6725 } 6725 }
6726 6726
6727 6727
6728 template <class T> 6728 template <class T>
6729 Local<T> MaybeLocal<T>::ToLocalChecked() {
6730 #ifdef V8_ENABLE_CHECKS
6731 if (val_ == nullptr) V8::ToLocalEmpty();
6732 #endif
6733 return Local<T>(val_);
6734 }
6735
6736
6737 template <class T>
6729 T* PersistentBase<T>::New(Isolate* isolate, T* that) { 6738 T* PersistentBase<T>::New(Isolate* isolate, T* that) {
6730 if (that == NULL) return NULL; 6739 if (that == NULL) return NULL;
6731 internal::Object** p = reinterpret_cast<internal::Object**>(that); 6740 internal::Object** p = reinterpret_cast<internal::Object**>(that);
6732 return reinterpret_cast<T*>( 6741 return reinterpret_cast<T*>(
6733 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), 6742 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
6734 p)); 6743 p));
6735 } 6744 }
6736 6745
6737 6746
6738 template <class T, class M> 6747 template <class T, class M>
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
7868 */ 7877 */
7869 7878
7870 7879
7871 } // namespace v8 7880 } // namespace v8
7872 7881
7873 7882
7874 #undef TYPE_CHECK 7883 #undef TYPE_CHECK
7875 7884
7876 7885
7877 #endif // V8_H_ 7886 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698