Put converters under atom/common/native_mate_converters.

This commit is contained in:
Cheng Zhao 2014-04-17 13:45:14 +08:00
parent 84397052fd
commit 5dae7b8658
38 changed files with 109 additions and 73 deletions

View file

@ -174,6 +174,12 @@
'atom/common/draggable_region.cc', 'atom/common/draggable_region.cc',
'atom/common/draggable_region.h', 'atom/common/draggable_region.h',
'atom/common/linux/application_info.cc', 'atom/common/linux/application_info.cc',
'atom/common/native_mate_converters/file_path_converter.h',
'atom/common/native_mate_converters/string16_converter.h',
'atom/common/native_mate_converters/v8_value_converter.cc',
'atom/common/native_mate_converters/v8_value_converter.h',
'atom/common/native_mate_converters/value_converter.cc',
'atom/common/native_mate_converters/value_converter.h',
'atom/common/node_bindings.cc', 'atom/common/node_bindings.cc',
'atom/common/node_bindings.h', 'atom/common/node_bindings.h',
'atom/common/node_bindings_linux.cc', 'atom/common/node_bindings_linux.cc',
@ -182,6 +188,7 @@
'atom/common/node_bindings_mac.h', 'atom/common/node_bindings_mac.h',
'atom/common/node_bindings_win.cc', 'atom/common/node_bindings_win.cc',
'atom/common/node_bindings_win.h', 'atom/common/node_bindings_win.h',
'atom/common/node_includes.h',
'atom/common/options_switches.cc', 'atom/common/options_switches.cc',
'atom/common/options_switches.h', 'atom/common/options_switches.h',
'atom/common/platform_util.h', 'atom/common/platform_util.h',
@ -189,11 +196,8 @@
'atom/common/platform_util_mac.mm', 'atom/common/platform_util_mac.mm',
'atom/common/platform_util_win.cc', 'atom/common/platform_util_win.cc',
'atom/common/swap_or_assign.h', 'atom/common/swap_or_assign.h',
'atom/common/v8/node_common.h',
'atom/common/v8/scoped_persistent.h', 'atom/common/v8/scoped_persistent.h',
'atom/common/v8/native_type_conversions.h', 'atom/common/v8/native_type_conversions.h',
'atom/common/v8/v8_value_converter.cc',
'atom/common/v8/v8_value_converter.h',
'atom/renderer/api/atom_api_renderer_ipc.cc', 'atom/renderer/api/atom_api_renderer_ipc.cc',
'atom/renderer/api/atom_renderer_bindings.cc', 'atom/renderer/api/atom_renderer_bindings.cc',
'atom/renderer/api/atom_renderer_bindings.h', 'atom/renderer/api/atom_renderer_bindings.h',

View file

@ -11,7 +11,7 @@
#include "atom/browser/browser.h" #include "atom/browser/browser.h"
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/v8/native_type_conversions.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -9,7 +9,7 @@
#include "atom/browser/auto_updater.h" #include "atom/browser/auto_updater.h"
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/v8/native_type_conversions.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -5,7 +5,7 @@
#include "atom/browser/api/atom_api_browser_ipc.h" #include "atom/browser/api/atom_api_browser_ipc.h"
#include "atom/common/api/api_messages.h" #include "atom/common/api/api_messages.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"

View file

@ -10,11 +10,11 @@
#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/v8_converters/file_path_converter.h" #include "atom/common/native_mate_converters/file_path_converter.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "native_mate/scoped_persistent.h" #include "native_mate/scoped_persistent.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace mate { namespace mate {

View file

@ -5,7 +5,7 @@
#include "atom/browser/api/atom_api_event.h" #include "atom/browser/api/atom_api_event.h"
#include "atom/common/api/api_messages.h" #include "atom/common/api/api_messages.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"

View file

@ -7,7 +7,7 @@
#include <string> #include <string>
#include "atom/browser/ui/accelerator_util.h" #include "atom/browser/ui/accelerator_util.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/v8/native_type_conversions.h"
#define UNWRAP_MEMNU_AND_CHECK \ #define UNWRAP_MEMNU_AND_CHECK \

View file

@ -10,7 +10,7 @@
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -7,7 +7,7 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "atom/browser/native_window.h" #include "atom/browser/native_window.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_contents_view.h"

View file

@ -10,7 +10,7 @@
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -7,7 +7,7 @@
#include "base/power_monitor/power_monitor.h" #include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_device_source.h" #include "base/power_monitor/power_monitor_device_source.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -13,7 +13,7 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -16,7 +16,7 @@
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
#include "vendor/node/src/node_buffer.h" #include "vendor/node/src/node_buffer.h"
using content::NavigationController; using content::NavigationController;

View file

@ -11,7 +11,7 @@
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/v8/native_type_conversions.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -15,7 +15,7 @@
#include "ui/gfx/win/dpi.h" #include "ui/gfx/win/dpi.h"
#endif #endif
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -8,7 +8,7 @@
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace { namespace {

View file

@ -9,7 +9,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace mate { namespace mate {

View file

@ -10,7 +10,7 @@
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/v8/native_type_conversions.h"
#include "base/logging.h" #include "base/logging.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -10,7 +10,7 @@
#include "native_mate/constructor.h" #include "native_mate/constructor.h"
#include "native_mate/object_template_builder.h" #include "native_mate/object_template_builder.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -5,7 +5,7 @@
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
#if defined(TOOLKIT_GTK) #if defined(TOOLKIT_GTK)
#include "base/command_line.h" #include "base/command_line.h"

View file

@ -5,11 +5,11 @@
#include <string> #include <string>
#include "atom/common/platform_util.h" #include "atom/common/platform_util.h"
#include "atom/common/v8_converters/file_path_converter.h" #include "atom/common/native_mate_converters/file_path_converter.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "url/gurl.h" #include "url/gurl.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace mate { namespace mate {

View file

@ -6,7 +6,7 @@
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "v8/include/v8-profiler.h" #include "v8/include/v8-profiler.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace { namespace {

View file

@ -10,7 +10,7 @@
#include "atom/common/v8/native_type_conversions.h" #include "atom/common/v8/native_type_conversions.h"
#include "base/logging.h" #include "base/logging.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -8,7 +8,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "vendor/node/src/node_version.h" #include "vendor/node/src/node_version.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATOM_COMMON_V8_CONVERTERS_FILE_PATH_CONVERTER_H_ #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_
#define ATOM_COMMON_V8_CONVERTERS_FILE_PATH_CONVERTER_H_ #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_
#include "atom/common/v8_converters/string16_converter.h" #include <string>
#include "atom/common/native_mate_converters/string16_converter.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
namespace mate { namespace mate {
@ -20,7 +22,7 @@ struct Converter<base::FilePath> {
v8::Handle<v8::Value> val, v8::Handle<v8::Value> val,
base::FilePath* out) { base::FilePath* out) {
base::FilePath::StringType path; base::FilePath::StringType path;
if (Converter<std::string>::FromV8(isolate, val, &path)) { if (Converter<base::FilePath::StringType>::FromV8(isolate, val, &path)) {
*out = base::FilePath(path); *out = base::FilePath(path);
return true; return true;
} else { } else {
@ -31,4 +33,4 @@ struct Converter<base::FilePath> {
} // namespace mate } // namespace mate
#endif // ATOM_COMMON_V8_CONVERTERS_FILE_PATH_CONVERTER_H_ #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_

View file

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATOM_COMMON_V8_CONVERTERS_STRING16_CONVERTER_H_ #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_STRING16_CONVERTER_H_
#define ATOM_COMMON_V8_CONVERTERS_STRING16_CONVERTER_H_ #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_STRING16_CONVERTER_H_
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "native_mate/converter.h" #include "native_mate/converter.h"
@ -28,4 +28,4 @@ struct Converter<string16> {
} // namespace mate } // namespace mate
#endif // ATOM_COMMON_V8_CONVERTERS_STRING16_CONVERTER_H_ #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_STRING16_CONVERTER_H_

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "atom/common/v8/v8_value_converter.h" #include "atom/common/native_mate_converters/v8_value_converter.h"
#include <string> #include <string>
#include <utility> #include <utility>

View file

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATOM_COMMON_V8_V8_VALUE_CONVERTER_H_ #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
#define ATOM_COMMON_V8_V8_VALUE_CONVERTER_H_ #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
#include <map> #include <map>
@ -77,4 +77,4 @@ class V8ValueConverter {
} // namespace atom } // namespace atom
#endif // ATOM_COMMON_V8_V8_VALUE_CONVERTER_H_ #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_

View file

@ -0,0 +1,26 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/native_mate_converters/v8_value_converter.h"
#include "base/values.h"
namespace mate {
bool Converter<base::ListValue>::FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
base::ListValue* out) {
scoped_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
scoped_ptr<base::Value> value(converter->FromV8Value(
val, v8::Context::GetCurrent()));
if (value->IsType(base::Value::TYPE_LIST)) {
out->Swap(static_cast<ListValue*>(value.get()));
return true;
} else {
return false;
}
}
} // namespace mate

View file

@ -0,0 +1,25 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_VALUE_CONVERTER_H_
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_VALUE_CONVERTER_H_
#include "native_mate/converter.h"
namespace base {
class ListValue;
}
namespace mate {
template<>
struct Converter<base::ListValue> {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
base::ListValue* out);
};
} // namespace mate
#endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_VALUE_CONVERTER_H_

View file

@ -18,7 +18,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#endif #endif
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
using content::BrowserThread; using content::BrowserThread;

View file

@ -9,7 +9,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATOM_COMMON_V8_NODE_COMMON_H_ #ifndef ATOM_COMMON_NODE_INCLUDES_H_
#define ATOM_COMMON_V8_NODE_COMMON_H_ #define ATOM_COMMON_NODE_INCLUDES_H_
// Include common headers for using node APIs. // Include common headers for using node APIs.
@ -24,4 +24,4 @@ namespace atom {
extern node::Environment* global_env; extern node::Environment* global_env;
} }
#endif // ATOM_COMMON_V8_NODE_COMMON_H_ #endif // ATOM_COMMON_NODE_INCLUDES_H_

View file

@ -12,7 +12,7 @@
#include "atom/browser/api/atom_api_window.h" #include "atom/browser/api/atom_api_window.h"
#include "atom/common/swap_or_assign.h" #include "atom/common/swap_or_assign.h"
#include "atom/common/v8/scoped_persistent.h" #include "atom/common/v8/scoped_persistent.h"
#include "atom/common/v8/v8_value_converter.h" #include "atom/common/native_mate_converters/v8_value_converter.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/template_util.h" #include "base/template_util.h"

View file

@ -3,40 +3,19 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "atom/common/api/api_messages.h" #include "atom/common/api/api_messages.h"
#include "atom/common/v8/v8_value_converter.h" #include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/v8_converters/string16_converter.h" #include "atom/common/native_mate_converters/value_converter.h"
#include "content/public/renderer/render_view.h" #include "content/public/renderer/render_view.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebView.h" #include "third_party/WebKit/public/web/WebView.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
using content::RenderView; using content::RenderView;
using WebKit::WebFrame; using WebKit::WebFrame;
using WebKit::WebView; using WebKit::WebView;
namespace mate {
template<>
struct Converter<base::ListValue> {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
base::ListValue* out) {
scoped_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
scoped_ptr<base::Value> value(converter->FromV8Value(
val, v8::Context::GetCurrent()));
if (value->IsType(base::Value::TYPE_LIST)) {
out->Swap(static_cast<ListValue*>(value.get()));
return true;
} else {
return false;
}
}
};
} // namespace mate
namespace { namespace {
RenderView* GetCurrentRenderView() { RenderView* GetCurrentRenderView() {

View file

@ -11,7 +11,7 @@
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebView.h" #include "third_party/WebKit/public/web/WebView.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {

View file

@ -16,7 +16,7 @@
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebView.h" #include "third_party/WebKit/public/web/WebView.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
using WebKit::WebFrame; using WebKit::WebFrame;

View file

@ -15,7 +15,7 @@
#include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
#include "atom/common/v8/node_common.h" #include "atom/common/node_includes.h"
namespace atom { namespace atom {