Use Dictionary to set module.exports.

This commit is contained in:
Cheng Zhao 2014-04-16 15:31:59 +08:00
parent aa1efe70e2
commit a2407c6b02
7 changed files with 59 additions and 68 deletions

View file

@ -6,7 +6,7 @@
#include "atom/common/platform_util.h"
#include "atom/common/v8_converters/file_path_converter.h"
#include "native_mate/object_template_builder.h"
#include "native_mate/dictionary.h"
#include "url/gurl.h"
#include "atom/common/v8/node_common.h"
@ -33,13 +33,12 @@ struct Converter<GURL> {
namespace {
void Initialize(v8::Handle<v8::Object> exports) {
mate::ObjectTemplateBuilder builder(v8::Isolate::GetCurrent());
builder.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder)
.SetMethod("openItem", &platform_util::OpenItem)
.SetMethod("openExternal", &platform_util::OpenExternal)
.SetMethod("moveItemToTrash", &platform_util::MoveItemToTrash)
.SetMethod("beep", &platform_util::Beep);
exports->SetPrototype(builder.Build()->NewInstance());
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
dict.SetMethod("openItem", &platform_util::OpenItem);
dict.SetMethod("openExternal", &platform_util::OpenExternal);
dict.SetMethod("moveItemToTrash", &platform_util::MoveItemToTrash);
dict.SetMethod("beep", &platform_util::Beep);
}
} // namespace