Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: gin/modules/console.cc

Issue 108723006: Gin: Fix console module to be varargs again. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ad Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gin/function_template.h.pump ('k') | gin/test/expect.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gin/modules/console.h" 5 #include "gin/modules/console.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "gin/arguments.h" 10 #include "gin/arguments.h"
11 #include "gin/converter.h" 11 #include "gin/converter.h"
12 #include "gin/object_template_builder.h" 12 #include "gin/object_template_builder.h"
13 #include "gin/per_isolate_data.h" 13 #include "gin/per_isolate_data.h"
14 #include "gin/public/wrapper_info.h" 14 #include "gin/public/wrapper_info.h"
15 15
16 using v8::ObjectTemplate; 16 using v8::ObjectTemplate;
17 17
18 namespace gin { 18 namespace gin {
19 19
20 namespace { 20 namespace {
21 21
22 void Log(const std::vector<std::string>& messages) { 22 void Log(Arguments* args) {
23 std::vector<std::string> messages;
24 if (!args->GetRemaining(&messages)) {
25 args->ThrowError();
26 return;
27 }
23 std::cout << JoinString(messages, ' ') << std::endl; 28 std::cout << JoinString(messages, ' ') << std::endl;
24 } 29 }
25 30
26 WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; 31 WrapperInfo g_wrapper_info = { kEmbedderNativeGin };
27 32
28 } // namespace 33 } // namespace
29 34
30 const char Console::kModuleName[] = "console"; 35 const char Console::kModuleName[] = "console";
31 36
32 v8::Local<v8::Value> Console::GetModule(v8::Isolate* isolate) { 37 v8::Local<v8::Value> Console::GetModule(v8::Isolate* isolate) {
33 PerIsolateData* data = PerIsolateData::From(isolate); 38 PerIsolateData* data = PerIsolateData::From(isolate);
34 v8::Local<ObjectTemplate> templ = data->GetObjectTemplate(&g_wrapper_info); 39 v8::Local<ObjectTemplate> templ = data->GetObjectTemplate(&g_wrapper_info);
35 if (templ.IsEmpty()) { 40 if (templ.IsEmpty()) {
36 templ = ObjectTemplateBuilder(isolate) 41 templ = ObjectTemplateBuilder(isolate)
37 .SetMethod("log", Log) 42 .SetMethod("log", Log)
38 .Build(); 43 .Build();
39 data->SetObjectTemplate(&g_wrapper_info, templ); 44 data->SetObjectTemplate(&g_wrapper_info, templ);
40 } 45 }
41 return templ->NewInstance(); 46 return templ->NewInstance();
42 } 47 }
43 48
44 } // namespace gin 49 } // namespace gin
OLDNEW
« no previous file with comments | « gin/function_template.h.pump ('k') | gin/test/expect.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698