Index: src/FileSystemJsObject.cpp |
=================================================================== |
--- a/src/FileSystemJsObject.cpp |
+++ b/src/FileSystemJsObject.cpp |
@@ -72,7 +72,7 @@ |
error = "Unknown error while reading from " + path; |
} |
- const JsContext context(jsEngine); |
+ const JsContext context{*jsEngine}; |
JsValuePtr result = jsEngine->NewObject(); |
result->SetProperty("content", content); |
result->SetProperty("error", error); |
@@ -113,7 +113,7 @@ |
error = "Unknown error while writing to " + path; |
} |
- const JsContext context(jsEngine); |
+ const JsContext context{*jsEngine}; |
JsValuePtr errorValue = jsEngine->NewValue(error); |
JsValueList params; |
params.push_back(errorValue); |
@@ -151,7 +151,7 @@ |
error = "Unknown error while moving " + fromPath + " to " + toPath; |
} |
- const JsContext context(jsEngine); |
+ const JsContext context{*jsEngine}; |
JsValuePtr errorValue = jsEngine->NewValue(error); |
JsValueList params; |
params.push_back(errorValue); |
@@ -189,7 +189,7 @@ |
error = "Unknown error while removing " + path; |
} |
- const JsContext context(jsEngine); |
+ const JsContext context{*jsEngine}; |
JsValuePtr errorValue = jsEngine->NewValue(error); |
JsValueList params; |
params.push_back(errorValue); |
@@ -228,7 +228,7 @@ |
error = "Unknown error while calling stat on " + path; |
} |
- const JsContext context(jsEngine); |
+ const JsContext context{*jsEngine}; |
JsValuePtr result = jsEngine->NewObject(); |
result->SetProperty("exists", statResult.exists); |
result->SetProperty("isFile", statResult.isFile); |
@@ -246,103 +246,141 @@ |
std::string path; |
}; |
- v8::Handle<v8::Value> ReadCallback(const v8::Arguments& arguments) |
+ void ReadCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
- AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments); |
- AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
+ AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(info); |
+ AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(info); |
+ auto isolate = info.GetIsolate(); |
if (converted.size() != 2) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"_fileSystem.read requires 2 parameters")); |
+ return; |
+ } |
if (!converted[1]->IsFunction()) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"Second argument to _fileSystem.read must be a function")); |
+ return; |
+ } |
ReadThread* const readThread = new ReadThread(jsEngine, converted[1], |
converted[0]->AsString()); |
readThread->Start(); |
- return v8::Undefined(); |
} |
- v8::Handle<v8::Value> WriteCallback(const v8::Arguments& arguments) |
+ void WriteCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
- AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments); |
- AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
+ AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(info); |
+ AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(info); |
+ auto isolate = info.GetIsolate(); |
if (converted.size() != 3) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"_fileSystem.write requires 3 parameters")); |
+ return; |
+ } |
if (!converted[2]->IsFunction()) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"Third argument to _fileSystem.write must be a function")); |
+ return; |
+ } |
WriteThread* const writeThread = new WriteThread(jsEngine, converted[2], |
converted[0]->AsString(), converted[1]->AsString()); |
writeThread->Start(); |
- return v8::Undefined(); |
} |
- v8::Handle<v8::Value> MoveCallback(const v8::Arguments& arguments) |
+ void MoveCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
- AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments); |
- AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
+ AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(info); |
+ AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(info); |
+ auto isolate = info.GetIsolate(); |
if (converted.size() != 3) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"_fileSystem.move requires 3 parameters")); |
+ return; |
+ } |
+ |
if (!converted[2]->IsFunction()) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"Third argument to _fileSystem.move must be a function")); |
+ return; |
+ } |
MoveThread* const moveThread = new MoveThread(jsEngine, converted[2], |
converted[0]->AsString(), converted[1]->AsString()); |
moveThread->Start(); |
- return v8::Undefined(); |
} |
- v8::Handle<v8::Value> RemoveCallback(const v8::Arguments& arguments) |
+ void RemoveCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
- AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments); |
- AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
+ AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(info); |
+ AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(info); |
+ auto isolate = info.GetIsolate(); |
if (converted.size() != 2) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"_fileSystem.remove requires 2 parameters")); |
+ return; |
+ } |
+ |
if (!converted[1]->IsFunction()) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"Second argument to _fileSystem.remove must be a function")); |
+ return; |
+ } |
RemoveThread* const removeThread = new RemoveThread(jsEngine, converted[1], |
converted[0]->AsString()); |
removeThread->Start(); |
- return v8::Undefined(); |
} |
- v8::Handle<v8::Value> StatCallback(const v8::Arguments& arguments) |
+ void StatCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
- AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments); |
- AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
+ AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(info); |
+ AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(info); |
+ auto isolate = info.GetIsolate(); |
if (converted.size() != 2) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"_fileSystem.stat requires 2 parameters")); |
+ return; |
+ } |
+ |
if (!converted[1]->IsFunction()) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"Second argument to _fileSystem.stat must be a function")); |
+ return; |
+ } |
+ |
StatThread* const statThread = new StatThread(jsEngine, converted[1], |
converted[0]->AsString()); |
statThread->Start(); |
- return v8::Undefined(); |
} |
- v8::Handle<v8::Value> ResolveCallback(const v8::Arguments& arguments) |
+ void ResolveCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
- AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments); |
- AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
+ AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(info); |
+ AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(info); |
+ auto isolate = info.GetIsolate(); |
if (converted.size() != 1) |
- return v8::ThrowException(v8::String::New( |
+ { |
+ isolate->ThrowException(AdblockPlus::Utils::ToV8String(isolate, |
"_fileSystem.resolve requires 1 parameter")); |
+ return; |
+ } |
std::string resolved = jsEngine->GetFileSystem()->Resolve(converted[0]->AsString()); |
- return Utils::ToV8String(arguments.GetIsolate(), resolved); |
+ info.GetReturnValue().Set(Utils::ToV8String(isolate, resolved)); |
} |
} |