Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/ConsoleJsObject.cpp

Issue 10252009: Support multiple arguments properly in console.error (Closed)
Patch Set: Created April 11, 2013, 10:59 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ConsoleJsObject.h ('k') | test/ConsoleJsObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <AdblockPlus/ErrorCallback.h>
1 #include <sstream> 2 #include <sstream>
2 3
3 #include "ConsoleJsObject.h" 4 #include "ConsoleJsObject.h"
4 5
5 namespace 6 namespace
6 { 7 {
7 v8::Handle<v8::Value> ErrorCallback(const v8::Arguments& arguments) 8 v8::Handle<v8::Value> ErrorCallback(const v8::Arguments& arguments)
8 { 9 {
9 std::stringstream message; 10 std::stringstream message;
10 const v8::HandleScope handleScope; 11 const v8::HandleScope handleScope;
11 for (int i = 0; i < arguments.Length(); i++) 12 for (int i = 0; i < arguments.Length(); i++)
12 { 13 {
13 const v8::Handle<v8::Value> argument = arguments[0]; 14 const v8::Handle<v8::Value> argument = arguments[i];
14 const v8::String::Utf8Value value(argument); 15 const v8::String::Utf8Value value(argument);
15 message << *value; 16 message << *value;
16 } 17 }
17 const v8::Handle<const v8::External> external = 18 const v8::Handle<const v8::External> external =
18 v8::Handle<const v8::External>::Cast(arguments.Data()); 19 v8::Handle<const v8::External>::Cast(arguments.Data());
19 AdblockPlus::ErrorCallback* const errorCallback = 20 AdblockPlus::ErrorCallback* const errorCallback =
20 static_cast<AdblockPlus::ErrorCallback*>(external->Value()); 21 static_cast<AdblockPlus::ErrorCallback*>(external->Value());
21 (*errorCallback)(message.str()); 22 (*errorCallback)(message.str());
22 return v8::Undefined(); 23 return v8::Undefined();
23 } 24 }
(...skipping 11 matching lines...) Expand all
35 const v8::Handle<v8::ObjectTemplate> console = v8::ObjectTemplate::New(); 36 const v8::Handle<v8::ObjectTemplate> console = v8::ObjectTemplate::New();
36 const v8::Handle<v8::FunctionTemplate> errorFunction = 37 const v8::Handle<v8::FunctionTemplate> errorFunction =
37 v8::FunctionTemplate::New(::ErrorCallback, 38 v8::FunctionTemplate::New(::ErrorCallback,
38 v8::External::New(&errorCallback)); 39 v8::External::New(&errorCallback));
39 console->Set(v8::String::New("error"), errorFunction); 40 console->Set(v8::String::New("error"), errorFunction);
40 const v8::Handle<v8::FunctionTemplate> traceFunction = 41 const v8::Handle<v8::FunctionTemplate> traceFunction =
41 v8::FunctionTemplate::New(TraceCallback); 42 v8::FunctionTemplate::New(TraceCallback);
42 console->Set(v8::String::New("trace"), traceFunction); 43 console->Set(v8::String::New("trace"), traceFunction);
43 return handleScope.Close(console); 44 return handleScope.Close(console);
44 } 45 }
OLDNEW
« no previous file with comments | « src/ConsoleJsObject.h ('k') | test/ConsoleJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld