OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 |
| 7 #include "fpdfsdk/javascript/JS_KeyValue.h" |
| 8 |
| 9 CJS_GlobalVariableArray::CJS_GlobalVariableArray() {} |
| 10 |
| 11 CJS_GlobalVariableArray::~CJS_GlobalVariableArray() {} |
| 12 |
| 13 void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) { |
| 14 m_Array.clear(); |
| 15 for (int i = 0, sz = array.Count(); i < sz; i++) { |
| 16 CJS_KeyValue* pOldObjData = array.GetAt(i); |
| 17 switch (pOldObjData->nType) { |
| 18 case JS_GlobalDataType::NUMBER: { |
| 19 CJS_KeyValue* pNewObjData = new CJS_KeyValue; |
| 20 pNewObjData->sKey = pOldObjData->sKey; |
| 21 pNewObjData->nType = pOldObjData->nType; |
| 22 pNewObjData->dData = pOldObjData->dData; |
| 23 Add(pNewObjData); |
| 24 } break; |
| 25 case JS_GlobalDataType::BOOLEAN: { |
| 26 CJS_KeyValue* pNewObjData = new CJS_KeyValue; |
| 27 pNewObjData->sKey = pOldObjData->sKey; |
| 28 pNewObjData->nType = pOldObjData->nType; |
| 29 pNewObjData->bData = pOldObjData->bData; |
| 30 Add(pNewObjData); |
| 31 } break; |
| 32 case JS_GlobalDataType::STRING: { |
| 33 CJS_KeyValue* pNewObjData = new CJS_KeyValue; |
| 34 pNewObjData->sKey = pOldObjData->sKey; |
| 35 pNewObjData->nType = pOldObjData->nType; |
| 36 pNewObjData->sData = pOldObjData->sData; |
| 37 Add(pNewObjData); |
| 38 } break; |
| 39 case JS_GlobalDataType::OBJECT: { |
| 40 CJS_KeyValue* pNewObjData = new CJS_KeyValue; |
| 41 pNewObjData->sKey = pOldObjData->sKey; |
| 42 pNewObjData->nType = pOldObjData->nType; |
| 43 pNewObjData->objData.Copy(pOldObjData->objData); |
| 44 Add(pNewObjData); |
| 45 } break; |
| 46 case JS_GlobalDataType::NULLOBJ: { |
| 47 CJS_KeyValue* pNewObjData = new CJS_KeyValue; |
| 48 pNewObjData->sKey = pOldObjData->sKey; |
| 49 pNewObjData->nType = pOldObjData->nType; |
| 50 Add(pNewObjData); |
| 51 } break; |
| 52 } |
| 53 } |
| 54 } |
| 55 |
| 56 void CJS_GlobalVariableArray::Add(CJS_KeyValue* p) { |
| 57 m_Array.push_back(std::unique_ptr<CJS_KeyValue>(p)); |
| 58 } |
| 59 |
| 60 int CJS_GlobalVariableArray::Count() const { |
| 61 return m_Array.size(); |
| 62 } |
| 63 |
| 64 CJS_KeyValue* CJS_GlobalVariableArray::GetAt(int index) const { |
| 65 return m_Array.at(index).get(); |
| 66 } |
| 67 |
| 68 CJS_KeyValue::CJS_KeyValue() {} |
| 69 |
| 70 CJS_KeyValue::~CJS_KeyValue() {} |
OLD | NEW |