Use Local instead of Handle

This commit is contained in:
Cheng Zhao 2015-05-22 19:11:22 +08:00
parent b169ac016e
commit d78efe7c22
54 changed files with 185 additions and 185 deletions

View file

@ -42,7 +42,7 @@ namespace mate {
#if defined(OS_WIN)
template<>
struct Converter<Browser::UserTask> {
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
Browser::UserTask* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
@ -277,8 +277,8 @@ void DockSetMenu(atom::api::Menu* menu) {
}
#endif
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();
auto command_line = base::CommandLine::ForCurrentProcess();

View file

@ -77,8 +77,8 @@ mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("autoUpdater", atom::api::AutoUpdater::Create(isolate));

View file

@ -20,7 +20,7 @@ namespace mate {
template<>
struct Converter<base::trace_event::CategoryFilter> {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
base::trace_event::CategoryFilter* out) {
std::string filter;
if (!ConvertFromV8(isolate, val, &filter))
@ -33,7 +33,7 @@ struct Converter<base::trace_event::CategoryFilter> {
template<>
struct Converter<base::trace_event::TraceOptions> {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
base::trace_event::TraceOptions* out) {
std::string options;
if (!ConvertFromV8(isolate, val, &options))
@ -46,8 +46,8 @@ struct Converter<base::trace_event::TraceOptions> {
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
auto controller = base::Unretained(TracingController::GetInstance());
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("getCategories", base::Bind(

View file

@ -22,7 +22,7 @@ namespace mate {
template<>
struct Converter<file_dialog::Filter> {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
file_dialog::Filter* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
@ -52,7 +52,7 @@ void ShowMessageBox(int type,
const std::string& message = texts[1];
const std::string& detail = texts[2];
v8::Handle<v8::Value> peek = args->PeekNext();
v8::Local<v8::Value> peek = args->PeekNext();
atom::MessageBoxCallback callback;
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(),
peek,
@ -72,7 +72,7 @@ void ShowOpenDialog(const std::string& title,
int properties,
atom::NativeWindow* window,
mate::Arguments* args) {
v8::Handle<v8::Value> peek = args->PeekNext();
v8::Local<v8::Value> peek = args->PeekNext();
file_dialog::OpenDialogCallback callback;
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(args->isolate(),
peek,
@ -92,7 +92,7 @@ void ShowSaveDialog(const std::string& title,
const file_dialog::Filters& filters,
atom::NativeWindow* window,
mate::Arguments* args) {
v8::Handle<v8::Value> peek = args->PeekNext();
v8::Local<v8::Value> peek = args->PeekNext();
file_dialog::SaveDialogCallback callback;
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(args->isolate(),
peek,
@ -106,8 +106,8 @@ void ShowSaveDialog(const std::string& title,
}
}
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("showMessageBox", &ShowMessageBox);
dict.SetMethod("showErrorBox", &atom::ShowErrorBox);

View file

@ -86,8 +86,8 @@ mate::Handle<GlobalShortcut> GlobalShortcut::Create(v8::Isolate* isolate) {
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("globalShortcut", atom::api::GlobalShortcut::Create(isolate));

View file

@ -58,7 +58,7 @@ bool Menu::GetAcceleratorForCommandId(int command_id,
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::Value> val = get_accelerator_.Run(command_id);
v8::Local<v8::Value> val = get_accelerator_.Run(command_id);
return mate::ConvertFromV8(isolate, val, accelerator);
}
@ -150,7 +150,7 @@ bool Menu::IsVisibleAt(int index) const {
// static
void Menu::BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype) {
v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("insertItem", &Menu::InsertItemAt)
.SetMethod("insertCheckItem", &Menu::InsertCheckItemAt)
@ -180,14 +180,14 @@ void Menu::BuildPrototype(v8::Isolate* isolate,
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
using atom::api::Menu;
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Function> constructor = mate::CreateConstructor<Menu>(
isolate, "Menu", base::Bind(&Menu::Create));
mate::Dictionary dict(isolate, exports);
dict.Set("Menu", static_cast<v8::Handle<v8::Value>>(constructor));
dict.Set("Menu", static_cast<v8::Local<v8::Value>>(constructor));
#if defined(OS_MACOSX)
dict.SetMethod("setApplicationMenu", &Menu::SetApplicationMenu);
dict.SetMethod("sendActionToFirstResponder",

View file

@ -23,7 +23,7 @@ class Menu : public mate::Wrappable,
static mate::Wrappable* Create();
static void BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype);
v8::Local<v8::ObjectTemplate> prototype);
#if defined(OS_MACOSX)
// Set the global menubar.
@ -88,7 +88,7 @@ class Menu : public mate::Wrappable,
base::Callback<bool(int)> is_checked_;
base::Callback<bool(int)> is_enabled_;
base::Callback<bool(int)> is_visible_;
base::Callback<v8::Handle<v8::Value>(int)> get_accelerator_;
base::Callback<v8::Local<v8::Value>(int)> get_accelerator_;
base::Callback<void(int)> execute_command_;
base::Callback<void()> menu_will_show_;

View file

@ -39,7 +39,7 @@ void PowerMonitor::OnResume() {
}
// static
v8::Handle<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
if (!Browser::Get()->is_ready()) {
node::ThrowError("Cannot initialize \"power-monitor\" module"
"before app is ready");
@ -56,8 +56,8 @@ v8::Handle<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
#if defined(OS_MACOSX)
base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
#endif

View file

@ -17,7 +17,7 @@ namespace api {
class PowerMonitor : public mate::EventEmitter,
public base::PowerObserver {
public:
static v8::Handle<v8::Value> Create(v8::Isolate* isolate);
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
protected:
PowerMonitor();

View file

@ -21,7 +21,7 @@ namespace mate {
template<>
struct Converter<const net::URLRequest*> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const net::URLRequest* val) {
return mate::ObjectTemplateBuilder(isolate)
.SetValue("method", val->method())
@ -63,7 +63,7 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
// Call the JS handler.
Protocol::JsProtocolHandler callback =
registry_->GetProtocolHandler(request()->url().scheme());
v8::Handle<v8::Value> result = callback.Run(request());
v8::Local<v8::Value> result = callback.Run(request());
// Determine the type of the job we are going to create.
if (result->IsString()) {
@ -73,7 +73,7 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
GetWeakPtr(), "text/plain", "UTF-8", data));
return;
} else if (result->IsObject()) {
v8::Handle<v8::Object> obj = result->ToObject();
v8::Local<v8::Object> obj = result->ToObject();
mate::Dictionary dict(isolate, obj);
std::string name = mate::V8ToString(obj->GetConstructorName());
if (name == "RequestStringJob") {
@ -88,7 +88,7 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
return;
} else if (name == "RequestBufferJob") {
std::string mime_type, encoding;
v8::Handle<v8::Value> buffer;
v8::Local<v8::Value> buffer;
dict.Get("mimeType", &mime_type);
dict.Get("encoding", &encoding);
dict.Get("data", &buffer);
@ -339,8 +339,8 @@ mate::Handle<Protocol> Protocol::Create(v8::Isolate* isolate) {
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("protocol", atom::api::Protocol::Create(isolate));

View file

@ -24,7 +24,7 @@ namespace api {
class Protocol : public mate::EventEmitter {
public:
typedef base::Callback<v8::Handle<v8::Value>(const net::URLRequest*)>
typedef base::Callback<v8::Local<v8::Value>(const net::URLRequest*)>
JsProtocolHandler;
static mate::Handle<Protocol> Create(v8::Isolate* isolate);

View file

@ -111,7 +111,7 @@ mate::ObjectTemplateBuilder Screen::GetObjectTemplateBuilder(
}
// static
v8::Handle<v8::Value> Screen::Create(v8::Isolate* isolate) {
v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
if (!Browser::Get()->is_ready()) {
node::ThrowError("Cannot initialize \"screen\" module before app is ready");
return v8::Null(isolate);
@ -132,8 +132,8 @@ v8::Handle<v8::Value> Screen::Create(v8::Isolate* isolate) {
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.Set("screen", atom::api::Screen::Create(context->GetIsolate()));
}

View file

@ -24,7 +24,7 @@ namespace api {
class Screen : public mate::EventEmitter,
public gfx::DisplayObserver {
public:
static v8::Handle<v8::Value> Create(v8::Isolate* isolate);
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
protected:
explicit Screen(gfx::Screen* screen);

View file

@ -128,7 +128,7 @@ bool Tray::CheckTrayLife(mate::Arguments* args) {
// static
void Tray::BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype) {
v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("destroy", &Tray::Destroy)
.SetMethod("setImage", &Tray::SetImage)
@ -147,14 +147,14 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
using atom::api::Tray;
v8::Isolate* isolate = context->GetIsolate();
v8::Handle<v8::Function> constructor = mate::CreateConstructor<Tray>(
v8::Local<v8::Function> constructor = mate::CreateConstructor<Tray>(
isolate, "Tray", base::Bind(&Tray::New));
mate::Dictionary dict(isolate, exports);
dict.Set("Tray", static_cast<v8::Handle<v8::Value>>(constructor));
dict.Set("Tray", static_cast<v8::Local<v8::Value>>(constructor));
}
} // namespace

View file

@ -34,7 +34,7 @@ class Tray : public mate::EventEmitter,
static mate::Wrappable* New(const gfx::Image& image);
static void BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype);
v8::Local<v8::ObjectTemplate> prototype);
protected:
explicit Tray(const gfx::Image& image);

View file

@ -751,8 +751,8 @@ mate::Handle<WebContents> WebContents::Create(
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.SetMethod("create", &atom::api::WebContents::Create);

View file

@ -15,7 +15,7 @@ namespace mate {
template<>
struct Converter<content::WebContents*> {
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
content::WebContents** out) {
atom::api::WebContents* contents;
if (!Converter<atom::api::WebContents*>::FromV8(isolate, val, &contents))
@ -27,7 +27,7 @@ struct Converter<content::WebContents*> {
template<>
struct Converter<atom::WebViewManager::WebViewInfo> {
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
atom::WebViewManager::WebViewInfo* out) {
Dictionary options;
if (!ConvertFromV8(isolate, val, &options))
@ -81,8 +81,8 @@ void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {
manager->RemoveGuest(guest_instance_id);
}
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("addGuest", &AddGuest);
dict.SetMethod("removeGuest", &RemoveGuest);

View file

@ -32,7 +32,7 @@ namespace mate {
template<>
struct Converter<PrintSettings> {
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
PrintSettings* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
@ -462,7 +462,7 @@ mate::Handle<WebContents> Window::GetDevToolsWebContents(
// static
void Window::BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype) {
v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("destroy", &Window::Destroy)
.SetMethod("close", &Window::Close)
@ -542,14 +542,14 @@ void Window::BuildPrototype(v8::Isolate* isolate,
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
using atom::api::Window;
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Function> constructor = mate::CreateConstructor<Window>(
isolate, "BrowserWindow", base::Bind(&Window::New));
mate::Dictionary dict(isolate, exports);
dict.Set("BrowserWindow", static_cast<v8::Handle<v8::Value>>(constructor));
dict.Set("BrowserWindow", static_cast<v8::Local<v8::Value>>(constructor));
}
} // namespace

View file

@ -40,7 +40,7 @@ class Window : public mate::EventEmitter,
const mate::Dictionary& options);
static void BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype);
v8::Local<v8::ObjectTemplate> prototype);
NativeWindow* window() const { return window_.get(); }
@ -160,7 +160,7 @@ namespace mate {
template<>
struct Converter<atom::NativeWindow*> {
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
atom::NativeWindow** out) {
// null would be tranfered to NULL.
if (val->IsNull()) {

View file

@ -43,13 +43,13 @@ bool EventEmitter::CallEmit(v8::Isolate* isolate,
content::WebContents* sender,
IPC::Message* message,
ValueArray args) {
v8::Handle<v8::Object> event;
v8::Local<v8::Object> event;
bool use_native_event = sender && message;
if (use_native_event) {
mate::Handle<mate::Event> native_event = mate::Event::Create(isolate);
native_event->SetSenderAndMessage(sender, message);
event = v8::Handle<v8::Object>::Cast(native_event.ToV8());
event = v8::Local<v8::Object>::Cast(native_event.ToV8());
} else {
event = CreateEventObject(isolate);
}

View file

@ -22,7 +22,7 @@ namespace mate {
// Provide helperers to emit event in JavaScript.
class EventEmitter : public Wrappable {
public:
typedef std::vector<v8::Handle<v8::Value>> ValueArray;
typedef std::vector<v8::Local<v8::Value>> ValueArray;
protected:
EventEmitter();