From b6c9b70356ca4d2d36424a384290baaa7ba85207 Mon Sep 17 00:00:00 2001 From: xaxxon Date: Fri, 29 Jan 2016 01:12:30 -0800 Subject: [PATCH] Make handle ctors explicit Without this change, the v8::Local<> constructor will be picked up by the compiler as an option for an implicit cast for any pointer type. This leads to bad error messages when accidentally passing an erroneous pointer type to a function wanting a Local<> (complains about a pointer assignment in Local<>'s constructor as opposed to a bad type for the parameter of the function being called) and also causes ambiguity errors where none should exist when calling overloaded functions (for example a function taking either a std::string or a v8::Local cannot be called with a const char * because the compiler sees both types as being constructable with a const char *). R=jochen@chromium.org BUG= Review URL: https://codereview.chromium.org/1647833005 Cr-Commit-Position: refs/heads/master@{#33602} --- AUTHORS | 3 ++- include/v8.h | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index f23ce3336a..9e6a398dfa 100644 --- a/AUTHORS +++ b/AUTHORS @@ -108,5 +108,6 @@ Vlad Burlik Vladimir Krivosheev Vladimir Shutoff Yu Yin +Zac Hansen Zhongping Wang -柳荣一 +柳荣一 \ No newline at end of file diff --git a/include/v8.h b/include/v8.h index 87ae8e0c50..171623a28f 100644 --- a/include/v8.h +++ b/include/v8.h @@ -329,9 +329,7 @@ class Local { friend class PersistentValueMapBase; template friend class PersistentValueVector; - template - V8_INLINE Local(S* that) - : val_(that) {} + explicit V8_INLINE Local(T* that) : val_(that) {} V8_INLINE static Local New(Isolate* isolate, T* that); T* val_; }; @@ -787,7 +785,7 @@ template class Persistent : public PersistentBase { template friend class Persistent; template friend class ReturnValue; - template V8_INLINE Persistent(S* that) : PersistentBase(that) { } + explicit V8_INLINE Persistent(T* that) : PersistentBase(that) {} V8_INLINE T* operator*() const { return this->val_; } template V8_INLINE void Copy(const Persistent& that);