summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-11 17:08:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-11 17:08:07 +0000
commit88398a4286dd2bd228d79fb0f3296b9f79cbe4a9 (patch)
treef38d621f227537f064234a6f38e1336763ec1354 /fxjs
parent8b4ddebff061b199f14684f17cac8915bade8fb2 (diff)
downloadpdfium-88398a4286dd2bd228d79fb0f3296b9f79cbe4a9.tar.xz
Use spans in CJX_Object.
Avoid explicitly finding array sizes. Change-Id: Id51e3d10ea4db0a6375807a53309ce8d68b3b413 Reviewed-on: https://pdfium-review.googlesource.com/34750 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/xfa/cjx_container.cpp2
-rw-r--r--fxjs/xfa/cjx_datawindow.cpp2
-rw-r--r--fxjs/xfa/cjx_delta.cpp2
-rw-r--r--fxjs/xfa/cjx_desc.cpp2
-rw-r--r--fxjs/xfa/cjx_eventpseudomodel.cpp2
-rw-r--r--fxjs/xfa/cjx_exclgroup.cpp2
-rw-r--r--fxjs/xfa/cjx_field.cpp2
-rw-r--r--fxjs/xfa/cjx_form.cpp2
-rw-r--r--fxjs/xfa/cjx_hostpseudomodel.cpp2
-rw-r--r--fxjs/xfa/cjx_instancemanager.cpp2
-rw-r--r--fxjs/xfa/cjx_layoutpseudomodel.cpp2
-rw-r--r--fxjs/xfa/cjx_list.cpp2
-rw-r--r--fxjs/xfa/cjx_logpseudomodel.cpp2
-rw-r--r--fxjs/xfa/cjx_manifest.cpp2
-rw-r--r--fxjs/xfa/cjx_model.cpp2
-rw-r--r--fxjs/xfa/cjx_node.cpp2
-rw-r--r--fxjs/xfa/cjx_object.cpp7
-rw-r--r--fxjs/xfa/cjx_object.h4
-rw-r--r--fxjs/xfa/cjx_packet.cpp2
-rw-r--r--fxjs/xfa/cjx_signaturepseudomodel.cpp2
-rw-r--r--fxjs/xfa/cjx_source.cpp2
-rw-r--r--fxjs/xfa/cjx_subform.cpp2
-rw-r--r--fxjs/xfa/cjx_template.cpp2
-rw-r--r--fxjs/xfa/cjx_tree.cpp2
-rw-r--r--fxjs/xfa/cjx_treelist.cpp2
-rw-r--r--fxjs/xfa/cjx_wsdlconnection.cpp2
26 files changed, 29 insertions, 30 deletions
diff --git a/fxjs/xfa/cjx_container.cpp b/fxjs/xfa/cjx_container.cpp
index 0e58a7ea22..a04fccfee0 100644
--- a/fxjs/xfa/cjx_container.cpp
+++ b/fxjs/xfa/cjx_container.cpp
@@ -19,7 +19,7 @@ const CJX_MethodSpec CJX_Container::MethodSpecs[] = {
{"getDeltas", getDeltas_static}};
CJX_Container::CJX_Container(CXFA_Node* node) : CJX_Node(node) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Container::~CJX_Container() {}
diff --git a/fxjs/xfa/cjx_datawindow.cpp b/fxjs/xfa/cjx_datawindow.cpp
index 1f5b6ec7b6..01a35f0ec8 100644
--- a/fxjs/xfa/cjx_datawindow.cpp
+++ b/fxjs/xfa/cjx_datawindow.cpp
@@ -19,7 +19,7 @@ const CJX_MethodSpec CJX_DataWindow::MethodSpecs[] = {
CJX_DataWindow::CJX_DataWindow(CScript_DataWindow* window)
: CJX_Object(window) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_DataWindow::~CJX_DataWindow() {}
diff --git a/fxjs/xfa/cjx_delta.cpp b/fxjs/xfa/cjx_delta.cpp
index 9732f4eecb..c87ff3507f 100644
--- a/fxjs/xfa/cjx_delta.cpp
+++ b/fxjs/xfa/cjx_delta.cpp
@@ -15,7 +15,7 @@
const CJX_MethodSpec CJX_Delta::MethodSpecs[] = {{"restore", restore_static}};
CJX_Delta::CJX_Delta(CXFA_Delta* delta) : CJX_Object(delta) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Delta::~CJX_Delta() {}
diff --git a/fxjs/xfa/cjx_desc.cpp b/fxjs/xfa/cjx_desc.cpp
index ae125c2d36..aa8ee2961b 100644
--- a/fxjs/xfa/cjx_desc.cpp
+++ b/fxjs/xfa/cjx_desc.cpp
@@ -15,7 +15,7 @@
const CJX_MethodSpec CJX_Desc::MethodSpecs[] = {{"metadata", metadata_static}};
CJX_Desc::CJX_Desc(CXFA_Desc* desc) : CJX_Node(desc) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Desc::~CJX_Desc() {}
diff --git a/fxjs/xfa/cjx_eventpseudomodel.cpp b/fxjs/xfa/cjx_eventpseudomodel.cpp
index a6c5560b03..2211905223 100644
--- a/fxjs/xfa/cjx_eventpseudomodel.cpp
+++ b/fxjs/xfa/cjx_eventpseudomodel.cpp
@@ -51,7 +51,7 @@ const CJX_MethodSpec CJX_EventPseudoModel::MethodSpecs[] = {
CJX_EventPseudoModel::CJX_EventPseudoModel(CScript_EventPseudoModel* model)
: CJX_Object(model) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_EventPseudoModel::~CJX_EventPseudoModel() {}
diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp
index 6e44e56079..0de0ef00fd 100644
--- a/fxjs/xfa/cjx_exclgroup.cpp
+++ b/fxjs/xfa/cjx_exclgroup.cpp
@@ -25,7 +25,7 @@ const CJX_MethodSpec CJX_ExclGroup::MethodSpecs[] = {
{"selectedMember", selectedMember_static}};
CJX_ExclGroup::CJX_ExclGroup(CXFA_ExclGroup* group) : CJX_Node(group) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_ExclGroup::~CJX_ExclGroup() {}
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index 3beb868f1d..d05e017b7e 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -33,7 +33,7 @@ const CJX_MethodSpec CJX_Field::MethodSpecs[] = {
{"setItemState", setItemState_static}};
CJX_Field::CJX_Field(CXFA_Field* field) : CJX_Container(field) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Field::~CJX_Field() {}
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp
index d1d50ad8f3..e1441b01ec 100644
--- a/fxjs/xfa/cjx_form.cpp
+++ b/fxjs/xfa/cjx_form.cpp
@@ -26,7 +26,7 @@ const CJX_MethodSpec CJX_Form::MethodSpecs[] = {
{"remerge", remerge_static}};
CJX_Form::CJX_Form(CXFA_Form* form) : CJX_Model(form) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Form::~CJX_Form() {}
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp
index 2d9b1bf712..6dd160639a 100644
--- a/fxjs/xfa/cjx_hostpseudomodel.cpp
+++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -68,7 +68,7 @@ const CJX_MethodSpec CJX_HostPseudoModel::MethodSpecs[] = {
CJX_HostPseudoModel::CJX_HostPseudoModel(CScript_HostPseudoModel* model)
: CJX_Object(model) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_HostPseudoModel::~CJX_HostPseudoModel() {}
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp
index f8df62cdbc..d9471cd253 100644
--- a/fxjs/xfa/cjx_instancemanager.cpp
+++ b/fxjs/xfa/cjx_instancemanager.cpp
@@ -27,7 +27,7 @@ const CJX_MethodSpec CJX_InstanceManager::MethodSpecs[] = {
CJX_InstanceManager::CJX_InstanceManager(CXFA_InstanceManager* mgr)
: CJX_Node(mgr) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_InstanceManager::~CJX_InstanceManager() {}
diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp
index 0ae4871d09..a5dcf98b00 100644
--- a/fxjs/xfa/cjx_layoutpseudomodel.cpp
+++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp
@@ -48,7 +48,7 @@ const CJX_MethodSpec CJX_LayoutPseudoModel::MethodSpecs[] = {
CJX_LayoutPseudoModel::CJX_LayoutPseudoModel(CScript_LayoutPseudoModel* model)
: CJX_Object(model) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_LayoutPseudoModel::~CJX_LayoutPseudoModel() {}
diff --git a/fxjs/xfa/cjx_list.cpp b/fxjs/xfa/cjx_list.cpp
index b6ac47ec79..fcac45f58c 100644
--- a/fxjs/xfa/cjx_list.cpp
+++ b/fxjs/xfa/cjx_list.cpp
@@ -22,7 +22,7 @@ const CJX_MethodSpec CJX_List::MethodSpecs[] = {{"append", append_static},
{"remove", remove_static}};
CJX_List::CJX_List(CXFA_List* list) : CJX_Object(list) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_List::~CJX_List() {}
diff --git a/fxjs/xfa/cjx_logpseudomodel.cpp b/fxjs/xfa/cjx_logpseudomodel.cpp
index 93772ed03d..9072fef592 100644
--- a/fxjs/xfa/cjx_logpseudomodel.cpp
+++ b/fxjs/xfa/cjx_logpseudomodel.cpp
@@ -20,7 +20,7 @@ const CJX_MethodSpec CJX_LogPseudoModel::MethodSpecs[] = {
CJX_LogPseudoModel::CJX_LogPseudoModel(CScript_LogPseudoModel* model)
: CJX_Object(model) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_LogPseudoModel::~CJX_LogPseudoModel() {}
diff --git a/fxjs/xfa/cjx_manifest.cpp b/fxjs/xfa/cjx_manifest.cpp
index 642f4ca59a..a8d1fd54c5 100644
--- a/fxjs/xfa/cjx_manifest.cpp
+++ b/fxjs/xfa/cjx_manifest.cpp
@@ -16,7 +16,7 @@ const CJX_MethodSpec CJX_Manifest::MethodSpecs[] = {
{"evaluate", evaluate_static}};
CJX_Manifest::CJX_Manifest(CXFA_Manifest* manifest) : CJX_Node(manifest) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Manifest::~CJX_Manifest() {}
diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp
index 688b30350a..d94a1b68fd 100644
--- a/fxjs/xfa/cjx_model.cpp
+++ b/fxjs/xfa/cjx_model.cpp
@@ -20,7 +20,7 @@ const CJX_MethodSpec CJX_Model::MethodSpecs[] = {
{"isCompatibleNS", isCompatibleNS_static}};
CJX_Model::CJX_Model(CXFA_Node* node) : CJX_Node(node) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Model::~CJX_Model() {}
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index 7c472db6c9..856fea5267 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -98,7 +98,7 @@ const CJX_MethodSpec CJX_Node::MethodSpecs[] = {
{"setElement", setElement_static}};
CJX_Node::CJX_Node(CXFA_Node* node) : CJX_Tree(node) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Node::~CJX_Node() = default;
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index d357c56091..a6b1d122ae 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -129,10 +129,9 @@ CJX_Object::~CJX_Object() {
ClearMapModuleBuffer();
}
-void CJX_Object::DefineMethods(const CJX_MethodSpec method_specs[],
- size_t count) {
- for (size_t i = 0; i < count; ++i)
- method_specs_[method_specs[i].pName] = method_specs[i].pMethodCall;
+void CJX_Object::DefineMethods(pdfium::span<const CJX_MethodSpec> methods) {
+ for (const auto& item : methods)
+ method_specs_[item.pName] = item.pMethodCall;
}
CXFA_Document* CJX_Object::GetDocument() const {
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index ac17a04522..1c5e40514e 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -17,6 +17,7 @@
#include "core/fxcrt/xml/cfx_xmlelement.h"
#include "fxjs/cjx_define.h"
#include "third_party/base/optional.h"
+#include "third_party/base/span.h"
#include "xfa/fxfa/fxfa_basic.h"
class CFXJSE_Value;
@@ -218,8 +219,7 @@ class CJX_Object {
void ThrowTooManyOccurancesException(const WideString& obj) const;
protected:
- void DefineMethods(const CJX_MethodSpec method_specs[], size_t count);
-
+ void DefineMethods(pdfium::span<const CJX_MethodSpec> methods);
void MoveBufferMapData(CXFA_Object* pSrcModule, CXFA_Object* pDstModule);
void SetMapModuleString(void* pKey, const WideStringView& wsValue);
void ThrowException(const wchar_t* str, ...) const;
diff --git a/fxjs/xfa/cjx_packet.cpp b/fxjs/xfa/cjx_packet.cpp
index c3d8dbbeba..e4119baf91 100644
--- a/fxjs/xfa/cjx_packet.cpp
+++ b/fxjs/xfa/cjx_packet.cpp
@@ -23,7 +23,7 @@ const CJX_MethodSpec CJX_Packet::MethodSpecs[] = {
{"setAttribute", setAttribute_static}};
CJX_Packet::CJX_Packet(CXFA_Packet* packet) : CJX_Node(packet) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Packet::~CJX_Packet() {}
diff --git a/fxjs/xfa/cjx_signaturepseudomodel.cpp b/fxjs/xfa/cjx_signaturepseudomodel.cpp
index 0e4d560da3..20cb5dcccf 100644
--- a/fxjs/xfa/cjx_signaturepseudomodel.cpp
+++ b/fxjs/xfa/cjx_signaturepseudomodel.cpp
@@ -21,7 +21,7 @@ const CJX_MethodSpec CJX_SignaturePseudoModel::MethodSpecs[] = {
CJX_SignaturePseudoModel::CJX_SignaturePseudoModel(
CScript_SignaturePseudoModel* model)
: CJX_Object(model) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_SignaturePseudoModel::~CJX_SignaturePseudoModel() {}
diff --git a/fxjs/xfa/cjx_source.cpp b/fxjs/xfa/cjx_source.cpp
index 98772b5acf..933229e07c 100644
--- a/fxjs/xfa/cjx_source.cpp
+++ b/fxjs/xfa/cjx_source.cpp
@@ -32,7 +32,7 @@ const CJX_MethodSpec CJX_Source::MethodSpecs[] = {
{"updateBatch", updateBatch_static}};
CJX_Source::CJX_Source(CXFA_Source* src) : CJX_Node(src) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Source::~CJX_Source() {}
diff --git a/fxjs/xfa/cjx_subform.cpp b/fxjs/xfa/cjx_subform.cpp
index 042bd85119..9f4736a6e5 100644
--- a/fxjs/xfa/cjx_subform.cpp
+++ b/fxjs/xfa/cjx_subform.cpp
@@ -23,7 +23,7 @@ const CJX_MethodSpec CJX_Subform::MethodSpecs[] = {
{"execValidate", execValidate_static}};
CJX_Subform::CJX_Subform(CXFA_Node* node) : CJX_Container(node) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Subform::~CJX_Subform() {}
diff --git a/fxjs/xfa/cjx_template.cpp b/fxjs/xfa/cjx_template.cpp
index 0b9c3b2472..8690083702 100644
--- a/fxjs/xfa/cjx_template.cpp
+++ b/fxjs/xfa/cjx_template.cpp
@@ -22,7 +22,7 @@ const CJX_MethodSpec CJX_Template::MethodSpecs[] = {
{"remerge", remerge_static}};
CJX_Template::CJX_Template(CXFA_Template* tmpl) : CJX_Model(tmpl) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Template::~CJX_Template() {}
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
index 442a82d1e6..8971ef989b 100644
--- a/fxjs/xfa/cjx_tree.cpp
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -24,7 +24,7 @@ const CJX_MethodSpec CJX_Tree::MethodSpecs[] = {
{"resolveNodes", resolveNodes_static}};
CJX_Tree::CJX_Tree(CXFA_Object* obj) : CJX_Object(obj) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_Tree::~CJX_Tree() {}
diff --git a/fxjs/xfa/cjx_treelist.cpp b/fxjs/xfa/cjx_treelist.cpp
index b608734e3c..b79b9e16b4 100644
--- a/fxjs/xfa/cjx_treelist.cpp
+++ b/fxjs/xfa/cjx_treelist.cpp
@@ -19,7 +19,7 @@ const CJX_MethodSpec CJX_TreeList::MethodSpecs[] = {
{"namedItem", namedItem_static}};
CJX_TreeList::CJX_TreeList(CXFA_TreeList* list) : CJX_List(list) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_TreeList::~CJX_TreeList() {}
diff --git a/fxjs/xfa/cjx_wsdlconnection.cpp b/fxjs/xfa/cjx_wsdlconnection.cpp
index 1f9ae59fdb..523ea2dd3e 100644
--- a/fxjs/xfa/cjx_wsdlconnection.cpp
+++ b/fxjs/xfa/cjx_wsdlconnection.cpp
@@ -17,7 +17,7 @@ const CJX_MethodSpec CJX_WsdlConnection::MethodSpecs[] = {
CJX_WsdlConnection::CJX_WsdlConnection(CXFA_WsdlConnection* connection)
: CJX_Node(connection) {
- DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
+ DefineMethods(MethodSpecs);
}
CJX_WsdlConnection::~CJX_WsdlConnection() {}