From 2a998ad24232be4913265f542d6da06afd2e7000 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 5 Jan 2017 16:10:53 -0500 Subject: Cleaning up memory allocation in CXFA_FM2JSContext - III This CL updates the unique_ptrs to use MakeUnique instead of new. The types are updated to be auto. Change-Id: I2a82a4ec6659e5c343cc03d4840b3046ecb6934e Reviewed-on: https://pdfium-review.googlesource.com/2156 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 177 +++++++++++++++++------------------- 1 file changed, 83 insertions(+), 94 deletions(-) (limited to 'xfa/fxfa/fm2js') diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index 4ed14dabf2..3c2b0ee126 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -553,20 +553,19 @@ void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis, continue; } - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); if (iLength > 2) { - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectPropertyByIdx(1, propertyValue.get()); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); if (propertyValue->IsNull()) { for (int32_t j = 2; j < iLength; j++) { argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); - std::unique_ptr defaultPropValue( - new CFXJSE_Value(pIsolate)); + auto defaultPropValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(jsObjectValue.get(), defaultPropValue.get()); if (defaultPropValue->IsNull()) continue; @@ -577,8 +576,7 @@ void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis, } else { for (int32_t j = 2; j < iLength; j++) { argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); jsObjectValue->GetObjectProperty( propertyValue->ToString().AsStringC(), newPropertyValue.get()); if (newPropertyValue->IsNull()) @@ -630,7 +628,7 @@ void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, continue; if (argValue->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); @@ -639,10 +637,9 @@ void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, return; } - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectPropertyByIdx(1, propertyValue.get()); argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) { @@ -661,8 +658,7 @@ void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, } } } else if (argValue->IsObject()) { - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); if (!newPropertyValue->IsNull()) iCount++; @@ -706,7 +702,7 @@ void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, continue; if (argValue->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); if (iLength <= 2) { @@ -714,10 +710,9 @@ void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, return; } - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectPropertyByIdx(1, propertyValue.get()); argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) { @@ -745,8 +740,7 @@ void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, } } } else if (argValue->IsObject()) { - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); if (newPropertyValue->IsNull()) continue; @@ -782,7 +776,7 @@ void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, continue; if (argValue->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); if (iLength <= 2) { @@ -790,10 +784,9 @@ void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, return; } - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectPropertyByIdx(1, propertyValue.get()); argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) { @@ -821,8 +814,7 @@ void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, } } } else if (argValue->IsObject()) { - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); if (newPropertyValue->IsNull()) continue; @@ -947,7 +939,7 @@ void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis, continue; if (argValue->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); if (iLength <= 2) { @@ -955,11 +947,10 @@ void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis, return; } - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); argValue->GetObjectPropertyByIdx(1, propertyValue.get()); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); if (propertyValue->IsNull()) { for (int32_t j = 2; j < iLength; j++) { argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); @@ -983,8 +974,7 @@ void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis, } } } else if (argValue->IsObject()) { - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); if (newPropertyValue->IsNull()) continue; @@ -2795,7 +2785,7 @@ void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { std::unique_ptr argIndexValue = args.GetValue(iArgIndex); if (argIndexValue->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argIndexValue->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); if (iLength > 3) @@ -2803,10 +2793,9 @@ void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, iValueIndex += (iLength - 2); if (iValueIndex >= iIndex) { - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr newPropertyValue( - new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); argIndexValue->GetObjectPropertyByIdx(1, propertyValue.get()); argIndexValue->GetObjectPropertyByIdx( (iLength - 1) - (iValueIndex - iIndex), jsObjectValue.get()); @@ -2973,7 +2962,7 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, std::unique_ptr pNewContext( CFXJSE_Context::Create(pIsolate, nullptr, nullptr)); - std::unique_ptr returnValue(new CFXJSE_Value(pIsolate)); + auto returnValue = pdfium::MakeUnique(pIsolate); CFX_WideString javaScript(wsJavaScriptBuf.AsStringC()); pNewContext->ExecuteScript( FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), @@ -3016,13 +3005,13 @@ void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, rgValues[2]->SetNull(); } else if (argOne->IsArray()) { #ifndef NDEBUG - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argOne->GetObjectProperty("length", lengthValue.get()); ASSERT(lengthValue->ToInteger() >= 3); #endif - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); argOne->GetObjectPropertyByIdx(1, propertyValue.get()); argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (!propertyValue->IsNull() || jsObjectValue->IsNull()) { @@ -5016,11 +5005,11 @@ void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, std::unique_ptr rValue = GetSimpleValue(pThis, args, 1); if (lValue->IsArray()) { v8::Isolate* pIsolate = pContext->GetScriptRuntime(); - std::unique_ptr leftLengthValue(new CFXJSE_Value(pIsolate)); + auto leftLengthValue = pdfium::MakeUnique(pIsolate); lValue->GetObjectProperty("length", leftLengthValue.get()); int32_t iLeftLength = leftLengthValue->ToInteger(); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); + auto propertyValue = pdfium::MakeUnique(pIsolate); lValue->GetObjectPropertyByIdx(1, propertyValue.get()); if (propertyValue->IsNull()) { for (int32_t i = 2; i < iLeftLength; i++) { @@ -5163,15 +5152,15 @@ bool CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, return false; v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); - std::unique_ptr firstFlagValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr secondFlagValue(new CFXJSE_Value(pIsolate)); + auto firstFlagValue = pdfium::MakeUnique(pIsolate); + auto secondFlagValue = pdfium::MakeUnique(pIsolate); argFirst->GetObjectPropertyByIdx(0, firstFlagValue.get()); argSecond->GetObjectPropertyByIdx(0, secondFlagValue.get()); if (firstFlagValue->ToInteger() != 3 || secondFlagValue->ToInteger() != 3) return false; - std::unique_ptr firstJSObject(new CFXJSE_Value(pIsolate)); - std::unique_ptr secondJSObject(new CFXJSE_Value(pIsolate)); + auto firstJSObject = pdfium::MakeUnique(pIsolate); + auto secondJSObject = pdfium::MakeUnique(pIsolate); argFirst->GetObjectPropertyByIdx(2, firstJSObject.get()); argSecond->GetObjectPropertyByIdx(2, secondJSObject.get()); if (firstJSObject->IsNull() || secondJSObject->IsNull()) @@ -5461,7 +5450,7 @@ void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, std::unique_ptr argAccessor = args.GetValue(0); if (argAccessor->IsArray()) { - std::unique_ptr pLengthValue(new CFXJSE_Value(pIsolate)); + auto pLengthValue = pdfium::MakeUnique(pIsolate); argAccessor->GetObjectProperty("length", pLengthValue.get()); int32_t iLength = pLengthValue->ToInteger(); if (iLength < 3) { @@ -5469,7 +5458,7 @@ void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, return; } - std::unique_ptr hJSObjValue(new CFXJSE_Value(pIsolate)); + auto hJSObjValue = pdfium::MakeUnique(pIsolate); std::vector>> resolveValues( iLength - 2); bool bAttribute = false; @@ -5587,7 +5576,7 @@ void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, std::unique_ptr argAccessor = args.GetValue(0); if (argAccessor->IsArray()) { - std::unique_ptr pLengthValue(new CFXJSE_Value(pIsolate)); + auto pLengthValue = pdfium::MakeUnique(pIsolate); argAccessor->GetObjectProperty("length", pLengthValue.get()); int32_t iLength = pLengthValue->ToInteger(); if (iLength < 3) { @@ -5599,7 +5588,7 @@ void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, std::vector>> resolveValues( iLength - 2); - std::unique_ptr hJSObjValue(new CFXJSE_Value(pIsolate)); + auto hJSObjValue = pdfium::MakeUnique(pIsolate); bool bAttribute = false; for (int32_t i = 2; i < iLength; i++) { argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get()); @@ -5759,8 +5748,8 @@ void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, std::unique_ptr argOne = args.GetValue(0); if (argOne->IsArray()) { v8::Isolate* pIsolate = pContext->GetScriptRuntime(); - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); argOne->GetObjectPropertyByIdx(1, propertyValue.get()); argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) { @@ -5799,7 +5788,7 @@ void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, #ifndef NDEBUG CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); v8::Isolate* pIsolate = pContext->GetScriptRuntime(); - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argOne->GetObjectProperty("length", lengthValue.get()); ASSERT(lengthValue->ToInteger() >= 3); #endif @@ -5826,12 +5815,12 @@ void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, } #ifndef NDEBUG - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argOne->GetObjectProperty("length", lengthValue.get()); ASSERT(lengthValue->ToInteger() >= 3); #endif - std::unique_ptr flagsValue(new CFXJSE_Value(pIsolate)); + auto flagsValue = pdfium::MakeUnique(pIsolate); argOne->GetObjectPropertyByIdx(0, flagsValue.get()); int32_t iFlags = flagsValue->ToInteger(); if (iFlags != 3 && iFlags != 4) { @@ -5855,7 +5844,7 @@ void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, return; } - std::unique_ptr objectValue(new CFXJSE_Value(pIsolate)); + auto objectValue = pdfium::MakeUnique(pIsolate); argOne->GetObjectPropertyByIdx(2, objectValue.get()); if (objectValue->IsNull()) { pContext->ThrowCompilerErrorException(); @@ -5875,7 +5864,7 @@ void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, for (int32_t i = 0; i < argc; i++) { argValues.push_back(args.GetValue(i)); if (argValues[i]->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argValues[i]->GetObjectProperty("length", lengthValue.get()); int32_t length = lengthValue->ToInteger(); iLength = iLength + ((length > 2) ? (length - 2) : 0); @@ -5890,7 +5879,7 @@ void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, int32_t index = 0; for (int32_t i = 0; i < argc; i++) { if (argValues[i]->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argValues[i]->GetObjectProperty("length", lengthValue.get()); int32_t length = lengthValue->ToInteger(); for (int32_t j = 2; j < length; j++) { @@ -5921,17 +5910,17 @@ std::unique_ptr CXFA_FM2JSContext::GetSimpleValue( return argIndex; if (argIndex->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argIndex->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); - std::unique_ptr simpleValue(new CFXJSE_Value(pIsolate)); + auto simpleValue = pdfium::MakeUnique(pIsolate); if (iLength < 3) { simpleValue.get()->SetUndefined(); return simpleValue; } - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); argIndex->GetObjectPropertyByIdx(1, propertyValue.get()); argIndex->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) { @@ -5944,7 +5933,7 @@ std::unique_ptr CXFA_FM2JSContext::GetSimpleValue( return simpleValue; } - std::unique_ptr defaultValue(new CFXJSE_Value(pIsolate)); + auto defaultValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(argIndex.get(), defaultValue.get()); return defaultValue; } @@ -5963,23 +5952,23 @@ bool CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { if (iLength < 3) return true; - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); arg->GetObjectPropertyByIdx(1, propertyValue.get()); arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) { - std::unique_ptr defaultValue(new CFXJSE_Value(pIsolate)); + auto defaultValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get()); return defaultValue->IsNull(); } - std::unique_ptr newPropertyValue(new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(), newPropertyValue.get()); return newPropertyValue->IsNull(); } - std::unique_ptr defaultValue(new CFXJSE_Value(pIsolate)); + auto defaultValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(arg, defaultValue.get()); return defaultValue->IsNull(); } @@ -5991,7 +5980,7 @@ int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, return 0; v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); arg->GetObjectProperty("length", lengthValue.get()); return lengthValue->ToInteger(); } @@ -6034,7 +6023,7 @@ void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, for (int32_t i = 0; i < argc - iStart; i++) { argsValue.push_back(args.GetValue(i + iStart)); if (argsValue[i]->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argsValue[i]->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); iCount += ((iLength > 2) ? (iLength - 2) : 0); @@ -6049,14 +6038,14 @@ void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, int32_t index = 0; for (int32_t i = 0; i < argc - iStart; i++) { if (argsValue[i]->IsArray()) { - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); argsValue[i]->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); if (iLength < 3) continue; - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); argsValue[i]->GetObjectPropertyByIdx(1, propertyValue.get()); if (propertyValue->IsNull()) { for (int32_t j = 2; j < iLength; j++) { @@ -6258,9 +6247,9 @@ int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); if (pValue->IsArray()) { - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr newPropertyValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); pValue->GetObjectPropertyByIdx(1, propertyValue.get()); pValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) { @@ -6273,7 +6262,7 @@ int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, return ValueToInteger(pThis, newPropertyValue.get()); } if (pValue->IsObject()) { - std::unique_ptr newPropertyValue(new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(pValue, newPropertyValue.get()); return ValueToInteger(pThis, newPropertyValue.get()); } @@ -6290,9 +6279,9 @@ FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); if (arg->IsArray()) { - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr newPropertyValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); arg->GetObjectPropertyByIdx(1, propertyValue.get()); arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) { @@ -6304,7 +6293,7 @@ FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, return ValueToFloat(pThis, newPropertyValue.get()); } if (arg->IsObject()) { - std::unique_ptr newPropertyValue(new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(arg, newPropertyValue.get()); return ValueToFloat(pThis, newPropertyValue.get()); } @@ -6324,9 +6313,9 @@ FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); if (arg->IsArray()) { - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr newPropertyValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); arg->GetObjectPropertyByIdx(1, propertyValue.get()); arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) { @@ -6338,7 +6327,7 @@ FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, return ValueToDouble(pThis, newPropertyValue.get()); } if (arg->IsObject()) { - std::unique_ptr newPropertyValue(new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); GetObjectDefaultValue(arg, newPropertyValue.get()); return ValueToDouble(pThis, newPropertyValue.get()); } @@ -6363,7 +6352,7 @@ double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis, return ValueToDouble(pThis, src); v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); - std::unique_ptr lengthValue(new CFXJSE_Value(pIsolate)); + auto lengthValue = pdfium::MakeUnique(pIsolate); src->GetObjectProperty("length", lengthValue.get()); int32_t iLength = lengthValue->ToInteger(); if (iLength <= 2) { @@ -6371,14 +6360,14 @@ double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis, return 0.0; } - std::unique_ptr propertyValue(new CFXJSE_Value(pIsolate)); - std::unique_ptr jsObjectValue(new CFXJSE_Value(pIsolate)); + auto propertyValue = pdfium::MakeUnique(pIsolate); + auto jsObjectValue = pdfium::MakeUnique(pIsolate); src->GetObjectPropertyByIdx(1, propertyValue.get()); src->GetObjectPropertyByIdx(2, jsObjectValue.get()); if (propertyValue->IsNull()) return ValueToDouble(pThis, jsObjectValue.get()); - std::unique_ptr newPropertyValue(new CFXJSE_Value(pIsolate)); + auto newPropertyValue = pdfium::MakeUnique(pIsolate); jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(), newPropertyValue.get()); return ValueToDouble(pThis, newPropertyValue.get()); -- cgit v1.2.3