From 31e56df122d32e81bfbdbb2394836f80d224fecc Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Tue, 30 Jul 2013 07:05:15 +0000 Subject: [PATCH] Prepare some ValueOf renamings. R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/20992005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15945 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8.h | 30 +++++++++++++++++++++++++----- src/api.cc | 10 +++++----- test/cctest/test-api.cc | 26 +++++++++++++++----------- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/include/v8.h b/include/v8.h index 3607740..eb166ab 100644 --- a/include/v8.h +++ b/include/v8.h @@ -2719,11 +2719,15 @@ class V8EXPORT Date : public Object { public: static Local New(double time); + // Deprecated, use Date::ValueOf() instead. + // TODO(svenpanne) Actually deprecate when Chrome is adapted. + double NumberValue() const { return ValueOf(); } + /** * A specialization of Value::NumberValue that is more efficient * because we know the structure of this object. */ - double NumberValue() const; + double ValueOf() const; V8_INLINE(static Date* Cast(v8::Value* obj)); @@ -2753,10 +2757,14 @@ class V8EXPORT NumberObject : public Object { public: static Local New(double value); + // Deprecated, use NumberObject::ValueOf() instead. + // TODO(svenpanne) Actually deprecate when Chrome is adapted. + double NumberValue() const { return ValueOf(); } + /** * Returns the Number held by the object. */ - double NumberValue() const; + double ValueOf() const; V8_INLINE(static NumberObject* Cast(v8::Value* obj)); @@ -2772,10 +2780,14 @@ class V8EXPORT BooleanObject : public Object { public: static Local New(bool value); + // Deprecated, use BooleanObject::ValueOf() instead. + // TODO(svenpanne) Actually deprecate when Chrome is adapted. + bool BooleanValue() const { return ValueOf(); } + /** * Returns the Boolean held by the object. */ - bool BooleanValue() const; + bool ValueOf() const; V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); @@ -2791,10 +2803,14 @@ class V8EXPORT StringObject : public Object { public: static Local New(Handle value); + // Deprecated, use StringObject::ValueOf() instead. + // TODO(svenpanne) Actually deprecate when Chrome is adapted. + Local StringValue() const { return ValueOf(); } + /** * Returns the String held by the object. */ - Local StringValue() const; + Local ValueOf() const; V8_INLINE(static StringObject* Cast(v8::Value* obj)); @@ -2812,10 +2828,14 @@ class V8EXPORT SymbolObject : public Object { public: static Local New(Isolate* isolate, Handle value); + // Deprecated, use SymbolObject::ValueOf() instead. + // TODO(svenpanne) Actually deprecate when Chrome is adapted. + Local SymbolValue() const { return ValueOf(); } + /** * Returns the Symbol held by the object. */ - Local SymbolValue() const; + Local ValueOf() const; V8_INLINE(static SymbolObject* Cast(v8::Value* obj)); diff --git a/src/api.cc b/src/api.cc index 3f5a079..a6f7d9d 100644 --- a/src/api.cc +++ b/src/api.cc @@ -6083,7 +6083,7 @@ Local v8::NumberObject::New(double value) { } -double v8::NumberObject::NumberValue() const { +double v8::NumberObject::ValueOf() const { i::Isolate* isolate = i::Isolate::Current(); if (IsDeadCheck(isolate, "v8::NumberObject::NumberValue()")) return 0; LOG_API(isolate, "NumberObject::NumberValue"); @@ -6107,7 +6107,7 @@ Local v8::BooleanObject::New(bool value) { } -bool v8::BooleanObject::BooleanValue() const { +bool v8::BooleanObject::ValueOf() const { i::Isolate* isolate = i::Isolate::Current(); if (IsDeadCheck(isolate, "v8::BooleanObject::BooleanValue()")) return 0; LOG_API(isolate, "BooleanObject::BooleanValue"); @@ -6128,7 +6128,7 @@ Local v8::StringObject::New(Handle value) { } -Local v8::StringObject::StringValue() const { +Local v8::StringObject::ValueOf() const { i::Isolate* isolate = i::Isolate::Current(); if (IsDeadCheck(isolate, "v8::StringObject::StringValue()")) { return Local(); @@ -6152,7 +6152,7 @@ Local v8::SymbolObject::New(Isolate* isolate, Handle value) { } -Local v8::SymbolObject::SymbolValue() const { +Local v8::SymbolObject::ValueOf() const { i::Isolate* isolate = i::Isolate::Current(); if (IsDeadCheck(isolate, "v8::SymbolObject::SymbolValue()")) return Local(); @@ -6181,7 +6181,7 @@ Local v8::Date::New(double time) { } -double v8::Date::NumberValue() const { +double v8::Date::ValueOf() const { i::Isolate* isolate = i::Isolate::Current(); if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0; LOG_API(isolate, "Date::NumberValue"); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index e25642e..3c6f85e 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -1488,13 +1488,13 @@ THREADED_TEST(StringObject) { CHECK(!not_object->IsStringObject()); v8::Handle as_boxed = boxed_string.As(); CHECK(!as_boxed.IsEmpty()); - Local the_string = as_boxed->StringValue(); + Local the_string = as_boxed->ValueOf(); CHECK(!the_string.IsEmpty()); ExpectObject("\"test\"", the_string); v8::Handle new_boxed_string = v8::StringObject::New(the_string); CHECK(new_boxed_string->IsStringObject()); as_boxed = new_boxed_string.As(); - the_string = as_boxed->StringValue(); + the_string = as_boxed->ValueOf(); CHECK(!the_string.IsEmpty()); ExpectObject("\"test\"", the_string); } @@ -1511,12 +1511,12 @@ THREADED_TEST(NumberObject) { CHECK(!boxed_not_number->IsNumberObject()); v8::Handle as_boxed = boxed_number.As(); CHECK(!as_boxed.IsEmpty()); - double the_number = as_boxed->NumberValue(); + double the_number = as_boxed->ValueOf(); CHECK_EQ(42.0, the_number); v8::Handle new_boxed_number = v8::NumberObject::New(43); CHECK(new_boxed_number->IsNumberObject()); as_boxed = new_boxed_number.As(); - the_number = as_boxed->NumberValue(); + the_number = as_boxed->ValueOf(); CHECK_EQ(43.0, the_number); } @@ -1533,16 +1533,16 @@ THREADED_TEST(BooleanObject) { v8::Handle as_boxed = boxed_boolean.As(); CHECK(!as_boxed.IsEmpty()); - bool the_boolean = as_boxed->BooleanValue(); + bool the_boolean = as_boxed->ValueOf(); CHECK_EQ(true, the_boolean); v8::Handle boxed_true = v8::BooleanObject::New(true); v8::Handle boxed_false = v8::BooleanObject::New(false); CHECK(boxed_true->IsBooleanObject()); CHECK(boxed_false->IsBooleanObject()); as_boxed = boxed_true.As(); - CHECK_EQ(true, as_boxed->BooleanValue()); + CHECK_EQ(true, as_boxed->ValueOf()); as_boxed = boxed_false.As(); - CHECK_EQ(false, as_boxed->BooleanValue()); + CHECK_EQ(false, as_boxed->ValueOf()); } @@ -1567,7 +1567,9 @@ THREADED_TEST(PrimitiveAndWrappedBooleans) { Local false_boolean_object = false_value.As(); CHECK(!false_boolean_object->IsBoolean()); CHECK(false_boolean_object->IsBooleanObject()); - CHECK(!false_boolean_object->BooleanValue()); + // TODO(svenpanne) Uncomment when BooleanObject::BooleanValue() is deleted. + // CHECK(false_boolean_object->BooleanValue()); + CHECK(!false_boolean_object->ValueOf()); CHECK(!false_boolean_object->IsTrue()); CHECK(!false_boolean_object->IsFalse()); @@ -1588,7 +1590,9 @@ THREADED_TEST(PrimitiveAndWrappedBooleans) { Local true_boolean_object = true_value.As(); CHECK(!true_boolean_object->IsBoolean()); CHECK(true_boolean_object->IsBooleanObject()); - CHECK(true_boolean_object->BooleanValue()); + // TODO(svenpanne) Uncomment when BooleanObject::BooleanValue() is deleted. + // CHECK(true_boolean_object->BooleanValue()); + CHECK(true_boolean_object->ValueOf()); CHECK(!true_boolean_object->IsTrue()); CHECK(!true_boolean_object->IsFalse()); } @@ -2616,7 +2620,7 @@ THREADED_TEST(SymbolProperties) { CHECK(sym_obj->Equals(sym2)); CHECK(!sym_obj->StrictEquals(sym2)); CHECK(v8::SymbolObject::Cast(*sym_obj)->Equals(sym_obj)); - CHECK(v8::SymbolObject::Cast(*sym_obj)->SymbolValue()->Equals(sym2)); + CHECK(v8::SymbolObject::Cast(*sym_obj)->ValueOf()->Equals(sym2)); // Make sure delete of a non-existent symbol property works. CHECK(obj->Delete(sym1)); @@ -13224,7 +13228,7 @@ THREADED_TEST(DateAccess) { v8::HandleScope scope(context->GetIsolate()); v8::Handle date = v8::Date::New(1224744689038.0); CHECK(date->IsDate()); - CHECK_EQ(1224744689038.0, date.As()->NumberValue()); + CHECK_EQ(1224744689038.0, date.As()->ValueOf()); } -- 2.7.4