summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-30 16:12:02 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-30 20:26:02 +0000
commit0bb1333a9eff1190ddd68f34c71d6a779c69dfef (patch)
tree5a46946c4852f147309e2b1389e6f42d6553abf7 /fxjs
parent908c848202ef137e98d96f82a4eadfae551403b7 (diff)
downloadpdfium-0bb1333a9eff1190ddd68f34c71d6a779c69dfef.tar.xz
Add some calls to MakeUnique
This CL replaces some new's with pdfium::MakeUnique. Change-Id: I50faf3ed55e7730b094c14a7989a9dd51cf33cbb Reviewed-on: https://pdfium-review.googlesource.com/3430 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cfxjse_class.cpp44
-rw-r--r--fxjs/cfxjse_context.cpp3
2 files changed, 19 insertions, 28 deletions
diff --git a/fxjs/cfxjse_class.cpp b/fxjs/cfxjse_class.cpp
index 3801fb520a..8924a48a47 100644
--- a/fxjs/cfxjse_class.cpp
+++ b/fxjs/cfxjse_class.cpp
@@ -10,6 +10,7 @@
#include "fxjs/cfxjse_context.h"
#include "fxjs/cfxjse_value.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -22,10 +23,9 @@ void V8FunctionCallback_Wrapper(
return;
CFX_ByteStringC szFunctionName(lpFunctionInfo->name);
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
+ auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpThisValue->ForceSetValue(info.Holder());
- std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
+ auto lpRetValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
CFXJSE_Arguments impl(&info, lpRetValue.get());
lpFunctionInfo->callbackProc(lpThisValue.get(), szFunctionName, impl);
if (!lpRetValue->DirectGetValue().IsEmpty())
@@ -41,10 +41,9 @@ void V8ClassGlobalConstructorCallback_Wrapper(
return;
CFX_ByteStringC szFunctionName(lpClassDefinition->name);
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
+ auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpThisValue->ForceSetValue(info.Holder());
- std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
+ auto lpRetValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
CFXJSE_Arguments impl(&info, lpRetValue.get());
lpClassDefinition->constructor(lpThisValue.get(), szFunctionName, impl);
if (!lpRetValue->DirectGetValue().IsEmpty())
@@ -60,10 +59,8 @@ void V8GetterCallback_Wrapper(v8::Local<v8::String> property,
return;
CFX_ByteStringC szPropertyName(lpPropertyInfo->name);
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- std::unique_ptr<CFXJSE_Value> lpPropValue(
- new CFXJSE_Value(info.GetIsolate()));
+ auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
+ auto lpPropValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpThisValue->ForceSetValue(info.Holder());
lpPropertyInfo->getProc(lpThisValue.get(), szPropertyName, lpPropValue.get());
info.GetReturnValue().Set(lpPropValue->DirectGetValue());
@@ -79,10 +76,8 @@ void V8SetterCallback_Wrapper(v8::Local<v8::String> property,
return;
CFX_ByteStringC szPropertyName(lpPropertyInfo->name);
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- std::unique_ptr<CFXJSE_Value> lpPropValue(
- new CFXJSE_Value(info.GetIsolate()));
+ auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
+ auto lpPropValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpThisValue->ForceSetValue(info.Holder());
lpPropValue->ForceSetValue(value);
lpPropertyInfo->setProc(lpThisValue.get(), szPropertyName, lpPropValue.get());
@@ -135,10 +130,9 @@ void DynPropGetterAdapter_MethodCallback(
ASSERT(lpClass && !hPropName.IsEmpty());
v8::String::Utf8Value szPropName(hPropName);
CFX_ByteStringC szFxPropName = *szPropName;
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
+ auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpThisValue->ForceSetValue(info.Holder());
- std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
+ auto lpRetValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
CFXJSE_Arguments impl(&info, lpRetValue.get());
lpClass->dynMethodCall(lpThisValue.get(), szFxPropName, impl);
if (!lpRetValue->DirectGetValue().IsEmpty())
@@ -233,8 +227,7 @@ void NamedPropertyQueryCallback(
v8::HandleScope scope(pIsolate);
v8::String::Utf8Value szPropName(property);
CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
+ auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpThisValue->ForceSetValue(thisObject);
if (DynPropQueryAdapter(lpClass, lpThisValue.get(), szFxPropName)) {
info.GetReturnValue().Set(v8::DontDelete);
@@ -254,8 +247,7 @@ void NamedPropertyDeleterCallback(
v8::HandleScope scope(pIsolate);
v8::String::Utf8Value szPropName(property);
CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
+ auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpThisValue->ForceSetValue(thisObject);
info.GetReturnValue().Set(
!!DynPropDeleterAdapter(lpClass, lpThisValue.get(), szFxPropName));
@@ -269,10 +261,9 @@ void NamedPropertyGetterCallback(
info.Data().As<v8::External>()->Value());
v8::String::Utf8Value szPropName(property);
CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
+ auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpThisValue->ForceSetValue(thisObject);
- std::unique_ptr<CFXJSE_Value> lpNewValue(new CFXJSE_Value(info.GetIsolate()));
+ auto lpNewValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
DynPropGetterAdapter(lpClass, lpThisValue.get(), szFxPropName,
lpNewValue.get());
info.GetReturnValue().Set(lpNewValue->DirectGetValue());
@@ -287,11 +278,10 @@ void NamedPropertySetterCallback(
info.Data().As<v8::External>()->Value());
v8::String::Utf8Value szPropName(property);
CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
+ auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpThisValue->ForceSetValue(thisObject);
- std::unique_ptr<CFXJSE_Value> lpNewValue(new CFXJSE_Value(info.GetIsolate()));
+ auto lpNewValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
lpNewValue->ForceSetValue(value);
DynPropSetterAdapter(lpClass, lpThisValue.get(), szFxPropName,
lpNewValue.get());
diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp
index 076e6cf2b1..d3b55ff43e 100644
--- a/fxjs/cfxjse_context.cpp
+++ b/fxjs/cfxjse_context.cpp
@@ -8,6 +8,7 @@
#include "fxjs/cfxjse_class.h"
#include "fxjs/cfxjse_value.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -187,7 +188,7 @@ CFXJSE_Context::CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {}
CFXJSE_Context::~CFXJSE_Context() {}
std::unique_ptr<CFXJSE_Value> CFXJSE_Context::GetGlobalObject() {
- std::unique_ptr<CFXJSE_Value> pValue(new CFXJSE_Value(m_pIsolate));
+ auto pValue = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate);
CFXJSE_ScopeUtil_IsolateHandleContext scope(this);
v8::Local<v8::Context> hContext =