| 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_simpleexpression.h" | 7 #include "xfa/fxfa/fm2js/xfa_simpleexpression.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
| 10 | 10 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 if (m_pArguments) { | 476 if (m_pArguments) { |
| 477 for (int i = 0; i < m_pArguments->GetSize(); ++i) { | 477 for (int i = 0; i < m_pArguments->GetSize(); ++i) { |
| 478 delete reinterpret_cast<CXFA_FMSimpleExpression*>(m_pArguments->GetAt(i)); | 478 delete reinterpret_cast<CXFA_FMSimpleExpression*>(m_pArguments->GetAt(i)); |
| 479 } | 479 } |
| 480 m_pArguments->RemoveAll(); | 480 m_pArguments->RemoveAll(); |
| 481 delete m_pArguments; | 481 delete m_pArguments; |
| 482 } | 482 } |
| 483 } | 483 } |
| 484 | 484 |
| 485 bool CXFA_FMCallExpression::IsBuildInFunc(CFX_WideTextBuf* funcName) { | 485 bool CXFA_FMCallExpression::IsBuildInFunc(CFX_WideTextBuf* funcName) { |
| 486 uint32_t uHash = FX_HashCode_String_GetW(funcName->GetBuffer(), | 486 uint32_t uHash = FX_HashCode_GetW(funcName->AsStringC(), true); |
| 487 funcName->GetLength(), TRUE); | |
| 488 const XFA_FMBuildInFunc* pEnd = g_BuildInFuncs + FX_ArraySize(g_BuildInFuncs); | 487 const XFA_FMBuildInFunc* pEnd = g_BuildInFuncs + FX_ArraySize(g_BuildInFuncs); |
| 489 const XFA_FMBuildInFunc* pFunc = | 488 const XFA_FMBuildInFunc* pFunc = |
| 490 std::lower_bound(g_BuildInFuncs, pEnd, uHash, | 489 std::lower_bound(g_BuildInFuncs, pEnd, uHash, |
| 491 [](const XFA_FMBuildInFunc& func, uint32_t hash) { | 490 [](const XFA_FMBuildInFunc& func, uint32_t hash) { |
| 492 return func.m_uHash < hash; | 491 return func.m_uHash < hash; |
| 493 }); | 492 }); |
| 494 if (pFunc < pEnd && uHash == pFunc->m_uHash) { | 493 if (pFunc < pEnd && uHash == pFunc->m_uHash) { |
| 495 funcName->Clear(); | 494 funcName->Clear(); |
| 496 *funcName << pFunc->m_buildinfunc; | 495 *funcName << pFunc->m_buildinfunc; |
| 497 return true; | 496 return true; |
| 498 } | 497 } |
| 499 return false; | 498 return false; |
| 500 } | 499 } |
| 501 | 500 |
| 502 uint32_t CXFA_FMCallExpression::IsMethodWithObjParam( | 501 uint32_t CXFA_FMCallExpression::IsMethodWithObjParam( |
| 503 const CFX_WideStringC& methodName) { | 502 const CFX_WideStringC& methodName) { |
| 504 int32_t iLength = methodName.GetLength(); | 503 uint32_t uHash = FX_HashCode_GetW(methodName, false); |
| 505 uint32_t uHash = FX_HashCode_String_GetW(methodName.c_str(), iLength); | |
| 506 XFA_FMSOMMethod somMethodWithObjPara; | 504 XFA_FMSOMMethod somMethodWithObjPara; |
| 507 uint32_t parameters = 0x00; | 505 uint32_t parameters = 0x00; |
| 508 int32_t iStart = 0, | 506 int32_t iStart = 0, |
| 509 iEnd = (sizeof(gs_FMSomMethods) / sizeof(gs_FMSomMethods[0])) - 1; | 507 iEnd = (sizeof(gs_FMSomMethods) / sizeof(gs_FMSomMethods[0])) - 1; |
| 510 int32_t iMid = (iStart + iEnd) / 2; | 508 int32_t iMid = (iStart + iEnd) / 2; |
| 511 do { | 509 do { |
| 512 iMid = (iStart + iEnd) / 2; | 510 iMid = (iStart + iEnd) / 2; |
| 513 somMethodWithObjPara = gs_FMSomMethods[iMid]; | 511 somMethodWithObjPara = gs_FMSomMethods[iMid]; |
| 514 if (uHash == somMethodWithObjPara.m_uHash) { | 512 if (uHash == somMethodWithObjPara.m_uHash) { |
| 515 parameters = somMethodWithObjPara.m_dParameters; | 513 parameters = somMethodWithObjPara.m_dParameters; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 L"for(var index = accessor_object.length - 1; index > 1; index--)\n{\n"); | 735 L"for(var index = accessor_object.length - 1; index > 1; index--)\n{\n"); |
| 738 javascript << FX_WSTRC(L"method_return_value = accessor_object[index]."); | 736 javascript << FX_WSTRC(L"method_return_value = accessor_object[index]."); |
| 739 m_pExp2->ToJavaScript(javascript); | 737 m_pExp2->ToJavaScript(javascript); |
| 740 javascript << FX_WSTRC(L";\n}\n}\n"); | 738 javascript << FX_WSTRC(L";\n}\n}\n"); |
| 741 javascript << FX_WSTRC(L"else\n{\nmethod_return_value = accessor_object."); | 739 javascript << FX_WSTRC(L"else\n{\nmethod_return_value = accessor_object."); |
| 742 m_pExp2->ToJavaScript(javascript); | 740 m_pExp2->ToJavaScript(javascript); |
| 743 javascript << FX_WSTRC(L";\n}\n"); | 741 javascript << FX_WSTRC(L";\n}\n"); |
| 744 javascript << FX_WSTRC(L"return method_return_value;\n"); | 742 javascript << FX_WSTRC(L"return method_return_value;\n"); |
| 745 javascript << FX_WSTRC(L"}\n).call(this)"); | 743 javascript << FX_WSTRC(L"}\n).call(this)"); |
| 746 } | 744 } |
| OLD | NEW |