#include <string>
#include <vector>
-#include "native_mate/object_template_builder.h"
+#include "native_mate/dictionary.h"
#include "ui/base/clipboard/clipboard.h"
#include "atom/common/v8/node_common.h"
}
void Initialize(v8::Handle<v8::Object> exports) {
- mate::ObjectTemplateBuilder builder(v8::Isolate::GetCurrent());
- builder.SetMethod("has", &Has)
- .SetMethod("read", &Read)
- .SetMethod("readText", &ReadText)
- .SetMethod("writeText", &WriteText)
- .SetMethod("clear", &Clear);
- exports->SetPrototype(builder.Build()->NewInstance());
+ mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+ dict.SetMethod("has", &Has);
+ dict.SetMethod("read", &Read);
+ dict.SetMethod("readText", &ReadText);
+ dict.SetMethod("writeText", &WriteText);
+ dict.SetMethod("clear", &Clear);
}
} // namespace
#include "atom/common/crash_reporter/crash_reporter.h"
#include "base/bind.h"
-#include "native_mate/object_template_builder.h"
+#include "native_mate/dictionary.h"
#include "atom/common/v8/node_common.h"
void Initialize(v8::Handle<v8::Object> exports) {
using crash_reporter::CrashReporter;
- mate::ObjectTemplateBuilder builder(v8::Isolate::GetCurrent());
- builder.SetMethod("start",
- base::Bind(&CrashReporter::Start,
- base::Unretained(CrashReporter::GetInstance())));
- exports->SetPrototype(builder.Build()->NewInstance());
+ mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+ dict.SetMethod("start",
+ base::Bind(&CrashReporter::Start,
+ base::Unretained(CrashReporter::GetInstance())));
}
} // namespace
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "native_mate/object_template_builder.h"
+#include "native_mate/dictionary.h"
#include "ui/gfx/screen.h"
#include "atom/common/v8/node_common.h"
#endif
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
-
- mate::ObjectTemplateBuilder builder(v8::Isolate::GetCurrent());
- builder.SetMethod("getCursorScreenPoint",
- base::Bind(&gfx::Screen::GetCursorScreenPoint,
- base::Unretained(screen)))
- .SetMethod("getPrimaryDisplay",
- base::Bind(&gfx::Screen::GetPrimaryDisplay,
- base::Unretained(screen)));
- exports->SetPrototype(builder.Build()->NewInstance());
+ mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+ dict.SetMethod("getCursorScreenPoint",
+ base::Bind(&gfx::Screen::GetCursorScreenPoint,
+ base::Unretained(screen)));
+ dict.SetMethod("getPrimaryDisplay",
+ base::Bind(&gfx::Screen::GetPrimaryDisplay,
+ base::Unretained(screen)));
}
} // namespace
#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"
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
// found in the LICENSE file.
#include "atom/common/api/object_life_monitor.h"
+#include "native_mate/dictionary.h"
#include "v8/include/v8-profiler.h"
#include "atom/common/v8/node_common.h"
-namespace atom {
-
-namespace api {
-
namespace {
-void CreateObjectWithName(const v8::FunctionCallbackInfo<v8::Value>& args) {
+v8::Handle<v8::Object> CreateObjectWithName(v8::Handle<v8::String> name) {
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
- t->SetClassName(args[0]->ToString());
- args.GetReturnValue().Set(t->GetFunction()->NewInstance());
+ t->SetClassName(name);
+ return t->GetFunction()->NewInstance();
}
-void GetHiddenValue(const v8::FunctionCallbackInfo<v8::Value>& args) {
- args.GetReturnValue().Set(
- args[0]->ToObject()->GetHiddenValue(args[1]->ToString()));
+v8::Handle<v8::Value> GetHiddenValue(v8::Handle<v8::Object> object,
+ v8::Handle<v8::String> key) {
+ return object->GetHiddenValue(key);
}
-void SetHiddenValue(const v8::FunctionCallbackInfo<v8::Value>& args) {
- args[0]->ToObject()->SetHiddenValue(args[1]->ToString(), args[2]);
+void SetHiddenValue(v8::Handle<v8::Object> object,
+ v8::Handle<v8::String> key,
+ v8::Handle<v8::Value> value) {
+ object->SetHiddenValue(key, value);
}
-void GetObjectHash(const v8::FunctionCallbackInfo<v8::Value>& args) {
- args.GetReturnValue().Set(args[0]->ToObject()->GetIdentityHash());
+int32_t GetObjectHash(v8::Handle<v8::Object> object) {
+ return object->GetIdentityHash();
}
-void SetDestructor(const v8::FunctionCallbackInfo<v8::Value>& args) {
- ObjectLifeMonitor::BindTo(args[0]->ToObject(), args[1]);
+void SetDestructor(v8::Handle<v8::Object> object,
+ v8::Handle<v8::Function> callback) {
+ atom::ObjectLifeMonitor::BindTo(object, callback);
}
-void TakeHeapSnapshot(const v8::FunctionCallbackInfo<v8::Value>& args) {
+void TakeHeapSnapshot() {
node::node_isolate->GetHeapProfiler()->TakeHeapSnapshot(
v8::String::New("test"));
}
-} // namespace
-
-void InitializeV8Util(v8::Handle<v8::Object> target) {
- NODE_SET_METHOD(target, "createObjectWithName", CreateObjectWithName);
- NODE_SET_METHOD(target, "getHiddenValue", GetHiddenValue);
- NODE_SET_METHOD(target, "setHiddenValue", SetHiddenValue);
- NODE_SET_METHOD(target, "getObjectHash", GetObjectHash);
- NODE_SET_METHOD(target, "setDestructor", SetDestructor);
- NODE_SET_METHOD(target, "takeHeapSnapshot", TakeHeapSnapshot);
+void Initialize(v8::Handle<v8::Object> exports) {
+ mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+ dict.SetMethod("createObjectWithName", &CreateObjectWithName);
+ dict.SetMethod("getHiddenValue", &GetHiddenValue);
+ dict.SetMethod("setHiddenValue", &SetHiddenValue);
+ dict.SetMethod("getObjectHash", &GetObjectHash);
+ dict.SetMethod("setDestructor", &SetDestructor);
+ dict.SetMethod("takeHeapSnapshot", &TakeHeapSnapshot);
}
-} // namespace api
-
-} // namespace atom
+} // namespace
-NODE_MODULE(atom_common_v8_util, atom::api::InitializeV8Util)
+NODE_MODULE(atom_common_v8_util, Initialize)
#include "atom/common/v8/v8_value_converter.h"
#include "atom/common/v8_converters/string16_converter.h"
#include "content/public/renderer/render_view.h"
-#include "native_mate/object_template_builder.h"
+#include "native_mate/dictionary.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
}
void Initialize(v8::Handle<v8::Object> exports) {
- mate::ObjectTemplateBuilder builder(v8::Isolate::GetCurrent());
- builder.SetMethod("send", &Send)
- .SetMethod("sendSync", &SendSync);
- exports->SetPrototype(builder.Build()->NewInstance());
+ mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+ dict.SetMethod("send", &Send);
+ dict.SetMethod("sendSync", &SendSync);
}
} // namespace
-Subproject commit c9fa29ef640e8d3d2edf6b48c2311b16ce314464
+Subproject commit 94dec0ff85c9337d33cae01638897bc1059b7dca