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

Unified Diff: src/FileSystemJsObject.cpp

Issue 10305024: Simplify context setup, set properties on the global object directly instead of using templates (Closed)
Patch Set: Created April 18, 2013, 6:26 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
« no previous file with comments | « src/FileSystemJsObject.h ('k') | src/GlobalJsObject.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FileSystemJsObject.cpp
===================================================================
--- a/src/FileSystemJsObject.cpp
+++ b/src/FileSystemJsObject.cpp
@@ -310,27 +310,17 @@ namespace
"Second argument to _fileSystem.stat must be a function"));
StatThread* const statThread = new StatThread(jsEngine, converted[1],
converted[0]->AsString());
statThread->Start();
return v8::Undefined();
}
}
-v8::Handle<v8::ObjectTemplate>
-FileSystemJsObject::Create(JsEngine& jsEngine)
+JsValuePtr FileSystemJsObject::Setup(JsEngine& jsEngine, JsValuePtr obj)
{
- v8::HandleScope handleScope;
- const v8::Local<v8::ObjectTemplate> file = v8::ObjectTemplate::New();
- const v8::Local<v8::External> jsEngineExternal =
- v8::External::New(&jsEngine);
- file->Set(v8::String::New("read"),
- v8::FunctionTemplate::New(ReadCallback, jsEngineExternal));
- file->Set(v8::String::New("write"),
- v8::FunctionTemplate::New(WriteCallback, jsEngineExternal));
- file->Set(v8::String::New("move"),
- v8::FunctionTemplate::New(MoveCallback, jsEngineExternal));
- file->Set(v8::String::New("remove"),
- v8::FunctionTemplate::New(RemoveCallback, jsEngineExternal));
- file->Set(v8::String::New("stat"),
- v8::FunctionTemplate::New(StatCallback, jsEngineExternal));
- return handleScope.Close(file);
+ obj->SetProperty("read", jsEngine.NewCallback(::ReadCallback));
+ obj->SetProperty("write", jsEngine.NewCallback(::WriteCallback));
+ obj->SetProperty("move", jsEngine.NewCallback(::MoveCallback));
+ obj->SetProperty("remove", jsEngine.NewCallback(::RemoveCallback));
+ obj->SetProperty("stat", jsEngine.NewCallback(::StatCallback));
+ return obj;
}
« no previous file with comments | « src/FileSystemJsObject.h ('k') | src/GlobalJsObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld