Put converters under atom/common/native_mate_converters.

This commit is contained in:
Cheng Zhao 2014-04-17 13:45:14 +08:00
Родитель 84397052fd
Коммит 5dae7b8658
38 изменённых файлов: 109 добавлений и 73 удалений

Просмотреть файл

@ -174,6 +174,12 @@
'atom/common/draggable_region.cc',
'atom/common/draggable_region.h',
'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.h',
'atom/common/node_bindings_linux.cc',
@ -182,6 +188,7 @@
'atom/common/node_bindings_mac.h',
'atom/common/node_bindings_win.cc',
'atom/common/node_bindings_win.h',
'atom/common/node_includes.h',
'atom/common/options_switches.cc',
'atom/common/options_switches.h',
'atom/common/platform_util.h',
@ -189,11 +196,8 @@
'atom/common/platform_util_mac.mm',
'atom/common/platform_util_win.cc',
'atom/common/swap_or_assign.h',
'atom/common/v8/node_common.h',
'atom/common/v8/scoped_persistent.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_renderer_bindings.cc',
'atom/renderer/api/atom_renderer_bindings.h',

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -5,7 +5,7 @@
#include "atom/browser/api/atom_api_browser_ipc.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 "content/public/browser/render_view_host.h"

Просмотреть файл

@ -10,11 +10,11 @@
#include "atom/browser/native_window.h"
#include "atom/browser/ui/file_dialog.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/scoped_persistent.h"
#include "atom/common/v8/node_common.h"
#include "atom/common/node_includes.h"
namespace mate {

Просмотреть файл

@ -5,7 +5,7 @@
#include "atom/browser/api/atom_api_event.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 "content/public/browser/web_contents.h"

Просмотреть файл

@ -7,7 +7,7 @@
#include <string>
#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"
#define UNWRAP_MEMNU_AND_CHECK \

Просмотреть файл

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

Просмотреть файл

@ -7,7 +7,7 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/sys_string_conversions.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 "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"

Просмотреть файл

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

Просмотреть файл

@ -7,7 +7,7 @@
#include "base/power_monitor/power_monitor.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 {

Просмотреть файл

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

Просмотреть файл

@ -16,7 +16,7 @@
#include "ui/gfx/point.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"
using content::NavigationController;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -5,11 +5,11 @@
#include <string>
#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 "url/gurl.h"
#include "atom/common/v8/node_common.h"
#include "atom/common/node_includes.h"
namespace mate {

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_COMMON_V8_CONVERTERS_FILE_PATH_CONVERTER_H_
#define ATOM_COMMON_V8_CONVERTERS_FILE_PATH_CONVERTER_H_
#ifndef ATOM_COMMON_NATIVE_MATE_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"
namespace mate {
@ -20,7 +22,7 @@ struct Converter<base::FilePath> {
v8::Handle<v8::Value> val,
base::FilePath* out) {
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);
return true;
} else {
@ -31,4 +33,4 @@ struct Converter<base::FilePath> {
} // namespace mate
#endif // ATOM_COMMON_V8_CONVERTERS_FILE_PATH_CONVERTER_H_
#endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_

Просмотреть файл

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

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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 <utility>

Просмотреть файл

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

Просмотреть файл

@ -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

Просмотреть файл

@ -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_

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -12,7 +12,7 @@
#include "atom/browser/api/atom_api_window.h"
#include "atom/common/swap_or_assign.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/strings/string16.h"
#include "base/template_util.h"

Просмотреть файл

@ -3,40 +3,19 @@
// found in the LICENSE file.
#include "atom/common/api/api_messages.h"
#include "atom/common/v8/v8_value_converter.h"
#include "atom/common/v8_converters/string16_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "content/public/renderer/render_view.h"
#include "native_mate/dictionary.h"
#include "third_party/WebKit/public/web/WebFrame.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 WebKit::WebFrame;
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 {
RenderView* GetCurrentRenderView() {

Просмотреть файл

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

Просмотреть файл

@ -16,7 +16,7 @@
#include "third_party/WebKit/public/web/WebFrame.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;

Просмотреть файл

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