summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina <tfarina@chromium.org>2015-05-04 07:12:29 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-04 14:12:57 +0000
commit777bfee5b402bca542f5431f088c8c011d7188c5 (patch)
treebce9b81d90ddf4e0ff4acbbbc5496feb31c72f56
parentc0f287d4d6fe0c096dec170644af1e618f709f5b (diff)
downloadchromium_src-777bfee5b402bca542f5431f088c8c011d7188c5.zip
chromium_src-777bfee5b402bca542f5431f088c8c011d7188c5.tar.gz
chromium_src-777bfee5b402bca542f5431f088c8c011d7188c5.tar.bz2
gin: Use v8::Local instead of v8::Handle.
Turns out, Handle is just an alias for Local: https://chromium.googlesource.com/v8/v8.git/+/master/include/v8.h#334 BUG=424445 TEST=gin_unittests R=jochen@chromium.org Review URL: https://codereview.chromium.org/1115273003 Cr-Commit-Position: refs/heads/master@{#328120}
-rw-r--r--gin/converter.cc99
-rw-r--r--gin/converter_unittest.cc8
2 files changed, 57 insertions, 50 deletions
diff --git a/gin/converter.cc b/gin/converter.cc
index 33656b5..d870beb 100644
--- a/gin/converter.cc
+++ b/gin/converter.cc
@@ -10,9 +10,9 @@ using v8::ArrayBuffer;
using v8::Boolean;
using v8::External;
using v8::Function;
-using v8::Handle;
using v8::Integer;
using v8::Isolate;
+using v8::Local;
using v8::Number;
using v8::Object;
using v8::String;
@@ -20,20 +20,21 @@ using v8::Value;
namespace gin {
-Handle<Value> Converter<bool>::ToV8(Isolate* isolate, bool val) {
+Local<Value> Converter<bool>::ToV8(Isolate* isolate, bool val) {
return Boolean::New(isolate, val).As<Value>();
}
-bool Converter<bool>::FromV8(Isolate* isolate, Handle<Value> val, bool* out) {
+bool Converter<bool>::FromV8(Isolate* isolate, Local<Value> val, bool* out) {
*out = val->BooleanValue();
return true;
}
-Handle<Value> Converter<int32_t>::ToV8(Isolate* isolate, int32_t val) {
+Local<Value> Converter<int32_t>::ToV8(Isolate* isolate, int32_t val) {
return Integer::New(isolate, val).As<Value>();
}
-bool Converter<int32_t>::FromV8(Isolate* isolate, Handle<Value> val,
+bool Converter<int32_t>::FromV8(Isolate* isolate,
+ Local<Value> val,
int32_t* out) {
if (!val->IsInt32())
return false;
@@ -41,11 +42,12 @@ bool Converter<int32_t>::FromV8(Isolate* isolate, Handle<Value> val,
return true;
}
-Handle<Value> Converter<uint32_t>::ToV8(Isolate* isolate, uint32_t val) {
+Local<Value> Converter<uint32_t>::ToV8(Isolate* isolate, uint32_t val) {
return Integer::NewFromUnsigned(isolate, val).As<Value>();
}
-bool Converter<uint32_t>::FromV8(Isolate* isolate, Handle<Value> val,
+bool Converter<uint32_t>::FromV8(Isolate* isolate,
+ Local<Value> val,
uint32_t* out) {
if (!val->IsUint32())
return false;
@@ -53,11 +55,12 @@ bool Converter<uint32_t>::FromV8(Isolate* isolate, Handle<Value> val,
return true;
}
-Handle<Value> Converter<int64_t>::ToV8(Isolate* isolate, int64_t val) {
+Local<Value> Converter<int64_t>::ToV8(Isolate* isolate, int64_t val) {
return Number::New(isolate, static_cast<double>(val)).As<Value>();
}
-bool Converter<int64_t>::FromV8(Isolate* isolate, Handle<Value> val,
+bool Converter<int64_t>::FromV8(Isolate* isolate,
+ Local<Value> val,
int64_t* out) {
if (!val->IsNumber())
return false;
@@ -67,11 +70,12 @@ bool Converter<int64_t>::FromV8(Isolate* isolate, Handle<Value> val,
return true;
}
-Handle<Value> Converter<uint64_t>::ToV8(Isolate* isolate, uint64_t val) {
+Local<Value> Converter<uint64_t>::ToV8(Isolate* isolate, uint64_t val) {
return Number::New(isolate, static_cast<double>(val)).As<Value>();
}
-bool Converter<uint64_t>::FromV8(Isolate* isolate, Handle<Value> val,
+bool Converter<uint64_t>::FromV8(Isolate* isolate,
+ Local<Value> val,
uint64_t* out) {
if (!val->IsNumber())
return false;
@@ -79,23 +83,23 @@ bool Converter<uint64_t>::FromV8(Isolate* isolate, Handle<Value> val,
return true;
}
-Handle<Value> Converter<float>::ToV8(Isolate* isolate, float val) {
+Local<Value> Converter<float>::ToV8(Isolate* isolate, float val) {
return Number::New(isolate, val).As<Value>();
}
-bool Converter<float>::FromV8(Isolate* isolate, Handle<Value> val,
- float* out) {
+bool Converter<float>::FromV8(Isolate* isolate, Local<Value> val, float* out) {
if (!val->IsNumber())
return false;
*out = static_cast<float>(val->NumberValue());
return true;
}
-Handle<Value> Converter<double>::ToV8(Isolate* isolate, double val) {
+Local<Value> Converter<double>::ToV8(Isolate* isolate, double val) {
return Number::New(isolate, val).As<Value>();
}
-bool Converter<double>::FromV8(Isolate* isolate, Handle<Value> val,
+bool Converter<double>::FromV8(Isolate* isolate,
+ Local<Value> val,
double* out) {
if (!val->IsNumber())
return false;
@@ -103,84 +107,87 @@ bool Converter<double>::FromV8(Isolate* isolate, Handle<Value> val,
return true;
}
-Handle<Value> Converter<base::StringPiece>::ToV8(
- Isolate* isolate, const base::StringPiece& val) {
+Local<Value> Converter<base::StringPiece>::ToV8(Isolate* isolate,
+ const base::StringPiece& val) {
return String::NewFromUtf8(isolate, val.data(), String::kNormalString,
static_cast<uint32_t>(val.length()));
}
-Handle<Value> Converter<std::string>::ToV8(Isolate* isolate,
- const std::string& val) {
+Local<Value> Converter<std::string>::ToV8(Isolate* isolate,
+ const std::string& val) {
return Converter<base::StringPiece>::ToV8(isolate, val);
}
-bool Converter<std::string>::FromV8(Isolate* isolate, Handle<Value> val,
+bool Converter<std::string>::FromV8(Isolate* isolate,
+ Local<Value> val,
std::string* out) {
if (!val->IsString())
return false;
- Handle<String> str = Handle<String>::Cast(val);
+ Local<String> str = Local<String>::Cast(val);
int length = str->Utf8Length();
out->resize(length);
str->WriteUtf8(&(*out)[0], length, NULL, String::NO_NULL_TERMINATION);
return true;
}
-bool Converter<Handle<Function> >::FromV8(Isolate* isolate, Handle<Value> val,
- Handle<Function>* out) {
+bool Converter<Local<Function>>::FromV8(Isolate* isolate,
+ Local<Value> val,
+ Local<Function>* out) {
if (!val->IsFunction())
return false;
- *out = Handle<Function>::Cast(val);
+ *out = Local<Function>::Cast(val);
return true;
}
-Handle<Value> Converter<Handle<Object> >::ToV8(Isolate* isolate,
- Handle<Object> val) {
+Local<Value> Converter<Local<Object>>::ToV8(Isolate* isolate,
+ Local<Object> val) {
return val.As<Value>();
}
-bool Converter<Handle<Object> >::FromV8(Isolate* isolate, Handle<Value> val,
- Handle<Object>* out) {
+bool Converter<Local<Object>>::FromV8(Isolate* isolate,
+ Local<Value> val,
+ Local<Object>* out) {
if (!val->IsObject())
return false;
- *out = Handle<Object>::Cast(val);
+ *out = Local<Object>::Cast(val);
return true;
}
-Handle<Value> Converter<Handle<ArrayBuffer> >::ToV8(Isolate* isolate,
- Handle<ArrayBuffer> val) {
+Local<Value> Converter<Local<ArrayBuffer>>::ToV8(Isolate* isolate,
+ Local<ArrayBuffer> val) {
return val.As<Value>();
}
-bool Converter<Handle<ArrayBuffer> >::FromV8(Isolate* isolate,
- Handle<Value> val,
- Handle<ArrayBuffer>* out) {
+bool Converter<Local<ArrayBuffer>>::FromV8(Isolate* isolate,
+ Local<Value> val,
+ Local<ArrayBuffer>* out) {
if (!val->IsArrayBuffer())
return false;
- *out = Handle<ArrayBuffer>::Cast(val);
+ *out = Local<ArrayBuffer>::Cast(val);
return true;
}
-Handle<Value> Converter<Handle<External> >::ToV8(Isolate* isolate,
- Handle<External> val) {
+Local<Value> Converter<Local<External>>::ToV8(Isolate* isolate,
+ Local<External> val) {
return val.As<Value>();
}
-bool Converter<Handle<External> >::FromV8(Isolate* isolate,
- v8::Local<Value> val,
- Handle<External>* out) {
+bool Converter<Local<External>>::FromV8(Isolate* isolate,
+ v8::Local<Value> val,
+ Local<External>* out) {
if (!val->IsExternal())
return false;
- *out = Handle<External>::Cast(val);
+ *out = Local<External>::Cast(val);
return true;
}
-Handle<Value> Converter<Handle<Value> >::ToV8(Isolate* isolate,
- Handle<Value> val) {
+Local<Value> Converter<Local<Value>>::ToV8(Isolate* isolate, Local<Value> val) {
return val;
}
-bool Converter<Handle<Value> >::FromV8(Isolate* isolate, Handle<Value> val,
- Handle<Value>* out) {
+bool Converter<Local<Value>>::FromV8(Isolate* isolate,
+ Local<Value> val,
+ Local<Value>* out) {
*out = val;
return true;
}
diff --git a/gin/converter_unittest.cc b/gin/converter_unittest.cc
index 6ac3087..940d4a2 100644
--- a/gin/converter_unittest.cc
+++ b/gin/converter_unittest.cc
@@ -16,9 +16,9 @@
using v8::Array;
using v8::Boolean;
-using v8::Handle;
using v8::HandleScope;
using v8::Integer;
+using v8::Local;
using v8::Null;
using v8::Number;
using v8::Object;
@@ -39,7 +39,7 @@ TEST_F(ConverterTest, Bool) {
Boolean::New(instance_->isolate(), false)));
struct {
- Handle<Value> input;
+ Local<Value> input;
bool expected;
} test_data[] = {
{ Boolean::New(instance_->isolate(), false).As<Value>(), false },
@@ -116,8 +116,8 @@ TEST_F(ConverterTest, Vector) {
expected.push_back(0);
expected.push_back(1);
- Handle<Array> js_array = Handle<Array>::Cast(
- Converter<std::vector<int> >::ToV8(instance_->isolate(), expected));
+ Local<Array> js_array = Local<Array>::Cast(
+ Converter<std::vector<int>>::ToV8(instance_->isolate(), expected));
ASSERT_FALSE(js_array.IsEmpty());
EXPECT_EQ(3u, js_array->Length());
for (size_t i = 0; i < expected.size(); ++i) {