From a61413414436e1c7c6aa5e80d8d107f4f1b3cede Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 5 Dec 2013 10:35:57 +0800 Subject: [PATCH] Simplify V8 operations. --- browser/api/atom_api_app.cc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/browser/api/atom_api_app.cc b/browser/api/atom_api_app.cc index 3bb7fd6..375087a 100644 --- a/browser/api/atom_api_app.cc +++ b/browser/api/atom_api_app.cc @@ -101,11 +101,7 @@ v8::Handle App::Focus(const v8::Arguments &args) { // static v8::Handle App::GetVersion(const v8::Arguments &args) { - v8::HandleScope scope; - - std::string version(Browser::Get()->GetVersion()); - - return v8::String::New(version.data(), version.size()); + return ToV8Value(Browser::Get()->GetVersion()); } // static @@ -123,11 +119,7 @@ v8::Handle App::SetVersion(const v8::Arguments &args) { // static v8::Handle App::GetName(const v8::Arguments &args) { - v8::HandleScope scope; - - std::string name(Browser::Get()->GetName()); - - return v8::String::New(name.data(), version.size()); + return ToV8Value(Browser::Get()->GetName()); } // static @@ -179,7 +171,10 @@ v8::Handle App::AppendArgument(const v8::Arguments &args) { // static v8::Handle App::DockBounce(const v8::Arguments& args) { - std::string type = FromV8Value(args[0]); + std::string type; + if (!FromV8Arguments(args, &type)) + return node::ThrowError("Bad argument"); + int request_id = -1; if (type == "critical") @@ -189,7 +184,7 @@ v8::Handle App::DockBounce(const v8::Arguments& args) { else return node::ThrowTypeError("Invalid bounce type"); - return v8::Integer::New(request_id); + return ToV8Value(request_id); } // static -- 2.7.4