summaryrefslogtreecommitdiff
path: root/fxjs/cjs_globalvariablearray.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-30 20:24:14 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-10-30 20:24:14 +0000
commita3254627c664e2b88f48f1d6dd856503ab8742b3 (patch)
tree427a2b6dddb490f379ba83bf9fdacd51c4673e3a /fxjs/cjs_globalvariablearray.cpp
parente0345a4aecfd16264d393234cf8fe22250d771fe (diff)
downloadpdfium-a3254627c664e2b88f48f1d6dd856503ab8742b3.tar.xz
Rename global data files to match contents
This CL renames the files related to Javascript global data to match their file contents. Change-Id: I65a6191968656b5e89c9eb6edb2ea9f9db92875a Reviewed-on: https://pdfium-review.googlesource.com/17090 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/cjs_globalvariablearray.cpp')
-rw-r--r--fxjs/cjs_globalvariablearray.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/fxjs/cjs_globalvariablearray.cpp b/fxjs/cjs_globalvariablearray.cpp
new file mode 100644
index 0000000000..8bf9f1b305
--- /dev/null
+++ b/fxjs/cjs_globalvariablearray.cpp
@@ -0,0 +1,68 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/cjs_globalvariablearray.h"
+
+#include "fxjs/cjs_keyvalue.h"
+
+CJS_GlobalVariableArray::CJS_GlobalVariableArray() {}
+
+CJS_GlobalVariableArray::~CJS_GlobalVariableArray() {}
+
+void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) {
+ m_Array.clear();
+ for (int i = 0, sz = array.Count(); i < sz; i++) {
+ CJS_KeyValue* pOldObjData = array.GetAt(i);
+ switch (pOldObjData->nType) {
+ case JS_GlobalDataType::NUMBER: {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ pNewObjData->dData = pOldObjData->dData;
+ Add(pNewObjData);
+ } break;
+ case JS_GlobalDataType::BOOLEAN: {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ pNewObjData->bData = pOldObjData->bData;
+ Add(pNewObjData);
+ } break;
+ case JS_GlobalDataType::STRING: {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ pNewObjData->sData = pOldObjData->sData;
+ Add(pNewObjData);
+ } break;
+ case JS_GlobalDataType::OBJECT: {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ pNewObjData->objData.Copy(pOldObjData->objData);
+ Add(pNewObjData);
+ } break;
+ case JS_GlobalDataType::NULLOBJ: {
+ CJS_KeyValue* pNewObjData = new CJS_KeyValue;
+ pNewObjData->sKey = pOldObjData->sKey;
+ pNewObjData->nType = pOldObjData->nType;
+ Add(pNewObjData);
+ } break;
+ }
+ }
+}
+
+void CJS_GlobalVariableArray::Add(CJS_KeyValue* p) {
+ m_Array.push_back(std::unique_ptr<CJS_KeyValue>(p));
+}
+
+int CJS_GlobalVariableArray::Count() const {
+ return m_Array.size();
+}
+
+CJS_KeyValue* CJS_GlobalVariableArray::GetAt(int index) const {
+ return m_Array.at(index).get();
+}