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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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"
#endif
#include "atom/common/v8/node_common.h"
#include "atom/common/node_includes.h"
using content::BrowserThread;

View file

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

View file

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

View file

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