diff options
Diffstat (limited to 'gin')
-rw-r--r-- | gin/modules/console.cc | 15 | ||||
-rw-r--r-- | gin/modules/module_runner_delegate.cc | 4 |
2 files changed, 8 insertions, 11 deletions
diff --git a/gin/modules/console.cc b/gin/modules/console.cc index 1484994..84c620a 100644 --- a/gin/modules/console.cc +++ b/gin/modules/console.cc @@ -9,6 +9,7 @@ #include "base/strings/string_util.h" #include "gin/arguments.h" #include "gin/converter.h" +#include "gin/object_template_builder.h" #include "gin/per_isolate_data.h" #include "gin/public/wrapper_info.h" @@ -18,13 +19,7 @@ namespace gin { namespace { -void Log(const v8::FunctionCallbackInfo<v8::Value>& info) { - Arguments args(info); - - std::vector<std::string> messages; - if (!args.GetRemaining(&messages)) - return args.ThrowTypeError("Expected strings."); - +void Log(const std::vector<std::string>& messages) { std::cout << JoinString(messages, ' ') << std::endl; } @@ -38,9 +33,9 @@ v8::Local<ObjectTemplate> Console::GetTemplate(v8::Isolate* isolate) { PerIsolateData* data = PerIsolateData::From(isolate); v8::Local<ObjectTemplate> templ = data->GetObjectTemplate(&g_wrapper_info); if (templ.IsEmpty()) { - templ = ObjectTemplate::New(); - templ->Set(StringToSymbol(isolate, "log"), - v8::FunctionTemplate::New(isolate, Log)); + templ = ObjectTemplateBuilder(isolate) + .SetMethod("log", Log) + .Build(); data->SetObjectTemplate(&g_wrapper_info, templ); } return templ; diff --git a/gin/modules/module_runner_delegate.cc b/gin/modules/module_runner_delegate.cc index 9bf2863..404f5dc 100644 --- a/gin/modules/module_runner_delegate.cc +++ b/gin/modules/module_runner_delegate.cc @@ -5,6 +5,7 @@ #include "gin/modules/module_runner_delegate.h" #include "gin/modules/module_registry.h" +#include "gin/object_template_builder.h" namespace gin { @@ -30,7 +31,8 @@ void ModuleRunnerDelegate::AttemptToLoadMoreModules(Runner* runner) { v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate( Runner* runner) { - v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); + v8::Handle<v8::ObjectTemplate> templ = + ObjectTemplateBuilder(runner->isolate()).Build(); ModuleRegistry::RegisterGlobals(runner->isolate(), templ); return templ; } |