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 <time.h> | 7 #include <time.h> |
8 | 8 |
9 #include "xfa/src/fxfa/src/fm2js/xfa_fm2js.h" | 9 #include "xfa/src/fxfa/src/fm2js/xfa_fm2js.h" |
10 | 10 |
(...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3270 rgValues[i] = FXJSE_Value_Create(hruntime); | 3270 rgValues[i] = FXJSE_Value_Create(hruntime); |
3271 } | 3271 } |
3272 FXJSE_Value_SetInteger(rgValues[0], 4); | 3272 FXJSE_Value_SetInteger(rgValues[0], 4); |
3273 FXJSE_Value_SetNull(rgValues[1]); | 3273 FXJSE_Value_SetNull(rgValues[1]); |
3274 FXJSE_Value_SetNull(rgValues[2]); | 3274 FXJSE_Value_SetNull(rgValues[2]); |
3275 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 3275 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
3276 for (int32_t i = 0; i < 3; i++) { | 3276 for (int32_t i = 0; i < 3; i++) { |
3277 FXJSE_Value_Release(rgValues[i]); | 3277 FXJSE_Value_Release(rgValues[i]); |
3278 } | 3278 } |
3279 } else if (FXJSE_Value_IsArray(argOne)) { | 3279 } else if (FXJSE_Value_IsArray(argOne)) { |
3280 #if defined(_DEBUG) | 3280 #ifndef NDEBUG |
3281 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); | 3281 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); |
3282 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 3282 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
3283 FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); | 3283 FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); |
3284 FXJSE_Value_Release(lengthValue); | 3284 FXJSE_Value_Release(lengthValue); |
3285 #endif | 3285 #endif |
3286 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); | 3286 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); |
3287 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); | 3287 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); |
3288 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 3288 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
3289 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); | 3289 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); |
3290 if (FXJSE_Value_IsNull(jsObjectValue)) { | 3290 if (FXJSE_Value_IsNull(jsObjectValue)) { |
(...skipping 3160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6451 } | 6451 } |
6452 void CXFA_FM2JSContext::get_fm_jsobj(FXJSE_HOBJECT hThis, | 6452 void CXFA_FM2JSContext::get_fm_jsobj(FXJSE_HOBJECT hThis, |
6453 const CFX_ByteStringC& szFuncName, | 6453 const CFX_ByteStringC& szFuncName, |
6454 CFXJSE_Arguments& args) { | 6454 CFXJSE_Arguments& args) { |
6455 CXFA_FM2JSContext* pContext = | 6455 CXFA_FM2JSContext* pContext = |
6456 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(hThis, nullptr)); | 6456 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(hThis, nullptr)); |
6457 int32_t argc = args.GetLength(); | 6457 int32_t argc = args.GetLength(); |
6458 if (argc == 1) { | 6458 if (argc == 1) { |
6459 FXJSE_HVALUE argOne = args.GetValue(0); | 6459 FXJSE_HVALUE argOne = args.GetValue(0); |
6460 if (FXJSE_Value_IsArray(argOne)) { | 6460 if (FXJSE_Value_IsArray(argOne)) { |
6461 #if defined(_DEBUG) | 6461 #ifndef NDEBUG |
6462 FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); | 6462 FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); |
6463 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); | 6463 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); |
6464 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 6464 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
6465 FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); | 6465 FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); |
6466 FXJSE_Value_Release(lengthValue); | 6466 FXJSE_Value_Release(lengthValue); |
6467 #endif | 6467 #endif |
6468 FXJSE_Value_GetObjectPropByIdx(argOne, 2, args.GetReturnValue()); | 6468 FXJSE_Value_GetObjectPropByIdx(argOne, 2, args.GetReturnValue()); |
6469 } else { | 6469 } else { |
6470 FXJSE_Value_Set(args.GetReturnValue(), argOne); | 6470 FXJSE_Value_Set(args.GetReturnValue(), argOne); |
6471 } | 6471 } |
6472 FXJSE_Value_Release(argOne); | 6472 FXJSE_Value_Release(argOne); |
6473 } else { | 6473 } else { |
6474 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6474 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
6475 } | 6475 } |
6476 } | 6476 } |
6477 void CXFA_FM2JSContext::fm_var_filter(FXJSE_HOBJECT hThis, | 6477 void CXFA_FM2JSContext::fm_var_filter(FXJSE_HOBJECT hThis, |
6478 const CFX_ByteStringC& szFuncName, | 6478 const CFX_ByteStringC& szFuncName, |
6479 CFXJSE_Arguments& args) { | 6479 CFXJSE_Arguments& args) { |
6480 CXFA_FM2JSContext* pContext = | 6480 CXFA_FM2JSContext* pContext = |
6481 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6481 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
6482 FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); | 6482 FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); |
6483 int32_t argc = args.GetLength(); | 6483 int32_t argc = args.GetLength(); |
6484 if (argc == 1) { | 6484 if (argc == 1) { |
6485 FXJSE_HVALUE argOne = args.GetValue(0); | 6485 FXJSE_HVALUE argOne = args.GetValue(0); |
6486 if (FXJSE_Value_IsArray(argOne)) { | 6486 if (FXJSE_Value_IsArray(argOne)) { |
6487 #if defined(_DEBUG) | 6487 #ifndef NDEBUG |
6488 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); | 6488 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); |
6489 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 6489 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
6490 FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); | 6490 FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); |
6491 FXJSE_Value_Release(lengthValue); | 6491 FXJSE_Value_Release(lengthValue); |
6492 #endif | 6492 #endif |
6493 FXJSE_HVALUE flagsValue = FXJSE_Value_Create(hruntime); | 6493 FXJSE_HVALUE flagsValue = FXJSE_Value_Create(hruntime); |
6494 FXJSE_Value_GetObjectPropByIdx(argOne, 0, flagsValue); | 6494 FXJSE_Value_GetObjectPropByIdx(argOne, 0, flagsValue); |
6495 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue); | 6495 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue); |
6496 FXJSE_Value_Release(flagsValue); | 6496 FXJSE_Value_Release(flagsValue); |
6497 if (iFlags == 4) { | 6497 if (iFlags == 4) { |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7213 FXSYS_assert(pAppProvider); | 7213 FXSYS_assert(pAppProvider); |
7214 CFX_WideString wsFormat; | 7214 CFX_WideString wsFormat; |
7215 pAppProvider->LoadString(iStringID, wsFormat); | 7215 pAppProvider->LoadString(iStringID, wsFormat); |
7216 CFX_WideString wsMessage; | 7216 CFX_WideString wsMessage; |
7217 va_list arg_ptr; | 7217 va_list arg_ptr; |
7218 va_start(arg_ptr, iStringID); | 7218 va_start(arg_ptr, iStringID); |
7219 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); | 7219 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); |
7220 va_end(arg_ptr); | 7220 va_end(arg_ptr); |
7221 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); | 7221 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); |
7222 } | 7222 } |
OLD | NEW |