Add Value::Cast.
It's needed for upcasting Persistent<Object> to Persistent<Value> after handlepocalypse (with Persistent::As or Persistent::Cast). BUG= R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/16206014 Patch from Marja Hölttä <marja@chromium.org>. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14995 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
987080415e
commit
72098711b7
@ -1469,6 +1469,8 @@ class V8EXPORT Value : public Data {
|
||||
bool Equals(Handle<Value> that) const;
|
||||
bool StrictEquals(Handle<Value> that) const;
|
||||
|
||||
template <class T> V8_INLINE(static Value* Cast(T* value));
|
||||
|
||||
private:
|
||||
V8_INLINE(bool QuickIsUndefined() const);
|
||||
V8_INLINE(bool QuickIsNull() const);
|
||||
@ -5997,6 +5999,11 @@ bool Value::QuickIsString() const {
|
||||
}
|
||||
|
||||
|
||||
template <class T> Value* Value::Cast(T* value) {
|
||||
return static_cast<Value*>(value);
|
||||
}
|
||||
|
||||
|
||||
Symbol* Symbol::Cast(v8::Value* value) {
|
||||
#ifdef V8_ENABLE_CHECKS
|
||||
CheckCast(value);
|
||||
|
@ -2898,6 +2898,24 @@ THREADED_TEST(ClearAndLeakGlobal) {
|
||||
}
|
||||
|
||||
|
||||
THREADED_TEST(GlobalHandleUpcast) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
v8::Local<String> local = v8::Local<String>::New(v8_str("str"));
|
||||
v8::Persistent<String> global_string(isolate, local);
|
||||
#ifdef V8_USE_UNSAFE_HANDLES
|
||||
v8::Persistent<Value> global_value =
|
||||
v8::Persistent<Value>::Cast(global_string);
|
||||
#else
|
||||
v8::Persistent<Value>& global_value =
|
||||
v8::Persistent<Value>::Cast(global_string);
|
||||
#endif
|
||||
CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString());
|
||||
CHECK(global_string == v8::Persistent<String>::Cast(global_value));
|
||||
global_string.Dispose();
|
||||
}
|
||||
|
||||
|
||||
THREADED_TEST(LocalHandle) {
|
||||
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
||||
v8::Local<String> local = v8::Local<String>::New(v8_str("str"));
|
||||
|
Loading…
Reference in New Issue
Block a user