Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp

Issue 2053583003: xfa_fm2jscontext method cleanup - pt IX of IX (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/fm2js/xfa_fm2jscontext.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_fm2jscontext.h" 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 5500 matching lines...) Expand 10 before | Expand all | Expand 10 after
5511 args.GetReturnValue()->SetInteger((first == 0.0) ? 1 : 0); 5511 args.GetReturnValue()->SetInteger((first == 0.0) ? 1 : 0);
5512 } 5512 }
5513 5513
5514 // static 5514 // static
5515 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, 5515 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
5516 const CFX_ByteStringC& szFuncName, 5516 const CFX_ByteStringC& szFuncName,
5517 CFXJSE_Arguments& args) { 5517 CFXJSE_Arguments& args) {
5518 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5518 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5519 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5519 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5520 int32_t argc = args.GetLength(); 5520 int32_t argc = args.GetLength();
5521 if ((argc == 4) || (argc == 5)) { 5521 if (argc < 4 || argc > 5) {
5522 FX_BOOL bIsStar = TRUE; 5522 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
Tom Sepez 2016/06/09 18:15:56 nit: Is this the right error? I thought the other
dsinclair 2016/06/09 18:23:58 I think this makes sense. In the cases above here
5523 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); 5523 return;
5524 CFX_ByteString bsAccessorName = args.GetUTF8String(1); 5524 }
5525 CFX_ByteString szName = args.GetUTF8String(2);
5526 int32_t iIndexFlags = args.GetInt32(3);
5527 int32_t iIndexValue = 0;
5528 if (argc > 4) {
5529 bIsStar = FALSE;
5530 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4);
5531 iIndexValue = ValueToInteger(pThis, argIndex.get());
5532 }
5533 CFX_ByteString szSomExp;
5534 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar,
5535 szSomExp);
5536 if (argAccessor->IsArray()) {
5537 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate));
5538 argAccessor->GetObjectProperty("length", pLengthValue.get());
5539 int32_t iLength = pLengthValue->ToInteger();
5540 int32_t iCounter = 0;
5541 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2);
5542 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2);
5543 for (int32_t i = 0; i < (iLength - 2); i++) {
5544 iSizes[i] = 0;
5545 }
5546 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate));
5547 FX_BOOL bAttribute = FALSE;
5548 for (int32_t i = 2; i < iLength; i++) {
5549 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get());
5550 XFA_RESOLVENODE_RS resoveNodeRS;
5551 int32_t iRet =
5552 ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(),
5553 resoveNodeRS, TRUE, szName.IsEmpty());
5554 if (iRet > 0) {
5555 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(),
5556 hResolveValues[i - 2], iSizes[i - 2], bAttribute);
5557 iCounter += iSizes[i - 2];
5558 }
5559 }
5560 if (iCounter > 0) {
5561 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2);
5562 for (int32_t i = 0; i < (iCounter + 2); i++)
5563 rgValues[i] = new CFXJSE_Value(pIsolate);
5564 5525
5565 rgValues[0]->SetInteger(1); 5526 bool bIsStar = true;
5566 if (bAttribute) { 5527 int32_t iIndexValue = 0;
5567 rgValues[1]->SetString(szName.AsStringC()); 5528 if (argc > 4) {
5568 } else { 5529 bIsStar = false;
5569 rgValues[1]->SetNull(); 5530 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4);
5570 } 5531 iIndexValue = ValueToInteger(pThis, argIndex.get());
Tom Sepez 2016/06/09 18:15:56 nit: local not needed, just args.GetValue(4).get()
dsinclair 2016/06/09 18:23:58 Done.
5571 int32_t iIndex = 2; 5532 }
5572 for (int32_t i = 0; i < iLength - 2; i++) {
5573 for (int32_t j = 0; j < iSizes[i]; j++) {
5574 rgValues[iIndex]->Assign(hResolveValues[i][j]);
5575 iIndex++;
5576 }
5577 }
5578 args.GetReturnValue()->SetArray(iCounter + 2, rgValues);
5579 for (int32_t i = 0; i < (iCounter + 2); i++)
5580 delete rgValues[i];
5581 5533
5582 FX_Free(rgValues); 5534 CFX_ByteString szName = args.GetUTF8String(2);
5583 } else { 5535 CFX_ByteString szSomExp;
5584 CFX_WideString wsPropertyName = 5536 GenerateSomExpression(szName.AsStringC(), args.GetInt32(3), iIndexValue,
5585 CFX_WideString::FromUTF8(szName.AsStringC()); 5537 bIsStar, szSomExp);
5586 CFX_WideString wsSomExpression =
5587 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5588 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5589 wsPropertyName.c_str(),
5590 wsSomExpression.c_str());
5591 }
5592 for (int32_t i = 0; i < iLength - 2; i++) {
5593 for (int32_t j = 0; j < iSizes[i]; j++)
5594 delete hResolveValues[i][j];
5595 5538
5596 if (iSizes[i] > 0) { 5539 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0);
5597 FX_Free(hResolveValues[i]); 5540 if (argAccessor->IsArray()) {
5598 } 5541 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate));
5599 } 5542 argAccessor->GetObjectProperty("length", pLengthValue.get());
5600 FX_Free(hResolveValues); 5543 int32_t iLength = pLengthValue->ToInteger();
5601 FX_Free(iSizes); 5544 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2);
5602 } else { 5545 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2);
5546 for (int32_t i = 0; i < (iLength - 2); i++)
5547 iSizes[i] = 0;
5548
5549 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate));
5550 FX_BOOL bAttribute = FALSE;
5551 int32_t iCounter = 0;
5552 for (int32_t i = 2; i < iLength; i++) {
5553 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get());
5554
5603 XFA_RESOLVENODE_RS resoveNodeRS; 5555 XFA_RESOLVENODE_RS resoveNodeRS;
5604 int32_t iRet = 0; 5556 if (ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(),
5605 if (argAccessor->IsObject() || 5557 resoveNodeRS, TRUE, szName.IsEmpty()) > 0) {
5606 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { 5558 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(),
5607 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), 5559 hResolveValues[i - 2], iSizes[i - 2], bAttribute);
5608 resoveNodeRS, TRUE, szName.IsEmpty()); 5560 iCounter += iSizes[i - 2];
5609 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty()) {
5610 FX_BOOL bGetObject = GetObjectByName(pThis, argAccessor.get(),
5611 bsAccessorName.AsStringC());
5612 if (bGetObject) {
5613 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5614 resoveNodeRS, TRUE, szName.IsEmpty());
5615 }
5616 }
5617 if (iRet > 0) {
5618 CFXJSE_Value** hResolveValues;
5619 int32_t iSize = 0;
5620 FX_BOOL bAttribute = FALSE;
5621 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(),
5622 hResolveValues, iSize, bAttribute);
5623 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2);
5624 for (int32_t i = 0; i < (iSize + 2); i++)
5625 rgValues[i] = new CFXJSE_Value(pIsolate);
5626
5627 rgValues[0]->SetInteger(1);
5628 if (bAttribute) {
5629 rgValues[1]->SetString(szName.AsStringC());
5630 } else {
5631 rgValues[1]->SetNull();
5632 }
5633 for (int32_t i = 0; i < iSize; i++) {
5634 rgValues[i + 2]->Assign(hResolveValues[i]);
5635 }
5636 args.GetReturnValue()->SetArray(iSize + 2, rgValues);
5637 for (int32_t i = 0; i < (iSize + 2); i++)
5638 delete rgValues[i];
5639
5640 FX_Free(rgValues);
5641 for (int32_t i = 0; i < iSize; i++)
5642 delete hResolveValues[i];
5643
5644 FX_Free(hResolveValues);
5645 } else {
5646 CFX_WideString wsPropertyName =
5647 CFX_WideString::FromUTF8(szName.AsStringC());
5648 CFX_WideString wsSomExpression =
5649 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5650 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5651 wsPropertyName.c_str(),
5652 wsSomExpression.c_str());
5653 } 5561 }
5654 } 5562 }
5655 } else { 5563 if (iCounter < 1) {
5656 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5564 CFX_WideString wsPropertyName =
5565 CFX_WideString::FromUTF8(szName.AsStringC());
5566 CFX_WideString wsSomExpression =
5567 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5568 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5569 wsPropertyName.c_str(), wsSomExpression.c_str());
5570 return;
5571 }
5572
5573 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2);
5574 for (int32_t i = 0; i < (iCounter + 2); i++)
5575 rgValues[i] = new CFXJSE_Value(pIsolate);
5576
5577 rgValues[0]->SetInteger(1);
5578 if (bAttribute)
5579 rgValues[1]->SetString(szName.AsStringC());
5580 else
5581 rgValues[1]->SetNull();
5582
5583 int32_t iIndex = 2;
5584 for (int32_t i = 0; i < iLength - 2; i++) {
5585 for (int32_t j = 0; j < iSizes[i]; j++) {
5586 rgValues[iIndex]->Assign(hResolveValues[i][j]);
5587 iIndex++;
5588 }
5589 }
5590 args.GetReturnValue()->SetArray(iCounter + 2, rgValues);
5591
5592 for (int32_t i = 0; i < (iCounter + 2); i++)
5593 delete rgValues[i];
5594 FX_Free(rgValues);
5595
5596 for (int32_t i = 0; i < iLength - 2; i++) {
5597 for (int32_t j = 0; j < iSizes[i]; j++)
5598 delete hResolveValues[i][j];
5599
5600 if (iSizes[i] > 0)
5601 FX_Free(hResolveValues[i]);
5602 }
5603 FX_Free(hResolveValues);
5604 FX_Free(iSizes);
5605
5606 return;
5657 } 5607 }
5608
5609 XFA_RESOLVENODE_RS resoveNodeRS;
5610 int32_t iRet = 0;
5611 CFX_ByteString bsAccessorName = args.GetUTF8String(1);
5612 if (argAccessor->IsObject() ||
5613 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) {
5614 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5615 resoveNodeRS, TRUE, szName.IsEmpty());
5616 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() &&
5617 GetObjectByName(pThis, argAccessor.get(),
5618 bsAccessorName.AsStringC())) {
5619 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5620 resoveNodeRS, TRUE, szName.IsEmpty());
5621 }
5622 if (iRet < 1) {
5623 CFX_WideString wsPropertyName =
5624 CFX_WideString::FromUTF8(szName.AsStringC());
5625 CFX_WideString wsSomExpression =
5626 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5627 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5628 wsPropertyName.c_str(), wsSomExpression.c_str());
5629 return;
5630 }
5631
5632 CFXJSE_Value** hResolveValues;
5633 int32_t iSize = 0;
5634 FX_BOOL bAttribute = FALSE;
5635 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(), hResolveValues,
5636 iSize, bAttribute);
5637 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2);
5638 for (int32_t i = 0; i < (iSize + 2); i++)
5639 rgValues[i] = new CFXJSE_Value(pIsolate);
5640
5641 rgValues[0]->SetInteger(1);
5642 if (bAttribute)
5643 rgValues[1]->SetString(szName.AsStringC());
5644 else
5645 rgValues[1]->SetNull();
5646
5647 for (int32_t i = 0; i < iSize; i++)
5648 rgValues[i + 2]->Assign(hResolveValues[i]);
5649
5650 args.GetReturnValue()->SetArray(iSize + 2, rgValues);
5651 for (int32_t i = 0; i < (iSize + 2); i++)
5652 delete rgValues[i];
5653 FX_Free(rgValues);
5654
5655 for (int32_t i = 0; i < iSize; i++)
5656 delete hResolveValues[i];
5657 FX_Free(hResolveValues);
5658 } 5658 }
5659 5659
5660 // static 5660 // static
5661 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, 5661 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis,
5662 const CFX_ByteStringC& szFuncName, 5662 const CFX_ByteStringC& szFuncName,
5663 CFXJSE_Arguments& args) { 5663 CFXJSE_Arguments& args) {
5664 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5664 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5665 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5665 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5666 int32_t argc = args.GetLength(); 5666 int32_t argc = args.GetLength();
5667 if ((argc == 4) || (argc == 5)) { 5667 if (argc < 4 || argc > 5) {
5668 FX_BOOL bIsStar = TRUE; 5668 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5669 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); 5669 return;
5670 CFX_ByteString bsAccessorName = args.GetUTF8String(1); 5670 }
5671 CFX_ByteString szName = args.GetUTF8String(2);
5672 int32_t iIndexFlags = args.GetInt32(3);
5673 int32_t iIndexValue = 0;
5674 if (argc > 4) {
5675 bIsStar = FALSE;
5676 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4);
5677 iIndexValue = ValueToInteger(pThis, argIndex.get());
5678 }
5679 CFX_ByteString szSomExp;
5680 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar,
5681 szSomExp);
5682 if (argAccessor->IsArray()) {
5683 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate));
5684 argAccessor->GetObjectProperty("length", pLengthValue.get());
5685 int32_t iLength = pLengthValue->ToInteger();
5686 int32_t iCounter = 0;
5687 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2);
5688 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2);
5689 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate));
5690 FX_BOOL bAttribute = FALSE;
5691 for (int32_t i = 2; i < iLength; i++) {
5692 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get());
5693 XFA_RESOLVENODE_RS resoveNodeRS;
5694 int32_t iRet =
5695 ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(),
5696 resoveNodeRS, FALSE);
5697 if (iRet > 0) {
5698 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(),
5699 hResolveValues[i - 2], iSizes[i - 2], bAttribute);
5700 iCounter += iSizes[i - 2];
5701 }
5702 }
5703 if (iCounter > 0) {
5704 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2);
5705 for (int32_t i = 0; i < (iCounter + 2); i++)
5706 rgValues[i] = new CFXJSE_Value(pIsolate);
5707 5671
5708 rgValues[0]->SetInteger(1); 5672 bool bIsStar = true;
5709 if (bAttribute) { 5673 int32_t iIndexValue = 0;
5710 rgValues[1]->SetString(szName.AsStringC()); 5674 if (argc > 4) {
5711 } else { 5675 bIsStar = false;
5712 rgValues[1]->SetNull(); 5676 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4);
5713 } 5677 iIndexValue = ValueToInteger(pThis, argIndex.get());
Tom Sepez 2016/06/09 18:15:56 nitto
dsinclair 2016/06/09 18:23:58 Done.
5714 int32_t iIndex = 2; 5678 }
5715 for (int32_t i = 0; i < iLength - 2; i++) {
5716 for (int32_t j = 0; j < iSizes[i]; j++) {
5717 rgValues[iIndex]->Assign(hResolveValues[i][j]);
5718 iIndex++;
5719 }
5720 }
5721 args.GetReturnValue()->SetArray(iCounter + 2, rgValues);
5722 for (int32_t i = 0; i < (iCounter + 2); i++)
5723 delete rgValues[i];
5724 5679
5725 FX_Free(rgValues); 5680 CFX_ByteString szSomExp;
5726 } else { 5681 CFX_ByteString szName = args.GetUTF8String(2);
5727 CFX_WideString wsPropertyName = 5682 GenerateSomExpression(szName.AsStringC(), args.GetInt32(3), iIndexValue,
5728 CFX_WideString::FromUTF8(szName.AsStringC()); 5683 bIsStar, szSomExp);
5729 CFX_WideString wsSomExpression =
5730 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5731 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5732 wsPropertyName.c_str(),
5733 wsSomExpression.c_str());
5734 }
5735 for (int32_t i = 0; i < iLength - 2; i++) {
5736 for (int32_t j = 0; j < iSizes[i]; j++)
5737 delete hResolveValues[i][j];
5738 5684
5739 FX_Free(hResolveValues[i]); 5685 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0);
5740 } 5686 if (argAccessor->IsArray()) {
5741 FX_Free(hResolveValues); 5687 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate));
5742 FX_Free(iSizes); 5688 argAccessor->GetObjectProperty("length", pLengthValue.get());
5743 } else { 5689 int32_t iLength = pLengthValue->ToInteger();
5690 int32_t iCounter = 0;
5691
5692 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2);
5693 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2);
5694 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate));
5695 FX_BOOL bAttribute = FALSE;
5696 for (int32_t i = 2; i < iLength; i++) {
5697 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get());
5744 XFA_RESOLVENODE_RS resoveNodeRS; 5698 XFA_RESOLVENODE_RS resoveNodeRS;
5745 int32_t iRet = 0; 5699 if (ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(),
5746 if (argAccessor->IsObject() || 5700 resoveNodeRS, FALSE) > 0) {
5747 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { 5701 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(),
5748 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), 5702 hResolveValues[i - 2], iSizes[i - 2], bAttribute);
5749 resoveNodeRS, FALSE); 5703 iCounter += iSizes[i - 2];
5750 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty()) {
5751 FX_BOOL bGetObject = GetObjectByName(pThis, argAccessor.get(),
5752 bsAccessorName.AsStringC());
5753 if (bGetObject) {
5754 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5755 resoveNodeRS, FALSE);
5756 }
5757 }
5758 if (iRet > 0) {
5759 CFXJSE_Value** hResolveValues;
5760 int32_t iSize = 0;
5761 FX_BOOL bAttribute = FALSE;
5762 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(),
5763 hResolveValues, iSize, bAttribute);
5764 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2);
5765 for (int32_t i = 0; i < (iSize + 2); i++)
5766 rgValues[i] = new CFXJSE_Value(pIsolate);
5767
5768 rgValues[0]->SetInteger(1);
5769 if (bAttribute) {
5770 rgValues[1]->SetString(szName.AsStringC());
5771 } else {
5772 rgValues[1]->SetNull();
5773 }
5774 for (int32_t i = 0; i < iSize; i++) {
5775 rgValues[i + 2]->Assign(hResolveValues[i]);
5776 }
5777 args.GetReturnValue()->SetArray(iSize + 2, rgValues);
5778 for (int32_t i = 0; i < (iSize + 2); i++)
5779 delete rgValues[i];
5780
5781 FX_Free(rgValues);
5782 for (int32_t i = 0; i < iSize; i++)
5783 delete hResolveValues[i];
5784
5785 FX_Free(hResolveValues);
5786 } else {
5787 CFX_WideString wsPropertyName =
5788 CFX_WideString::FromUTF8(szName.AsStringC());
5789 CFX_WideString wsSomExpression =
5790 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5791 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5792 wsPropertyName.c_str(),
5793 wsSomExpression.c_str());
5794 } 5704 }
5795 } 5705 }
5796 } else { 5706 if (iCounter < 1) {
5797 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5707 CFX_WideString wsPropertyName =
5708 CFX_WideString::FromUTF8(szName.AsStringC());
5709 CFX_WideString wsSomExpression =
5710 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5711 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5712 wsPropertyName.c_str(), wsSomExpression.c_str());
5713 return;
5714 }
5715
5716 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2);
5717 for (int32_t i = 0; i < (iCounter + 2); i++)
5718 rgValues[i] = new CFXJSE_Value(pIsolate);
5719
5720 rgValues[0]->SetInteger(1);
5721 if (bAttribute)
5722 rgValues[1]->SetString(szName.AsStringC());
5723 else
5724 rgValues[1]->SetNull();
5725
5726 int32_t iIndex = 2;
5727 for (int32_t i = 0; i < iLength - 2; i++) {
5728 for (int32_t j = 0; j < iSizes[i]; j++) {
5729 rgValues[iIndex]->Assign(hResolveValues[i][j]);
5730 iIndex++;
5731 }
5732 }
5733 args.GetReturnValue()->SetArray(iCounter + 2, rgValues);
5734 for (int32_t i = 0; i < (iCounter + 2); i++)
5735 delete rgValues[i];
5736 FX_Free(rgValues);
5737
5738 for (int32_t i = 0; i < iLength - 2; i++) {
5739 for (int32_t j = 0; j < iSizes[i]; j++)
5740 delete hResolveValues[i][j];
5741 FX_Free(hResolveValues[i]);
5742 }
5743 FX_Free(hResolveValues);
5744 FX_Free(iSizes);
5745 return;
5798 } 5746 }
5747
5748 XFA_RESOLVENODE_RS resoveNodeRS;
5749 int32_t iRet = 0;
5750 CFX_ByteString bsAccessorName = args.GetUTF8String(1);
5751 if (argAccessor->IsObject() ||
5752 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) {
5753 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5754 resoveNodeRS, FALSE);
5755 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() &&
5756 GetObjectByName(pThis, argAccessor.get(),
5757 bsAccessorName.AsStringC())) {
5758 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5759 resoveNodeRS, FALSE);
5760 }
5761 if (iRet < 1) {
5762 CFX_WideString wsPropertyName =
5763 CFX_WideString::FromUTF8(szName.AsStringC());
5764 CFX_WideString wsSomExpression =
5765 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5766 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5767 wsPropertyName.c_str(), wsSomExpression.c_str());
5768 return;
5769 }
5770
5771 CFXJSE_Value** hResolveValues;
5772 int32_t iSize = 0;
5773 FX_BOOL bAttribute = FALSE;
5774 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(), hResolveValues,
5775 iSize, bAttribute);
5776 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2);
5777 for (int32_t i = 0; i < (iSize + 2); i++)
5778 rgValues[i] = new CFXJSE_Value(pIsolate);
5779
5780 rgValues[0]->SetInteger(1);
5781 if (bAttribute)
5782 rgValues[1]->SetString(szName.AsStringC());
5783 else
5784 rgValues[1]->SetNull();
5785
5786 for (int32_t i = 0; i < iSize; i++)
5787 rgValues[i + 2]->Assign(hResolveValues[i]);
5788
5789 args.GetReturnValue()->SetArray(iSize + 2, rgValues);
5790
5791 for (int32_t i = 0; i < (iSize + 2); i++)
5792 delete rgValues[i];
5793 FX_Free(rgValues);
5794
5795 for (int32_t i = 0; i < iSize; i++)
5796 delete hResolveValues[i];
5797 FX_Free(hResolveValues);
5799 } 5798 }
5800 5799
5801 // static 5800 // static
5802 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, 5801 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
5803 const CFX_ByteStringC& szFuncName, 5802 const CFX_ByteStringC& szFuncName,
5804 CFXJSE_Arguments& args) { 5803 CFXJSE_Arguments& args) {
5805 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5804 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5806 if (args.GetLength() == 1) { 5805 if (args.GetLength() != 1) {
5807 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5808 CFX_ByteString argString;
5809 ValueToUTF8String(argOne.get(), argString);
5810 if (argString.IsEmpty()) {
5811 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
5812 } else {
5813 CFX_WideString scriptString =
5814 CFX_WideString::FromUTF8(argString.AsStringC());
5815 CFX_WideTextBuf wsJavaScriptBuf;
5816 CFX_WideString wsError;
5817 CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf,
5818 wsError);
5819 if (wsError.IsEmpty()) {
5820 CFX_WideString javaScript = wsJavaScriptBuf.MakeString();
5821 args.GetReturnValue()->SetString(
5822 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength())
5823 .AsStringC());
5824 } else {
5825 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5826 }
5827 }
5828 } else {
5829 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval"); 5806 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
5807 return;
5830 } 5808 }
5809
5810 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5811 CFX_ByteString argString;
5812 ValueToUTF8String(argOne.get(), argString);
5813 if (argString.IsEmpty()) {
5814 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
5815 return;
5816 }
5817
5818 CFX_WideString scriptString = CFX_WideString::FromUTF8(argString.AsStringC());
5819 CFX_WideTextBuf wsJavaScriptBuf;
5820 CFX_WideString wsError;
5821 CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf,
5822 wsError);
5823 if (!wsError.IsEmpty()) {
5824 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5825 return;
5826 }
5827
5828 CFX_WideString javaScript = wsJavaScriptBuf.MakeString();
5829 args.GetReturnValue()->SetString(
5830 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).AsStringC());
5831 } 5831 }
5832 5832
5833 // static 5833 // static
5834 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, 5834 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis,
5835 const CFX_ByteStringC& szFuncName, 5835 const CFX_ByteStringC& szFuncName,
5836 CFXJSE_Arguments& args) { 5836 CFXJSE_Arguments& args) {
5837 if (args.GetLength() == 1) { 5837 if (args.GetLength() != 1) {
5838 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5839 args.GetReturnValue()->SetBoolean(argOne->IsObject());
5840 } else {
5841 args.GetReturnValue()->SetBoolean(FALSE); 5838 args.GetReturnValue()->SetBoolean(FALSE);
5839 return;
5842 } 5840 }
5841
5842 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5843 args.GetReturnValue()->SetBoolean(argOne->IsObject());
5843 } 5844 }
5844 5845
5845 // static 5846 // static
5846 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, 5847 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis,
5847 const CFX_ByteStringC& szFuncName, 5848 const CFX_ByteStringC& szFuncName,
5848 CFXJSE_Arguments& args) { 5849 CFXJSE_Arguments& args) {
5849 if (args.GetLength() == 1) { 5850 if (args.GetLength() != 1) {
5850 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5851 args.GetReturnValue()->SetBoolean(argOne->IsArray());
5852 } else {
5853 args.GetReturnValue()->SetBoolean(FALSE); 5851 args.GetReturnValue()->SetBoolean(FALSE);
5852 return;
5854 } 5853 }
5854
5855 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5856 args.GetReturnValue()->SetBoolean(argOne->IsArray());
5855 } 5857 }
5856 5858
5857 // static 5859 // static
5858 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, 5860 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis,
5859 const CFX_ByteStringC& szFuncName, 5861 const CFX_ByteStringC& szFuncName,
5860 CFXJSE_Arguments& args) { 5862 CFXJSE_Arguments& args) {
5861 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5863 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5862 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5864 if (args.GetLength() != 1) {
5863 if (args.GetLength() == 1) { 5865 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5864 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5866 return;
5865 if (argOne->IsArray()) { 5867 }
5866 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 5868
5867 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 5869 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5868 argOne->GetObjectPropertyByIdx(1, propertyValue.get()); 5870 if (argOne->IsArray()) {
5869 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); 5871 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5870 if (propertyValue->IsNull()) { 5872 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
5871 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); 5873 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
5872 } else { 5874 argOne->GetObjectPropertyByIdx(1, propertyValue.get());
5873 CFX_ByteString propertyStr; 5875 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get());
5874 propertyValue->ToString(propertyStr); 5876 if (propertyValue->IsNull()) {
5875 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), 5877 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue());
5876 args.GetReturnValue()); 5878 return;
5877 }
5878 } else if (argOne->IsObject()) {
5879 GetObjectDefaultValue(argOne.get(), args.GetReturnValue());
5880 } else {
5881 args.GetReturnValue()->Assign(argOne.get());
5882 } 5879 }
5883 } else { 5880
5884 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5881 CFX_ByteString propertyStr;
5882 propertyValue->ToString(propertyStr);
5883 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
5884 args.GetReturnValue());
5885 return;
5885 } 5886 }
5887
5888 if (argOne->IsObject()) {
5889 GetObjectDefaultValue(argOne.get(), args.GetReturnValue());
5890 return;
5891 }
5892
5893 args.GetReturnValue()->Assign(argOne.get());
5886 } 5894 }
5887 5895
5888 // static 5896 // static
5889 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, 5897 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis,
5890 const CFX_ByteStringC& szFuncName, 5898 const CFX_ByteStringC& szFuncName,
5891 CFXJSE_Arguments& args) { 5899 CFXJSE_Arguments& args) {
5892 if (args.GetLength() == 1) { 5900 if (args.GetLength() != 1) {
5893 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5901 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5894 if (argOne->IsArray()) { 5902 return;
5903 }
5904
5905 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5906 if (!argOne->IsArray()) {
5907 args.GetReturnValue()->Assign(argOne.get());
5908 return;
5909 }
5910
5895 #ifndef NDEBUG 5911 #ifndef NDEBUG
5896 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5912 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5897 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5913 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5898 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 5914 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
5899 argOne->GetObjectProperty("length", lengthValue.get()); 5915 argOne->GetObjectProperty("length", lengthValue.get());
5900 ASSERT(lengthValue->ToInteger() >= 3); 5916 ASSERT(lengthValue->ToInteger() >= 3);
5901 #endif 5917 #endif
5902 argOne->GetObjectPropertyByIdx(2, args.GetReturnValue()); 5918
5903 } else { 5919 argOne->GetObjectPropertyByIdx(2, args.GetReturnValue());
5904 args.GetReturnValue()->Assign(argOne.get());
5905 }
5906 } else {
5907 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5908 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5909 }
5910 } 5920 }
5911 5921
5912 // static 5922 // static
5913 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, 5923 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis,
5914 const CFX_ByteStringC& szFuncName, 5924 const CFX_ByteStringC& szFuncName,
5915 CFXJSE_Arguments& args) { 5925 CFXJSE_Arguments& args) {
5916 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5926 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5927 if (args.GetLength() != 1) {
5928 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5929 return;
5930 }
5931
5917 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5932 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5918 if (args.GetLength() == 1) { 5933 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5919 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5934 if (!argOne->IsArray()) {
5920 if (argOne->IsArray()) { 5935 std::unique_ptr<CFXJSE_Value> simpleValue = GetSimpleValue(pThis, args, 0);
5936 args.GetReturnValue()->Assign(simpleValue.get());
5937 return;
5938 }
5939
5921 #ifndef NDEBUG 5940 #ifndef NDEBUG
5922 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 5941 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
5923 argOne->GetObjectProperty("length", lengthValue.get()); 5942 argOne->GetObjectProperty("length", lengthValue.get());
5924 ASSERT(lengthValue->ToInteger() >= 3); 5943 ASSERT(lengthValue->ToInteger() >= 3);
5925 #endif 5944 #endif
5926 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate));
5927 argOne->GetObjectPropertyByIdx(0, flagsValue.get());
5928 int32_t iFlags = flagsValue->ToInteger();
5929 if (iFlags == 4) {
5930 CFXJSE_Value* rgValues[3];
5931 for (int32_t i = 0; i < 3; i++)
5932 rgValues[i] = new CFXJSE_Value(pIsolate);
5933 5945
5934 rgValues[0]->SetInteger(3); 5946 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate));
5935 rgValues[1]->SetNull(); 5947 argOne->GetObjectPropertyByIdx(0, flagsValue.get());
5936 rgValues[2]->SetNull(); 5948 int32_t iFlags = flagsValue->ToInteger();
5937 args.GetReturnValue()->SetArray(3, rgValues); 5949 if (iFlags != 3 && iFlags != 4) {
5938 for (int32_t i = 0; i < 3; i++) 5950 std::unique_ptr<CFXJSE_Value> simpleValue = GetSimpleValue(pThis, args, 0);
5939 delete rgValues[i]; 5951 args.GetReturnValue()->Assign(simpleValue.get());
5940 } else if (iFlags == 3) { 5952 return;
5941 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate)); 5953 }
5942 argOne->GetObjectPropertyByIdx(2, objectValue.get()); 5954
5943 if (!objectValue->IsNull()) { 5955 if (iFlags == 4) {
5944 args.GetReturnValue()->Assign(argOne.get()); 5956 CFXJSE_Value* rgValues[3];
5945 } else { 5957 for (int32_t i = 0; i < 3; i++)
5946 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5958 rgValues[i] = new CFXJSE_Value(pIsolate);
5947 } 5959
5948 } else { 5960 rgValues[0]->SetInteger(3);
5949 std::unique_ptr<CFXJSE_Value> simpleValue = 5961 rgValues[1]->SetNull();
5950 GetSimpleValue(pThis, args, 0); 5962 rgValues[2]->SetNull();
5951 args.GetReturnValue()->Assign(simpleValue.get()); 5963 args.GetReturnValue()->SetArray(3, rgValues);
5952 } 5964 for (int32_t i = 0; i < 3; i++)
5953 } else { 5965 delete rgValues[i];
5954 std::unique_ptr<CFXJSE_Value> simpleValue = 5966
5955 GetSimpleValue(pThis, args, 0); 5967 return;
5956 args.GetReturnValue()->Assign(simpleValue.get()); 5968 }
5957 } 5969
5958 } else { 5970 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate));
5971 argOne->GetObjectPropertyByIdx(2, objectValue.get());
5972 if (objectValue->IsNull()) {
5959 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5973 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5974 return;
5960 } 5975 }
5976 args.GetReturnValue()->Assign(argOne.get());
5961 } 5977 }
5962 5978
5963 // static 5979 // static
5964 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, 5980 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis,
5965 const CFX_ByteStringC& szFuncName, 5981 const CFX_ByteStringC& szFuncName,
5966 CFXJSE_Arguments& args) { 5982 CFXJSE_Arguments& args) {
5967 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 5983 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
5968 uint32_t iLength = 0; 5984 uint32_t iLength = 0;
5969 int32_t argc = args.GetLength(); 5985 int32_t argc = args.GetLength();
5970 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; 5986 std::vector<std::unique_ptr<CFXJSE_Value>> argValues;
5971 for (int32_t i = 0; i < argc; i++) { 5987 for (int32_t i = 0; i < argc; i++) {
5972 argValues.push_back(args.GetValue(i)); 5988 argValues.push_back(args.GetValue(i));
5973 if (argValues[i]->IsArray()) { 5989 if (argValues[i]->IsArray()) {
5974 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 5990 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
5975 argValues[i]->GetObjectProperty("length", lengthValue.get()); 5991 argValues[i]->GetObjectProperty("length", lengthValue.get());
5976 int32_t length = lengthValue->ToInteger(); 5992 int32_t length = lengthValue->ToInteger();
5977 iLength = iLength + ((length > 2) ? (length - 2) : 0); 5993 iLength = iLength + ((length > 2) ? (length - 2) : 0);
5978 } 5994 }
5979 iLength += 1; 5995 iLength += 1;
5980 } 5996 }
5997
5981 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); 5998 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength);
5982 for (int32_t i = 0; i < (int32_t)iLength; i++) 5999 for (int32_t i = 0; i < (int32_t)iLength; i++)
5983 returnValues[i] = new CFXJSE_Value(pIsolate); 6000 returnValues[i] = new CFXJSE_Value(pIsolate);
5984 6001
5985 int32_t index = 0; 6002 int32_t index = 0;
5986 for (int32_t i = 0; i < argc; i++) { 6003 for (int32_t i = 0; i < argc; i++) {
5987 if (argValues[i]->IsArray()) { 6004 if (argValues[i]->IsArray()) {
5988 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6005 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
5989 argValues[i]->GetObjectProperty("length", lengthValue.get()); 6006 argValues[i]->GetObjectProperty("length", lengthValue.get());
5990 int32_t length = lengthValue->ToInteger(); 6007 int32_t length = lengthValue->ToInteger();
(...skipping 12 matching lines...) Expand all
6003 FX_Free(returnValues); 6020 FX_Free(returnValues);
6004 } 6021 }
6005 6022
6006 // static 6023 // static
6007 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue( 6024 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue(
6008 CFXJSE_Value* pThis, 6025 CFXJSE_Value* pThis,
6009 CFXJSE_Arguments& args, 6026 CFXJSE_Arguments& args,
6010 uint32_t index) { 6027 uint32_t index) {
6011 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6028 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6012 ASSERT(index < (uint32_t)args.GetLength()); 6029 ASSERT(index < (uint32_t)args.GetLength());
6030
6013 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index); 6031 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index);
6032 if (!argIndex->IsArray() && !argIndex->IsObject())
6033 return argIndex;
6034
6014 if (argIndex->IsArray()) { 6035 if (argIndex->IsArray()) {
6015 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6036 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6016 argIndex->GetObjectProperty("length", lengthValue.get()); 6037 argIndex->GetObjectProperty("length", lengthValue.get());
6017 int32_t iLength = lengthValue->ToInteger(); 6038 int32_t iLength = lengthValue->ToInteger();
6018 std::unique_ptr<CFXJSE_Value> simpleValue(new CFXJSE_Value(pIsolate)); 6039 std::unique_ptr<CFXJSE_Value> simpleValue(new CFXJSE_Value(pIsolate));
6019 if (iLength > 2) { 6040 if (iLength < 3) {
6020 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6021 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6022 argIndex->GetObjectPropertyByIdx(1, propertyValue.get());
6023 argIndex->GetObjectPropertyByIdx(2, jsObjectValue.get());
6024 if (propertyValue->IsNull()) {
6025 GetObjectDefaultValue(jsObjectValue.get(), simpleValue.get());
6026 } else {
6027 CFX_ByteString propertyStr;
6028 propertyValue->ToString(propertyStr);
6029 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6030 simpleValue.get());
6031 }
6032 } else {
6033 simpleValue.get()->SetUndefined(); 6041 simpleValue.get()->SetUndefined();
6042 return simpleValue;
6034 } 6043 }
6044
6045 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6046 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6047 argIndex->GetObjectPropertyByIdx(1, propertyValue.get());
6048 argIndex->GetObjectPropertyByIdx(2, jsObjectValue.get());
6049 if (propertyValue->IsNull()) {
6050 GetObjectDefaultValue(jsObjectValue.get(), simpleValue.get());
6051 return simpleValue;
6052 }
6053
6054 CFX_ByteString propertyStr;
6055 propertyValue->ToString(propertyStr);
6056 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6057 simpleValue.get());
6035 return simpleValue; 6058 return simpleValue;
6036 } else if (argIndex->IsObject()) {
6037 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6038 GetObjectDefaultValue(argIndex.get(), defaultValue.get());
6039 return defaultValue;
6040 } else {
6041 return argIndex;
6042 } 6059 }
6060
6061 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6062 GetObjectDefaultValue(argIndex.get(), defaultValue.get());
6063 return defaultValue;
6043 } 6064 }
6044 6065
6045 // static 6066 // static
6046 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { 6067 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) {
6068 if (!arg || arg->IsNull())
6069 return TRUE;
6070
6071 if (!arg->IsArray() && !arg->IsObject())
6072 return FALSE;
6073
6047 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6074 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6048 FX_BOOL isNull = FALSE; 6075 if (arg->IsArray()) {
6049 if (!arg || arg->IsNull()) {
6050 isNull = TRUE;
6051 } else if (arg->IsArray()) {
6052 int32_t iLength = hvalue_get_array_length(pThis, arg); 6076 int32_t iLength = hvalue_get_array_length(pThis, arg);
6053 if (iLength > 2) { 6077 if (iLength < 3)
6054 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6078 return TRUE;
6055 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6079
6056 arg->GetObjectPropertyByIdx(1, propertyValue.get()); 6080 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6057 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); 6081 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6058 if (propertyValue->IsNull()) { 6082 arg->GetObjectPropertyByIdx(1, propertyValue.get());
6059 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); 6083 arg->GetObjectPropertyByIdx(2, jsObjectValue.get());
6060 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get()); 6084 if (propertyValue->IsNull()) {
6061 if (defaultValue->IsNull()) { 6085 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6062 isNull = TRUE; 6086 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get());
6063 } 6087 return defaultValue->IsNull();
6064 } else {
6065 CFX_ByteString propertyStr;
6066 propertyValue->ToString(propertyStr);
6067 std::unique_ptr<CFXJSE_Value> newPropertyValue(
6068 new CFXJSE_Value(pIsolate));
6069 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6070 newPropertyValue.get());
6071 if (newPropertyValue->IsNull()) {
6072 isNull = TRUE;
6073 }
6074 }
6075 } else {
6076 isNull = TRUE;
6077 } 6088 }
6078 } else if (arg->IsObject()) { 6089
6079 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); 6090 CFX_ByteString propertyStr;
6080 GetObjectDefaultValue(arg, defaultValue.get()); 6091 propertyValue->ToString(propertyStr);
6081 if (defaultValue->IsNull()) { 6092 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6082 isNull = TRUE; 6093 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6083 } 6094 newPropertyValue.get());
6095 return newPropertyValue->IsNull();
6084 } 6096 }
6085 return isNull; 6097
6098 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6099 GetObjectDefaultValue(arg, defaultValue.get());
6100 return defaultValue->IsNull();
6086 } 6101 }
6087 6102
6088 // static 6103 // static
6089 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, 6104 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis,
6090 CFXJSE_Value* arg) { 6105 CFXJSE_Value* arg) {
6091 if (!arg || !arg->IsArray()) 6106 if (!arg || !arg->IsArray())
6092 return 0; 6107 return 0;
6093 6108
6094 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6109 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6095 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6110 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6096 arg->GetObjectProperty("length", lengthValue.get()); 6111 arg->GetObjectProperty("length", lengthValue.get());
6097 return lengthValue->ToInteger(); 6112 return lengthValue->ToInteger();
6098 } 6113 }
6099 6114
6100 // static 6115 // static
6101 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, 6116 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis,
6102 CFXJSE_Value* firstValue, 6117 CFXJSE_Value* firstValue,
6103 CFXJSE_Value* secondValue) { 6118 CFXJSE_Value* secondValue) {
6104 if (!firstValue) 6119 if (!firstValue)
6105 return FALSE; 6120 return FALSE;
6106 6121
6107 FX_BOOL bReturn = FALSE;
6108 if (firstValue->IsString()) { 6122 if (firstValue->IsString()) {
6109 CFX_ByteString firstString, secondString; 6123 CFX_ByteString firstString, secondString;
6110 ValueToUTF8String(firstValue, firstString); 6124 ValueToUTF8String(firstValue, firstString);
6111 ValueToUTF8String(secondValue, secondString); 6125 ValueToUTF8String(secondValue, secondString);
6112 bReturn = firstString == secondString; 6126 return firstString == secondString;
6113 } else if (firstValue->IsNumber()) { 6127 }
6128 if (firstValue->IsNumber()) {
6114 FX_FLOAT first = ValueToFloat(pThis, firstValue); 6129 FX_FLOAT first = ValueToFloat(pThis, firstValue);
6115 FX_FLOAT second = ValueToFloat(pThis, secondValue); 6130 FX_FLOAT second = ValueToFloat(pThis, secondValue);
6116 bReturn = (first == second); 6131 return (first == second);
6117 } else if (firstValue->IsBoolean()) {
6118 bReturn = (firstValue->ToBoolean() == secondValue->ToBoolean());
6119 } else if (firstValue->IsNull() && secondValue && secondValue->IsNull()) {
6120 bReturn = TRUE;
6121 } 6132 }
6122 return bReturn; 6133 if (firstValue->IsBoolean())
6134 return (firstValue->ToBoolean() == secondValue->ToBoolean());
6135
6136 return firstValue->IsNull() && secondValue && secondValue->IsNull();
6123 } 6137 }
6124 6138
6125 // static 6139 // static
6126 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, 6140 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis,
6127 CFXJSE_Arguments& args, 6141 CFXJSE_Arguments& args,
6128 CFXJSE_Value**& resultValues, 6142 CFXJSE_Value**& resultValues,
6129 int32_t& iCount, 6143 int32_t& iCount,
6130 int32_t iStart) { 6144 int32_t iStart) {
6145 iCount = 0;
6146
6131 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6147 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6132 iCount = 0;
6133 int32_t argc = args.GetLength(); 6148 int32_t argc = args.GetLength();
6134 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue; 6149 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue;
6135 for (int32_t i = 0; i < argc - iStart; i++) { 6150 for (int32_t i = 0; i < argc - iStart; i++) {
6136 argsValue.push_back(args.GetValue(i + iStart)); 6151 argsValue.push_back(args.GetValue(i + iStart));
6137 if (argsValue[i]->IsArray()) { 6152 if (argsValue[i]->IsArray()) {
6138 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6153 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6139 argsValue[i]->GetObjectProperty("length", lengthValue.get()); 6154 argsValue[i]->GetObjectProperty("length", lengthValue.get());
6140 int32_t iLength = lengthValue->ToInteger(); 6155 int32_t iLength = lengthValue->ToInteger();
6141 iCount += ((iLength > 2) ? (iLength - 2) : 0); 6156 iCount += ((iLength > 2) ? (iLength - 2) : 0);
6142 } else { 6157 } else {
6143 iCount += 1; 6158 iCount += 1;
6144 } 6159 }
6145 } 6160 }
6146 resultValues = FX_Alloc(CFXJSE_Value*, iCount); 6161 resultValues = FX_Alloc(CFXJSE_Value*, iCount);
6147 for (int32_t i = 0; i < iCount; i++) 6162 for (int32_t i = 0; i < iCount; i++)
6148 resultValues[i] = new CFXJSE_Value(pIsolate); 6163 resultValues[i] = new CFXJSE_Value(pIsolate);
6149 6164
6150 int32_t index = 0; 6165 int32_t index = 0;
6151 for (int32_t i = 0; i < argc - iStart; i++) { 6166 for (int32_t i = 0; i < argc - iStart; i++) {
6152 if (argsValue[i]->IsArray()) { 6167 if (argsValue[i]->IsArray()) {
6153 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6168 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6154 argsValue[i]->GetObjectProperty("length", lengthValue.get()); 6169 argsValue[i]->GetObjectProperty("length", lengthValue.get());
6155 int32_t iLength = lengthValue->ToInteger(); 6170 int32_t iLength = lengthValue->ToInteger();
6156 if (iLength > 2) { 6171 if (iLength < 3)
6157 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6172 continue;
6158 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6173
6159 argsValue[i]->GetObjectPropertyByIdx(1, propertyValue.get()); 6174 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6160 if (propertyValue->IsNull()) { 6175 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6161 for (int32_t j = 2; j < iLength; j++) { 6176 argsValue[i]->GetObjectPropertyByIdx(1, propertyValue.get());
6162 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); 6177 if (propertyValue->IsNull()) {
6163 GetObjectDefaultValue(jsObjectValue.get(), resultValues[index]); 6178 for (int32_t j = 2; j < iLength; j++) {
6164 index++; 6179 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get());
6165 } 6180 GetObjectDefaultValue(jsObjectValue.get(), resultValues[index]);
6166 } else { 6181 index++;
6167 CFX_ByteString propertyString; 6182 }
6168 propertyValue->ToString(propertyString); 6183 } else {
6169 for (int32_t j = 2; j < iLength; j++) { 6184 CFX_ByteString propertyString;
6170 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); 6185 propertyValue->ToString(propertyString);
6171 jsObjectValue->GetObjectProperty(propertyString.AsStringC(), 6186 for (int32_t j = 2; j < iLength; j++) {
6172 resultValues[index]); 6187 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get());
6173 index++; 6188 jsObjectValue->GetObjectProperty(propertyString.AsStringC(),
6174 } 6189 resultValues[index]);
6190 index++;
6175 } 6191 }
6176 } 6192 }
6177 } else if (argsValue[i]->IsObject()) { 6193 } else if (argsValue[i]->IsObject()) {
6178 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); 6194 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]);
6179 index++; 6195 index++;
6180 } else { 6196 } else {
6181 resultValues[index]->Assign(argsValue[i].get()); 6197 resultValues[index]->Assign(argsValue[i].get());
6182 index++; 6198 index++;
6183 } 6199 }
6184 } 6200 }
(...skipping 18 matching lines...) Expand all
6203 return FALSE; 6219 return FALSE;
6204 6220
6205 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); 6221 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1);
6206 return TRUE; 6222 return TRUE;
6207 } 6223 }
6208 6224
6209 // static 6225 // static
6210 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, 6226 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName,
6211 int32_t iIndexFlags, 6227 int32_t iIndexFlags,
6212 int32_t iIndexValue, 6228 int32_t iIndexValue,
6213 FX_BOOL bIsStar, 6229 bool bIsStar,
6214 CFX_ByteString& szSomExp) { 6230 CFX_ByteString& szSomExp) {
6215 if (bIsStar) { 6231 if (bIsStar) {
6216 szSomExp = szName + "[*]"; 6232 szSomExp = szName + "[*]";
6217 return; 6233 return;
6218 } 6234 }
6219 if (iIndexFlags == 0) { 6235 if (iIndexFlags == 0) {
6220 szSomExp = szName; 6236 szSomExp = szName;
6221 return; 6237 return;
6222 } 6238 }
6223 if (iIndexFlags == 1 || iIndexValue == 0) { 6239 if (iIndexFlags == 1 || iIndexValue == 0) {
(...skipping 11 matching lines...) Expand all
6235 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); 6251 szSomExp += CFX_ByteString::FormatInteger(iIndexValue);
6236 szSomExp += "]"; 6252 szSomExp += "]";
6237 } 6253 }
6238 } 6254 }
6239 6255
6240 // static 6256 // static
6241 FX_BOOL CXFA_FM2JSContext::GetObjectByName( 6257 FX_BOOL CXFA_FM2JSContext::GetObjectByName(
6242 CFXJSE_Value* pThis, 6258 CFXJSE_Value* pThis,
6243 CFXJSE_Value* accessorValue, 6259 CFXJSE_Value* accessorValue,
6244 const CFX_ByteStringC& szAccessorName) { 6260 const CFX_ByteStringC& szAccessorName) {
6245 FX_BOOL bFlags = FALSE;
6246 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); 6261 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
6247 if (!pDoc) { 6262 if (!pDoc)
6248 return bFlags; 6263 return FALSE;
6249 } 6264
6250 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); 6265 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext();
6251 XFA_RESOLVENODE_RS resoveNodeRS; 6266 XFA_RESOLVENODE_RS resoveNodeRS;
6252 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 6267 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
6253 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; 6268 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
6254 int32_t iRet = pScriptContext->ResolveObjects( 6269 int32_t iRet = pScriptContext->ResolveObjects(
6255 pScriptContext->GetThisObject(), 6270 pScriptContext->GetThisObject(),
6256 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, 6271 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS,
6257 dwFlags); 6272 dwFlags);
6258 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 6273 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
6259 accessorValue->Assign( 6274 accessorValue->Assign(
6260 pScriptContext->GetJSValueFromMap(resoveNodeRS.nodes.GetAt(0))); 6275 pScriptContext->GetJSValueFromMap(resoveNodeRS.nodes.GetAt(0)));
6261 bFlags = TRUE; 6276 return TRUE;
6262 } 6277 }
6263 return bFlags; 6278 return FALSE;
6264 } 6279 }
6265 6280
6266 // static 6281 // static
6267 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, 6282 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis,
6268 CFXJSE_Value* pRefValue, 6283 CFXJSE_Value* pRefValue,
6269 const CFX_ByteStringC& bsSomExp, 6284 const CFX_ByteStringC& bsSomExp,
6270 XFA_RESOLVENODE_RS& resoveNodeRS, 6285 XFA_RESOLVENODE_RS& resoveNodeRS,
6271 FX_BOOL bdotAccessor, 6286 FX_BOOL bdotAccessor,
6272 FX_BOOL bHasNoResolveName) { 6287 FX_BOOL bHasNoResolveName) {
6288 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
6289 if (!pDoc)
6290 return -1;
6291
6273 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); 6292 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp);
6274 int32_t iRet = -1;
6275 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
6276 if (!pDoc) {
6277 return iRet;
6278 }
6279 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); 6293 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext();
6280 CXFA_Object* pNode = nullptr; 6294 CXFA_Object* pNode = nullptr;
6281 uint32_t dFlags = 0UL; 6295 uint32_t dFlags = 0UL;
6282 if (bdotAccessor) { 6296 if (bdotAccessor) {
6283 if (pRefValue && pRefValue->IsNull()) { 6297 if (pRefValue && pRefValue->IsNull()) {
6284 pNode = pScriptContext->GetThisObject(); 6298 pNode = pScriptContext->GetThisObject();
6285 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; 6299 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
6286 } else { 6300 } else {
6287 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr); 6301 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr);
6288 ASSERT(pNode); 6302 ASSERT(pNode);
6289 if (bHasNoResolveName) { 6303 if (bHasNoResolveName) {
6290 CFX_WideString wsName; 6304 CFX_WideString wsName;
6291 if (CXFA_Node* pXFANode = pNode->AsNode()) { 6305 if (CXFA_Node* pXFANode = pNode->AsNode())
6292 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); 6306 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE);
6293 } 6307
6294 if (wsName.IsEmpty()) { 6308 if (wsName.IsEmpty()) {
6295 CFX_WideStringC className; 6309 CFX_WideStringC className;
6296 pNode->GetClassName(className); 6310 pNode->GetClassName(className);
6297 wsName = FX_WSTRC(L"#") + className; 6311 wsName = FX_WSTRC(L"#") + className;
6298 } 6312 }
6299 wsSomExpression = wsName + wsSomExpression; 6313 wsSomExpression = wsName + wsSomExpression;
6300 dFlags = XFA_RESOLVENODE_Siblings; 6314 dFlags = XFA_RESOLVENODE_Siblings;
6301 } else { 6315 } else {
6302 dFlags = (bsSomExp == "*") 6316 dFlags = (bsSomExp == "*")
6303 ? (XFA_RESOLVENODE_Children) 6317 ? (XFA_RESOLVENODE_Children)
6304 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | 6318 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
6305 XFA_RESOLVENODE_Properties); 6319 XFA_RESOLVENODE_Properties);
6306 } 6320 }
6307 } 6321 }
6308 } else { 6322 } else {
6309 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr); 6323 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr);
6310 dFlags = XFA_RESOLVENODE_AnyChild; 6324 dFlags = XFA_RESOLVENODE_AnyChild;
6311 } 6325 }
6312 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), 6326 return pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(),
6313 resoveNodeRS, dFlags); 6327 resoveNodeRS, dFlags);
6314 return iRet;
6315 } 6328 }
6316 6329
6317 // static 6330 // static
6318 void CXFA_FM2JSContext::ParseResolveResult( 6331 void CXFA_FM2JSContext::ParseResolveResult(
6319 CFXJSE_Value* pThis, 6332 CFXJSE_Value* pThis,
6320 const XFA_RESOLVENODE_RS& resoveNodeRS, 6333 const XFA_RESOLVENODE_RS& resoveNodeRS,
6321 CFXJSE_Value* pParentValue, 6334 CFXJSE_Value* pParentValue,
6322 CFXJSE_Value**& resultValues, 6335 CFXJSE_Value**& resultValues,
6323 int32_t& iSize, 6336 int32_t& iSize,
6324 FX_BOOL& bAttribute) { 6337 FX_BOOL& bAttribute) {
6338 iSize = 0;
6339 resultValues = nullptr;
6340
6325 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 6341 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
6326 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6342 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6327 iSize = 0;
6328 resultValues = nullptr;
6329 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 6343 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
6330 bAttribute = FALSE; 6344 bAttribute = FALSE;
6331 iSize = resoveNodeRS.nodes.GetSize(); 6345 iSize = resoveNodeRS.nodes.GetSize();
6332 resultValues = FX_Alloc(CFXJSE_Value*, iSize); 6346 resultValues = FX_Alloc(CFXJSE_Value*, iSize);
6333 for (int32_t i = 0; i < iSize; i++) { 6347 for (int32_t i = 0; i < iSize; i++) {
6334 resultValues[i] = new CFXJSE_Value(pIsolate); 6348 resultValues[i] = new CFXJSE_Value(pIsolate);
6335 resultValues[i]->Assign( 6349 resultValues[i]->Assign(
6336 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( 6350 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap(
6337 resoveNodeRS.nodes.GetAt(i))); 6351 resoveNodeRS.nodes.GetAt(i)));
6338 } 6352 }
6339 } else { 6353 return;
6340 CXFA_ValueArray objectProperties(pIsolate); 6354 }
6341 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); 6355
6342 bAttribute = (iRet == 0); 6356 CXFA_ValueArray objectProperties(pIsolate);
6343 if (bAttribute) { 6357 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties);
6344 if (pParentValue && pParentValue->IsObject()) { 6358 bAttribute = (iRet == 0);
6345 iSize = 1; 6359 if (!bAttribute) {
6346 resultValues = FX_Alloc(CFXJSE_Value*, 1); 6360 iSize = iRet;
6347 resultValues[0] = new CFXJSE_Value(pIsolate); 6361 resultValues = FX_Alloc(CFXJSE_Value*, iSize);
6348 resultValues[0]->Assign(pParentValue); 6362 for (int32_t i = 0; i < iSize; i++) {
6349 } 6363 resultValues[i] = new CFXJSE_Value(pIsolate);
6350 } else { 6364 resultValues[i]->Assign(objectProperties[i]);
6351 iSize = iRet;
6352 resultValues = FX_Alloc(CFXJSE_Value*, iSize);
6353 for (int32_t i = 0; i < iSize; i++) {
6354 resultValues[i] = new CFXJSE_Value(pIsolate);
6355 resultValues[i]->Assign(objectProperties[i]);
6356 }
6357 } 6365 }
6366 return;
6358 } 6367 }
6368
6369 if (!pParentValue || !pParentValue->IsObject())
6370 return;
6371
6372 iSize = 1;
6373 resultValues = FX_Alloc(CFXJSE_Value*, 1);
6374 resultValues[0] = new CFXJSE_Value(pIsolate);
6375 resultValues[0]->Assign(pParentValue);
6359 } 6376 }
6360 6377
6361 // static 6378 // static
6362 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, 6379 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis,
6363 CFXJSE_Value* pValue) { 6380 CFXJSE_Value* pValue) {
6364 if (!pValue) 6381 if (!pValue)
6365 return 0; 6382 return 0;
6366 6383
6367 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6384 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6368 int32_t iValue = 0;
6369 if (pValue->IsArray()) { 6385 if (pValue->IsArray()) {
6370 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6386 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6371 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6387 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6372 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6388 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6373 pValue->GetObjectPropertyByIdx(1, propertyValue.get()); 6389 pValue->GetObjectPropertyByIdx(1, propertyValue.get());
6374 pValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); 6390 pValue->GetObjectPropertyByIdx(2, jsObjectValue.get());
6375 if (propertyValue->IsNull()) { 6391 if (propertyValue->IsNull()) {
6376 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 6392 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
6377 } else { 6393 return ValueToInteger(pThis, newPropertyValue.get());
6378 CFX_ByteString propertyStr;
6379 propertyValue->ToString(propertyStr);
6380 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6381 newPropertyValue.get());
6382 } 6394 }
6383 iValue = ValueToInteger(pThis, newPropertyValue.get()); 6395
6384 return iValue; 6396 CFX_ByteString propertyStr;
6385 } else if (pValue->IsObject()) { 6397 propertyValue->ToString(propertyStr);
6398 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6399 newPropertyValue.get());
6400 return ValueToInteger(pThis, newPropertyValue.get());
6401 }
6402 if (pValue->IsObject()) {
6386 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6403 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6387 GetObjectDefaultValue(pValue, newPropertyValue.get()); 6404 GetObjectDefaultValue(pValue, newPropertyValue.get());
6388 iValue = ValueToInteger(pThis, newPropertyValue.get()); 6405 return ValueToInteger(pThis, newPropertyValue.get());
6389 return iValue; 6406 }
6390 } else if (pValue->IsString()) { 6407 if (pValue->IsString()) {
6391 CFX_ByteString szValue; 6408 CFX_ByteString szValue;
6392 pValue->ToString(szValue); 6409 pValue->ToString(szValue);
6393 iValue = FXSYS_atoi(szValue.c_str()); 6410 return FXSYS_atoi(szValue.c_str());
6394 } else {
6395 iValue = pValue->ToInteger();
6396 } 6411 }
6397 return iValue; 6412 return pValue->ToInteger();
6398 } 6413 }
6399 6414
6400 // static 6415 // static
6401 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, 6416 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis,
6402 CFXJSE_Value* arg) { 6417 CFXJSE_Value* arg) {
6403 if (!arg) 6418 if (!arg)
6404 return 0.0f; 6419 return 0.0f;
6405 6420
6406 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6421 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6407 FX_FLOAT fRet = 0.0f;
6408 if (arg->IsArray()) { 6422 if (arg->IsArray()) {
6409 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6423 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6410 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6424 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6411 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6425 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6412 arg->GetObjectPropertyByIdx(1, propertyValue.get()); 6426 arg->GetObjectPropertyByIdx(1, propertyValue.get());
6413 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); 6427 arg->GetObjectPropertyByIdx(2, jsObjectValue.get());
6414 if (propertyValue->IsNull()) { 6428 if (propertyValue->IsNull()) {
6415 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 6429 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
6416 } else { 6430 return ValueToFloat(pThis, newPropertyValue.get());
6417 CFX_ByteString propertyStr;
6418 propertyValue->ToString(propertyStr);
6419 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6420 newPropertyValue.get());
6421 } 6431 }
6422 fRet = ValueToFloat(pThis, newPropertyValue.get()); 6432 CFX_ByteString propertyStr;
6423 } else if (arg->IsObject()) { 6433 propertyValue->ToString(propertyStr);
6434 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6435 newPropertyValue.get());
6436 return ValueToFloat(pThis, newPropertyValue.get());
6437 }
6438 if (arg->IsObject()) {
6424 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6439 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6425 GetObjectDefaultValue(arg, newPropertyValue.get()); 6440 GetObjectDefaultValue(arg, newPropertyValue.get());
6426 fRet = ValueToFloat(pThis, newPropertyValue.get()); 6441 return ValueToFloat(pThis, newPropertyValue.get());
6427 } else if (arg->IsString()) { 6442 }
6443 if (arg->IsString()) {
6428 CFX_ByteString bsOutput; 6444 CFX_ByteString bsOutput;
6429 arg->ToString(bsOutput); 6445 arg->ToString(bsOutput);
6430 fRet = (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC()); 6446 return (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC());
6431 } else if (arg->IsUndefined()) {
6432 fRet = 0;
6433 } else {
6434 fRet = arg->ToFloat();
6435 } 6447 }
6436 return fRet; 6448 if (arg->IsUndefined())
6449 return 0;
6450
6451 return arg->ToFloat();
6437 } 6452 }
6438 6453
6439 // static 6454 // static
6440 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, 6455 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis,
6441 CFXJSE_Value* arg) { 6456 CFXJSE_Value* arg) {
6442 if (!arg) 6457 if (!arg)
6443 return 0; 6458 return 0;
6444 6459
6445 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6460 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6446 FX_DOUBLE dRet = 0;
6447 if (arg->IsArray()) { 6461 if (arg->IsArray()) {
6448 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6462 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6449 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6463 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6450 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6464 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6451 arg->GetObjectPropertyByIdx(1, propertyValue.get()); 6465 arg->GetObjectPropertyByIdx(1, propertyValue.get());
6452 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); 6466 arg->GetObjectPropertyByIdx(2, jsObjectValue.get());
6453 if (propertyValue->IsNull()) { 6467 if (propertyValue->IsNull()) {
6454 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 6468 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
6455 } else { 6469 return ValueToDouble(pThis, newPropertyValue.get());
6456 CFX_ByteString propertyStr;
6457 propertyValue->ToString(propertyStr);
6458 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6459 newPropertyValue.get());
6460 } 6470 }
6461 dRet = ValueToDouble(pThis, newPropertyValue.get()); 6471 CFX_ByteString propertyStr;
6462 } else if (arg->IsObject()) { 6472 propertyValue->ToString(propertyStr);
6473 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6474 newPropertyValue.get());
6475 return ValueToDouble(pThis, newPropertyValue.get());
6476 }
6477 if (arg->IsObject()) {
6463 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6478 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6464 GetObjectDefaultValue(arg, newPropertyValue.get()); 6479 GetObjectDefaultValue(arg, newPropertyValue.get());
6465 dRet = ValueToDouble(pThis, newPropertyValue.get()); 6480 return ValueToDouble(pThis, newPropertyValue.get());
6466 } else if (arg->IsString()) { 6481 }
6482 if (arg->IsString()) {
6467 CFX_ByteString bsOutput; 6483 CFX_ByteString bsOutput;
6468 arg->ToString(bsOutput); 6484 arg->ToString(bsOutput);
6469 dRet = XFA_ByteStringToDouble(bsOutput.AsStringC()); 6485 return XFA_ByteStringToDouble(bsOutput.AsStringC());
6470 } else if (arg->IsUndefined()) {
6471 dRet = 0;
6472 } else {
6473 dRet = arg->ToDouble();
6474 } 6486 }
6475 return dRet; 6487 if (arg->IsUndefined())
6488 return 0;
6489 return arg->ToDouble();
6476 } 6490 }
6477 6491
6478 // static. 6492 // static.
6479 double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis, 6493 double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis,
6480 CFXJSE_Value* src, 6494 CFXJSE_Value* src,
6481 bool* ret) { 6495 bool* ret) {
6482 ASSERT(ret); 6496 ASSERT(ret);
6483
6484 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6485 *ret = true; 6497 *ret = true;
6486 6498
6487 if (!src) 6499 if (!src)
6488 return 0; 6500 return 0;
6489 6501
6490 if (src->IsArray()) { 6502 if (!src->IsArray())
6491 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6503 return ValueToDouble(pThis, src);
6492 src->GetObjectProperty("length", lengthValue.get());
6493 int32_t iLength = lengthValue->ToInteger();
6494 if (iLength <= 2) {
6495 *ret = false;
6496 return 0.0;
6497 }
6498 6504
6499 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6505 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6500 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6506 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6501 src->GetObjectPropertyByIdx(1, propertyValue.get()); 6507 src->GetObjectProperty("length", lengthValue.get());
6502 src->GetObjectPropertyByIdx(2, jsObjectValue.get()); 6508 int32_t iLength = lengthValue->ToInteger();
6503 if (propertyValue->IsNull()) 6509 if (iLength <= 2) {
6504 return ValueToDouble(pThis, jsObjectValue.get()); 6510 *ret = false;
6511 return 0.0;
6512 }
6505 6513
6506 CFX_ByteString propertyStr; 6514 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6507 propertyValue->ToString(propertyStr); 6515 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6508 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6516 src->GetObjectPropertyByIdx(1, propertyValue.get());
6509 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), 6517 src->GetObjectPropertyByIdx(2, jsObjectValue.get());
6510 newPropertyValue.get()); 6518 if (propertyValue->IsNull())
6511 return ValueToDouble(pThis, newPropertyValue.get()); 6519 return ValueToDouble(pThis, jsObjectValue.get());
6512 } 6520
6513 return ValueToDouble(pThis, src); 6521 CFX_ByteString propertyStr;
6522 propertyValue->ToString(propertyStr);
6523 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6524 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6525 newPropertyValue.get());
6526 return ValueToDouble(pThis, newPropertyValue.get());
6514 } 6527 }
6515 6528
6516 // static 6529 // static
6517 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, 6530 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg,
6518 CFX_ByteString& szOutputString) { 6531 CFX_ByteString& szOutputString) {
6519 if (!arg) 6532 if (!arg)
6520 return; 6533 return;
6521 6534
6522 if (arg->IsNull() || arg->IsUndefined()) { 6535 if (arg->IsNull() || arg->IsUndefined()) {
6523 szOutputString = ""; 6536 szOutputString = "";
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
6578 CFX_WideString wsFormat; 6591 CFX_WideString wsFormat;
6579 pAppProvider->LoadString(iStringID, wsFormat); 6592 pAppProvider->LoadString(iStringID, wsFormat);
6580 CFX_WideString wsMessage; 6593 CFX_WideString wsMessage;
6581 va_list arg_ptr; 6594 va_list arg_ptr;
6582 va_start(arg_ptr, iStringID); 6595 va_start(arg_ptr, iStringID);
6583 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); 6596 wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
6584 va_end(arg_ptr); 6597 va_end(arg_ptr);
6585 FXJSE_ThrowMessage( 6598 FXJSE_ThrowMessage(
6586 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 6599 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
6587 } 6600 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_fm2jscontext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698