Discard all our custom V8 helpers, use native-mate instead.

This commit is contained in:
Cheng Zhao 2014-04-22 23:07:21 +08:00
parent ef5342b86e
commit a040a96652
28 changed files with 484 additions and 1552 deletions

View file

@ -0,0 +1,34 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_GURL_CONVERTER_H_
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_GURL_CONVERTER_H_
#include "native_mate/converter.h"
#include "url/gurl.h"
namespace mate {
template<>
struct Converter<GURL> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
const GURL& val) {
return Converter<std::string>::ToV8(isolate, val.spec());
}
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
GURL* out) {
std::string url;
if (Converter<std::string>::FromV8(isolate, val, &url)) {
*out = GURL(url);
return true;
} else {
return false;
}
}
};
} // namespace mate
#endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_GURL_CONVERTER_H_

View file

@ -9,6 +9,20 @@
namespace mate {
bool Converter<base::DictionaryValue>::FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
base::DictionaryValue* out) {
scoped_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
scoped_ptr<base::Value> value(converter->FromV8Value(
val, v8::Context::GetCurrent()));
if (value->IsType(base::Value::TYPE_DICTIONARY)) {
out->Swap(static_cast<DictionaryValue*>(value.get()));
return true;
} else {
return false;
}
}
bool Converter<base::ListValue>::FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
base::ListValue* out) {

View file

@ -8,11 +8,19 @@
#include "native_mate/converter.h"
namespace base {
class DictionaryValue;
class ListValue;
}
namespace mate {
template<>
struct Converter<base::DictionaryValue> {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
base::DictionaryValue* out);
};
template<>
struct Converter<base::ListValue> {
static bool FromV8(v8::Isolate* isolate,