Upgrade to new V8 APIs.
This commit is contained in:
parent
91c7458ab8
commit
c713deb1e8
5 changed files with 82 additions and 64 deletions
|
@ -20,26 +20,23 @@ namespace api {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Call method of delegate object.
|
// Call method of delegate object.
|
||||||
v8::Handle<v8::Value> CallDelegate(v8::Handle<v8::Value> default_value,
|
v8::Handle<v8::Value> CallDelegate(v8::Isolate* isolate,
|
||||||
|
v8::Handle<v8::Value> default_value,
|
||||||
v8::Handle<v8::Object> menu,
|
v8::Handle<v8::Object> menu,
|
||||||
const char* method,
|
const char* method,
|
||||||
int command_id) {
|
int command_id) {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Handle<v8::Value> delegate = menu->Get(
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
MATE_STRING_NEW(isolate, "delegate"));
|
||||||
|
|
||||||
v8::Handle<v8::Value> delegate = menu->Get(v8::String::New("delegate"));
|
|
||||||
if (!delegate->IsObject())
|
if (!delegate->IsObject())
|
||||||
return default_value;
|
return default_value;
|
||||||
|
|
||||||
v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(
|
v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(
|
||||||
delegate->ToObject()->Get(v8::String::New(method)));
|
delegate->ToObject()->Get(MATE_STRING_NEW(isolate, method)));
|
||||||
if (!function->IsFunction())
|
if (!function->IsFunction())
|
||||||
return default_value;
|
return default_value;
|
||||||
|
|
||||||
v8::Handle<v8::Value> argv = v8::Integer::New(command_id);
|
v8::Handle<v8::Value> argv = MATE_INTEGER_NEW(isolate, command_id);
|
||||||
|
return function->Call(isolate->GetCurrentContext()->Global(), 1, &argv);
|
||||||
return handle_scope.Close(
|
|
||||||
function->Call(v8::Context::GetCurrent()->Global(), 1, &argv));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -53,38 +50,46 @@ Menu::~Menu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Menu::IsCommandIdChecked(int command_id) const {
|
bool Menu::IsCommandIdChecked(int command_id) const {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::Locker locker(isolate);
|
||||||
return CallDelegate(v8::False(),
|
v8::HandleScope handle_scope(isolate);
|
||||||
const_cast<Menu*>(this)->GetWrapper(node_isolate),
|
return CallDelegate(isolate,
|
||||||
|
MATE_FALSE(isolate),
|
||||||
|
const_cast<Menu*>(this)->GetWrapper(isolate),
|
||||||
"isCommandIdChecked",
|
"isCommandIdChecked",
|
||||||
command_id)->BooleanValue();
|
command_id)->BooleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Menu::IsCommandIdEnabled(int command_id) const {
|
bool Menu::IsCommandIdEnabled(int command_id) const {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::Locker locker(isolate);
|
||||||
return CallDelegate(v8::True(),
|
v8::HandleScope handle_scope(isolate);
|
||||||
const_cast<Menu*>(this)->GetWrapper(node_isolate),
|
return CallDelegate(isolate,
|
||||||
|
MATE_TRUE(isolate),
|
||||||
|
const_cast<Menu*>(this)->GetWrapper(isolate),
|
||||||
"isCommandIdEnabled",
|
"isCommandIdEnabled",
|
||||||
command_id)->BooleanValue();
|
command_id)->BooleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Menu::IsCommandIdVisible(int command_id) const {
|
bool Menu::IsCommandIdVisible(int command_id) const {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::Locker locker(isolate);
|
||||||
return CallDelegate(v8::True(),
|
v8::HandleScope handle_scope(isolate);
|
||||||
const_cast<Menu*>(this)->GetWrapper(node_isolate),
|
return CallDelegate(isolate,
|
||||||
|
MATE_TRUE(isolate),
|
||||||
|
const_cast<Menu*>(this)->GetWrapper(isolate),
|
||||||
"isCommandIdVisible",
|
"isCommandIdVisible",
|
||||||
command_id)->BooleanValue();
|
command_id)->BooleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Menu::GetAcceleratorForCommandId(int command_id,
|
bool Menu::GetAcceleratorForCommandId(int command_id,
|
||||||
ui::Accelerator* accelerator) {
|
ui::Accelerator* accelerator) {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::Locker locker(isolate);
|
||||||
v8::Handle<v8::Value> shortcut = CallDelegate(v8::Undefined(),
|
v8::HandleScope handle_scope(isolate);
|
||||||
GetWrapper(node_isolate),
|
v8::Handle<v8::Value> shortcut = CallDelegate(isolate,
|
||||||
|
MATE_UNDEFINED(isolate),
|
||||||
|
GetWrapper(isolate),
|
||||||
"getAcceleratorForCommandId",
|
"getAcceleratorForCommandId",
|
||||||
command_id);
|
command_id);
|
||||||
if (shortcut->IsString()) {
|
if (shortcut->IsString()) {
|
||||||
|
@ -96,20 +101,24 @@ bool Menu::GetAcceleratorForCommandId(int command_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Menu::IsItemForCommandIdDynamic(int command_id) const {
|
bool Menu::IsItemForCommandIdDynamic(int command_id) const {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::Locker locker(isolate);
|
||||||
return CallDelegate(v8::False(),
|
v8::HandleScope handle_scope(isolate);
|
||||||
const_cast<Menu*>(this)->GetWrapper(node_isolate),
|
return CallDelegate(isolate,
|
||||||
|
MATE_FALSE(isolate),
|
||||||
|
const_cast<Menu*>(this)->GetWrapper(isolate),
|
||||||
"isItemForCommandIdDynamic",
|
"isItemForCommandIdDynamic",
|
||||||
command_id)->BooleanValue();
|
command_id)->BooleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
string16 Menu::GetLabelForCommandId(int command_id) const {
|
string16 Menu::GetLabelForCommandId(int command_id) const {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::Locker locker(isolate);
|
||||||
|
v8::HandleScope handle_scope(isolate);
|
||||||
v8::Handle<v8::Value> result = CallDelegate(
|
v8::Handle<v8::Value> result = CallDelegate(
|
||||||
v8::False(),
|
isolate,
|
||||||
const_cast<Menu*>(this)->GetWrapper(node_isolate),
|
MATE_FALSE(isolate),
|
||||||
|
const_cast<Menu*>(this)->GetWrapper(isolate),
|
||||||
"getLabelForCommandId",
|
"getLabelForCommandId",
|
||||||
command_id);
|
command_id);
|
||||||
string16 label;
|
string16 label;
|
||||||
|
@ -118,29 +127,34 @@ string16 Menu::GetLabelForCommandId(int command_id) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
string16 Menu::GetSublabelForCommandId(int command_id) const {
|
string16 Menu::GetSublabelForCommandId(int command_id) const {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::Locker locker(isolate);
|
||||||
|
v8::HandleScope handle_scope(isolate);
|
||||||
v8::Handle<v8::Value> result = CallDelegate(
|
v8::Handle<v8::Value> result = CallDelegate(
|
||||||
v8::False(),
|
isolate,
|
||||||
const_cast<Menu*>(this)->GetWrapper(node_isolate),
|
MATE_FALSE(isolate),
|
||||||
|
const_cast<Menu*>(this)->GetWrapper(isolate),
|
||||||
"getSubLabelForCommandId",
|
"getSubLabelForCommandId",
|
||||||
command_id);
|
command_id);
|
||||||
string16 label;
|
string16 label;
|
||||||
mate::ConvertFromV8(node_isolate, result, &label);
|
mate::ConvertFromV8(isolate, result, &label);
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::ExecuteCommand(int command_id, int event_flags) {
|
void Menu::ExecuteCommand(int command_id, int event_flags) {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::Locker locker(isolate);
|
||||||
CallDelegate(v8::False(), GetWrapper(node_isolate), "executeCommand",
|
v8::HandleScope handle_scope(isolate);
|
||||||
command_id);
|
CallDelegate(isolate, MATE_FALSE(isolate), GetWrapper(isolate),
|
||||||
|
"executeCommand", command_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
|
void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
|
||||||
v8::Locker locker(node_isolate);
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::Locker locker(isolate);
|
||||||
CallDelegate(v8::False(), GetWrapper(node_isolate), "menuWillShow", -1);
|
v8::HandleScope handle_scope(isolate);
|
||||||
|
CallDelegate(isolate, MATE_FALSE(isolate), GetWrapper(isolate),
|
||||||
|
"menuWillShow", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::InsertItemAt(
|
void Menu::InsertItemAt(
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// This file is generated by script/bootstrap.py, you should never modify it
|
// This file is generated by script/bootstrap.py, you should never modify it
|
||||||
// by hand.
|
// by hand.
|
||||||
|
|
||||||
#ifndef ATOM_COMMON_CHROME_VERSION_H_
|
#ifndef ATOM_COMMON_CHROME_VERSION_H_
|
||||||
#define ATOM_COMMON_CHROME_VERSION_H_
|
#define ATOM_COMMON_CHROME_VERSION_H_
|
||||||
|
|
||||||
#define CHROME_VERSION_STRING "31.0.1650.57"
|
#define CHROME_VERSION_STRING "35.0.1916.153"
|
||||||
#define CHROME_VERSION "v" CHROME_VERSION_STRING
|
#define CHROME_VERSION "v" CHROME_VERSION_STRING
|
||||||
|
|
||||||
#endif // ATOM_COMMON_CHROME_VERSION_H_
|
#endif // ATOM_COMMON_CHROME_VERSION_H_
|
||||||
|
|
|
@ -14,8 +14,8 @@ template<>
|
||||||
struct Converter<string16> {
|
struct Converter<string16> {
|
||||||
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
|
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
|
||||||
const string16& val) {
|
const string16& val) {
|
||||||
return v8::String::New(reinterpret_cast<const uint16_t*>(val.data()),
|
return MATE_STRING_NEW_FROM_UTF16(
|
||||||
val.size());
|
isolate, reinterpret_cast<const uint16_t*>(val.data()), val.size());
|
||||||
}
|
}
|
||||||
static bool FromV8(v8::Isolate* isolate,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
v8::Handle<v8::Value> val,
|
v8::Handle<v8::Value> val,
|
||||||
|
|
|
@ -10,13 +10,17 @@
|
||||||
#undef CHECK
|
#undef CHECK
|
||||||
#undef CHECK_EQ
|
#undef CHECK_EQ
|
||||||
#undef CHECK_NE
|
#undef CHECK_NE
|
||||||
|
#undef CHECK_GE
|
||||||
|
#undef CHECK_GT
|
||||||
|
#undef CHECK_LE
|
||||||
|
#undef CHECK_LT
|
||||||
#undef DISALLOW_COPY_AND_ASSIGN
|
#undef DISALLOW_COPY_AND_ASSIGN
|
||||||
|
#undef debug_string // This is defined in OS X 10.9 SDK in AssertMacros.h.
|
||||||
#include "vendor/node/src/env.h"
|
#include "vendor/node/src/env.h"
|
||||||
#include "vendor/node/src/env-inl.h"
|
#include "vendor/node/src/env-inl.h"
|
||||||
#include "vendor/node/src/node.h"
|
#include "vendor/node/src/node.h"
|
||||||
#include "vendor/node/src/node_buffer.h"
|
#include "vendor/node/src/node_buffer.h"
|
||||||
#include "vendor/node/src/node_internals.h"
|
#include "vendor/node/src/node_internals.h"
|
||||||
using node::node_isolate;
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
// Defined in node_bindings.cc.
|
// Defined in node_bindings.cc.
|
||||||
|
|
2
vendor/native_mate
vendored
2
vendor/native_mate
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit a5c4a2c7c64239ec5d007342f00f16f3981d6d80
|
Subproject commit c49cebacb23149f82571b2ca691be7d9a345352c
|
Loading…
Reference in a new issue