From 4a99e6f49308c1294a60a1e879f063af6d952f8c Mon Sep 17 00:00:00 2001 From: dcarney Date: Tue, 17 Mar 2015 02:03:40 -0700 Subject: [PATCH] add missing dcheck to ToLocalChecked R=svenpanne@chromium.org BUG=v8:3929 LOG=n Review URL: https://codereview.chromium.org/1017663002 Cr-Commit-Position: refs/heads/master@{#27229} --- include/v8.h | 17 +++++++++++++---- src/api.cc | 5 +++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/v8.h b/include/v8.h index db625ee..10152f6 100644 --- a/include/v8.h +++ b/include/v8.h @@ -429,10 +429,7 @@ class MaybeLocal { return !IsEmpty(); } - V8_INLINE Local ToLocalChecked() { - // TODO(dcarney): add DCHECK. - return Local(val_); - } + V8_INLINE Local ToLocalChecked(); template V8_INLINE Local FromMaybe(Local default_value) const { @@ -5893,10 +5890,13 @@ class V8_EXPORT V8 { static Local GetEternal(Isolate* isolate, int index); static void CheckIsJust(bool is_just); + static void ToLocalEmpty(); template friend class Handle; template friend class Local; template + friend class MaybeLocal; + template friend class Maybe; template friend class Eternal; template friend class PersistentBase; @@ -6726,6 +6726,15 @@ Local Eternal::Get(Isolate* isolate) { template +Local MaybeLocal::ToLocalChecked() { +#ifdef V8_ENABLE_CHECKS + if (val_ == nullptr) V8::ToLocalEmpty(); +#endif + return Local(val_); +} + + +template T* PersistentBase::New(Isolate* isolate, T* that) { if (that == NULL) return NULL; internal::Object** p = reinterpret_cast(that); diff --git a/src/api.cc b/src/api.cc index 7eeb57d..1c27857 100644 --- a/src/api.cc +++ b/src/api.cc @@ -617,6 +617,11 @@ void V8::CheckIsJust(bool is_just) { } +void V8::ToLocalEmpty() { + Utils::ApiCheck(false, "v8::ToLocalChecked", "Empty MaybeLocal."); +} + + // --- H a n d l e s --- -- 2.7.4