summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-27 16:03:43 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-28 13:58:08 +0000
commit369fe1f7f9f3a424ee3cf8f992c3128db27fa479 (patch)
treea263d96bf4b45e572157d1c093dc321d941be3fd /xfa
parent1ded376f257f0894d68a0be68d0628171792e823 (diff)
downloadpdfium-369fe1f7f9f3a424ee3cf8f992c3128db27fa479.tar.xz
Remove CFX_ArrayTemplate in CXFA_ValueArray
Change-Id: I68f317b9fb9b162a5d99cdacc619c85f96a5bf52 Reviewed-on: https://pdfium-review.googlesource.com/3239 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_valuearray.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_valuearray.h4
-rw-r--r--xfa/fxfa/parser/xfa_resolvenode_rs.h12
5 files changed, 22 insertions, 18 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index e951716802..8a42c2619c 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -6169,13 +6169,13 @@ void CXFA_FM2JSContext::ParseResolveResult(
}
CXFA_ValueArray objectProperties(pIsolate);
- int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties);
+ int32_t iRet = resoveNodeRS.GetAttributeResult(&objectProperties);
*bAttribute = true;
if (iRet != 0) {
*bAttribute = false;
for (int32_t i = 0; i < iRet; i++) {
resultValues->push_back(pdfium::MakeUnique<CFXJSE_Value>(pIsolate));
- resultValues->back()->Assign(objectProperties[i]);
+ resultValues->back()->Assign(objectProperties.m_Values[i].get());
}
return;
}
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 645f907525..509decd037 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1055,7 +1055,7 @@ void CXFA_Node::Script_Som_ResolveNodeList(CFXJSE_Value* pValue,
}
} else {
CXFA_ValueArray valueArray(pScriptContext->GetRuntime());
- if (resoveNodeRS.GetAttributeResult(valueArray) > 0) {
+ if (resoveNodeRS.GetAttributeResult(&valueArray) > 0) {
for (CXFA_Object* pObject : valueArray.GetAttributeObject()) {
if (pObject->IsNode())
pNodeList->Append(pObject->AsNode());
diff --git a/xfa/fxfa/parser/cxfa_valuearray.cpp b/xfa/fxfa/parser/cxfa_valuearray.cpp
index 1170010139..eded624c36 100644
--- a/xfa/fxfa/parser/cxfa_valuearray.cpp
+++ b/xfa/fxfa/parser/cxfa_valuearray.cpp
@@ -6,20 +6,20 @@
#include "xfa/fxfa/parser/cxfa_valuearray.h"
+#include <algorithm>
+
#include "xfa/fxfa/parser/cxfa_scriptcontext.h"
CXFA_ValueArray::CXFA_ValueArray(v8::Isolate* pIsolate)
: m_pIsolate(pIsolate) {}
-CXFA_ValueArray::~CXFA_ValueArray() {
- for (int32_t i = 0; i < GetSize(); i++)
- delete GetAt(i);
-}
+CXFA_ValueArray::~CXFA_ValueArray() {}
std::vector<CXFA_Object*> CXFA_ValueArray::GetAttributeObject() {
- std::vector<CXFA_Object*> objArray;
- for (int32_t i = 0; i < GetSize(); i++)
- objArray.push_back(CXFA_ScriptContext::ToObject(GetAt(i), nullptr));
-
- return objArray;
+ std::vector<CXFA_Object*> result(m_Values.size());
+ std::transform(m_Values.begin(), m_Values.end(), result.begin(),
+ [](const std::unique_ptr<CFXJSE_Value>& value) {
+ return CXFA_ScriptContext::ToObject(value.get(), nullptr);
+ });
+ return result;
}
diff --git a/xfa/fxfa/parser/cxfa_valuearray.h b/xfa/fxfa/parser/cxfa_valuearray.h
index 48efae4774..f0c5d234c9 100644
--- a/xfa/fxfa/parser/cxfa_valuearray.h
+++ b/xfa/fxfa/parser/cxfa_valuearray.h
@@ -7,12 +7,13 @@
#ifndef XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
#define XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
+#include <memory>
#include <vector>
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/fxfa.h"
-class CXFA_ValueArray : public CFX_ArrayTemplate<CFXJSE_Value*> {
+class CXFA_ValueArray {
public:
explicit CXFA_ValueArray(v8::Isolate* pIsolate);
~CXFA_ValueArray();
@@ -20,6 +21,7 @@ class CXFA_ValueArray : public CFX_ArrayTemplate<CFXJSE_Value*> {
std::vector<CXFA_Object*> GetAttributeObject();
v8::Isolate* const m_pIsolate;
+ std::vector<std::unique_ptr<CFXJSE_Value>> m_Values;
};
#endif // XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
diff --git a/xfa/fxfa/parser/xfa_resolvenode_rs.h b/xfa/fxfa/parser/xfa_resolvenode_rs.h
index a60ef9a3c6..a30d540ef0 100644
--- a/xfa/fxfa/parser/xfa_resolvenode_rs.h
+++ b/xfa/fxfa/parser/xfa_resolvenode_rs.h
@@ -8,6 +8,7 @@
#define XFA_FXFA_PARSER_XFA_RESOLVENODE_RS_H_
#include <memory>
+#include <utility>
#include <vector>
#include "fxjs/cfxjse_value.h"
@@ -45,16 +46,17 @@ struct XFA_RESOLVENODE_RS {
XFA_RESOLVENODE_RS();
~XFA_RESOLVENODE_RS();
- int32_t GetAttributeResult(CXFA_ValueArray& valueArray) const {
+ size_t GetAttributeResult(CXFA_ValueArray* valueArray) const {
if (pScriptAttribute && pScriptAttribute->eValueType == XFA_SCRIPT_Object) {
for (CXFA_Object* pObject : objects) {
- auto pValue = pdfium::MakeUnique<CFXJSE_Value>(valueArray.m_pIsolate);
+ auto pValue = pdfium::MakeUnique<CFXJSE_Value>(valueArray->m_pIsolate);
(pObject->*(pScriptAttribute->lpfnCallback))(
- pValue.get(), false, (XFA_ATTRIBUTE)pScriptAttribute->eAttribute);
- valueArray.Add(pValue.release());
+ pValue.get(), false,
+ static_cast<XFA_ATTRIBUTE>(pScriptAttribute->eAttribute));
+ valueArray->m_Values.push_back(std::move(pValue));
}
}
- return valueArray.GetSize();
+ return valueArray->m_Values.size();
}
std::vector<CXFA_Object*> objects; // Not owned.