| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/fm2js/xfa_expression.h" | 7 #include "xfa/fxfa/fm2js/xfa_expression.h" |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 javascript << FX_WSTRC(L"1"); | 503 javascript << FX_WSTRC(L"1"); |
| 504 } | 504 } |
| 505 javascript << FX_WSTRC(L")\n"); | 505 javascript << FX_WSTRC(L")\n"); |
| 506 m_pList->ToImpliedReturnJS(javascript); | 506 m_pList->ToImpliedReturnJS(javascript); |
| 507 javascript << FX_WSTRC(L"}\n"); | 507 javascript << FX_WSTRC(L"}\n"); |
| 508 } | 508 } |
| 509 | 509 |
| 510 CXFA_FMForeachExpression::CXFA_FMForeachExpression( | 510 CXFA_FMForeachExpression::CXFA_FMForeachExpression( |
| 511 uint32_t line, | 511 uint32_t line, |
| 512 const CFX_WideStringC& wsIdentifier, | 512 const CFX_WideStringC& wsIdentifier, |
| 513 CFX_ArrayTemplate<CXFA_FMSimpleExpression*>* pAccessors, | 513 std::vector<std::unique_ptr<CXFA_FMSimpleExpression>>&& pAccessors, |
| 514 CXFA_FMExpression* pList) | 514 CXFA_FMExpression* pList) |
| 515 : CXFA_FMLoopExpression(line), | 515 : CXFA_FMLoopExpression(line), |
| 516 m_wsIdentifier(wsIdentifier), | 516 m_wsIdentifier(wsIdentifier), |
| 517 m_pAccessors(pAccessors), | 517 m_pAccessors(std::move(pAccessors)), |
| 518 m_pList(pList) {} | 518 m_pList(pList) {} |
| 519 | 519 |
| 520 CXFA_FMForeachExpression::~CXFA_FMForeachExpression() { | 520 CXFA_FMForeachExpression::~CXFA_FMForeachExpression() {} |
| 521 if (m_pAccessors) { | |
| 522 for (int i = 0; i < m_pAccessors->GetSize(); ++i) | |
| 523 m_pAccessors->GetAt(i); | |
| 524 | |
| 525 delete m_pAccessors; | |
| 526 } | |
| 527 } | |
| 528 | 521 |
| 529 void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { | 522 void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| 530 javascript << FX_WSTRC(L"{\n"); | 523 javascript << FX_WSTRC(L"{\n"); |
| 531 javascript << FX_WSTRC(L"var "); | 524 javascript << FX_WSTRC(L"var "); |
| 532 if (m_wsIdentifier.GetAt(0) == L'!') { | 525 if (m_wsIdentifier.GetAt(0) == L'!') { |
| 533 CFX_WideString tempIdentifier = | 526 CFX_WideString tempIdentifier = |
| 534 EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); | 527 EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); |
| 535 javascript << tempIdentifier; | 528 javascript << tempIdentifier; |
| 536 } else { | 529 } else { |
| 537 javascript << m_wsIdentifier; | 530 javascript << m_wsIdentifier; |
| 538 } | 531 } |
| 539 javascript << FX_WSTRC(L" = null;\n"); | 532 javascript << FX_WSTRC(L" = null;\n"); |
| 540 javascript << FX_WSTRC(L"var "); | 533 javascript << FX_WSTRC(L"var "); |
| 541 javascript << RUNTIMEBLOCKTEMPARRAY; | 534 javascript << RUNTIMEBLOCKTEMPARRAY; |
| 542 javascript << FX_WSTRC(L" = "); | 535 javascript << FX_WSTRC(L" = "); |
| 543 javascript << XFA_FM_EXPTypeToString(CONCATFMOBJECT); | 536 javascript << XFA_FM_EXPTypeToString(CONCATFMOBJECT); |
| 544 javascript << FX_WSTRC(L"("); | 537 javascript << FX_WSTRC(L"("); |
| 545 | 538 |
| 546 for (int i = 0; i < m_pAccessors->GetSize(); ++i) { | 539 for (size_t i = 0; i < m_pAccessors.size(); ++i) { |
| 547 CXFA_FMSimpleExpression* s = m_pAccessors->GetAt(i); | 540 CXFA_FMSimpleExpression* s = m_pAccessors.at(i).get(); |
| 548 s->ToJavaScript(javascript); | 541 s->ToJavaScript(javascript); |
| 549 if (i + 1 < m_pAccessors->GetSize()) { | 542 if (i + 1 < m_pAccessors.size()) { |
| 550 javascript << FX_WSTRC(L", "); | 543 javascript << FX_WSTRC(L", "); |
| 551 } | 544 } |
| 552 } | 545 } |
| 553 javascript << FX_WSTRC(L");\n"); | 546 javascript << FX_WSTRC(L");\n"); |
| 554 javascript << FX_WSTRC(L"var "); | 547 javascript << FX_WSTRC(L"var "); |
| 555 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; | 548 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; |
| 556 javascript << FX_WSTRC(L" = 0;\n"); | 549 javascript << FX_WSTRC(L" = 0;\n"); |
| 557 javascript << FX_WSTRC(L"while("); | 550 javascript << FX_WSTRC(L"while("); |
| 558 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; | 551 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; |
| 559 javascript << FX_WSTRC(L" < "); | 552 javascript << FX_WSTRC(L" < "); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 587 javascript << tempIdentifier; | 580 javascript << tempIdentifier; |
| 588 } else { | 581 } else { |
| 589 javascript << m_wsIdentifier; | 582 javascript << m_wsIdentifier; |
| 590 } | 583 } |
| 591 javascript << FX_WSTRC(L" = null;\n"); | 584 javascript << FX_WSTRC(L" = null;\n"); |
| 592 javascript << FX_WSTRC(L"var "); | 585 javascript << FX_WSTRC(L"var "); |
| 593 javascript << RUNTIMEBLOCKTEMPARRAY; | 586 javascript << RUNTIMEBLOCKTEMPARRAY; |
| 594 javascript << FX_WSTRC(L" = "); | 587 javascript << FX_WSTRC(L" = "); |
| 595 javascript << XFA_FM_EXPTypeToString(CONCATFMOBJECT); | 588 javascript << XFA_FM_EXPTypeToString(CONCATFMOBJECT); |
| 596 javascript << FX_WSTRC(L"("); | 589 javascript << FX_WSTRC(L"("); |
| 597 for (int i = 0; i < m_pAccessors->GetSize(); ++i) { | 590 for (size_t i = 0; i < m_pAccessors.size(); ++i) { |
| 598 CXFA_FMSimpleExpression* s = m_pAccessors->GetAt(i); | 591 CXFA_FMSimpleExpression* s = m_pAccessors.at(i).get(); |
| 599 s->ToJavaScript(javascript); | 592 s->ToJavaScript(javascript); |
| 600 if (i + 1 < m_pAccessors->GetSize()) { | 593 if (i + 1 < m_pAccessors.size()) { |
| 601 javascript << FX_WSTRC(L", "); | 594 javascript << FX_WSTRC(L", "); |
| 602 } | 595 } |
| 603 } | 596 } |
| 604 javascript << FX_WSTRC(L");\n"); | 597 javascript << FX_WSTRC(L");\n"); |
| 605 javascript << FX_WSTRC(L"var "); | 598 javascript << FX_WSTRC(L"var "); |
| 606 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; | 599 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; |
| 607 javascript << FX_WSTRC(L" = 0;\n"); | 600 javascript << FX_WSTRC(L" = 0;\n"); |
| 608 javascript << FX_WSTRC(L"while("); | 601 javascript << FX_WSTRC(L"while("); |
| 609 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; | 602 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; |
| 610 javascript << FX_WSTRC(L" < "); | 603 javascript << FX_WSTRC(L" < "); |
| 611 javascript << RUNTIMEBLOCKTEMPARRAY; | 604 javascript << RUNTIMEBLOCKTEMPARRAY; |
| 612 javascript << FX_WSTRC(L".length)\n{\n"); | 605 javascript << FX_WSTRC(L".length)\n{\n"); |
| 613 if (m_wsIdentifier.GetAt(0) == L'!') { | 606 if (m_wsIdentifier.GetAt(0) == L'!') { |
| 614 CFX_WideString tempIdentifier = | 607 CFX_WideString tempIdentifier = |
| 615 EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); | 608 EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); |
| 616 javascript << tempIdentifier; | 609 javascript << tempIdentifier; |
| 617 } else { | 610 } else { |
| 618 javascript << m_wsIdentifier; | 611 javascript << m_wsIdentifier; |
| 619 } | 612 } |
| 620 javascript << FX_WSTRC(L" = "); | 613 javascript << FX_WSTRC(L" = "); |
| 621 javascript << RUNTIMEBLOCKTEMPARRAY; | 614 javascript << RUNTIMEBLOCKTEMPARRAY; |
| 622 javascript << FX_WSTRC(L"["); | 615 javascript << FX_WSTRC(L"["); |
| 623 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; | 616 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; |
| 624 javascript << FX_WSTRC(L"++];\n"); | 617 javascript << FX_WSTRC(L"++];\n"); |
| 625 m_pList->ToImpliedReturnJS(javascript); | 618 m_pList->ToImpliedReturnJS(javascript); |
| 626 javascript << FX_WSTRC(L"}\n"); | 619 javascript << FX_WSTRC(L"}\n"); |
| 627 javascript << FX_WSTRC(L"}\n"); | 620 javascript << FX_WSTRC(L"}\n"); |
| 628 } | 621 } |
| OLD | NEW |