This commit is contained in:
Cheng Zhao 2015-05-22 19:11:02 +08:00
Родитель 047a8de934
Коммит 269be86998
23 изменённых файлов: 238 добавлений и 238 удалений

Просмотреть файл

@ -26,13 +26,13 @@ Arguments::Arguments(const MATE_METHOD_ARGS_TYPE& info)
Arguments::~Arguments() {
}
v8::Handle<v8::Value> Arguments::PeekNext() const {
v8::Local<v8::Value> Arguments::PeekNext() const {
if (next_ >= info_->Length())
return v8::Handle<v8::Value>();
return v8::Local<v8::Value>();
return (*info_)[next_];
}
v8::Handle<v8::Value> Arguments::ThrowError() const {
v8::Local<v8::Value> Arguments::ThrowError() const {
if (insufficient_arguments_)
return ThrowTypeError("Insufficient number of arguments.");
@ -40,13 +40,13 @@ v8::Handle<v8::Value> Arguments::ThrowError() const {
"Error processing argument %d.", next_ - 1));
}
v8::Handle<v8::Value> Arguments::ThrowError(const std::string& message) const {
v8::Local<v8::Value> Arguments::ThrowError(const std::string& message) const {
MATE_THROW_EXCEPTION(isolate_, v8::Exception::Error(
StringToV8(isolate_, message)));
return MATE_UNDEFINED(isolate_);
}
v8::Handle<v8::Value> Arguments::ThrowTypeError(
v8::Local<v8::Value> Arguments::ThrowTypeError(
const std::string& message) const {
MATE_THROW_EXCEPTION(isolate_, v8::Exception::TypeError(
StringToV8(isolate_, message)));

Просмотреть файл

@ -36,7 +36,7 @@ class Arguments {
insufficient_arguments_ = true;
return false;
}
v8::Handle<v8::Value> val = (*info_)[next_++];
v8::Local<v8::Value> val = (*info_)[next_++];
return ConvertFromV8(isolate_, val, out);
}
@ -49,14 +49,14 @@ class Arguments {
int remaining = info_->Length() - next_;
out->resize(remaining);
for (int i = 0; i < remaining; ++i) {
v8::Handle<v8::Value> val = (*info_)[next_++];
v8::Local<v8::Value> val = (*info_)[next_++];
if (!ConvertFromV8(isolate_, val, &out->at(i)))
return false;
}
return true;
}
v8::Handle<v8::Object> GetThis() {
v8::Local<v8::Object> GetThis() {
return info_->This();
}
@ -75,11 +75,11 @@ class Arguments {
}
#endif
v8::Handle<v8::Value> PeekNext() const;
v8::Local<v8::Value> PeekNext() const;
v8::Handle<v8::Value> ThrowError() const;
v8::Handle<v8::Value> ThrowError(const std::string& message) const;
v8::Handle<v8::Value> ThrowTypeError(const std::string& message) const;
v8::Local<v8::Value> ThrowError() const;
v8::Local<v8::Value> ThrowError(const std::string& message) const;
v8::Local<v8::Value> ThrowTypeError(const std::string& message) const;
v8::Isolate* isolate() const { return isolate_; }

Просмотреть файл

@ -28,8 +28,8 @@ struct V8FunctionInvoker<R()> {
R ret;
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> val(holder->Call(holder, 0, NULL));
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> val(holder->Call(holder, 0, NULL));
Converter<R>::FromV8(isolate, val, &ret);
return ret;
}
@ -40,7 +40,7 @@ struct V8FunctionInvoker<void()> {
static void Go(v8::Isolate* isolate, SafeV8Function function) {
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Local<v8::Function> holder = function->NewHandle();
holder->Call(holder, 0, NULL);
}
};
@ -51,11 +51,11 @@ struct V8FunctionInvoker<R(P1)> {
R ret;
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
};
v8::Handle<v8::Value> val(holder->Call(holder, arraysize(args), args));
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
Converter<R>::FromV8(isolate, val, &ret);
return ret;
}
@ -66,8 +66,8 @@ struct V8FunctionInvoker<void(P1)> {
static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1) {
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
};
holder->Call(holder, arraysize(args), args);
@ -80,12 +80,12 @@ struct V8FunctionInvoker<R(P1, P2)> {
R ret;
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
};
v8::Handle<v8::Value> val(holder->Call(holder, arraysize(args), args));
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
Converter<R>::FromV8(isolate, val, &ret);
return ret;
}
@ -96,8 +96,8 @@ struct V8FunctionInvoker<void(P1, P2)> {
static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2) {
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
};
@ -112,13 +112,13 @@ struct V8FunctionInvoker<R(P1, P2, P3)> {
R ret;
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
ConvertToV8(isolate, a3),
};
v8::Handle<v8::Value> val(holder->Call(holder, arraysize(args), args));
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
Converter<R>::FromV8(isolate, val, &ret);
return ret;
}
@ -130,8 +130,8 @@ struct V8FunctionInvoker<void(P1, P2, P3)> {
P3 a3) {
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
ConvertToV8(isolate, a3),
@ -147,14 +147,14 @@ struct V8FunctionInvoker<R(P1, P2, P3, P4)> {
R ret;
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
ConvertToV8(isolate, a3),
ConvertToV8(isolate, a4),
};
v8::Handle<v8::Value> val(holder->Call(holder, arraysize(args), args));
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
Converter<R>::FromV8(isolate, val, &ret);
return ret;
}
@ -166,8 +166,8 @@ struct V8FunctionInvoker<void(P1, P2, P3, P4)> {
P3 a3, P4 a4) {
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
ConvertToV8(isolate, a3),
@ -185,15 +185,15 @@ struct V8FunctionInvoker<R(P1, P2, P3, P4, P5)> {
R ret;
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
ConvertToV8(isolate, a3),
ConvertToV8(isolate, a4),
ConvertToV8(isolate, a5),
};
v8::Handle<v8::Value> val(holder->Call(holder, arraysize(args), args));
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
Converter<R>::FromV8(isolate, val, &ret);
return ret;
}
@ -205,8 +205,8 @@ struct V8FunctionInvoker<void(P1, P2, P3, P4, P5)> {
P3 a3, P4 a4, P5 a5) {
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
ConvertToV8(isolate, a3),
@ -225,8 +225,8 @@ struct V8FunctionInvoker<R(P1, P2, P3, P4, P5, P6)> {
R ret;
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
ConvertToV8(isolate, a3),
@ -234,7 +234,7 @@ struct V8FunctionInvoker<R(P1, P2, P3, P4, P5, P6)> {
ConvertToV8(isolate, a5),
ConvertToV8(isolate, a6),
};
v8::Handle<v8::Value> val(holder->Call(holder, arraysize(args), args));
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
Converter<R>::FromV8(isolate, val, &ret);
return ret;
}
@ -247,8 +247,8 @@ struct V8FunctionInvoker<void(P1, P2, P3, P4, P5, P6)> {
P3 a3, P4 a4, P5 a5, P6 a6) {
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Function> holder = function->NewHandle();
v8::Local<v8::Value> args[] = {
ConvertToV8(isolate, a1),
ConvertToV8(isolate, a2),
ConvertToV8(isolate, a3),
@ -264,12 +264,12 @@ struct V8FunctionInvoker<void(P1, P2, P3, P4, P5, P6)> {
template<typename Sig>
struct Converter<base::Callback<Sig> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::Callback<Sig>& val) {
return CreateFunctionTemplate(isolate, val)->GetFunction();
}
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
base::Callback<Sig>* out) {
if (!val->IsFunction())
return false;

Просмотреть файл

@ -35,19 +35,19 @@ struct V8FunctionInvoker<R($for ARG , [[P$(ARG)]])> {
R ret;
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Local<v8::Function> holder = function->NewHandle();
$if ARITY == 0 [[
v8::Handle<v8::Value> val(holder->Call(holder, 0, NULL));
v8::Local<v8::Value> val(holder->Call(holder, 0, NULL));
]] $else [[
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Value> args[] = {
$for ARG [[
ConvertToV8(isolate, a$(ARG)),
]]
};
v8::Handle<v8::Value> val(holder->Call(holder, arraysize(args), args));
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
]]
Converter<R>::FromV8(isolate, val, &ret);
@ -60,12 +60,12 @@ struct V8FunctionInvoker<void($for ARG , [[P$(ARG)]])> {
static void Go(v8::Isolate* isolate, SafeV8Function function$for ARG [[, P$(ARG) a$(ARG)]]) {
Locker locker(isolate);
MATE_HANDLE_SCOPE(isolate);
v8::Handle<v8::Function> holder = function->NewHandle();
v8::Local<v8::Function> holder = function->NewHandle();
$if ARITY == 0 [[
holder->Call(holder, 0, NULL);
]] $else [[
v8::Handle<v8::Value> args[] = {
v8::Local<v8::Value> args[] = {
$for ARG [[
ConvertToV8(isolate, a$(ARG)),
@ -84,12 +84,12 @@ $for ARG [[
template<typename Sig>
struct Converter<base::Callback<Sig> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::Callback<Sig>& val) {
return CreateFunctionTemplate(isolate, val)->GetFunction();
}
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
base::Callback<Sig>* out) {
if (!val->IsFunction())
return false;

Просмотреть файл

@ -69,7 +69,7 @@
#define MATE_HANDLE_SCOPE(isolate) v8::HandleScope handle_scope
#define MATE_METHOD_ARGS_TYPE v8::Arguments
#define MATE_METHOD_RETURN_TYPE v8::Handle<v8::Value>
#define MATE_METHOD_RETURN_TYPE v8::Local<v8::Value>
#define MATE_METHOD_RETURN_VALUE(value) return value
#define MATE_METHOD_RETURN_UNDEFINED() return v8::Undefined()

Просмотреть файл

@ -133,7 +133,7 @@ class Constructor {
MATE_PERSISTENT_RESET(constructor_);
}
v8::Handle<v8::FunctionTemplate> GetFunctionTemplate(
v8::Local<v8::FunctionTemplate> GetFunctionTemplate(
v8::Isolate* isolate, const WrappableFactoryFunction& factory) {
if (constructor_.IsEmpty()) {
v8::Local<v8::FunctionTemplate> constructor = CreateFunctionTemplate(

Просмотреть файл

@ -69,7 +69,7 @@ class Constructor {
MATE_PERSISTENT_RESET(constructor_);
}
v8::Handle<v8::FunctionTemplate> GetFunctionTemplate(
v8::Local<v8::FunctionTemplate> GetFunctionTemplate(
v8::Isolate* isolate, const WrappableFactoryFunction& factory) {
if (constructor_.IsEmpty()) {
v8::Local<v8::FunctionTemplate> constructor = CreateFunctionTemplate(

Просмотреть файл

@ -10,9 +10,9 @@
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,11 +20,11 @@ using v8::Value;
namespace mate {
Handle<Value> Converter<bool>::ToV8(Isolate* isolate, bool val) {
Local<Value> Converter<bool>::ToV8(Isolate* isolate, bool val) {
return MATE_BOOLEAN_NEW(isolate, val);
}
bool Converter<bool>::FromV8(Isolate* isolate, Handle<Value> val, bool* out) {
bool Converter<bool>::FromV8(Isolate* isolate, Local<Value> val, bool* out) {
if (!val->IsBoolean())
return false;
*out = val->BooleanValue();
@ -32,12 +32,12 @@ bool Converter<bool>::FromV8(Isolate* isolate, Handle<Value> val, bool* out) {
}
#if !defined(OS_LINUX)
Handle<Value> Converter<unsigned long>::ToV8(Isolate* isolate,
Local<Value> Converter<unsigned long>::ToV8(Isolate* isolate,
unsigned long val) {
return MATE_INTEGER_NEW(isolate, val);
}
bool Converter<unsigned long>::FromV8(Isolate* isolate, Handle<Value> val,
bool Converter<unsigned long>::FromV8(Isolate* isolate, Local<Value> val,
unsigned long* out) {
if (!val->IsNumber())
return false;
@ -46,11 +46,11 @@ bool Converter<unsigned long>::FromV8(Isolate* isolate, Handle<Value> val,
}
#endif
Handle<Value> Converter<int32_t>::ToV8(Isolate* isolate, int32_t val) {
Local<Value> Converter<int32_t>::ToV8(Isolate* isolate, int32_t val) {
return MATE_INTEGER_NEW(isolate, val);
}
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;
@ -58,11 +58,11 @@ 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 MATE_INTEGER_NEW_UNSIGNED(isolate, val);
}
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;
@ -70,11 +70,11 @@ 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 MATE_NUMBER_NEW(isolate, static_cast<double>(val));
}
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;
@ -84,11 +84,11 @@ 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 MATE_NUMBER_NEW(isolate, static_cast<double>(val));
}
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;
@ -96,11 +96,11 @@ 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 MATE_NUMBER_NEW(isolate, val);
}
bool Converter<float>::FromV8(Isolate* isolate, Handle<Value> val,
bool Converter<float>::FromV8(Isolate* isolate, Local<Value> val,
float* out) {
if (!val->IsNumber())
return false;
@ -108,11 +108,11 @@ bool Converter<float>::FromV8(Isolate* isolate, Handle<Value> val,
return true;
}
Handle<Value> Converter<double>::ToV8(Isolate* isolate, double val) {
Local<Value> Converter<double>::ToV8(Isolate* isolate, double val) {
return MATE_NUMBER_NEW(isolate, val);
}
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;
@ -120,100 +120,100 @@ bool Converter<double>::FromV8(Isolate* isolate, Handle<Value> val,
return true;
}
Handle<Value> Converter<const char*>::ToV8(
Local<Value> Converter<const char*>::ToV8(
Isolate* isolate, const char* val) {
return MATE_STRING_NEW_FROM_UTF8(isolate, val, -1);
}
Handle<Value> Converter<base::StringPiece>::ToV8(
Local<Value> Converter<base::StringPiece>::ToV8(
Isolate* isolate, const base::StringPiece& val) {
return MATE_STRING_NEW_FROM_UTF8(isolate, val.data(),
static_cast<uint32_t>(val.length()));
}
Handle<Value> Converter<std::string>::ToV8(Isolate* isolate,
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;
}
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<String> >::ToV8(Isolate* isolate,
Handle<String> val) {
Local<Value> Converter<Local<String> >::ToV8(Isolate* isolate,
Local<String> val) {
return val;
}
bool Converter<Handle<String> >::FromV8(Isolate* isolate, Handle<Value> val,
Handle<String>* out) {
bool Converter<Local<String> >::FromV8(Isolate* isolate, Local<Value> val,
Local<String>* out) {
if (!val->IsString())
return false;
*out = Handle<String>::Cast(val);
*out = Local<String>::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;
}
bool Converter<Handle<External> >::FromV8(Isolate* isolate,
v8::Handle<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;
}
v8::Handle<v8::String> StringToSymbol(v8::Isolate* isolate,
v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
const base::StringPiece& val) {
return MATE_STRING_NEW_SYMBOL(isolate,
val.data(),
static_cast<uint32_t>(val.length()));
}
std::string V8ToString(v8::Handle<v8::Value> value) {
std::string V8ToString(v8::Local<v8::Value> value) {
if (value.IsEmpty())
return std::string();
std::string result;

Просмотреть файл

@ -20,156 +20,156 @@ struct Converter {};
template<>
struct Converter<void*> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, void* val) {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, void* val) {
return MATE_UNDEFINED(isolate);
}
};
template<>
struct Converter<bool> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
bool val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
bool* out);
};
#if !defined(OS_LINUX)
template<>
struct Converter<unsigned long> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
unsigned long val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
unsigned long* out);
};
#endif
template<>
struct Converter<int32_t> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
int32_t val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
int32_t* out);
};
template<>
struct Converter<uint32_t> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
uint32_t val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
uint32_t* out);
};
template<>
struct Converter<int64_t> {
// Warning: JavaScript cannot represent 64 integers precisely.
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
int64_t val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
int64_t* out);
};
template<>
struct Converter<uint64_t> {
// Warning: JavaScript cannot represent 64 integers precisely.
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
uint64_t val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
uint64_t* out);
};
template<>
struct Converter<float> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
float val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
float* out);
};
template<>
struct Converter<double> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
double val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
double* out);
};
template<>
struct Converter<const char*> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, const char* val);
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, const char* val);
};
template<>
struct Converter<base::StringPiece> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::StringPiece& val);
// No conversion out is possible because StringPiece does not contain storage.
};
template<>
struct Converter<std::string> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const std::string& val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
std::string* out);
};
template<>
struct Converter<v8::Handle<v8::Function> > {
struct Converter<v8::Local<v8::Function> > {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Handle<v8::Function>* out);
v8::Local<v8::Value> val,
v8::Local<v8::Function>* out);
};
template<>
struct Converter<v8::Handle<v8::Object> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
v8::Handle<v8::Object> val);
struct Converter<v8::Local<v8::Object> > {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
v8::Local<v8::Object> val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Handle<v8::Object>* out);
v8::Local<v8::Value> val,
v8::Local<v8::Object>* out);
};
template<>
struct Converter<v8::Handle<v8::String> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
v8::Handle<v8::String> val);
struct Converter<v8::Local<v8::String> > {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
v8::Local<v8::String> val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Handle<v8::String>* out);
v8::Local<v8::Value> val,
v8::Local<v8::String>* out);
};
template<>
struct Converter<v8::Handle<v8::External> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
v8::Handle<v8::External> val);
struct Converter<v8::Local<v8::External> > {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
v8::Local<v8::External> val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Handle<v8::External>* out);
v8::Local<v8::Value> val,
v8::Local<v8::External>* out);
};
template<>
struct Converter<v8::Handle<v8::Value> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val);
struct Converter<v8::Local<v8::Value> > {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
v8::Local<v8::Value> val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Handle<v8::Value>* out);
v8::Local<v8::Value> val,
v8::Local<v8::Value>* out);
};
template<typename T>
struct Converter<std::vector<T> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const std::vector<T>& val) {
v8::Handle<v8::Array> result(
v8::Local<v8::Array> result(
MATE_ARRAY_NEW(isolate, static_cast<int>(val.size())));
for (size_t i = 0; i < val.size(); ++i) {
result->Set(static_cast<int>(i), Converter<T>::ToV8(isolate, val[i]));
@ -178,13 +178,13 @@ struct Converter<std::vector<T> > {
}
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
std::vector<T>* out) {
if (!val->IsArray())
return false;
std::vector<T> result;
v8::Handle<v8::Array> array(v8::Handle<v8::Array>::Cast(val));
v8::Local<v8::Array> array(v8::Local<v8::Array>::Cast(val));
uint32_t length = array->Length();
for (uint32_t i = 0; i < length; ++i) {
T item;
@ -200,9 +200,9 @@ struct Converter<std::vector<T> > {
template<typename T>
struct Converter<std::set<T> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const std::set<T>& val) {
v8::Handle<v8::Array> result(
v8::Local<v8::Array> result(
MATE_ARRAY_NEW(isolate, static_cast<int>(val.size())));
typename std::set<T>::const_iterator it;
int i;
@ -212,13 +212,13 @@ struct Converter<std::set<T> > {
}
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
std::set<T>* out) {
if (!val->IsArray())
return false;
std::set<T> result;
v8::Handle<v8::Array> array(v8::Handle<v8::Array>::Cast(val));
v8::Local<v8::Array> array(v8::Local<v8::Array>::Cast(val));
uint32_t length = array->Length();
for (uint32_t i = 0; i < length; ++i) {
T item;
@ -234,32 +234,32 @@ struct Converter<std::set<T> > {
// Convenience functions that deduce T.
template<typename T>
v8::Handle<v8::Value> ConvertToV8(v8::Isolate* isolate,
v8::Local<v8::Value> ConvertToV8(v8::Isolate* isolate,
const T& input) {
return Converter<T>::ToV8(isolate, input);
}
inline v8::Handle<v8::Value> ConvertToV8(v8::Isolate* isolate,
inline v8::Local<v8::Value> ConvertToV8(v8::Isolate* isolate,
const char* input) {
return Converter<const char*>::ToV8(isolate, input);
}
inline v8::Handle<v8::String> StringToV8(
inline v8::Local<v8::String> StringToV8(
v8::Isolate* isolate,
const base::StringPiece& input) {
return ConvertToV8(isolate, input).As<v8::String>();
}
v8::Handle<v8::String> StringToSymbol(v8::Isolate* isolate,
v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
const base::StringPiece& input);
template<typename T>
bool ConvertFromV8(v8::Isolate* isolate, v8::Handle<v8::Value> input,
bool ConvertFromV8(v8::Isolate* isolate, v8::Local<v8::Value> input,
T* result) {
return Converter<T>::FromV8(isolate, input, result);
}
std::string V8ToString(v8::Handle<v8::Value> value);
std::string V8ToString(v8::Local<v8::Value> value);
} // namespace mate

Просмотреть файл

@ -11,7 +11,7 @@ Dictionary::Dictionary()
}
Dictionary::Dictionary(v8::Isolate* isolate,
v8::Handle<v8::Object> object)
v8::Local<v8::Object> object)
: isolate_(isolate),
object_(object) {
}
@ -19,21 +19,21 @@ Dictionary::Dictionary(v8::Isolate* isolate,
Dictionary::~Dictionary() {
}
v8::Handle<v8::Object> Dictionary::GetHandle() const {
v8::Local<v8::Object> Dictionary::GetHandle() const {
return object_;
}
v8::Handle<v8::Value> Converter<Dictionary>::ToV8(v8::Isolate* isolate,
v8::Local<v8::Value> Converter<Dictionary>::ToV8(v8::Isolate* isolate,
Dictionary val) {
return val.GetHandle();
}
bool Converter<Dictionary>::FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
Dictionary* out) {
if (!val->IsObject())
return false;
*out = Dictionary(isolate, v8::Handle<v8::Object>::Cast(val));
*out = Dictionary(isolate, v8::Local<v8::Object>::Cast(val));
return true;
}

Просмотреть файл

@ -25,12 +25,12 @@ namespace mate {
class Dictionary {
public:
Dictionary();
Dictionary(v8::Isolate* isolate, v8::Handle<v8::Object> object);
Dictionary(v8::Isolate* isolate, v8::Local<v8::Object> object);
~Dictionary();
template<typename T>
bool Get(const base::StringPiece& key, T* out) const {
v8::Handle<v8::Value> val = GetHandle()->Get(StringToV8(isolate_, key));
v8::Local<v8::Value> val = GetHandle()->Get(StringToV8(isolate_, key));
return ConvertFromV8(isolate_, val, out);
}
@ -49,7 +49,7 @@ class Dictionary {
bool IsEmpty() const { return isolate() == NULL; }
virtual v8::Handle<v8::Object> GetHandle() const;
virtual v8::Local<v8::Object> GetHandle() const;
v8::Isolate* isolate() const { return isolate_; }
@ -57,15 +57,15 @@ class Dictionary {
v8::Isolate* isolate_;
private:
v8::Handle<v8::Object> object_;
v8::Local<v8::Object> object_;
};
template<>
struct Converter<Dictionary> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
Dictionary val);
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
Dictionary* out);
};

Просмотреть файл

@ -17,7 +17,7 @@ CallbackHolderBase::~CallbackHolderBase() {
DCHECK(v8_ref_.IsEmpty());
}
v8::Handle<v8::External> CallbackHolderBase::GetHandle(v8::Isolate* isolate) {
v8::Local<v8::External> CallbackHolderBase::GetHandle(v8::Isolate* isolate) {
return MATE_PERSISTENT_TO_LOCAL(v8::External, isolate, v8_ref_);
}

Просмотреть файл

@ -48,7 +48,7 @@ struct CallbackParamTraits<const T*> {
// among every CallbackHolder instance.
class CallbackHolderBase {
public:
v8::Handle<v8::External> GetHandle(v8::Isolate* isolate);
v8::Local<v8::External> GetHandle(v8::Isolate* isolate);
protected:
explicit CallbackHolderBase(v8::Isolate* isolate);
@ -333,7 +333,7 @@ template<typename R>
struct Dispatcher<R()> {
static MATE_METHOD(DispatchToCallback) {
Arguments args(info);
v8::Handle<v8::External> v8_holder;
v8::Local<v8::External> v8_holder;
CHECK(args.GetData(&v8_holder));
CallbackHolderBase* holder_base = reinterpret_cast<CallbackHolderBase*>(
v8_holder->Value());
@ -349,7 +349,7 @@ template<typename R, typename P1>
struct Dispatcher<R(P1)> {
static MATE_METHOD(DispatchToCallback) {
Arguments args(info);
v8::Handle<v8::External> v8_holder;
v8::Local<v8::External> v8_holder;
CHECK(args.GetData(&v8_holder));
CallbackHolderBase* holder_base = reinterpret_cast<CallbackHolderBase*>(
v8_holder->Value());
@ -371,7 +371,7 @@ template<typename R, typename P1, typename P2>
struct Dispatcher<R(P1, P2)> {
static MATE_METHOD(DispatchToCallback) {
Arguments args(info);
v8::Handle<v8::External> v8_holder;
v8::Local<v8::External> v8_holder;
CHECK(args.GetData(&v8_holder));
CallbackHolderBase* holder_base = reinterpret_cast<CallbackHolderBase*>(
v8_holder->Value());
@ -395,7 +395,7 @@ template<typename R, typename P1, typename P2, typename P3>
struct Dispatcher<R(P1, P2, P3)> {
static MATE_METHOD(DispatchToCallback) {
Arguments args(info);
v8::Handle<v8::External> v8_holder;
v8::Local<v8::External> v8_holder;
CHECK(args.GetData(&v8_holder));
CallbackHolderBase* holder_base = reinterpret_cast<CallbackHolderBase*>(
v8_holder->Value());
@ -421,7 +421,7 @@ template<typename R, typename P1, typename P2, typename P3, typename P4>
struct Dispatcher<R(P1, P2, P3, P4)> {
static MATE_METHOD(DispatchToCallback) {
Arguments args(info);
v8::Handle<v8::External> v8_holder;
v8::Local<v8::External> v8_holder;
CHECK(args.GetData(&v8_holder));
CallbackHolderBase* holder_base = reinterpret_cast<CallbackHolderBase*>(
v8_holder->Value());
@ -451,7 +451,7 @@ template<typename R, typename P1, typename P2, typename P3, typename P4,
struct Dispatcher<R(P1, P2, P3, P4, P5)> {
static MATE_METHOD(DispatchToCallback) {
Arguments args(info);
v8::Handle<v8::External> v8_holder;
v8::Local<v8::External> v8_holder;
CHECK(args.GetData(&v8_holder));
CallbackHolderBase* holder_base = reinterpret_cast<CallbackHolderBase*>(
v8_holder->Value());
@ -483,7 +483,7 @@ template<typename R, typename P1, typename P2, typename P3, typename P4,
struct Dispatcher<R(P1, P2, P3, P4, P5, P6)> {
static MATE_METHOD(DispatchToCallback) {
Arguments args(info);
v8::Handle<v8::External> v8_holder;
v8::Local<v8::External> v8_holder;
CHECK(args.GetData(&v8_holder));
CallbackHolderBase* holder_base = reinterpret_cast<CallbackHolderBase*>(
v8_holder->Value());
@ -517,7 +517,7 @@ template<typename R, typename P1, typename P2, typename P3, typename P4,
struct Dispatcher<R(P1, P2, P3, P4, P5, P6, P7)> {
static MATE_METHOD(DispatchToCallback) {
Arguments args(info);
v8::Handle<v8::External> v8_holder;
v8::Local<v8::External> v8_holder;
CHECK(args.GetData(&v8_holder));
CallbackHolderBase* holder_base = reinterpret_cast<CallbackHolderBase*>(
v8_holder->Value());
@ -567,7 +567,7 @@ v8::Local<v8::FunctionTemplate> CreateFunctionTemplate(
isolate,
#endif
&internal::Dispatcher<Sig>::DispatchToCallback,
ConvertToV8<v8::Handle<v8::External> >(isolate,
ConvertToV8<v8::Local<v8::External> >(isolate,
holder->GetHandle(isolate)));
}

Просмотреть файл

@ -51,7 +51,7 @@ struct CallbackParamTraits<const T*> {
// among every CallbackHolder instance.
class CallbackHolderBase {
public:
v8::Handle<v8::External> GetHandle(v8::Isolate* isolate);
v8::Local<v8::External> GetHandle(v8::Isolate* isolate);
protected:
explicit CallbackHolderBase(v8::Isolate* isolate);
@ -169,7 +169,7 @@ template<typename R$for ARG [[, typename P$(ARG)]]>
struct Dispatcher<R($for ARG , [[P$(ARG)]])> {
static MATE_METHOD(DispatchToCallback) {
Arguments args(info);
v8::Handle<v8::External> v8_holder;
v8::Local<v8::External> v8_holder;
CHECK(args.GetData(&v8_holder));
CallbackHolderBase* holder_base = reinterpret_cast<CallbackHolderBase*>(
v8_holder->Value());
@ -216,7 +216,7 @@ v8::Local<v8::FunctionTemplate> CreateFunctionTemplate(
isolate,
#endif
&internal::Dispatcher<Sig>::DispatchToCallback,
ConvertToV8<v8::Handle<v8::External> >(isolate,
ConvertToV8<v8::Local<v8::External> >(isolate,
holder->GetHandle(isolate)));
}

Просмотреть файл

@ -18,7 +18,7 @@ class Handle {
public:
Handle() : object_(NULL) {}
Handle(v8::Handle<v8::Value> wrapper, T* object)
Handle(v8::Local<v8::Value> wrapper, T* object)
: wrapper_(wrapper),
object_(object) {
}
@ -31,21 +31,21 @@ class Handle {
}
T* operator->() const { return object_; }
v8::Handle<v8::Value> ToV8() const { return wrapper_; }
v8::Local<v8::Value> ToV8() const { return wrapper_; }
T* get() const { return object_; }
private:
v8::Handle<v8::Value> wrapper_;
v8::Local<v8::Value> wrapper_;
T* object_;
};
template<typename T>
struct Converter<mate::Handle<T> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const mate::Handle<T>& val) {
return val.ToV8();
}
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
mate::Handle<T>* out) {
T* object = NULL;
if (!Converter<T*>::FromV8(isolate, val, &object)) {

Просмотреть файл

@ -17,14 +17,14 @@ ObjectTemplateBuilder::~ObjectTemplateBuilder() {
}
ObjectTemplateBuilder& ObjectTemplateBuilder::SetImpl(
const base::StringPiece& name, v8::Handle<v8::Data> val) {
const base::StringPiece& name, v8::Local<v8::Data> val) {
template_->Set(StringToSymbol(isolate_, name), val);
return *this;
}
ObjectTemplateBuilder& ObjectTemplateBuilder::SetPropertyImpl(
const base::StringPiece& name, v8::Handle<v8::FunctionTemplate> getter,
v8::Handle<v8::FunctionTemplate> setter) {
const base::StringPiece& name, v8::Local<v8::FunctionTemplate> getter,
v8::Local<v8::FunctionTemplate> setter) {
#if NODE_VERSION_AT_LEAST(0, 11, 0)
template_->SetAccessorProperty(StringToSymbol(isolate_, name), getter,
setter);

Просмотреть файл

@ -22,7 +22,7 @@ namespace {
// because of base::Bind().
template<typename T, typename Enable = void>
struct CallbackTraits {
static v8::Handle<v8::FunctionTemplate> CreateTemplate(v8::Isolate* isolate,
static v8::Local<v8::FunctionTemplate> CreateTemplate(v8::Isolate* isolate,
T callback) {
return CreateFunctionTemplate(isolate, base::Bind(callback));
}
@ -31,7 +31,7 @@ struct CallbackTraits {
// Specialization for base::Callback.
template<typename T>
struct CallbackTraits<base::Callback<T> > {
static v8::Handle<v8::FunctionTemplate> CreateTemplate(
static v8::Local<v8::FunctionTemplate> CreateTemplate(
v8::Isolate* isolate, const base::Callback<T>& callback) {
return CreateFunctionTemplate(isolate, callback);
}
@ -44,7 +44,7 @@ struct CallbackTraits<base::Callback<T> > {
template<typename T>
struct CallbackTraits<T, typename enable_if<
is_member_function_pointer<T>::value>::type> {
static v8::Handle<v8::FunctionTemplate> CreateTemplate(v8::Isolate* isolate,
static v8::Local<v8::FunctionTemplate> CreateTemplate(v8::Isolate* isolate,
T callback) {
return CreateFunctionTemplate(isolate, base::Bind(callback),
HolderIsFirstArgument);
@ -54,9 +54,9 @@ struct CallbackTraits<T, typename enable_if<
// This specialization allows people to construct function templates directly if
// they need to do fancier stuff.
template<>
struct CallbackTraits<v8::Handle<v8::FunctionTemplate> > {
static v8::Handle<v8::FunctionTemplate> CreateTemplate(
v8::Handle<v8::FunctionTemplate> templ) {
struct CallbackTraits<v8::Local<v8::FunctionTemplate> > {
static v8::Local<v8::FunctionTemplate> CreateTemplate(
v8::Local<v8::FunctionTemplate> templ) {
return templ;
}
};
@ -109,10 +109,10 @@ class ObjectTemplateBuilder {
private:
ObjectTemplateBuilder& SetImpl(const base::StringPiece& name,
v8::Handle<v8::Data> val);
v8::Local<v8::Data> val);
ObjectTemplateBuilder& SetPropertyImpl(
const base::StringPiece& name, v8::Handle<v8::FunctionTemplate> getter,
v8::Handle<v8::FunctionTemplate> setter);
const base::StringPiece& name, v8::Local<v8::FunctionTemplate> getter,
v8::Local<v8::FunctionTemplate> setter);
v8::Isolate* isolate_;

Просмотреть файл

@ -10,7 +10,7 @@ PersistentDictionary::PersistentDictionary() {
}
PersistentDictionary::PersistentDictionary(v8::Isolate* isolate,
v8::Handle<v8::Object> object)
v8::Local<v8::Object> object)
: handle_(new RefCountedPersistent<v8::Object>(isolate, object)) {
isolate_ = isolate;
}
@ -18,16 +18,16 @@ PersistentDictionary::PersistentDictionary(v8::Isolate* isolate,
PersistentDictionary::~PersistentDictionary() {
}
v8::Handle<v8::Object> PersistentDictionary::GetHandle() const {
v8::Local<v8::Object> PersistentDictionary::GetHandle() const {
return handle_->NewHandle();
}
bool Converter<PersistentDictionary>::FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
PersistentDictionary* out) {
if (!val->IsObject())
return false;
*out = PersistentDictionary(isolate, v8::Handle<v8::Object>::Cast(val));
*out = PersistentDictionary(isolate, v8::Local<v8::Object>::Cast(val));
return true;
}

Просмотреть файл

@ -15,10 +15,10 @@ namespace mate {
class PersistentDictionary : public Dictionary {
public:
PersistentDictionary();
PersistentDictionary(v8::Isolate* isolate, v8::Handle<v8::Object> object);
PersistentDictionary(v8::Isolate* isolate, v8::Local<v8::Object> object);
virtual ~PersistentDictionary();
v8::Handle<v8::Object> GetHandle() const override;
v8::Local<v8::Object> GetHandle() const override;
private:
scoped_refptr<RefCountedPersistent<v8::Object> > handle_;
@ -27,7 +27,7 @@ class PersistentDictionary : public Dictionary {
template<>
struct Converter<PersistentDictionary> {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
PersistentDictionary* out);
};

Просмотреть файл

@ -18,16 +18,16 @@ class ScopedPersistent {
public:
ScopedPersistent() : isolate_(v8::Isolate::GetCurrent()) {}
ScopedPersistent(v8::Isolate* isolate, v8::Handle<v8::Value> handle)
ScopedPersistent(v8::Isolate* isolate, v8::Local<v8::Value> handle)
: isolate_(isolate) {
reset(isolate, v8::Handle<T>::Cast(handle));
reset(isolate, v8::Local<T>::Cast(handle));
}
~ScopedPersistent() {
reset();
}
void reset(v8::Isolate* isolate, v8::Handle<T> handle) {
void reset(v8::Isolate* isolate, v8::Local<T> handle) {
if (!handle.IsEmpty()) {
isolate_ = isolate;
MATE_PERSISTENT_ASSIGN(T, isolate, handle_, handle);
@ -44,11 +44,11 @@ class ScopedPersistent {
return handle_.IsEmpty();
}
v8::Handle<T> NewHandle() const {
v8::Local<T> NewHandle() const {
return NewHandle(isolate_);
}
v8::Handle<T> NewHandle(v8::Isolate* isolate) const {
v8::Local<T> NewHandle(v8::Isolate* isolate) const {
if (handle_.IsEmpty())
return v8::Local<T>();
return MATE_PERSISTENT_TO_LOCAL(T, isolate, handle_);
@ -74,7 +74,7 @@ class RefCountedPersistent : public ScopedPersistent<T>,
public:
RefCountedPersistent() {}
RefCountedPersistent(v8::Isolate* isolate, v8::Handle<v8::Value> handle)
RefCountedPersistent(v8::Isolate* isolate, v8::Local<v8::Value> handle)
: ScopedPersistent<T>(isolate, handle) {
}
@ -89,16 +89,16 @@ class RefCountedPersistent : public ScopedPersistent<T>,
template<typename T>
struct Converter<ScopedPersistent<T> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const ScopedPersistent<T>& val) {
return val.NewHandle(isolate);
}
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
ScopedPersistent<T>* out) {
v8::Handle<T> converted;
if (!Converter<v8::Handle<T> >::FromV8(isolate, val, &converted))
v8::Local<T> converted;
if (!Converter<v8::Local<T> >::FromV8(isolate, val, &converted))
return false;
out->reset(isolate, converted);

Просмотреть файл

@ -26,17 +26,17 @@ std::string TryCatch::GetStackTrace() {
}
std::stringstream ss;
v8::Handle<v8::Message> message = try_catch_.Message();
v8::Local<v8::Message> message = try_catch_.Message();
ss << V8ToString(message->Get()) << std::endl
<< V8ToString(message->GetSourceLine()) << std::endl;
v8::Handle<v8::StackTrace> trace = message->GetStackTrace();
v8::Local<v8::StackTrace> trace = message->GetStackTrace();
if (trace.IsEmpty())
return ss.str();
int len = trace->GetFrameCount();
for (int i = 0; i < len; ++i) {
v8::Handle<v8::StackFrame> frame = trace->GetFrame(i);
v8::Local<v8::StackFrame> frame = trace->GetFrame(i);
ss << V8ToString(frame->GetScriptName()) << ":"
<< frame->GetLineNumber() << ":"
<< frame->GetColumn() << ": "

Просмотреть файл

@ -17,7 +17,7 @@ Wrappable::~Wrappable() {
MATE_PERSISTENT_RESET(wrapper_);
}
void Wrappable::Wrap(v8::Isolate* isolate, v8::Handle<v8::Object> wrapper) {
void Wrappable::Wrap(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) {
if (!wrapper_.IsEmpty())
return;
@ -26,7 +26,7 @@ void Wrappable::Wrap(v8::Isolate* isolate, v8::Handle<v8::Object> wrapper) {
MATE_PERSISTENT_SET_WEAK(wrapper_, this, WeakCallback);
// Call object._init if we have one.
v8::Handle<v8::Function> init;
v8::Local<v8::Function> init;
if (Dictionary(isolate, wrapper).Get("_init", &init))
init->Call(wrapper, 0, NULL);
@ -35,7 +35,7 @@ void Wrappable::Wrap(v8::Isolate* isolate, v8::Handle<v8::Object> wrapper) {
// static
void Wrappable::BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype) {
v8::Local<v8::ObjectTemplate> prototype) {
}
ObjectTemplateBuilder Wrappable::GetObjectTemplateBuilder(
@ -49,7 +49,7 @@ MATE_WEAK_CALLBACK(Wrappable::WeakCallback, v8::Object, Wrappable) {
delete self;
}
v8::Handle<v8::Object> Wrappable::GetWrapper(v8::Isolate* isolate) {
v8::Local<v8::Object> Wrappable::GetWrapper(v8::Isolate* isolate) {
if (!wrapper_.IsEmpty())
return MATE_PERSISTENT_TO_LOCAL(v8::Object, isolate, wrapper_);
@ -57,17 +57,17 @@ v8::Handle<v8::Object> Wrappable::GetWrapper(v8::Isolate* isolate) {
GetObjectTemplateBuilder(isolate).Build();
CHECK(!templ.IsEmpty());
CHECK_EQ(1, templ->InternalFieldCount());
v8::Handle<v8::Object> wrapper = templ->NewInstance();
v8::Local<v8::Object> wrapper = templ->NewInstance();
Wrap(isolate, wrapper);
return wrapper;
}
namespace internal {
void* FromV8Impl(v8::Isolate* isolate, v8::Handle<v8::Value> val) {
void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val) {
if (!val->IsObject())
return NULL;
v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(val);
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(val);
if (obj->InternalFieldCount() != 1)
return NULL;
return MATE_GET_INTERNAL_FIELD_POINTER(obj, 0);

Просмотреть файл

@ -13,7 +13,7 @@ namespace mate {
namespace internal {
void* FromV8Impl(v8::Isolate* isolate, v8::Handle<v8::Value> val);
void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val);
} // namespace internal
@ -52,15 +52,15 @@ class Wrappable {
// If the type is created via the Constructor, then the GetWrapper would
// return the constructed object, otherwise it would try to create a new
// object constructed by GetObjectTemplateBuilder.
v8::Handle<v8::Object> GetWrapper(v8::Isolate* isolate);
v8::Local<v8::Object> GetWrapper(v8::Isolate* isolate);
// Bind the C++ class to the JS wrapper.
void Wrap(v8::Isolate* isolate, v8::Handle<v8::Object> wrapper);
void Wrap(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
// The user should define T::BuildPrototype if they want to use Constructor
// to build a constructor function for this type.
static void BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype);
v8::Local<v8::ObjectTemplate> prototype);
protected:
Wrappable();
@ -84,11 +84,11 @@ class Wrappable {
template<typename T>
struct Converter<T*, typename enable_if<
is_convertible<T*, Wrappable*>::value>::type> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, T* val) {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, T* val) {
return val->GetWrapper(isolate);
}
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val, T** out) {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val, T** out) {
*out = static_cast<T*>(static_cast<Wrappable*>(
internal::FromV8Impl(isolate, val)));
return *out != NULL;