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

Unified Diff: src/ConsoleJsObject.cpp

Issue 10305024: Simplify context setup, set properties on the global object directly instead of using templates (Closed)
Patch Set: Unbitrotted patch Created April 18, 2013, 11:44 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/ConsoleJsObject.cpp
===================================================================
--- a/src/ConsoleJsObject.cpp
+++ b/src/ConsoleJsObject.cpp
@@ -22,22 +22,15 @@ namespace
}
v8::Handle<v8::Value> TraceCallback(const v8::Arguments& arguments)
{
return v8::Undefined();
}
}
-v8::Handle<v8::ObjectTemplate> AdblockPlus::ConsoleJsObject::Create(
- AdblockPlus::JsEngine& jsEngine)
+AdblockPlus::JsValuePtr AdblockPlus::ConsoleJsObject::Setup(
+ AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValuePtr obj)
{
- v8::HandleScope handleScope;
- const v8::Handle<v8::ObjectTemplate> console = v8::ObjectTemplate::New();
- const v8::Handle<v8::FunctionTemplate> errorFunction =
- v8::FunctionTemplate::New(::ErrorCallback,
- v8::External::New(&jsEngine));
- console->Set(v8::String::New("error"), errorFunction);
- const v8::Handle<v8::FunctionTemplate> traceFunction =
- v8::FunctionTemplate::New(TraceCallback);
- console->Set(v8::String::New("trace"), traceFunction);
- return handleScope.Close(console);
+ obj->SetProperty("error", jsEngine.NewCallback(::ErrorCallback));
+ obj->SetProperty("trace", jsEngine.NewCallback(::TraceCallback));
+ return obj;
}
« no previous file with comments | « src/ConsoleJsObject.h ('k') | src/FileSystemJsObject.h » ('j') | src/GlobalJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld