Move callback converter from native mate to electron
This commit is contained in:
parent
3402871741
commit
2ff104d012
15 changed files with 453 additions and 13 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include "atom/browser/atom_browser_main_parts.h"
|
#include "atom/browser/atom_browser_main_parts.h"
|
||||||
#include "atom/browser/browser.h"
|
#include "atom/browser/browser.h"
|
||||||
#include "atom/browser/api/atom_api_web_contents.h"
|
#include "atom/browser/api/atom_api_web_contents.h"
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/environment.h"
|
#include "base/environment.h"
|
||||||
|
@ -25,7 +26,6 @@
|
||||||
#include "brightray/browser/brightray_paths.h"
|
#include "brightray/browser/brightray_paths.h"
|
||||||
#include "content/public/browser/client_certificate_delegate.h"
|
#include "content/public/browser/client_certificate_delegate.h"
|
||||||
#include "content/public/browser/gpu_data_manager.h"
|
#include "content/public/browser/gpu_data_manager.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
#include "net/ssl/ssl_cert_request_info.h"
|
#include "net/ssl/ssl_cert_request_info.h"
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "content/public/browser/tracing_controller.h"
|
#include "content/public/browser/tracing_controller.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
#include "atom/browser/api/atom_api_cookies.h"
|
#include "atom/browser/api/atom_api_cookies.h"
|
||||||
|
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/time/time.h"
|
#include "base/time/time.h"
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
#include "net/cookies/cookie_monster.h"
|
#include "net/cookies/cookie_monster.h"
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
#include "atom/browser/ui/file_dialog.h"
|
#include "atom/browser/ui/file_dialog.h"
|
||||||
#include "atom/browser/ui/message_box.h"
|
#include "atom/browser/ui/message_box.h"
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||||
#include "atom/common/native_mate_converters/image_converter.h"
|
#include "atom/common/native_mate_converters/image_converter.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "atom/common/native_mate_converters/accelerator_converter.h"
|
#include "atom/common/native_mate_converters/accelerator_converter.h"
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
#include "atom/common/native_mate_converters/accelerator_converter.h"
|
#include "atom/common/native_mate_converters/accelerator_converter.h"
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/image_converter.h"
|
#include "atom/common/native_mate_converters/image_converter.h"
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/constructor.h"
|
#include "native_mate/constructor.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
#include "atom/browser/api/atom_api_session.h"
|
#include "atom/browser/api/atom_api_session.h"
|
||||||
#include "atom/browser/net/adapter_request_job.h"
|
#include "atom/browser/net/adapter_request_job.h"
|
||||||
#include "atom/browser/net/atom_url_request_job_factory.h"
|
#include "atom/browser/net/atom_url_request_job_factory.h"
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "net/url_request/url_request_context.h"
|
#include "net/url_request/url_request_context.h"
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "atom/browser/api/atom_api_cookies.h"
|
#include "atom/browser/api/atom_api_cookies.h"
|
||||||
#include "atom/browser/atom_browser_context.h"
|
#include "atom/browser/atom_browser_context.h"
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
|
@ -18,7 +19,6 @@
|
||||||
#include "chrome/common/pref_names.h"
|
#include "chrome/common/pref_names.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/storage_partition.h"
|
#include "content/public/browser/storage_partition.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
#include "net/base/load_flags.h"
|
#include "net/base/load_flags.h"
|
||||||
#include "net/disk_cache/disk_cache.h"
|
#include "net/disk_cache/disk_cache.h"
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "atom/browser/web_view_guest_delegate.h"
|
#include "atom/browser/web_view_guest_delegate.h"
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
#include "atom/common/event_emitter_caller.h"
|
#include "atom/common/event_emitter_caller.h"
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||||
|
@ -37,7 +38,6 @@
|
||||||
#include "content/public/browser/storage_partition.h"
|
#include "content/public/browser/storage_partition.h"
|
||||||
#include "content/public/browser/site_instance.h"
|
#include "content/public/browser/site_instance.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
#include "net/http/http_response_headers.h"
|
#include "net/http/http_response_headers.h"
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
#include "atom/browser/api/atom_api_web_contents.h"
|
#include "atom/browser/api/atom_api_web_contents.h"
|
||||||
#include "atom/browser/browser.h"
|
#include "atom/browser/browser.h"
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||||
#include "atom/common/native_mate_converters/image_converter.h"
|
#include "atom/common/native_mate_converters/image_converter.h"
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "content/public/browser/render_process_host.h"
|
#include "content/public/browser/render_process_host.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/constructor.h"
|
#include "native_mate/constructor.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "ui/gfx/geometry/rect.h"
|
#include "ui/gfx/geometry/rect.h"
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
|
|
||||||
#include "atom_natives.h" // NOLINT: This file is generated with coffee2c.
|
#include "atom_natives.h" // NOLINT: This file is generated with coffee2c.
|
||||||
#include "atom/common/asar/archive.h"
|
#include "atom/common/asar/archive.h"
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||||
#include "native_mate/arguments.h"
|
#include "native_mate/arguments.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
#include "native_mate/wrappable.h"
|
#include "native_mate/wrappable.h"
|
||||||
|
|
439
atom/common/native_mate_converters/callback.h
Normal file
439
atom/common/native_mate_converters/callback.h
Normal file
|
@ -0,0 +1,439 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
|
#include "base/callback.h"
|
||||||
|
#include "native_mate/function_template.h"
|
||||||
|
#include "native_mate/locker.h"
|
||||||
|
#include "native_mate/scoped_persistent.h"
|
||||||
|
|
||||||
|
namespace mate {
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
typedef scoped_refptr<RefCountedPersistent<v8::Function> > SafeV8Function;
|
||||||
|
|
||||||
|
// This set of templates invokes a V8::Function by converting the C++ types.
|
||||||
|
template<typename Sig>
|
||||||
|
struct V8FunctionInvoker;
|
||||||
|
|
||||||
|
template<typename V>
|
||||||
|
struct V8FunctionInvoker<v8::Local<V>()> {
|
||||||
|
static v8::Local<V> Go(v8::Isolate* isolate, SafeV8Function function) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, 0, NULL));
|
||||||
|
return handle_scope.Escape(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename R>
|
||||||
|
struct V8FunctionInvoker<R()> {
|
||||||
|
static R Go(v8::Isolate* isolate, SafeV8Function function) {
|
||||||
|
R ret;
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, 0, NULL));
|
||||||
|
Converter<R>::FromV8(isolate, val, &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct V8FunctionInvoker<void()> {
|
||||||
|
static void Go(v8::Isolate* isolate, SafeV8Function function) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
holder->Call(holder, 0, NULL);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename V, typename P1>
|
||||||
|
struct V8FunctionInvoker<v8::Local<V>(P1)> {
|
||||||
|
static v8::Local<V> Go(v8::Isolate* isolate, SafeV8Function function, P1 a1) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
return handle_scope.Escape(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename R, typename P1>
|
||||||
|
struct V8FunctionInvoker<R(P1)> {
|
||||||
|
static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1) {
|
||||||
|
R ret;
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
Converter<R>::FromV8(isolate, val, &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename P1>
|
||||||
|
struct V8FunctionInvoker<void(P1)> {
|
||||||
|
static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
};
|
||||||
|
holder->Call(holder, arraysize(args), args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename V, typename P1, typename P2>
|
||||||
|
struct V8FunctionInvoker<v8::Local<V>(P1, P2)> {
|
||||||
|
static v8::Local<V> Go(v8::Isolate* isolate, SafeV8Function function, P1 a1,
|
||||||
|
P2 a2) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
return handle_scope.Escape(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename R, typename P1, typename P2>
|
||||||
|
struct V8FunctionInvoker<R(P1, P2)> {
|
||||||
|
static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2) {
|
||||||
|
R ret;
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
Converter<R>::FromV8(isolate, val, &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename P1, typename P2>
|
||||||
|
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::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
};
|
||||||
|
holder->Call(holder, arraysize(args), args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename V, typename P1, typename P2, typename P3>
|
||||||
|
struct V8FunctionInvoker<v8::Local<V>(P1, P2, P3)> {
|
||||||
|
static v8::Local<V> Go(v8::Isolate* isolate, SafeV8Function function, P1 a1,
|
||||||
|
P2 a2, P3 a3) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
return handle_scope.Escape(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename R, typename P1, typename P2, typename P3>
|
||||||
|
struct V8FunctionInvoker<R(P1, P2, P3)> {
|
||||||
|
static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2,
|
||||||
|
P3 a3) {
|
||||||
|
R ret;
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
Converter<R>::FromV8(isolate, val, &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename P1, typename P2, typename P3>
|
||||||
|
struct V8FunctionInvoker<void(P1, P2, P3)> {
|
||||||
|
static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2,
|
||||||
|
P3 a3) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
};
|
||||||
|
holder->Call(holder, arraysize(args), args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename V, typename P1, typename P2, typename P3, typename P4>
|
||||||
|
struct V8FunctionInvoker<v8::Local<V>(P1, P2, P3, P4)> {
|
||||||
|
static v8::Local<V> Go(v8::Isolate* isolate, SafeV8Function function, P1 a1,
|
||||||
|
P2 a2, P3 a3, P4 a4) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
ConvertToV8(isolate, a4),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
return handle_scope.Escape(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename R, typename P1, typename P2, typename P3, typename P4>
|
||||||
|
struct V8FunctionInvoker<R(P1, P2, P3, P4)> {
|
||||||
|
static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2,
|
||||||
|
P3 a3, P4 a4) {
|
||||||
|
R ret;
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
ConvertToV8(isolate, a4),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
Converter<R>::FromV8(isolate, val, &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename P1, typename P2, typename P3, typename P4>
|
||||||
|
struct V8FunctionInvoker<void(P1, P2, P3, P4)> {
|
||||||
|
static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2,
|
||||||
|
P3 a3, P4 a4) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
ConvertToV8(isolate, a4),
|
||||||
|
};
|
||||||
|
holder->Call(holder, arraysize(args), args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename V, typename P1, typename P2, typename P3, typename P4,
|
||||||
|
typename P5>
|
||||||
|
struct V8FunctionInvoker<v8::Local<V>(P1, P2, P3, P4, P5)> {
|
||||||
|
static v8::Local<V> Go(v8::Isolate* isolate, SafeV8Function function, P1 a1,
|
||||||
|
P2 a2, P3 a3, P4 a4, P5 a5) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
ConvertToV8(isolate, a4),
|
||||||
|
ConvertToV8(isolate, a5),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
return handle_scope.Escape(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename R, typename P1, typename P2, typename P3, typename P4,
|
||||||
|
typename P5>
|
||||||
|
struct V8FunctionInvoker<R(P1, P2, P3, P4, P5)> {
|
||||||
|
static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2,
|
||||||
|
P3 a3, P4 a4, P5 a5) {
|
||||||
|
R ret;
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
ConvertToV8(isolate, a4),
|
||||||
|
ConvertToV8(isolate, a5),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
Converter<R>::FromV8(isolate, val, &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename P1, typename P2, typename P3, typename P4, typename P5>
|
||||||
|
struct V8FunctionInvoker<void(P1, P2, P3, P4, P5)> {
|
||||||
|
static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2,
|
||||||
|
P3 a3, P4 a4, P5 a5) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
ConvertToV8(isolate, a4),
|
||||||
|
ConvertToV8(isolate, a5),
|
||||||
|
};
|
||||||
|
holder->Call(holder, arraysize(args), args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename V, typename P1, typename P2, typename P3, typename P4,
|
||||||
|
typename P5, typename P6>
|
||||||
|
struct V8FunctionInvoker<v8::Local<V>(P1, P2, P3, P4, P5, P6)> {
|
||||||
|
static v8::Local<V> Go(v8::Isolate* isolate, SafeV8Function function, P1 a1,
|
||||||
|
P2 a2, P3 a3, P4 a4, P5 a5, P6 a6) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
v8::EscapableHandleScope handle_scope(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
ConvertToV8(isolate, a4),
|
||||||
|
ConvertToV8(isolate, a5),
|
||||||
|
ConvertToV8(isolate, a6),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
return handle_scope.Escape(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename R, typename P1, typename P2, typename P3, typename P4,
|
||||||
|
typename P5, typename P6>
|
||||||
|
struct V8FunctionInvoker<R(P1, P2, P3, P4, P5, P6)> {
|
||||||
|
static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2,
|
||||||
|
P3 a3, P4 a4, P5 a5, P6 a6) {
|
||||||
|
R ret;
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
ConvertToV8(isolate, a4),
|
||||||
|
ConvertToV8(isolate, a5),
|
||||||
|
ConvertToV8(isolate, a6),
|
||||||
|
};
|
||||||
|
v8::Local<v8::Value> val(holder->Call(holder, arraysize(args), args));
|
||||||
|
Converter<R>::FromV8(isolate, val, &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename P1, typename P2, typename P3, typename P4, typename P5,
|
||||||
|
typename P6>
|
||||||
|
struct V8FunctionInvoker<void(P1, P2, P3, P4, P5, P6)> {
|
||||||
|
static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2,
|
||||||
|
P3 a3, P4 a4, P5 a5, P6 a6) {
|
||||||
|
Locker locker(isolate);
|
||||||
|
MATE_HANDLE_SCOPE(isolate);
|
||||||
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::Value> args[] = {
|
||||||
|
ConvertToV8(isolate, a1),
|
||||||
|
ConvertToV8(isolate, a2),
|
||||||
|
ConvertToV8(isolate, a3),
|
||||||
|
ConvertToV8(isolate, a4),
|
||||||
|
ConvertToV8(isolate, a5),
|
||||||
|
ConvertToV8(isolate, a6),
|
||||||
|
};
|
||||||
|
holder->Call(holder, arraysize(args), args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
template<typename Sig>
|
||||||
|
struct Converter<base::Callback<Sig> > {
|
||||||
|
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::Local<v8::Value> val,
|
||||||
|
base::Callback<Sig>* out) {
|
||||||
|
if (!val->IsFunction())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
internal::SafeV8Function function(
|
||||||
|
new RefCountedPersistent<v8::Function>(isolate, val));
|
||||||
|
*out = base::Bind(&internal::V8FunctionInvoker<Sig>::Go, isolate, function);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mate
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
#include "atom/renderer/api/atom_api_web_frame.h"
|
#include "atom/renderer/api/atom_api_web_frame.h"
|
||||||
|
|
||||||
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "atom/renderer/api/atom_api_spell_check_client.h"
|
#include "atom/renderer/api/atom_api_spell_check_client.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "native_mate/callback.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||||
|
|
|
@ -274,6 +274,7 @@
|
||||||
'atom/common/linux/application_info.cc',
|
'atom/common/linux/application_info.cc',
|
||||||
'atom/common/native_mate_converters/accelerator_converter.cc',
|
'atom/common/native_mate_converters/accelerator_converter.cc',
|
||||||
'atom/common/native_mate_converters/accelerator_converter.h',
|
'atom/common/native_mate_converters/accelerator_converter.h',
|
||||||
|
'atom/common/native_mate_converters/callback.h',
|
||||||
'atom/common/native_mate_converters/file_path_converter.h',
|
'atom/common/native_mate_converters/file_path_converter.h',
|
||||||
'atom/common/native_mate_converters/gfx_converter.cc',
|
'atom/common/native_mate_converters/gfx_converter.cc',
|
||||||
'atom/common/native_mate_converters/gfx_converter.h',
|
'atom/common/native_mate_converters/gfx_converter.h',
|
||||||
|
|
2
vendor/native_mate
vendored
2
vendor/native_mate
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 656e403f0102c59428261c1eaad22912d2bbd3c5
|
Subproject commit ebcf4c022467a43a5379446e1c031ffd10438b9c
|
Loading…
Reference in a new issue