| OLD | NEW |
| 1 #include <AdblockPlus/FileSystem.h> | 1 #include <AdblockPlus/FileSystem.h> |
| 2 #include <stdexcept> | 2 #include <stdexcept> |
| 3 #include <sstream> | 3 #include <sstream> |
| 4 #include <vector> | 4 #include <vector> |
| 5 | 5 |
| 6 #include <AdblockPlus/JsEngine.h> | 6 #include <AdblockPlus/JsEngine.h> |
| 7 #include <AdblockPlus/JsValue.h> | 7 #include <AdblockPlus/JsValue.h> |
| 8 #include "FileSystemJsObject.h" | 8 #include "FileSystemJsObject.h" |
| 9 #include "Utils.h" | 9 #include "Utils.h" |
| 10 #include "Thread.h" | 10 #include "Thread.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 if (!converted[1]->IsFunction()) | 308 if (!converted[1]->IsFunction()) |
| 309 return v8::ThrowException(v8::String::New( | 309 return v8::ThrowException(v8::String::New( |
| 310 "Second argument to _fileSystem.stat must be a function")); | 310 "Second argument to _fileSystem.stat must be a function")); |
| 311 StatThread* const statThread = new StatThread(jsEngine, converted[1], | 311 StatThread* const statThread = new StatThread(jsEngine, converted[1], |
| 312 converted[0]->AsString()); | 312 converted[0]->AsString()); |
| 313 statThread->Start(); | 313 statThread->Start(); |
| 314 return v8::Undefined(); | 314 return v8::Undefined(); |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 | 317 |
| 318 v8::Handle<v8::ObjectTemplate> | 318 JsValuePtr FileSystemJsObject::Setup(JsEngine& jsEngine, JsValuePtr obj) |
| 319 FileSystemJsObject::Create(JsEngine& jsEngine) | |
| 320 { | 319 { |
| 321 v8::HandleScope handleScope; | 320 obj->SetProperty("read", jsEngine.NewCallback(::ReadCallback)); |
| 322 const v8::Local<v8::ObjectTemplate> file = v8::ObjectTemplate::New(); | 321 obj->SetProperty("write", jsEngine.NewCallback(::WriteCallback)); |
| 323 const v8::Local<v8::External> jsEngineExternal = | 322 obj->SetProperty("move", jsEngine.NewCallback(::MoveCallback)); |
| 324 v8::External::New(&jsEngine); | 323 obj->SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); |
| 325 file->Set(v8::String::New("read"), | 324 obj->SetProperty("stat", jsEngine.NewCallback(::StatCallback)); |
| 326 v8::FunctionTemplate::New(ReadCallback, jsEngineExternal)); | 325 return obj; |
| 327 file->Set(v8::String::New("write"), | |
| 328 v8::FunctionTemplate::New(WriteCallback, jsEngineExternal)); | |
| 329 file->Set(v8::String::New("move"), | |
| 330 v8::FunctionTemplate::New(MoveCallback, jsEngineExternal)); | |
| 331 file->Set(v8::String::New("remove"), | |
| 332 v8::FunctionTemplate::New(RemoveCallback, jsEngineExternal)); | |
| 333 file->Set(v8::String::New("stat"), | |
| 334 v8::FunctionTemplate::New(StatCallback, jsEngineExternal)); | |
| 335 return handleScope.Close(file); | |
| 336 } | 326 } |
| OLD | NEW |