Commit b714772c authored by dcarney@chromium.org's avatar dcarney@chromium.org

pass isolate to Value::To* functions

BUG=
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/669373002

Cr-Commit-Position: refs/heads/master@{#24893}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24893 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 89885c8a
......@@ -1703,14 +1703,24 @@ class V8_EXPORT Value : public Data {
*/
bool IsDataView() const;
Local<Boolean> ToBoolean() const;
Local<Number> ToNumber() const;
Local<String> ToString() const;
Local<String> ToDetailString() const;
Local<Object> ToObject() const;
Local<Integer> ToInteger() const;
Local<Uint32> ToUint32() const;
Local<Int32> ToInt32() const;
Local<Boolean> ToBoolean(Isolate* isolate) const;
Local<Number> ToNumber(Isolate* isolate) const;
Local<String> ToString(Isolate* isolate) const;
Local<String> ToDetailString(Isolate* isolate) const;
Local<Object> ToObject(Isolate* isolate) const;
Local<Integer> ToInteger(Isolate* isolate) const;
Local<Uint32> ToUint32(Isolate* isolate) const;
Local<Int32> ToInt32(Isolate* isolate) const;
// TODO(dcarney): deprecate all these.
inline Local<Boolean> ToBoolean() const;
inline Local<Number> ToNumber() const;
inline Local<String> ToString() const;
inline Local<String> ToDetailString() const;
inline Local<Object> ToObject() const;
inline Local<Integer> ToInteger() const;
inline Local<Uint32> ToUint32() const;
inline Local<Int32> ToInt32() const;
/**
* Attempts to convert a string to an array index.
......@@ -6638,6 +6648,44 @@ template <class T> Value* Value::Cast(T* value) {
}
Local<Boolean> Value::ToBoolean() const {
return ToBoolean(Isolate::GetCurrent());
}
Local<Number> Value::ToNumber() const {
return ToNumber(Isolate::GetCurrent());
}
Local<String> Value::ToString() const {
return ToString(Isolate::GetCurrent());
}
Local<String> Value::ToDetailString() const {
return ToDetailString(Isolate::GetCurrent());
}
Local<Object> Value::ToObject() const {
return ToObject(Isolate::GetCurrent());
}
Local<Integer> Value::ToInteger() const {
return ToInteger(Isolate::GetCurrent());
}
Local<Uint32> Value::ToUint32() const {
return ToUint32(Isolate::GetCurrent());
}
Local<Int32> Value::ToInt32() const { return ToInt32(Isolate::GetCurrent()); }
Name* Name::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
......
......@@ -2580,13 +2580,13 @@ bool Value::IsGeneratorObject() const {
}
Local<String> Value::ToString() const {
Local<String> Value::ToString(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> str;
if (obj->IsString()) {
str = obj;
} else {
i::Isolate* isolate = i::Isolate::Current();
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToString");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
......@@ -2598,13 +2598,13 @@ Local<String> Value::ToString() const {
}
Local<String> Value::ToDetailString() const {
Local<String> Value::ToDetailString(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> str;
if (obj->IsString()) {
str = obj;
} else {
i::Isolate* isolate = i::Isolate::Current();
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToDetailString");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
......@@ -2616,13 +2616,13 @@ Local<String> Value::ToDetailString() const {
}
Local<v8::Object> Value::ToObject() const {
Local<v8::Object> Value::ToObject(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> val;
if (obj->IsJSObject()) {
val = obj;
} else {
i::Isolate* isolate = i::Isolate::Current();
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToObject");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
......@@ -2634,12 +2634,12 @@ Local<v8::Object> Value::ToObject() const {
}
Local<Boolean> Value::ToBoolean() const {
Local<Boolean> Value::ToBoolean(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsBoolean()) {
return ToApiHandle<Boolean>(obj);
} else {
i::Isolate* isolate = i::Isolate::Current();
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToBoolean");
ENTER_V8(isolate);
i::Handle<i::Object> val =
......@@ -2649,13 +2649,13 @@ Local<Boolean> Value::ToBoolean() const {
}
Local<Number> Value::ToNumber() const {
Local<Number> Value::ToNumber(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> num;
if (obj->IsNumber()) {
num = obj;
} else {
i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToNumber");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
......@@ -2667,13 +2667,13 @@ Local<Number> Value::ToNumber() const {
}
Local<Integer> Value::ToInteger() const {
Local<Integer> Value::ToInteger(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> num;
if (obj->IsSmi()) {
num = obj;
} else {
i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToInteger");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
......@@ -2935,13 +2935,13 @@ int64_t Value::IntegerValue() const {
}
Local<Int32> Value::ToInt32() const {
Local<Int32> Value::ToInt32(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> num;
if (obj->IsSmi()) {
num = obj;
} else {
i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToInt32");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
......@@ -2952,13 +2952,13 @@ Local<Int32> Value::ToInt32() const {
}
Local<Uint32> Value::ToUint32() const {
Local<Uint32> Value::ToUint32(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> num;
if (obj->IsSmi()) {
num = obj;
} else {
i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToUInt32");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
......@@ -6916,7 +6916,7 @@ String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
ENTER_V8(isolate);
i::HandleScope scope(isolate);
TryCatch try_catch;
Handle<String> str = obj->ToString();
Handle<String> str = obj->ToString(reinterpret_cast<v8::Isolate*>(isolate));
if (str.IsEmpty()) return;
i::Handle<i::String> i_str = Utils::OpenHandle(*str);
length_ = v8::Utf8Length(*i_str, isolate);
......@@ -6937,7 +6937,7 @@ String::Value::Value(v8::Handle<v8::Value> obj)
ENTER_V8(isolate);
i::HandleScope scope(isolate);
TryCatch try_catch;
Handle<String> str = obj->ToString();
Handle<String> str = obj->ToString(reinterpret_cast<v8::Isolate*>(isolate));
if (str.IsEmpty()) return;
length_ = str->Length();
str_ = i::NewArray<uint16_t>(length_ + 1);
......
......@@ -124,7 +124,7 @@ void HandleDebugEvent(const Debug::EventDetails& event_details) {
printf("%s\n", *text_str);
}
running = response_details->Get(String::NewFromUtf8(isolate, "running"))
->ToBoolean()
->ToBoolean(isolate)
->Value();
}
}
......
......@@ -186,7 +186,7 @@ ScriptCompiler::CachedData* CompileForCachedData(
int name_length = 0;
uint16_t* name_buffer = NULL;
if (name->IsString()) {
Local<String> name_string = name->ToString();
Local<String> name_string = Local<String>::Cast(name);
name_length = name_string->Length();
name_buffer = new uint16_t[name_length];
name_string->Write(name_buffer, 0, name_length);
......@@ -410,7 +410,7 @@ void Shell::RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args) {
Throw(args.GetIsolate(), "Invalid argument");
return;
}
int index = data->RealmFind(args[0]->ToObject()->CreationContext());
int index = data->RealmFind(args[0]->ToObject(isolate)->CreationContext());
if (index == -1) return;
args.GetReturnValue().Set(index);
}
......@@ -480,7 +480,7 @@ void Shell::RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args) {
Throw(args.GetIsolate(), "Invalid argument");
return;
}
ScriptCompiler::Source script_source(args[1]->ToString());
ScriptCompiler::Source script_source(args[1]->ToString(isolate));
Handle<UnboundScript> script = ScriptCompiler::CompileUnbound(
isolate, &script_source);
if (script.IsEmpty()) return;
......@@ -526,7 +526,7 @@ void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) {
// Explicitly catch potential exceptions in toString().
v8::TryCatch try_catch;
Handle<String> str_obj = args[i]->ToString();
Handle<String> str_obj = args[i]->ToString(args.GetIsolate());
if (try_catch.HasCaught()) {
try_catch.ReThrow();
return;
......
......@@ -53,7 +53,8 @@ void StatisticsExtension::GetCounters(
Heap* heap = isolate->heap();
if (args.Length() > 0) { // GC if first argument evaluates to true.
if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) {
if (args[0]->IsBoolean() &&
args[0]->ToBoolean(args.GetIsolate())->Value()) {
heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment