]> khamidou — GitHub mirrors - electron.git/commitdiff
Upgrade to new V8 APIs.
authorCheng Zhao <zcbenz@gmail.com>
Sat, 28 Jun 2014 11:31:23 +0000 (19:31 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 28 Jun 2014 11:31:23 +0000 (19:31 +0800)
atom/browser/api/atom_api_menu.cc
atom/common/chrome_version.h
atom/common/native_mate_converters/string16_converter.h
atom/common/node_includes.h
vendor/native_mate

index a76d77b0f3e461bc712120648a1f9952978233f2..d93d84fdd112a3386acbda33748249041f806bed 100644 (file)
@@ -20,26 +20,23 @@ namespace api {
 namespace {
 
 // 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,
                                    const char* method,
                                    int command_id) {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
-
-  v8::Handle<v8::Value> delegate = menu->Get(v8::String::New("delegate"));
+  v8::Handle<v8::Value> delegate = menu->Get(
+      MATE_STRING_NEW(isolate, "delegate"));
   if (!delegate->IsObject())
     return default_value;
 
   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())
     return default_value;
 
-  v8::Handle<v8::Value> argv = v8::Integer::New(command_id);
-
-  return handle_scope.Close(
-      function->Call(v8::Context::GetCurrent()->Global(), 1, &argv));
+  v8::Handle<v8::Value> argv = MATE_INTEGER_NEW(isolate, command_id);
+  return function->Call(isolate->GetCurrentContext()->Global(), 1, &argv);
 }
 
 }  // namespace
@@ -53,38 +50,46 @@ Menu::~Menu() {
 }
 
 bool Menu::IsCommandIdChecked(int command_id) const {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
-  return CallDelegate(v8::False(),
-                      const_cast<Menu*>(this)->GetWrapper(node_isolate),
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Locker locker(isolate);
+  v8::HandleScope handle_scope(isolate);
+  return CallDelegate(isolate,
+                      MATE_FALSE(isolate),
+                      const_cast<Menu*>(this)->GetWrapper(isolate),
                       "isCommandIdChecked",
                       command_id)->BooleanValue();
 }
 
 bool Menu::IsCommandIdEnabled(int command_id) const {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
-  return CallDelegate(v8::True(),
-                      const_cast<Menu*>(this)->GetWrapper(node_isolate),
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Locker locker(isolate);
+  v8::HandleScope handle_scope(isolate);
+  return CallDelegate(isolate,
+                      MATE_TRUE(isolate),
+                      const_cast<Menu*>(this)->GetWrapper(isolate),
                       "isCommandIdEnabled",
                       command_id)->BooleanValue();
 }
 
 bool Menu::IsCommandIdVisible(int command_id) const {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
-  return CallDelegate(v8::True(),
-                      const_cast<Menu*>(this)->GetWrapper(node_isolate),
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Locker locker(isolate);
+  v8::HandleScope handle_scope(isolate);
+  return CallDelegate(isolate,
+                      MATE_TRUE(isolate),
+                      const_cast<Menu*>(this)->GetWrapper(isolate),
                       "isCommandIdVisible",
                       command_id)->BooleanValue();
 }
 
 bool Menu::GetAcceleratorForCommandId(int command_id,
                                       ui::Accelerator* accelerator) {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
-  v8::Handle<v8::Value> shortcut = CallDelegate(v8::Undefined(),
-                                                GetWrapper(node_isolate),
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Locker locker(isolate);
+  v8::HandleScope handle_scope(isolate);
+  v8::Handle<v8::Value> shortcut = CallDelegate(isolate,
+                                                MATE_UNDEFINED(isolate),
+                                                GetWrapper(isolate),
                                                 "getAcceleratorForCommandId",
                                                 command_id);
   if (shortcut->IsString()) {
@@ -96,20 +101,24 @@ bool Menu::GetAcceleratorForCommandId(int command_id,
 }
 
 bool Menu::IsItemForCommandIdDynamic(int command_id) const {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
-  return CallDelegate(v8::False(),
-                      const_cast<Menu*>(this)->GetWrapper(node_isolate),
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Locker locker(isolate);
+  v8::HandleScope handle_scope(isolate);
+  return CallDelegate(isolate,
+                      MATE_FALSE(isolate),
+                      const_cast<Menu*>(this)->GetWrapper(isolate),
                       "isItemForCommandIdDynamic",
                       command_id)->BooleanValue();
 }
 
 string16 Menu::GetLabelForCommandId(int command_id) const {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Locker locker(isolate);
+  v8::HandleScope handle_scope(isolate);
   v8::Handle<v8::Value> result = CallDelegate(
-      v8::False(),
-      const_cast<Menu*>(this)->GetWrapper(node_isolate),
+      isolate,
+      MATE_FALSE(isolate),
+      const_cast<Menu*>(this)->GetWrapper(isolate),
       "getLabelForCommandId",
       command_id);
   string16 label;
@@ -118,29 +127,34 @@ string16 Menu::GetLabelForCommandId(int command_id) const {
 }
 
 string16 Menu::GetSublabelForCommandId(int command_id) const {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Locker locker(isolate);
+  v8::HandleScope handle_scope(isolate);
   v8::Handle<v8::Value> result = CallDelegate(
-      v8::False(),
-      const_cast<Menu*>(this)->GetWrapper(node_isolate),
+      isolate,
+      MATE_FALSE(isolate),
+      const_cast<Menu*>(this)->GetWrapper(isolate),
       "getSubLabelForCommandId",
       command_id);
   string16 label;
-  mate::ConvertFromV8(node_isolate, result, &label);
+  mate::ConvertFromV8(isolate, result, &label);
   return label;
 }
 
 void Menu::ExecuteCommand(int command_id, int event_flags) {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
-  CallDelegate(v8::False(), GetWrapper(node_isolate), "executeCommand",
-               command_id);
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Locker locker(isolate);
+  v8::HandleScope handle_scope(isolate);
+  CallDelegate(isolate, MATE_FALSE(isolate), GetWrapper(isolate),
+               "executeCommand", command_id);
 }
 
 void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
-  v8::Locker locker(node_isolate);
-  v8::HandleScope handle_scope(node_isolate);
-  CallDelegate(v8::False(), GetWrapper(node_isolate), "menuWillShow", -1);
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Locker locker(isolate);
+  v8::HandleScope handle_scope(isolate);
+  CallDelegate(isolate, MATE_FALSE(isolate), GetWrapper(isolate),
+               "menuWillShow", -1);
 }
 
 void Menu::InsertItemAt(
index d0ebcb54aa3b8f13e89ff2dc838178446055a738..f6b1b8febed31777797505208ff9217aac2df594 100644 (file)
@@ -1,14 +1,14 @@
-// Copyright (c) 2014 GitHub, Inc. All rights reserved.\r
-// Use of this source code is governed by the MIT license that can be\r
-// found in the LICENSE file.\r
-\r
-// This file is generated by script/bootstrap.py, you should never modify it\r
-// by hand.\r
-\r
-#ifndef ATOM_COMMON_CHROME_VERSION_H_\r
-#define ATOM_COMMON_CHROME_VERSION_H_\r
-\r
-#define CHROME_VERSION_STRING "31.0.1650.57"\r
-#define CHROME_VERSION "v" CHROME_VERSION_STRING\r
-\r
-#endif  // ATOM_COMMON_CHROME_VERSION_H_\r
+// Copyright (c) 2014 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+// This file is generated by script/bootstrap.py, you should never modify it
+// by hand.
+
+#ifndef ATOM_COMMON_CHROME_VERSION_H_
+#define ATOM_COMMON_CHROME_VERSION_H_
+
+#define CHROME_VERSION_STRING "35.0.1916.153"
+#define CHROME_VERSION "v" CHROME_VERSION_STRING
+
+#endif  // ATOM_COMMON_CHROME_VERSION_H_
index 172bed74a37bf9437fa28880d2a67e9c3f3e4d45..a171de5e74462ca5f9b7ac42b7e1adf78e4ddd9e 100644 (file)
@@ -14,8 +14,8 @@ template<>
 struct Converter<string16> {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     const string16& val) {
-    return v8::String::New(reinterpret_cast<const uint16_t*>(val.data()),
-                           val.size());
+    return MATE_STRING_NEW_FROM_UTF16(
+        isolate, reinterpret_cast<const uint16_t*>(val.data()), val.size());
   }
   static bool FromV8(v8::Isolate* isolate,
                      v8::Handle<v8::Value> val,
index 9f544a124e84a3ee2ced7f5f1e7a1568649a8822..680a211f03913c29766312ac3cda496f356d61c0 100644 (file)
 #undef CHECK
 #undef CHECK_EQ
 #undef CHECK_NE
+#undef CHECK_GE
+#undef CHECK_GT
+#undef CHECK_LE
+#undef CHECK_LT
 #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-inl.h"
 #include "vendor/node/src/node.h"
 #include "vendor/node/src/node_buffer.h"
 #include "vendor/node/src/node_internals.h"
-using node::node_isolate;
 
 namespace atom {
 // Defined in node_bindings.cc.
index a5c4a2c7c64239ec5d007342f00f16f3981d6d80..c49cebacb23149f82571b2ca691be7d9a345352c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a5c4a2c7c64239ec5d007342f00f16f3981d6d80
+Subproject commit c49cebacb23149f82571b2ca691be7d9a345352c