 Issue 29813591:
  Issue 6526 - Use Maybe<> version of soon to be deprecated API in v8 6.7  (Closed) 
  Base URL: https://hg.adblockplus.org/libadblockplus/
    
  
    Issue 29813591:
  Issue 6526 - Use Maybe<> version of soon to be deprecated API in v8 6.7  (Closed) 
  Base URL: https://hg.adblockplus.org/libadblockplus/| Index: src/JsValue.cpp | 
| =================================================================== | 
| --- a/src/JsValue.cpp | 
| +++ b/src/JsValue.cpp | 
| @@ -131,50 +131,60 @@ | 
| { | 
| const JsContext context(*jsEngine); | 
| return Utils::StringBufferFromV8String(jsEngine->GetIsolate(), UnwrapValue()); | 
| } | 
| int64_t AdblockPlus::JsValue::AsInt() const | 
| { | 
| const JsContext context(*jsEngine); | 
| - return UnwrapValue()->IntegerValue(); | 
| + auto currentContext = jsEngine->GetIsolate()->GetCurrentContext(); | 
| + auto value = UnwrapValue()->IntegerValue(currentContext); | 
| + return CHECKED_TO_VALUE(std::move(value)); | 
| 
sergei
2018/08/07 16:47:35
I find the usage of std::move good here too, for t
 | 
| } | 
| bool AdblockPlus::JsValue::AsBool() const | 
| { | 
| const JsContext context(*jsEngine); | 
| - return UnwrapValue()->BooleanValue(); | 
| + auto currentContext = jsEngine->GetIsolate()->GetCurrentContext(); | 
| + auto value = UnwrapValue()->BooleanValue(currentContext); | 
| + return CHECKED_TO_VALUE(std::move(value)); | 
| } | 
| AdblockPlus::JsValueList AdblockPlus::JsValue::AsList() const | 
| { | 
| if (!IsArray()) | 
| throw std::runtime_error("Cannot convert a non-array to list"); | 
| const JsContext context(*jsEngine); | 
| + auto isolate = jsEngine->GetIsolate(); | 
| + auto currentContext = isolate->GetCurrentContext(); | 
| JsValueList result; | 
| v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(UnwrapValue()); | 
| uint32_t length = array->Length(); | 
| for (uint32_t i = 0; i < length; i++) | 
| { | 
| - v8::Local<v8::Value> item = array->Get(i); | 
| + v8::Local<v8::Value> item = CHECKED_TO_LOCAL( | 
| + isolate, array->Get(currentContext, i)); | 
| result.push_back(JsValue(jsEngine, item)); | 
| } | 
| return result; | 
| } | 
| std::vector<std::string> AdblockPlus::JsValue::GetOwnPropertyNames() const | 
| { | 
| if (!IsObject()) | 
| throw std::runtime_error("Attempting to get propert list for a non-object"); | 
| const JsContext context(*jsEngine); | 
| + auto isolate = jsEngine->GetIsolate(); | 
| v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(UnwrapValue()); | 
| - JsValueList properties = JsValue(jsEngine, object->GetOwnPropertyNames()).AsList(); | 
| + auto propertyNames = CHECKED_TO_LOCAL(isolate, | 
| + object->GetOwnPropertyNames(isolate->GetCurrentContext())); | 
| + JsValueList properties = JsValue(jsEngine, propertyNames).AsList(); | 
| std::vector<std::string> result; | 
| for (const auto& property : properties) | 
| result.push_back(property.AsString()); | 
| return result; | 
| } | 
| AdblockPlus::JsValue AdblockPlus::JsValue::GetProperty(const std::string& name) const | 
| @@ -195,17 +205,17 @@ | 
| { | 
| if (!IsObject()) | 
| throw std::runtime_error("Attempting to set property on a non-object"); | 
| auto isolate = jsEngine->GetIsolate(); | 
| v8::Local<v8::String> property = CHECKED_TO_LOCAL( | 
| isolate, Utils::ToV8String(isolate, name)); | 
| v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue()); | 
| - obj->Set(property, val); | 
| + CHECKED_TO_VALUE(obj->Set(isolate->GetCurrentContext(), property, val)); | 
| } | 
| v8::Local<v8::Value> AdblockPlus::JsValue::UnwrapValue() const | 
| { | 
| return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value); | 
| } | 
| void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::string& val) |