| 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_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
| 8 | 8 |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 wsPattern.SetAt(i, wsAltSymbols[nAlt]); | 291 wsPattern.SetAt(i, wsAltSymbols[nAlt]); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 i++; | 294 i++; |
| 295 bEscape = FALSE; | 295 bEscape = FALSE; |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 } // namespace | 299 } // namespace |
| 300 | 300 |
| 301 void CXFA_FM2JSContext::Abs(FXJSE_HOBJECT hThis, | 301 void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis, |
| 302 const CFX_ByteStringC& szFuncName, | 302 const CFX_ByteStringC& szFuncName, |
| 303 CFXJSE_Arguments& args) { | 303 CFXJSE_Arguments& args) { |
| 304 if (args.GetLength() == 1) { | 304 if (args.GetLength() == 1) { |
| 305 FXJSE_HVALUE argOne = args.GetValue(0); | 305 CFXJSE_Value* argOne = args.GetValue(0); |
| 306 if (HValueIsNull(hThis, argOne)) { | 306 if (ValueIsNull(pThis, argOne)) { |
| 307 FXJSE_Value_SetNull(args.GetReturnValue()); | 307 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 308 } else { | 308 } else { |
| 309 FX_DOUBLE dValue = HValueToDouble(hThis, argOne); | 309 FX_DOUBLE dValue = ValueToDouble(pThis, argOne); |
| 310 if (dValue < 0) { | 310 if (dValue < 0) { |
| 311 dValue = -dValue; | 311 dValue = -dValue; |
| 312 } | 312 } |
| 313 FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); | 313 FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); |
| 314 } | 314 } |
| 315 FXJSE_Value_Release(argOne); | 315 FXJSE_Value_Release(argOne); |
| 316 } else { | 316 } else { |
| 317 CXFA_FM2JSContext* pContext = | 317 CXFA_FM2JSContext* pContext = |
| 318 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 318 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 319 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 319 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 320 L"Abs"); | 320 L"Abs"); |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 void CXFA_FM2JSContext::Avg(FXJSE_HOBJECT hThis, | 323 void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis, |
| 324 const CFX_ByteStringC& szFuncName, | 324 const CFX_ByteStringC& szFuncName, |
| 325 CFXJSE_Arguments& args) { | 325 CFXJSE_Arguments& args) { |
| 326 CXFA_FM2JSContext* pContext = | 326 CXFA_FM2JSContext* pContext = |
| 327 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 327 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 328 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 328 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 329 int32_t argc = args.GetLength(); | 329 int32_t argc = args.GetLength(); |
| 330 uint32_t uCount = 0; | 330 uint32_t uCount = 0; |
| 331 FX_DOUBLE dSum = 0.0; | 331 FX_DOUBLE dSum = 0.0; |
| 332 if (argc >= 1) { | 332 if (argc >= 1) { |
| 333 FXJSE_HVALUE argValue = 0; | 333 CFXJSE_Value* argValue = nullptr; |
| 334 for (int32_t i = 0; i < argc; i++) { | 334 for (int32_t i = 0; i < argc; i++) { |
| 335 argValue = args.GetValue(i); | 335 argValue = args.GetValue(i); |
| 336 if (FXJSE_Value_IsNull(argValue)) { | 336 if (FXJSE_Value_IsNull(argValue)) { |
| 337 FXJSE_Value_Release(argValue); | 337 FXJSE_Value_Release(argValue); |
| 338 continue; | 338 continue; |
| 339 } else if (FXJSE_Value_IsArray(argValue)) { | 339 } else if (FXJSE_Value_IsArray(argValue)) { |
| 340 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 340 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 341 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 341 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 342 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 342 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 343 FXJSE_Value_Release(lengthValue); | 343 FXJSE_Value_Release(lengthValue); |
| 344 if (iLength > 2) { | 344 if (iLength > 2) { |
| 345 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 345 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 346 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 346 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 347 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 347 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 348 if (FXJSE_Value_IsNull(propertyValue)) { | 348 if (FXJSE_Value_IsNull(propertyValue)) { |
| 349 for (int32_t j = 2; j < iLength; j++) { | 349 for (int32_t j = 2; j < iLength; j++) { |
| 350 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); | 350 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); |
| 351 FXJSE_HVALUE defaultPropValue = FXJSE_Value_Create(pIsolate); | 351 CFXJSE_Value* defaultPropValue = FXJSE_Value_Create(pIsolate); |
| 352 GetObjectDefaultValue(jsObjectValue, defaultPropValue); | 352 GetObjectDefaultValue(jsObjectValue, defaultPropValue); |
| 353 if (!FXJSE_Value_IsNull(defaultPropValue)) { | 353 if (!FXJSE_Value_IsNull(defaultPropValue)) { |
| 354 dSum += HValueToDouble(hThis, defaultPropValue); | 354 dSum += ValueToDouble(pThis, defaultPropValue); |
| 355 uCount++; | 355 uCount++; |
| 356 } | 356 } |
| 357 FXJSE_Value_Release(defaultPropValue); | 357 FXJSE_Value_Release(defaultPropValue); |
| 358 } | 358 } |
| 359 } else { | 359 } else { |
| 360 CFX_ByteString propertyStr; | 360 CFX_ByteString propertyStr; |
| 361 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 361 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 362 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 362 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 363 for (int32_t j = 2; j < iLength; j++) { | 363 for (int32_t j = 2; j < iLength; j++) { |
| 364 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); | 364 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); |
| 365 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 365 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 366 newPropertyValue); | 366 newPropertyValue); |
| 367 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 367 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 368 dSum += HValueToDouble(hThis, newPropertyValue); | 368 dSum += ValueToDouble(pThis, newPropertyValue); |
| 369 uCount++; | 369 uCount++; |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 FXJSE_Value_Release(newPropertyValue); | 372 FXJSE_Value_Release(newPropertyValue); |
| 373 } | 373 } |
| 374 FXJSE_Value_Release(jsObjectValue); | 374 FXJSE_Value_Release(jsObjectValue); |
| 375 FXJSE_Value_Release(propertyValue); | 375 FXJSE_Value_Release(propertyValue); |
| 376 } | 376 } |
| 377 } else { | 377 } else { |
| 378 dSum += HValueToDouble(hThis, argValue); | 378 dSum += ValueToDouble(pThis, argValue); |
| 379 uCount++; | 379 uCount++; |
| 380 } | 380 } |
| 381 FXJSE_Value_Release(argValue); | 381 FXJSE_Value_Release(argValue); |
| 382 } | 382 } |
| 383 argValue = 0; | 383 argValue = nullptr; |
| 384 } | 384 } |
| 385 if (0 == uCount) { | 385 if (0 == uCount) { |
| 386 FXJSE_Value_SetNull(args.GetReturnValue()); | 386 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 387 } else { | 387 } else { |
| 388 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); | 388 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 void CXFA_FM2JSContext::Ceil(FXJSE_HOBJECT hThis, | 391 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, |
| 392 const CFX_ByteStringC& szFuncName, | 392 const CFX_ByteStringC& szFuncName, |
| 393 CFXJSE_Arguments& args) { | 393 CFXJSE_Arguments& args) { |
| 394 CXFA_FM2JSContext* pContext = | 394 CXFA_FM2JSContext* pContext = |
| 395 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 395 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 396 if (args.GetLength() == 1) { | 396 if (args.GetLength() == 1) { |
| 397 FXJSE_HVALUE argValue = GetSimpleHValue(hThis, args, 0); | 397 CFXJSE_Value* argValue = GetSimpleValue(pThis, args, 0); |
| 398 if (HValueIsNull(hThis, argValue)) { | 398 if (ValueIsNull(pThis, argValue)) { |
| 399 FXJSE_Value_SetNull(args.GetReturnValue()); | 399 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 400 } else { | 400 } else { |
| 401 FXJSE_Value_SetFloat(args.GetReturnValue(), | 401 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 402 FXSYS_ceil(HValueToFloat(hThis, argValue))); | 402 FXSYS_ceil(ValueToFloat(pThis, argValue))); |
| 403 } | 403 } |
| 404 FXJSE_Value_Release(argValue); | 404 FXJSE_Value_Release(argValue); |
| 405 } else { | 405 } else { |
| 406 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 406 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 407 L"Ceil"); | 407 L"Ceil"); |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 void CXFA_FM2JSContext::Count(FXJSE_HOBJECT hThis, | 410 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, |
| 411 const CFX_ByteStringC& szFuncName, | 411 const CFX_ByteStringC& szFuncName, |
| 412 CFXJSE_Arguments& args) { | 412 CFXJSE_Arguments& args) { |
| 413 CXFA_FM2JSContext* pContext = | 413 CXFA_FM2JSContext* pContext = |
| 414 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 414 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 415 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 415 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 416 int32_t argc = args.GetLength(); | 416 int32_t argc = args.GetLength(); |
| 417 uint32_t uCount = 0; | 417 uint32_t uCount = 0; |
| 418 FXJSE_HVALUE argValue = 0; | 418 CFXJSE_Value* argValue = nullptr; |
| 419 for (int32_t i = 0; i < argc; i++) { | 419 for (int32_t i = 0; i < argc; i++) { |
| 420 argValue = args.GetValue(i); | 420 argValue = args.GetValue(i); |
| 421 if (FXJSE_Value_IsNull(argValue)) { | 421 if (FXJSE_Value_IsNull(argValue)) { |
| 422 FXJSE_Value_Release(argValue); | 422 FXJSE_Value_Release(argValue); |
| 423 continue; | 423 continue; |
| 424 } else if (FXJSE_Value_IsArray(argValue)) { | 424 } else if (FXJSE_Value_IsArray(argValue)) { |
| 425 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 425 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 426 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 426 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 427 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 427 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 428 FXJSE_Value_Release(lengthValue); | 428 FXJSE_Value_Release(lengthValue); |
| 429 if (iLength > 2) { | 429 if (iLength > 2) { |
| 430 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 430 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 431 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 431 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 432 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 432 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 433 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 433 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 434 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); | 434 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); |
| 435 if (FXJSE_Value_IsNull(propertyValue)) { | 435 if (FXJSE_Value_IsNull(propertyValue)) { |
| 436 for (int32_t i = 2; i < iLength; i++) { | 436 for (int32_t i = 2; i < iLength; i++) { |
| 437 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 437 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 438 GetObjectDefaultValue(jsObjectValue, newPropertyValue); | 438 GetObjectDefaultValue(jsObjectValue, newPropertyValue); |
| 439 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 439 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 440 uCount++; | 440 uCount++; |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 } else { | 443 } else { |
| 444 CFX_ByteString propertyStr; | 444 CFX_ByteString propertyStr; |
| 445 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 445 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 446 for (int32_t i = 2; i < iLength; i++) { | 446 for (int32_t i = 2; i < iLength; i++) { |
| 447 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 447 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 448 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 448 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 449 newPropertyValue); | 449 newPropertyValue); |
| 450 uCount += (FXJSE_Value_IsNull(newPropertyValue) ? 0 : 1); | 450 uCount += (FXJSE_Value_IsNull(newPropertyValue) ? 0 : 1); |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 FXJSE_Value_Release(propertyValue); | 453 FXJSE_Value_Release(propertyValue); |
| 454 FXJSE_Value_Release(jsObjectValue); | 454 FXJSE_Value_Release(jsObjectValue); |
| 455 FXJSE_Value_Release(newPropertyValue); | 455 FXJSE_Value_Release(newPropertyValue); |
| 456 } else { | 456 } else { |
| 457 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 457 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 458 } | 458 } |
| 459 } else if (FXJSE_Value_IsObject(argValue)) { | 459 } else if (FXJSE_Value_IsObject(argValue)) { |
| 460 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 460 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 461 GetObjectDefaultValue(argValue, newPropertyValue); | 461 GetObjectDefaultValue(argValue, newPropertyValue); |
| 462 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 462 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 463 uCount++; | 463 uCount++; |
| 464 } | 464 } |
| 465 FXJSE_Value_Release(newPropertyValue); | 465 FXJSE_Value_Release(newPropertyValue); |
| 466 } else { | 466 } else { |
| 467 uCount++; | 467 uCount++; |
| 468 } | 468 } |
| 469 FXJSE_Value_Release(argValue); | 469 FXJSE_Value_Release(argValue); |
| 470 } | 470 } |
| 471 argValue = 0; | 471 argValue = nullptr; |
| 472 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)uCount); | 472 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)uCount); |
| 473 } | 473 } |
| 474 void CXFA_FM2JSContext::Floor(FXJSE_HOBJECT hThis, | 474 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, |
| 475 const CFX_ByteStringC& szFuncName, | 475 const CFX_ByteStringC& szFuncName, |
| 476 CFXJSE_Arguments& args) { | 476 CFXJSE_Arguments& args) { |
| 477 CXFA_FM2JSContext* pContext = | 477 CXFA_FM2JSContext* pContext = |
| 478 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 478 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 479 if (args.GetLength() == 1) { | 479 if (args.GetLength() == 1) { |
| 480 FXJSE_HVALUE argValue = GetSimpleHValue(hThis, args, 0); | 480 CFXJSE_Value* argValue = GetSimpleValue(pThis, args, 0); |
| 481 if (HValueIsNull(hThis, argValue)) { | 481 if (ValueIsNull(pThis, argValue)) { |
| 482 FXJSE_Value_SetNull(args.GetReturnValue()); | 482 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 483 } else { | 483 } else { |
| 484 FXJSE_Value_SetFloat(args.GetReturnValue(), | 484 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 485 FXSYS_floor(HValueToFloat(hThis, argValue))); | 485 FXSYS_floor(ValueToFloat(pThis, argValue))); |
| 486 } | 486 } |
| 487 FXJSE_Value_Release(argValue); | 487 FXJSE_Value_Release(argValue); |
| 488 } else { | 488 } else { |
| 489 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 489 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 490 L"Floor"); | 490 L"Floor"); |
| 491 } | 491 } |
| 492 } | 492 } |
| 493 void CXFA_FM2JSContext::Max(FXJSE_HOBJECT hThis, | 493 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, |
| 494 const CFX_ByteStringC& szFuncName, | 494 const CFX_ByteStringC& szFuncName, |
| 495 CFXJSE_Arguments& args) { | 495 CFXJSE_Arguments& args) { |
| 496 CXFA_FM2JSContext* pContext = | 496 CXFA_FM2JSContext* pContext = |
| 497 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 497 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 498 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 498 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 499 int32_t argc = args.GetLength(); | 499 int32_t argc = args.GetLength(); |
| 500 uint32_t uCount = 0; | 500 uint32_t uCount = 0; |
| 501 FX_DOUBLE dMaxValue = 0.0; | 501 FX_DOUBLE dMaxValue = 0.0; |
| 502 FXJSE_HVALUE argValue = 0; | 502 CFXJSE_Value* argValue = nullptr; |
| 503 for (int32_t i = 0; i < argc; i++) { | 503 for (int32_t i = 0; i < argc; i++) { |
| 504 argValue = args.GetValue(i); | 504 argValue = args.GetValue(i); |
| 505 if (FXJSE_Value_IsNull(argValue)) { | 505 if (FXJSE_Value_IsNull(argValue)) { |
| 506 FXJSE_Value_Release(argValue); | 506 FXJSE_Value_Release(argValue); |
| 507 continue; | 507 continue; |
| 508 } else if (FXJSE_Value_IsArray(argValue)) { | 508 } else if (FXJSE_Value_IsArray(argValue)) { |
| 509 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 509 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 510 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 510 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 511 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 511 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 512 FXJSE_Value_Release(lengthValue); | 512 FXJSE_Value_Release(lengthValue); |
| 513 if (iLength > 2) { | 513 if (iLength > 2) { |
| 514 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 514 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 515 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 515 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 516 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 516 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 517 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 517 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 518 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); | 518 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); |
| 519 if (FXJSE_Value_IsNull(propertyValue)) { | 519 if (FXJSE_Value_IsNull(propertyValue)) { |
| 520 for (int32_t i = 2; i < iLength; i++) { | 520 for (int32_t i = 2; i < iLength; i++) { |
| 521 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 521 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 522 GetObjectDefaultValue(jsObjectValue, newPropertyValue); | 522 GetObjectDefaultValue(jsObjectValue, newPropertyValue); |
| 523 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 523 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 524 uCount++; | 524 uCount++; |
| 525 if (uCount == 1) { | 525 if (uCount == 1) { |
| 526 dMaxValue = HValueToDouble(hThis, newPropertyValue); | 526 dMaxValue = ValueToDouble(pThis, newPropertyValue); |
| 527 } else { | 527 } else { |
| 528 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 528 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 529 if (dMaxValue < dValue) { | 529 if (dMaxValue < dValue) { |
| 530 dMaxValue = dValue; | 530 dMaxValue = dValue; |
| 531 } | 531 } |
| 532 } | 532 } |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 } else { | 535 } else { |
| 536 CFX_ByteString propertyStr; | 536 CFX_ByteString propertyStr; |
| 537 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 537 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 538 for (int32_t i = 2; i < iLength; i++) { | 538 for (int32_t i = 2; i < iLength; i++) { |
| 539 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 539 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 540 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 540 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 541 newPropertyValue); | 541 newPropertyValue); |
| 542 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 542 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 543 uCount++; | 543 uCount++; |
| 544 if (uCount == 1) { | 544 if (uCount == 1) { |
| 545 dMaxValue = HValueToDouble(hThis, newPropertyValue); | 545 dMaxValue = ValueToDouble(pThis, newPropertyValue); |
| 546 } else { | 546 } else { |
| 547 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 547 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 548 if (dMaxValue < dValue) { | 548 if (dMaxValue < dValue) { |
| 549 dMaxValue = dValue; | 549 dMaxValue = dValue; |
| 550 } | 550 } |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 FXJSE_Value_Release(propertyValue); | 555 FXJSE_Value_Release(propertyValue); |
| 556 FXJSE_Value_Release(jsObjectValue); | 556 FXJSE_Value_Release(jsObjectValue); |
| 557 FXJSE_Value_Release(newPropertyValue); | 557 FXJSE_Value_Release(newPropertyValue); |
| 558 } else { | 558 } else { |
| 559 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 559 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 560 } | 560 } |
| 561 } else if (FXJSE_Value_IsObject(argValue)) { | 561 } else if (FXJSE_Value_IsObject(argValue)) { |
| 562 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 562 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 563 GetObjectDefaultValue(argValue, newPropertyValue); | 563 GetObjectDefaultValue(argValue, newPropertyValue); |
| 564 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 564 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 565 uCount++; | 565 uCount++; |
| 566 if (uCount == 1) { | 566 if (uCount == 1) { |
| 567 dMaxValue = HValueToDouble(hThis, newPropertyValue); | 567 dMaxValue = ValueToDouble(pThis, newPropertyValue); |
| 568 } else { | 568 } else { |
| 569 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 569 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 570 if (dMaxValue < dValue) { | 570 if (dMaxValue < dValue) { |
| 571 dMaxValue = dValue; | 571 dMaxValue = dValue; |
| 572 } | 572 } |
| 573 } | 573 } |
| 574 } | 574 } |
| 575 FXJSE_Value_Release(newPropertyValue); | 575 FXJSE_Value_Release(newPropertyValue); |
| 576 } else { | 576 } else { |
| 577 uCount++; | 577 uCount++; |
| 578 if (uCount == 1) { | 578 if (uCount == 1) { |
| 579 dMaxValue = HValueToDouble(hThis, argValue); | 579 dMaxValue = ValueToDouble(pThis, argValue); |
| 580 } else { | 580 } else { |
| 581 FX_DOUBLE dValue = HValueToDouble(hThis, argValue); | 581 FX_DOUBLE dValue = ValueToDouble(pThis, argValue); |
| 582 if (dMaxValue < dValue) { | 582 if (dMaxValue < dValue) { |
| 583 dMaxValue = dValue; | 583 dMaxValue = dValue; |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 } | 586 } |
| 587 FXJSE_Value_Release(argValue); | 587 FXJSE_Value_Release(argValue); |
| 588 } | 588 } |
| 589 argValue = 0; | 589 argValue = nullptr; |
| 590 if (uCount) { | 590 if (uCount) { |
| 591 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); | 591 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); |
| 592 } else { | 592 } else { |
| 593 FXJSE_Value_SetNull(args.GetReturnValue()); | 593 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 void CXFA_FM2JSContext::Min(FXJSE_HOBJECT hThis, | 596 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, |
| 597 const CFX_ByteStringC& szFuncName, | 597 const CFX_ByteStringC& szFuncName, |
| 598 CFXJSE_Arguments& args) { | 598 CFXJSE_Arguments& args) { |
| 599 CXFA_FM2JSContext* pContext = | 599 CXFA_FM2JSContext* pContext = |
| 600 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 600 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 601 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 601 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 602 int32_t argc = args.GetLength(); | 602 int32_t argc = args.GetLength(); |
| 603 uint32_t uCount = 0; | 603 uint32_t uCount = 0; |
| 604 FX_DOUBLE dMinValue = 0.0; | 604 FX_DOUBLE dMinValue = 0.0; |
| 605 FXJSE_HVALUE argValue = 0; | 605 CFXJSE_Value* argValue = nullptr; |
| 606 for (int32_t i = 0; i < argc; i++) { | 606 for (int32_t i = 0; i < argc; i++) { |
| 607 argValue = args.GetValue(i); | 607 argValue = args.GetValue(i); |
| 608 if (FXJSE_Value_IsNull(argValue)) { | 608 if (FXJSE_Value_IsNull(argValue)) { |
| 609 FXJSE_Value_Release(argValue); | 609 FXJSE_Value_Release(argValue); |
| 610 continue; | 610 continue; |
| 611 } else if (FXJSE_Value_IsArray(argValue)) { | 611 } else if (FXJSE_Value_IsArray(argValue)) { |
| 612 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 612 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 613 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 613 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 614 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 614 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 615 FXJSE_Value_Release(lengthValue); | 615 FXJSE_Value_Release(lengthValue); |
| 616 if (iLength > 2) { | 616 if (iLength > 2) { |
| 617 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 617 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 618 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 618 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 619 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 619 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 620 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 620 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 621 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); | 621 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); |
| 622 if (FXJSE_Value_IsNull(propertyValue)) { | 622 if (FXJSE_Value_IsNull(propertyValue)) { |
| 623 for (int32_t i = 2; i < iLength; i++) { | 623 for (int32_t i = 2; i < iLength; i++) { |
| 624 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 624 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 625 GetObjectDefaultValue(jsObjectValue, newPropertyValue); | 625 GetObjectDefaultValue(jsObjectValue, newPropertyValue); |
| 626 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 626 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 627 uCount++; | 627 uCount++; |
| 628 if (uCount == 1) { | 628 if (uCount == 1) { |
| 629 dMinValue = HValueToDouble(hThis, newPropertyValue); | 629 dMinValue = ValueToDouble(pThis, newPropertyValue); |
| 630 } else { | 630 } else { |
| 631 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 631 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 632 if (dMinValue > dValue) { | 632 if (dMinValue > dValue) { |
| 633 dMinValue = dValue; | 633 dMinValue = dValue; |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 } else { | 638 } else { |
| 639 CFX_ByteString propertyStr; | 639 CFX_ByteString propertyStr; |
| 640 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 640 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 641 for (int32_t i = 2; i < iLength; i++) { | 641 for (int32_t i = 2; i < iLength; i++) { |
| 642 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 642 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 643 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 643 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 644 newPropertyValue); | 644 newPropertyValue); |
| 645 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 645 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 646 uCount++; | 646 uCount++; |
| 647 if (uCount == 1) { | 647 if (uCount == 1) { |
| 648 dMinValue = HValueToDouble(hThis, newPropertyValue); | 648 dMinValue = ValueToDouble(pThis, newPropertyValue); |
| 649 } else { | 649 } else { |
| 650 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 650 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 651 if (dMinValue > dValue) { | 651 if (dMinValue > dValue) { |
| 652 dMinValue = dValue; | 652 dMinValue = dValue; |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 } | 657 } |
| 658 FXJSE_Value_Release(propertyValue); | 658 FXJSE_Value_Release(propertyValue); |
| 659 FXJSE_Value_Release(jsObjectValue); | 659 FXJSE_Value_Release(jsObjectValue); |
| 660 FXJSE_Value_Release(newPropertyValue); | 660 FXJSE_Value_Release(newPropertyValue); |
| 661 } else { | 661 } else { |
| 662 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 662 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 663 } | 663 } |
| 664 } else if (FXJSE_Value_IsObject(argValue)) { | 664 } else if (FXJSE_Value_IsObject(argValue)) { |
| 665 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 665 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 666 GetObjectDefaultValue(argValue, newPropertyValue); | 666 GetObjectDefaultValue(argValue, newPropertyValue); |
| 667 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 667 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 668 uCount++; | 668 uCount++; |
| 669 if (uCount == 1) { | 669 if (uCount == 1) { |
| 670 dMinValue = HValueToDouble(hThis, newPropertyValue); | 670 dMinValue = ValueToDouble(pThis, newPropertyValue); |
| 671 } else { | 671 } else { |
| 672 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 672 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 673 if (dMinValue > dValue) { | 673 if (dMinValue > dValue) { |
| 674 dMinValue = dValue; | 674 dMinValue = dValue; |
| 675 } | 675 } |
| 676 } | 676 } |
| 677 } | 677 } |
| 678 FXJSE_Value_Release(newPropertyValue); | 678 FXJSE_Value_Release(newPropertyValue); |
| 679 } else { | 679 } else { |
| 680 uCount++; | 680 uCount++; |
| 681 if (uCount == 1) { | 681 if (uCount == 1) { |
| 682 dMinValue = HValueToDouble(hThis, argValue); | 682 dMinValue = ValueToDouble(pThis, argValue); |
| 683 } else { | 683 } else { |
| 684 FX_DOUBLE dValue = HValueToDouble(hThis, argValue); | 684 FX_DOUBLE dValue = ValueToDouble(pThis, argValue); |
| 685 if (dMinValue > dValue) { | 685 if (dMinValue > dValue) { |
| 686 dMinValue = dValue; | 686 dMinValue = dValue; |
| 687 } | 687 } |
| 688 } | 688 } |
| 689 } | 689 } |
| 690 FXJSE_Value_Release(argValue); | 690 FXJSE_Value_Release(argValue); |
| 691 } | 691 } |
| 692 argValue = 0; | 692 argValue = nullptr; |
| 693 if (uCount) { | 693 if (uCount) { |
| 694 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); | 694 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); |
| 695 } else { | 695 } else { |
| 696 FXJSE_Value_SetNull(args.GetReturnValue()); | 696 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 697 } | 697 } |
| 698 } | 698 } |
| 699 void CXFA_FM2JSContext::Mod(FXJSE_HOBJECT hThis, | 699 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis, |
| 700 const CFX_ByteStringC& szFuncName, | 700 const CFX_ByteStringC& szFuncName, |
| 701 CFXJSE_Arguments& args) { | 701 CFXJSE_Arguments& args) { |
| 702 CXFA_FM2JSContext* pContext = | 702 CXFA_FM2JSContext* pContext = |
| 703 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 703 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 704 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 704 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 705 if (args.GetLength() == 2) { | 705 if (args.GetLength() == 2) { |
| 706 FXJSE_HVALUE argOne = args.GetValue(0); | 706 CFXJSE_Value* argOne = args.GetValue(0); |
| 707 FXJSE_HVALUE argTwo = args.GetValue(1); | 707 CFXJSE_Value* argTwo = args.GetValue(1); |
| 708 if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { | 708 if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { |
| 709 FXJSE_Value_SetNull(args.GetReturnValue()); | 709 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 710 } else { | 710 } else { |
| 711 FX_DOUBLE dDividend = 0.0; | 711 FX_DOUBLE dDividend = 0.0; |
| 712 FX_DOUBLE dDividor = 0.0; | 712 FX_DOUBLE dDividor = 0.0; |
| 713 if (FXJSE_Value_IsArray(argOne)) { | 713 if (FXJSE_Value_IsArray(argOne)) { |
| 714 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 714 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 715 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 715 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
| 716 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 716 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 717 FXJSE_Value_Release(lengthValue); | 717 FXJSE_Value_Release(lengthValue); |
| 718 if (iLength > 2) { | 718 if (iLength > 2) { |
| 719 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 719 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 720 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 720 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 721 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 721 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
| 722 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); | 722 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); |
| 723 if (FXJSE_Value_IsNull(propertyValue)) { | 723 if (FXJSE_Value_IsNull(propertyValue)) { |
| 724 dDividend = HValueToDouble(hThis, jsObjectValue); | 724 dDividend = ValueToDouble(pThis, jsObjectValue); |
| 725 } else { | 725 } else { |
| 726 CFX_ByteString propertyStr; | 726 CFX_ByteString propertyStr; |
| 727 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 727 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 728 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 728 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 729 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 729 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 730 newPropertyValue); | 730 newPropertyValue); |
| 731 dDividend = HValueToDouble(hThis, newPropertyValue); | 731 dDividend = ValueToDouble(pThis, newPropertyValue); |
| 732 FXJSE_Value_Release(newPropertyValue); | 732 FXJSE_Value_Release(newPropertyValue); |
| 733 } | 733 } |
| 734 FXJSE_Value_Release(propertyValue); | 734 FXJSE_Value_Release(propertyValue); |
| 735 FXJSE_Value_Release(jsObjectValue); | 735 FXJSE_Value_Release(jsObjectValue); |
| 736 } else { | 736 } else { |
| 737 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 737 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 738 } | 738 } |
| 739 } else { | 739 } else { |
| 740 dDividend = HValueToDouble(hThis, argOne); | 740 dDividend = ValueToDouble(pThis, argOne); |
| 741 } | 741 } |
| 742 if (FXJSE_Value_IsArray(argTwo)) { | 742 if (FXJSE_Value_IsArray(argTwo)) { |
| 743 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 743 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 744 FXJSE_Value_GetObjectProp(argTwo, "length", lengthValue); | 744 FXJSE_Value_GetObjectProp(argTwo, "length", lengthValue); |
| 745 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 745 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 746 FXJSE_Value_Release(lengthValue); | 746 FXJSE_Value_Release(lengthValue); |
| 747 if (iLength > 2) { | 747 if (iLength > 2) { |
| 748 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 748 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 749 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 749 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 750 FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); | 750 FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); |
| 751 FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); | 751 FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); |
| 752 if (FXJSE_Value_IsNull(propertyValue)) { | 752 if (FXJSE_Value_IsNull(propertyValue)) { |
| 753 dDividor = HValueToDouble(hThis, jsObjectValue); | 753 dDividor = ValueToDouble(pThis, jsObjectValue); |
| 754 } else { | 754 } else { |
| 755 CFX_ByteString propertyStr; | 755 CFX_ByteString propertyStr; |
| 756 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 756 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 757 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 757 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 758 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 758 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 759 newPropertyValue); | 759 newPropertyValue); |
| 760 dDividor = HValueToDouble(hThis, newPropertyValue); | 760 dDividor = ValueToDouble(pThis, newPropertyValue); |
| 761 FXJSE_Value_Release(newPropertyValue); | 761 FXJSE_Value_Release(newPropertyValue); |
| 762 } | 762 } |
| 763 FXJSE_Value_Release(propertyValue); | 763 FXJSE_Value_Release(propertyValue); |
| 764 FXJSE_Value_Release(jsObjectValue); | 764 FXJSE_Value_Release(jsObjectValue); |
| 765 } else { | 765 } else { |
| 766 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 766 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 767 } | 767 } |
| 768 } else { | 768 } else { |
| 769 dDividor = HValueToDouble(hThis, argTwo); | 769 dDividor = ValueToDouble(pThis, argTwo); |
| 770 } | 770 } |
| 771 if (dDividor) { | 771 if (dDividor) { |
| 772 FXJSE_Value_SetDouble( | 772 FXJSE_Value_SetDouble( |
| 773 args.GetReturnValue(), | 773 args.GetReturnValue(), |
| 774 dDividend - dDividor * (int32_t)(dDividend / dDividor)); | 774 dDividend - dDividor * (int32_t)(dDividend / dDividor)); |
| 775 } else { | 775 } else { |
| 776 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); | 776 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); |
| 777 } | 777 } |
| 778 } | 778 } |
| 779 FXJSE_Value_Release(argOne); | 779 FXJSE_Value_Release(argOne); |
| 780 FXJSE_Value_Release(argTwo); | 780 FXJSE_Value_Release(argTwo); |
| 781 } else { | 781 } else { |
| 782 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 782 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 783 L"Mod"); | 783 L"Mod"); |
| 784 } | 784 } |
| 785 } | 785 } |
| 786 void CXFA_FM2JSContext::Round(FXJSE_HOBJECT hThis, | 786 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis, |
| 787 const CFX_ByteStringC& szFuncName, | 787 const CFX_ByteStringC& szFuncName, |
| 788 CFXJSE_Arguments& args) { | 788 CFXJSE_Arguments& args) { |
| 789 CXFA_FM2JSContext* pContext = | 789 CXFA_FM2JSContext* pContext = |
| 790 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 790 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 791 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 791 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 792 int32_t argc = args.GetLength(); | 792 int32_t argc = args.GetLength(); |
| 793 uint8_t uPrecision = 0; | 793 uint8_t uPrecision = 0; |
| 794 if (argc == 1) { | 794 if (argc == 1) { |
| 795 FXJSE_HVALUE argOne = args.GetValue(0); | 795 CFXJSE_Value* argOne = args.GetValue(0); |
| 796 if (FXJSE_Value_IsNull(argOne)) { | 796 if (FXJSE_Value_IsNull(argOne)) { |
| 797 FXJSE_Value_SetNull(args.GetReturnValue()); | 797 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 798 } else { | 798 } else { |
| 799 FX_DOUBLE dValue = 0.0; | 799 FX_DOUBLE dValue = 0.0; |
| 800 if (FXJSE_Value_IsArray(argOne)) { | 800 if (FXJSE_Value_IsArray(argOne)) { |
| 801 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 801 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 802 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 802 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 803 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 803 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
| 804 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); | 804 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); |
| 805 if (FXJSE_Value_IsNull(propertyValue)) { | 805 if (FXJSE_Value_IsNull(propertyValue)) { |
| 806 dValue = HValueToDouble(hThis, jsObjectValue); | 806 dValue = ValueToDouble(pThis, jsObjectValue); |
| 807 } else { | 807 } else { |
| 808 CFX_ByteString propertyStr; | 808 CFX_ByteString propertyStr; |
| 809 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 809 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 810 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 810 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 811 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 811 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 812 newPropertyValue); | 812 newPropertyValue); |
| 813 dValue = HValueToDouble(hThis, newPropertyValue); | 813 dValue = ValueToDouble(pThis, newPropertyValue); |
| 814 FXJSE_Value_Release(newPropertyValue); | 814 FXJSE_Value_Release(newPropertyValue); |
| 815 } | 815 } |
| 816 FXJSE_Value_Release(propertyValue); | 816 FXJSE_Value_Release(propertyValue); |
| 817 FXJSE_Value_Release(jsObjectValue); | 817 FXJSE_Value_Release(jsObjectValue); |
| 818 } else { | 818 } else { |
| 819 dValue = HValueToDouble(hThis, argOne); | 819 dValue = ValueToDouble(pThis, argOne); |
| 820 } | 820 } |
| 821 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); | 821 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); |
| 822 CFX_WideString wsValue = decimalValue; | 822 CFX_WideString wsValue = decimalValue; |
| 823 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 823 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 824 wsValue.UTF8Encode().AsStringC()); | 824 wsValue.UTF8Encode().AsStringC()); |
| 825 } | 825 } |
| 826 FXJSE_Value_Release(argOne); | 826 FXJSE_Value_Release(argOne); |
| 827 } else if (argc == 2) { | 827 } else if (argc == 2) { |
| 828 FXJSE_HVALUE argOne = args.GetValue(0); | 828 CFXJSE_Value* argOne = args.GetValue(0); |
| 829 FXJSE_HVALUE argTwo = args.GetValue(1); | 829 CFXJSE_Value* argTwo = args.GetValue(1); |
| 830 if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { | 830 if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { |
| 831 FXJSE_Value_SetNull(args.GetReturnValue()); | 831 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 832 } else { | 832 } else { |
| 833 FX_DOUBLE dValue = 0.0; | 833 FX_DOUBLE dValue = 0.0; |
| 834 if (FXJSE_Value_IsArray(argOne)) { | 834 if (FXJSE_Value_IsArray(argOne)) { |
| 835 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 835 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 836 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 836 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 837 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 837 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
| 838 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); | 838 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); |
| 839 if (FXJSE_Value_IsNull(propertyValue)) { | 839 if (FXJSE_Value_IsNull(propertyValue)) { |
| 840 dValue = HValueToDouble(hThis, jsObjectValue); | 840 dValue = ValueToDouble(pThis, jsObjectValue); |
| 841 } else { | 841 } else { |
| 842 CFX_ByteString propertyStr; | 842 CFX_ByteString propertyStr; |
| 843 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 843 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 844 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 844 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 845 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 845 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 846 newPropertyValue); | 846 newPropertyValue); |
| 847 dValue = HValueToDouble(hThis, newPropertyValue); | 847 dValue = ValueToDouble(pThis, newPropertyValue); |
| 848 FXJSE_Value_Release(newPropertyValue); | 848 FXJSE_Value_Release(newPropertyValue); |
| 849 } | 849 } |
| 850 FXJSE_Value_Release(propertyValue); | 850 FXJSE_Value_Release(propertyValue); |
| 851 FXJSE_Value_Release(jsObjectValue); | 851 FXJSE_Value_Release(jsObjectValue); |
| 852 } else { | 852 } else { |
| 853 dValue = HValueToDouble(hThis, argOne); | 853 dValue = ValueToDouble(pThis, argOne); |
| 854 } | 854 } |
| 855 FX_DOUBLE dPrecision = 0.0; | 855 FX_DOUBLE dPrecision = 0.0; |
| 856 if (FXJSE_Value_IsArray(argTwo)) { | 856 if (FXJSE_Value_IsArray(argTwo)) { |
| 857 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 857 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 858 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 858 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 859 FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); | 859 FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); |
| 860 FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); | 860 FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); |
| 861 if (FXJSE_Value_IsNull(propertyValue)) { | 861 if (FXJSE_Value_IsNull(propertyValue)) { |
| 862 dPrecision = HValueToDouble(hThis, jsObjectValue); | 862 dPrecision = ValueToDouble(pThis, jsObjectValue); |
| 863 } else { | 863 } else { |
| 864 CFX_ByteString propertyStr; | 864 CFX_ByteString propertyStr; |
| 865 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 865 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 866 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 866 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 867 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 867 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 868 newPropertyValue); | 868 newPropertyValue); |
| 869 dPrecision = HValueToDouble(hThis, newPropertyValue); | 869 dPrecision = ValueToDouble(pThis, newPropertyValue); |
| 870 FXJSE_Value_Release(newPropertyValue); | 870 FXJSE_Value_Release(newPropertyValue); |
| 871 } | 871 } |
| 872 FXJSE_Value_Release(propertyValue); | 872 FXJSE_Value_Release(propertyValue); |
| 873 FXJSE_Value_Release(jsObjectValue); | 873 FXJSE_Value_Release(jsObjectValue); |
| 874 } else { | 874 } else { |
| 875 dPrecision = HValueToDouble(hThis, argTwo); | 875 dPrecision = ValueToDouble(pThis, argTwo); |
| 876 } | 876 } |
| 877 if (dPrecision < 0) { | 877 if (dPrecision < 0) { |
| 878 uPrecision = 0; | 878 uPrecision = 0; |
| 879 } else if (dPrecision > 12.0) { | 879 } else if (dPrecision > 12.0) { |
| 880 uPrecision = 12; | 880 uPrecision = 12; |
| 881 } else { | 881 } else { |
| 882 uPrecision = (uint8_t)dPrecision; | 882 uPrecision = (uint8_t)dPrecision; |
| 883 } | 883 } |
| 884 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); | 884 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); |
| 885 CFX_WideString wsValue = decimalValue; | 885 CFX_WideString wsValue = decimalValue; |
| 886 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 886 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 887 wsValue.UTF8Encode().AsStringC()); | 887 wsValue.UTF8Encode().AsStringC()); |
| 888 } | 888 } |
| 889 FXJSE_Value_Release(argOne); | 889 FXJSE_Value_Release(argOne); |
| 890 FXJSE_Value_Release(argTwo); | 890 FXJSE_Value_Release(argTwo); |
| 891 } else { | 891 } else { |
| 892 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 892 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 893 L"Round"); | 893 L"Round"); |
| 894 } | 894 } |
| 895 } | 895 } |
| 896 void CXFA_FM2JSContext::Sum(FXJSE_HOBJECT hThis, | 896 void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis, |
| 897 const CFX_ByteStringC& szFuncName, | 897 const CFX_ByteStringC& szFuncName, |
| 898 CFXJSE_Arguments& args) { | 898 CFXJSE_Arguments& args) { |
| 899 CXFA_FM2JSContext* pContext = | 899 CXFA_FM2JSContext* pContext = |
| 900 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 900 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 901 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 901 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 902 int32_t argc = args.GetLength(); | 902 int32_t argc = args.GetLength(); |
| 903 uint32_t uCount = 0; | 903 uint32_t uCount = 0; |
| 904 FX_DOUBLE dSum = 0.0; | 904 FX_DOUBLE dSum = 0.0; |
| 905 if (argc) { | 905 if (argc) { |
| 906 FXJSE_HVALUE argValue = 0; | 906 CFXJSE_Value* argValue = nullptr; |
| 907 for (int32_t i = 0; i < argc; i++) { | 907 for (int32_t i = 0; i < argc; i++) { |
| 908 argValue = args.GetValue(i); | 908 argValue = args.GetValue(i); |
| 909 if (FXJSE_Value_IsNull(argValue)) { | 909 if (FXJSE_Value_IsNull(argValue)) { |
| 910 FXJSE_Value_Release(argValue); | 910 FXJSE_Value_Release(argValue); |
| 911 continue; | 911 continue; |
| 912 } else if (FXJSE_Value_IsArray(argValue)) { | 912 } else if (FXJSE_Value_IsArray(argValue)) { |
| 913 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 913 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 914 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 914 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 915 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 915 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 916 FXJSE_Value_Release(lengthValue); | 916 FXJSE_Value_Release(lengthValue); |
| 917 if (iLength > 2) { | 917 if (iLength > 2) { |
| 918 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 918 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 919 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 919 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 920 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 920 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 921 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 921 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 922 if (FXJSE_Value_IsNull(propertyValue)) { | 922 if (FXJSE_Value_IsNull(propertyValue)) { |
| 923 for (int32_t j = 2; j < iLength; j++) { | 923 for (int32_t j = 2; j < iLength; j++) { |
| 924 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); | 924 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); |
| 925 GetObjectDefaultValue(jsObjectValue, newPropertyValue); | 925 GetObjectDefaultValue(jsObjectValue, newPropertyValue); |
| 926 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 926 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 927 dSum += HValueToDouble(hThis, jsObjectValue); | 927 dSum += ValueToDouble(pThis, jsObjectValue); |
| 928 uCount++; | 928 uCount++; |
| 929 } | 929 } |
| 930 } | 930 } |
| 931 } else { | 931 } else { |
| 932 CFX_ByteString propertyStr; | 932 CFX_ByteString propertyStr; |
| 933 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 933 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 934 for (int32_t j = 2; j < iLength; j++) { | 934 for (int32_t j = 2; j < iLength; j++) { |
| 935 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); | 935 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); |
| 936 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 936 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 937 newPropertyValue); | 937 newPropertyValue); |
| 938 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 938 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 939 dSum += HValueToDouble(hThis, newPropertyValue); | 939 dSum += ValueToDouble(pThis, newPropertyValue); |
| 940 uCount++; | 940 uCount++; |
| 941 } | 941 } |
| 942 } | 942 } |
| 943 } | 943 } |
| 944 FXJSE_Value_Release(newPropertyValue); | 944 FXJSE_Value_Release(newPropertyValue); |
| 945 FXJSE_Value_Release(jsObjectValue); | 945 FXJSE_Value_Release(jsObjectValue); |
| 946 FXJSE_Value_Release(propertyValue); | 946 FXJSE_Value_Release(propertyValue); |
| 947 } else { | 947 } else { |
| 948 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 948 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 949 } | 949 } |
| 950 } else if (FXJSE_Value_IsObject(argValue)) { | 950 } else if (FXJSE_Value_IsObject(argValue)) { |
| 951 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 951 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 952 GetObjectDefaultValue(argValue, newPropertyValue); | 952 GetObjectDefaultValue(argValue, newPropertyValue); |
| 953 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 953 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 954 dSum += HValueToDouble(hThis, argValue); | 954 dSum += ValueToDouble(pThis, argValue); |
| 955 uCount++; | 955 uCount++; |
| 956 } | 956 } |
| 957 FXJSE_Value_Release(newPropertyValue); | 957 FXJSE_Value_Release(newPropertyValue); |
| 958 } else { | 958 } else { |
| 959 dSum += HValueToDouble(hThis, argValue); | 959 dSum += ValueToDouble(pThis, argValue); |
| 960 uCount++; | 960 uCount++; |
| 961 } | 961 } |
| 962 FXJSE_Value_Release(argValue); | 962 FXJSE_Value_Release(argValue); |
| 963 } | 963 } |
| 964 argValue = 0; | 964 argValue = nullptr; |
| 965 } | 965 } |
| 966 if (uCount < 1) { | 966 if (uCount < 1) { |
| 967 FXJSE_Value_SetNull(args.GetReturnValue()); | 967 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 968 } else { | 968 } else { |
| 969 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); | 969 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); |
| 970 } | 970 } |
| 971 } | 971 } |
| 972 void CXFA_FM2JSContext::Date(FXJSE_HOBJECT hThis, | 972 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis, |
| 973 const CFX_ByteStringC& szFuncName, | 973 const CFX_ByteStringC& szFuncName, |
| 974 CFXJSE_Arguments& args) { | 974 CFXJSE_Arguments& args) { |
| 975 if (args.GetLength() == 0) { | 975 if (args.GetLength() == 0) { |
| 976 struct tm* pTmStruct = 0; | 976 struct tm* pTmStruct = 0; |
| 977 time_t currentTime; | 977 time_t currentTime; |
| 978 time(¤tTime); | 978 time(¤tTime); |
| 979 pTmStruct = gmtime(¤tTime); | 979 pTmStruct = gmtime(¤tTime); |
| 980 CFX_ByteString bufferYear; | 980 CFX_ByteString bufferYear; |
| 981 CFX_ByteString bufferMon; | 981 CFX_ByteString bufferMon; |
| 982 CFX_ByteString bufferDay; | 982 CFX_ByteString bufferDay; |
| 983 bufferYear.Format("%d", pTmStruct->tm_year + 1900); | 983 bufferYear.Format("%d", pTmStruct->tm_year + 1900); |
| 984 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); | 984 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); |
| 985 bufferDay.Format("%02d", pTmStruct->tm_mday); | 985 bufferDay.Format("%02d", pTmStruct->tm_mday); |
| 986 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; | 986 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; |
| 987 int32_t dDays = DateString2Num(bufferCurrent.AsStringC()); | 987 int32_t dDays = DateString2Num(bufferCurrent.AsStringC()); |
| 988 FXJSE_Value_SetInteger(args.GetReturnValue(), dDays); | 988 FXJSE_Value_SetInteger(args.GetReturnValue(), dDays); |
| 989 } else { | 989 } else { |
| 990 CXFA_FM2JSContext* pContext = | 990 CXFA_FM2JSContext* pContext = |
| 991 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 991 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 992 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 992 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 993 L"Date"); | 993 L"Date"); |
| 994 } | 994 } |
| 995 } | 995 } |
| 996 void CXFA_FM2JSContext::Date2Num(FXJSE_HOBJECT hThis, | 996 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis, |
| 997 const CFX_ByteStringC& szFuncName, | 997 const CFX_ByteStringC& szFuncName, |
| 998 CFXJSE_Arguments& args) { | 998 CFXJSE_Arguments& args) { |
| 999 int32_t argc = args.GetLength(); | 999 int32_t argc = args.GetLength(); |
| 1000 if ((argc > 0) && (argc < 4)) { | 1000 if ((argc > 0) && (argc < 4)) { |
| 1001 FX_BOOL bFlags = FALSE; | 1001 FX_BOOL bFlags = FALSE; |
| 1002 CFX_ByteString dateString; | 1002 CFX_ByteString dateString; |
| 1003 CFX_ByteString formatString; | 1003 CFX_ByteString formatString; |
| 1004 CFX_ByteString localString; | 1004 CFX_ByteString localString; |
| 1005 FXJSE_HVALUE dateValue = GetSimpleHValue(hThis, args, 0); | 1005 CFXJSE_Value* dateValue = GetSimpleValue(pThis, args, 0); |
| 1006 FXJSE_HVALUE formatValue = 0; | 1006 CFXJSE_Value* formatValue = nullptr; |
| 1007 FXJSE_HVALUE localValue = 0; | 1007 CFXJSE_Value* localValue = nullptr; |
| 1008 if (HValueIsNull(hThis, dateValue)) { | 1008 if (ValueIsNull(pThis, dateValue)) { |
| 1009 bFlags = TRUE; | 1009 bFlags = TRUE; |
| 1010 } else { | 1010 } else { |
| 1011 HValueToUTF8String(dateValue, dateString); | 1011 ValueToUTF8String(dateValue, dateString); |
| 1012 } | 1012 } |
| 1013 if (argc > 1) { | 1013 if (argc > 1) { |
| 1014 formatValue = GetSimpleHValue(hThis, args, 1); | 1014 formatValue = GetSimpleValue(pThis, args, 1); |
| 1015 if (HValueIsNull(hThis, formatValue)) { | 1015 if (ValueIsNull(pThis, formatValue)) { |
| 1016 bFlags = TRUE; | 1016 bFlags = TRUE; |
| 1017 } else { | 1017 } else { |
| 1018 HValueToUTF8String(formatValue, formatString); | 1018 ValueToUTF8String(formatValue, formatString); |
| 1019 } | 1019 } |
| 1020 } | 1020 } |
| 1021 if (argc == 3) { | 1021 if (argc == 3) { |
| 1022 localValue = GetSimpleHValue(hThis, args, 2); | 1022 localValue = GetSimpleValue(pThis, args, 2); |
| 1023 if (HValueIsNull(hThis, localValue)) { | 1023 if (ValueIsNull(pThis, localValue)) { |
| 1024 bFlags = TRUE; | 1024 bFlags = TRUE; |
| 1025 } else { | 1025 } else { |
| 1026 HValueToUTF8String(localValue, localString); | 1026 ValueToUTF8String(localValue, localString); |
| 1027 } | 1027 } |
| 1028 } | 1028 } |
| 1029 if (!bFlags) { | 1029 if (!bFlags) { |
| 1030 CFX_ByteString szIsoDateString; | 1030 CFX_ByteString szIsoDateString; |
| 1031 FX_BOOL bRet = | 1031 FX_BOOL bRet = |
| 1032 Local2IsoDate(hThis, dateString.AsStringC(), formatString.AsStringC(), | 1032 Local2IsoDate(pThis, dateString.AsStringC(), formatString.AsStringC(), |
| 1033 localString.AsStringC(), szIsoDateString); | 1033 localString.AsStringC(), szIsoDateString); |
| 1034 if (bRet) { | 1034 if (bRet) { |
| 1035 FXJSE_Value_SetInteger(args.GetReturnValue(), | 1035 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 1036 DateString2Num(szIsoDateString.AsStringC())); | 1036 DateString2Num(szIsoDateString.AsStringC())); |
| 1037 } else { | 1037 } else { |
| 1038 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 1038 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 1039 } | 1039 } |
| 1040 } else { | 1040 } else { |
| 1041 FXJSE_Value_SetNull(args.GetReturnValue()); | 1041 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1042 } | 1042 } |
| 1043 FXJSE_Value_Release(dateValue); | 1043 FXJSE_Value_Release(dateValue); |
| 1044 if (argc > 1) { | 1044 if (argc > 1) { |
| 1045 FXJSE_Value_Release(formatValue); | 1045 FXJSE_Value_Release(formatValue); |
| 1046 if (argc == 3) { | 1046 if (argc == 3) { |
| 1047 FXJSE_Value_Release(localValue); | 1047 FXJSE_Value_Release(localValue); |
| 1048 } | 1048 } |
| 1049 } | 1049 } |
| 1050 } else { | 1050 } else { |
| 1051 CXFA_FM2JSContext* pContext = | 1051 CXFA_FM2JSContext* pContext = |
| 1052 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1052 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1053 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1053 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1054 L"Date2Num"); | 1054 L"Date2Num"); |
| 1055 } | 1055 } |
| 1056 } | 1056 } |
| 1057 void CXFA_FM2JSContext::DateFmt(FXJSE_HOBJECT hThis, | 1057 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis, |
| 1058 const CFX_ByteStringC& szFuncName, | 1058 const CFX_ByteStringC& szFuncName, |
| 1059 CFXJSE_Arguments& args) { | 1059 CFXJSE_Arguments& args) { |
| 1060 int32_t argc = args.GetLength(); | 1060 int32_t argc = args.GetLength(); |
| 1061 if (argc < 3) { | 1061 if (argc < 3) { |
| 1062 FX_BOOL bFlags = FALSE; | 1062 FX_BOOL bFlags = FALSE; |
| 1063 int32_t iStyle = 0; | 1063 int32_t iStyle = 0; |
| 1064 CFX_ByteString szLocal; | 1064 CFX_ByteString szLocal; |
| 1065 FXJSE_HVALUE argStyle = 0; | 1065 CFXJSE_Value* argStyle = nullptr; |
| 1066 FXJSE_HVALUE argLocal = 0; | 1066 CFXJSE_Value* argLocal = nullptr; |
| 1067 if (argc > 0) { | 1067 if (argc > 0) { |
| 1068 argStyle = GetSimpleHValue(hThis, args, 0); | 1068 argStyle = GetSimpleValue(pThis, args, 0); |
| 1069 if (FXJSE_Value_IsNull(argStyle)) { | 1069 if (FXJSE_Value_IsNull(argStyle)) { |
| 1070 bFlags = TRUE; | 1070 bFlags = TRUE; |
| 1071 } | 1071 } |
| 1072 iStyle = (int32_t)HValueToFloat(hThis, argStyle); | 1072 iStyle = (int32_t)ValueToFloat(pThis, argStyle); |
| 1073 if (iStyle > 4 || iStyle < 0) { | 1073 if (iStyle > 4 || iStyle < 0) { |
| 1074 iStyle = 0; | 1074 iStyle = 0; |
| 1075 } | 1075 } |
| 1076 } | 1076 } |
| 1077 if (argc == 2) { | 1077 if (argc == 2) { |
| 1078 argLocal = GetSimpleHValue(hThis, args, 1); | 1078 argLocal = GetSimpleValue(pThis, args, 1); |
| 1079 if (FXJSE_Value_IsNull(argLocal)) { | 1079 if (FXJSE_Value_IsNull(argLocal)) { |
| 1080 bFlags = TRUE; | 1080 bFlags = TRUE; |
| 1081 } else { | 1081 } else { |
| 1082 HValueToUTF8String(argLocal, szLocal); | 1082 ValueToUTF8String(argLocal, szLocal); |
| 1083 } | 1083 } |
| 1084 } | 1084 } |
| 1085 if (!bFlags) { | 1085 if (!bFlags) { |
| 1086 CFX_ByteString formatStr; | 1086 CFX_ByteString formatStr; |
| 1087 GetStandardDateFormat(hThis, iStyle, szLocal.AsStringC(), formatStr); | 1087 GetStandardDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); |
| 1088 if (formatStr.IsEmpty()) { | 1088 if (formatStr.IsEmpty()) { |
| 1089 formatStr = ""; | 1089 formatStr = ""; |
| 1090 } | 1090 } |
| 1091 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1091 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1092 } else { | 1092 } else { |
| 1093 FXJSE_Value_SetNull(args.GetReturnValue()); | 1093 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1094 } | 1094 } |
| 1095 if (argc > 0) { | 1095 if (argc > 0) { |
| 1096 FXJSE_Value_Release(argStyle); | 1096 FXJSE_Value_Release(argStyle); |
| 1097 if (argc == 2) { | 1097 if (argc == 2) { |
| 1098 FXJSE_Value_Release(argLocal); | 1098 FXJSE_Value_Release(argLocal); |
| 1099 } | 1099 } |
| 1100 } | 1100 } |
| 1101 } else { | 1101 } else { |
| 1102 CXFA_FM2JSContext* pContext = | 1102 CXFA_FM2JSContext* pContext = |
| 1103 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1103 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1104 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1104 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1105 L"Date2Num"); | 1105 L"Date2Num"); |
| 1106 } | 1106 } |
| 1107 } | 1107 } |
| 1108 void CXFA_FM2JSContext::IsoDate2Num(FXJSE_HOBJECT hThis, | 1108 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, |
| 1109 const CFX_ByteStringC& szFuncName, | 1109 const CFX_ByteStringC& szFuncName, |
| 1110 CFXJSE_Arguments& args) { | 1110 CFXJSE_Arguments& args) { |
| 1111 if (args.GetLength() == 1) { | 1111 if (args.GetLength() == 1) { |
| 1112 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 1112 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 1113 if (FXJSE_Value_IsNull(argOne)) { | 1113 if (FXJSE_Value_IsNull(argOne)) { |
| 1114 FXJSE_Value_SetNull(args.GetReturnValue()); | 1114 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1115 } else { | 1115 } else { |
| 1116 CFX_ByteString szArgString; | 1116 CFX_ByteString szArgString; |
| 1117 HValueToUTF8String(argOne, szArgString); | 1117 ValueToUTF8String(argOne, szArgString); |
| 1118 int32_t dDays = DateString2Num(szArgString.AsStringC()); | 1118 int32_t dDays = DateString2Num(szArgString.AsStringC()); |
| 1119 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)dDays); | 1119 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)dDays); |
| 1120 } | 1120 } |
| 1121 FXJSE_Value_Release(argOne); | 1121 FXJSE_Value_Release(argOne); |
| 1122 } else { | 1122 } else { |
| 1123 CXFA_FM2JSContext* pContext = | 1123 CXFA_FM2JSContext* pContext = |
| 1124 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1124 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1125 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1125 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1126 L"IsoDate2Num"); | 1126 L"IsoDate2Num"); |
| 1127 } | 1127 } |
| 1128 } | 1128 } |
| 1129 void CXFA_FM2JSContext::IsoTime2Num(FXJSE_HOBJECT hThis, | 1129 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, |
| 1130 const CFX_ByteStringC& szFuncName, | 1130 const CFX_ByteStringC& szFuncName, |
| 1131 CFXJSE_Arguments& args) { | 1131 CFXJSE_Arguments& args) { |
| 1132 CXFA_FM2JSContext* pContext = | 1132 CXFA_FM2JSContext* pContext = |
| 1133 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1133 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1134 if (args.GetLength() == 1) { | 1134 if (args.GetLength() == 1) { |
| 1135 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 1135 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 1136 if (HValueIsNull(hThis, argOne)) { | 1136 if (ValueIsNull(pThis, argOne)) { |
| 1137 FXJSE_Value_SetNull(args.GetReturnValue()); | 1137 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1138 } else { | 1138 } else { |
| 1139 CXFA_Document* pDoc = pContext->GetDocument(); | 1139 CXFA_Document* pDoc = pContext->GetDocument(); |
| 1140 ASSERT(pDoc); | 1140 ASSERT(pDoc); |
| 1141 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 1141 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 1142 CFX_ByteString szArgString; | 1142 CFX_ByteString szArgString; |
| 1143 HValueToUTF8String(argOne, szArgString); | 1143 ValueToUTF8String(argOne, szArgString); |
| 1144 szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1); | 1144 szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1); |
| 1145 if (szArgString.IsEmpty()) { | 1145 if (szArgString.IsEmpty()) { |
| 1146 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 1146 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 1147 FXJSE_Value_Release(argOne); | 1147 FXJSE_Value_Release(argOne); |
| 1148 return; | 1148 return; |
| 1149 } | 1149 } |
| 1150 CXFA_LocaleValue timeValue( | 1150 CXFA_LocaleValue timeValue( |
| 1151 XFA_VT_TIME, CFX_WideString::FromUTF8(szArgString.AsStringC()), | 1151 XFA_VT_TIME, CFX_WideString::FromUTF8(szArgString.AsStringC()), |
| 1152 (CXFA_LocaleMgr*)pMgr); | 1152 (CXFA_LocaleMgr*)pMgr); |
| 1153 if (timeValue.IsValid()) { | 1153 if (timeValue.IsValid()) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1176 } else { | 1176 } else { |
| 1177 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 1177 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 1178 } | 1178 } |
| 1179 } | 1179 } |
| 1180 FXJSE_Value_Release(argOne); | 1180 FXJSE_Value_Release(argOne); |
| 1181 } else { | 1181 } else { |
| 1182 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1182 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1183 L"IsoTime2Num"); | 1183 L"IsoTime2Num"); |
| 1184 } | 1184 } |
| 1185 } | 1185 } |
| 1186 void CXFA_FM2JSContext::LocalDateFmt(FXJSE_HOBJECT hThis, | 1186 void CXFA_FM2JSContext::LocalDateFmt(CFXJSE_Value* pThis, |
| 1187 const CFX_ByteStringC& szFuncName, | 1187 const CFX_ByteStringC& szFuncName, |
| 1188 CFXJSE_Arguments& args) { | 1188 CFXJSE_Arguments& args) { |
| 1189 int32_t argc = args.GetLength(); | 1189 int32_t argc = args.GetLength(); |
| 1190 if (argc < 3) { | 1190 if (argc < 3) { |
| 1191 FX_BOOL bFlags = FALSE; | 1191 FX_BOOL bFlags = FALSE; |
| 1192 int32_t iStyle = 0; | 1192 int32_t iStyle = 0; |
| 1193 CFX_ByteString szLocal; | 1193 CFX_ByteString szLocal; |
| 1194 FXJSE_HVALUE argStyle = 0; | 1194 CFXJSE_Value* argStyle = nullptr; |
| 1195 FXJSE_HVALUE argLocal = 0; | 1195 CFXJSE_Value* argLocal = nullptr; |
| 1196 if (argc > 0) { | 1196 if (argc > 0) { |
| 1197 argStyle = GetSimpleHValue(hThis, args, 0); | 1197 argStyle = GetSimpleValue(pThis, args, 0); |
| 1198 if (FXJSE_Value_IsNull(argStyle)) { | 1198 if (FXJSE_Value_IsNull(argStyle)) { |
| 1199 bFlags = TRUE; | 1199 bFlags = TRUE; |
| 1200 } | 1200 } |
| 1201 iStyle = (int32_t)HValueToFloat(hThis, argStyle); | 1201 iStyle = (int32_t)ValueToFloat(pThis, argStyle); |
| 1202 if (iStyle > 4 || iStyle < 0) { | 1202 if (iStyle > 4 || iStyle < 0) { |
| 1203 iStyle = 0; | 1203 iStyle = 0; |
| 1204 } | 1204 } |
| 1205 } | 1205 } |
| 1206 if (argc == 2) { | 1206 if (argc == 2) { |
| 1207 argLocal = GetSimpleHValue(hThis, args, 1); | 1207 argLocal = GetSimpleValue(pThis, args, 1); |
| 1208 if (FXJSE_Value_IsNull(argLocal)) { | 1208 if (FXJSE_Value_IsNull(argLocal)) { |
| 1209 bFlags = TRUE; | 1209 bFlags = TRUE; |
| 1210 } else { | 1210 } else { |
| 1211 HValueToUTF8String(argLocal, szLocal); | 1211 ValueToUTF8String(argLocal, szLocal); |
| 1212 } | 1212 } |
| 1213 } | 1213 } |
| 1214 if (!bFlags) { | 1214 if (!bFlags) { |
| 1215 CFX_ByteString formatStr; | 1215 CFX_ByteString formatStr; |
| 1216 GetLocalDateFormat(hThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); | 1216 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); |
| 1217 if (formatStr.IsEmpty()) { | 1217 if (formatStr.IsEmpty()) { |
| 1218 formatStr = ""; | 1218 formatStr = ""; |
| 1219 } | 1219 } |
| 1220 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1220 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1221 } else { | 1221 } else { |
| 1222 FXJSE_Value_SetNull(args.GetReturnValue()); | 1222 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1223 } | 1223 } |
| 1224 if (argc > 0) { | 1224 if (argc > 0) { |
| 1225 FXJSE_Value_Release(argStyle); | 1225 FXJSE_Value_Release(argStyle); |
| 1226 if (argc == 2) { | 1226 if (argc == 2) { |
| 1227 FXJSE_Value_Release(argLocal); | 1227 FXJSE_Value_Release(argLocal); |
| 1228 } | 1228 } |
| 1229 } | 1229 } |
| 1230 } else { | 1230 } else { |
| 1231 CXFA_FM2JSContext* pContext = | 1231 CXFA_FM2JSContext* pContext = |
| 1232 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1232 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1233 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1233 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1234 L"LocalDateFmt"); | 1234 L"LocalDateFmt"); |
| 1235 } | 1235 } |
| 1236 } | 1236 } |
| 1237 void CXFA_FM2JSContext::LocalTimeFmt(FXJSE_HOBJECT hThis, | 1237 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, |
| 1238 const CFX_ByteStringC& szFuncName, | 1238 const CFX_ByteStringC& szFuncName, |
| 1239 CFXJSE_Arguments& args) { | 1239 CFXJSE_Arguments& args) { |
| 1240 int32_t argc = args.GetLength(); | 1240 int32_t argc = args.GetLength(); |
| 1241 if (argc < 3) { | 1241 if (argc < 3) { |
| 1242 FX_BOOL bFlags = FALSE; | 1242 FX_BOOL bFlags = FALSE; |
| 1243 int32_t iStyle = 0; | 1243 int32_t iStyle = 0; |
| 1244 CFX_ByteString szLocal; | 1244 CFX_ByteString szLocal; |
| 1245 FXJSE_HVALUE argStyle = 0; | 1245 CFXJSE_Value* argStyle = nullptr; |
| 1246 FXJSE_HVALUE argLocal = 0; | 1246 CFXJSE_Value* argLocal = nullptr; |
| 1247 if (argc > 0) { | 1247 if (argc > 0) { |
| 1248 argStyle = GetSimpleHValue(hThis, args, 0); | 1248 argStyle = GetSimpleValue(pThis, args, 0); |
| 1249 if (FXJSE_Value_IsNull(argStyle)) { | 1249 if (FXJSE_Value_IsNull(argStyle)) { |
| 1250 bFlags = TRUE; | 1250 bFlags = TRUE; |
| 1251 } | 1251 } |
| 1252 iStyle = (int32_t)HValueToFloat(hThis, argStyle); | 1252 iStyle = (int32_t)ValueToFloat(pThis, argStyle); |
| 1253 if (iStyle > 4 || iStyle < 0) { | 1253 if (iStyle > 4 || iStyle < 0) { |
| 1254 iStyle = 0; | 1254 iStyle = 0; |
| 1255 } | 1255 } |
| 1256 } | 1256 } |
| 1257 if (argc == 2) { | 1257 if (argc == 2) { |
| 1258 argLocal = GetSimpleHValue(hThis, args, 1); | 1258 argLocal = GetSimpleValue(pThis, args, 1); |
| 1259 if (FXJSE_Value_IsNull(argLocal)) { | 1259 if (FXJSE_Value_IsNull(argLocal)) { |
| 1260 bFlags = TRUE; | 1260 bFlags = TRUE; |
| 1261 } else { | 1261 } else { |
| 1262 HValueToUTF8String(argLocal, szLocal); | 1262 ValueToUTF8String(argLocal, szLocal); |
| 1263 } | 1263 } |
| 1264 } | 1264 } |
| 1265 if (!bFlags) { | 1265 if (!bFlags) { |
| 1266 CFX_ByteString formatStr; | 1266 CFX_ByteString formatStr; |
| 1267 GetLocalTimeFormat(hThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); | 1267 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); |
| 1268 if (formatStr.IsEmpty()) { | 1268 if (formatStr.IsEmpty()) { |
| 1269 formatStr = ""; | 1269 formatStr = ""; |
| 1270 } | 1270 } |
| 1271 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1271 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1272 } else { | 1272 } else { |
| 1273 FXJSE_Value_SetNull(args.GetReturnValue()); | 1273 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1274 } | 1274 } |
| 1275 if (argc > 0) { | 1275 if (argc > 0) { |
| 1276 FXJSE_Value_Release(argStyle); | 1276 FXJSE_Value_Release(argStyle); |
| 1277 if (argc == 2) { | 1277 if (argc == 2) { |
| 1278 FXJSE_Value_Release(argLocal); | 1278 FXJSE_Value_Release(argLocal); |
| 1279 } | 1279 } |
| 1280 } | 1280 } |
| 1281 } else { | 1281 } else { |
| 1282 CXFA_FM2JSContext* pContext = | 1282 CXFA_FM2JSContext* pContext = |
| 1283 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1283 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1284 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1284 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1285 L"LocalTimeFmt"); | 1285 L"LocalTimeFmt"); |
| 1286 } | 1286 } |
| 1287 } | 1287 } |
| 1288 void CXFA_FM2JSContext::Num2Date(FXJSE_HOBJECT hThis, | 1288 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, |
| 1289 const CFX_ByteStringC& szFuncName, | 1289 const CFX_ByteStringC& szFuncName, |
| 1290 CFXJSE_Arguments& args) { | 1290 CFXJSE_Arguments& args) { |
| 1291 int32_t argc = args.GetLength(); | 1291 int32_t argc = args.GetLength(); |
| 1292 if ((argc > 0) && (argc < 4)) { | 1292 if ((argc > 0) && (argc < 4)) { |
| 1293 FX_BOOL bFlags = FALSE; | 1293 FX_BOOL bFlags = FALSE; |
| 1294 int32_t dDate = 0; | 1294 int32_t dDate = 0; |
| 1295 CFX_ByteString formatString; | 1295 CFX_ByteString formatString; |
| 1296 CFX_ByteString localString; | 1296 CFX_ByteString localString; |
| 1297 FXJSE_HVALUE dateValue = GetSimpleHValue(hThis, args, 0); | 1297 CFXJSE_Value* dateValue = GetSimpleValue(pThis, args, 0); |
| 1298 FXJSE_HVALUE formatValue = 0; | 1298 CFXJSE_Value* formatValue = nullptr; |
| 1299 FXJSE_HVALUE localValue = 0; | 1299 CFXJSE_Value* localValue = nullptr; |
| 1300 if (HValueIsNull(hThis, dateValue)) { | 1300 if (ValueIsNull(pThis, dateValue)) { |
| 1301 bFlags = TRUE; | 1301 bFlags = TRUE; |
| 1302 } else { | 1302 } else { |
| 1303 dDate = (int32_t)HValueToFloat(hThis, dateValue); | 1303 dDate = (int32_t)ValueToFloat(pThis, dateValue); |
| 1304 bFlags = dDate < 1; | 1304 bFlags = dDate < 1; |
| 1305 } | 1305 } |
| 1306 if (argc > 1) { | 1306 if (argc > 1) { |
| 1307 formatValue = GetSimpleHValue(hThis, args, 1); | 1307 formatValue = GetSimpleValue(pThis, args, 1); |
| 1308 if (HValueIsNull(hThis, formatValue)) { | 1308 if (ValueIsNull(pThis, formatValue)) { |
| 1309 bFlags = TRUE; | 1309 bFlags = TRUE; |
| 1310 } else { | 1310 } else { |
| 1311 HValueToUTF8String(formatValue, formatString); | 1311 ValueToUTF8String(formatValue, formatString); |
| 1312 } | 1312 } |
| 1313 } | 1313 } |
| 1314 if (argc == 3) { | 1314 if (argc == 3) { |
| 1315 localValue = GetSimpleHValue(hThis, args, 2); | 1315 localValue = GetSimpleValue(pThis, args, 2); |
| 1316 if (HValueIsNull(hThis, localValue)) { | 1316 if (ValueIsNull(pThis, localValue)) { |
| 1317 bFlags = TRUE; | 1317 bFlags = TRUE; |
| 1318 } else { | 1318 } else { |
| 1319 HValueToUTF8String(localValue, localString); | 1319 ValueToUTF8String(localValue, localString); |
| 1320 } | 1320 } |
| 1321 } | 1321 } |
| 1322 if (!bFlags) { | 1322 if (!bFlags) { |
| 1323 int32_t iYear = 1900; | 1323 int32_t iYear = 1900; |
| 1324 int32_t iMonth = 1; | 1324 int32_t iMonth = 1; |
| 1325 int32_t iDay = 1; | 1325 int32_t iDay = 1; |
| 1326 int32_t i = 0; | 1326 int32_t i = 0; |
| 1327 while (dDate > 0) { | 1327 while (dDate > 0) { |
| 1328 if (iMonth == 2) { | 1328 if (iMonth == 2) { |
| 1329 if ((!((iYear + i) % 4) && ((iYear + i) % 100)) || | 1329 if ((!((iYear + i) % 4) && ((iYear + i) % 100)) || |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 } else { | 1408 } else { |
| 1409 iDay += static_cast<int32_t>(dDate) - 1; | 1409 iDay += static_cast<int32_t>(dDate) - 1; |
| 1410 dDate = 0; | 1410 dDate = 0; |
| 1411 } | 1411 } |
| 1412 } | 1412 } |
| 1413 } | 1413 } |
| 1414 } | 1414 } |
| 1415 CFX_ByteString szIsoDateString; | 1415 CFX_ByteString szIsoDateString; |
| 1416 szIsoDateString.Format("%d%02d%02d", iYear + i, iMonth, iDay); | 1416 szIsoDateString.Format("%d%02d%02d", iYear + i, iMonth, iDay); |
| 1417 CFX_ByteString szLocalDateString; | 1417 CFX_ByteString szLocalDateString; |
| 1418 IsoDate2Local(hThis, szIsoDateString.AsStringC(), | 1418 IsoDate2Local(pThis, szIsoDateString.AsStringC(), |
| 1419 formatString.AsStringC(), localString.AsStringC(), | 1419 formatString.AsStringC(), localString.AsStringC(), |
| 1420 szLocalDateString); | 1420 szLocalDateString); |
| 1421 if (szLocalDateString.IsEmpty()) { | 1421 if (szLocalDateString.IsEmpty()) { |
| 1422 szLocalDateString = ""; | 1422 szLocalDateString = ""; |
| 1423 } | 1423 } |
| 1424 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1424 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 1425 szLocalDateString.AsStringC()); | 1425 szLocalDateString.AsStringC()); |
| 1426 } else { | 1426 } else { |
| 1427 FXJSE_Value_SetNull(args.GetReturnValue()); | 1427 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1428 } | 1428 } |
| 1429 FXJSE_Value_Release(dateValue); | 1429 FXJSE_Value_Release(dateValue); |
| 1430 if (argc > 1) { | 1430 if (argc > 1) { |
| 1431 FXJSE_Value_Release(formatValue); | 1431 FXJSE_Value_Release(formatValue); |
| 1432 if (argc == 3) { | 1432 if (argc == 3) { |
| 1433 FXJSE_Value_Release(localValue); | 1433 FXJSE_Value_Release(localValue); |
| 1434 } | 1434 } |
| 1435 } | 1435 } |
| 1436 } else { | 1436 } else { |
| 1437 CXFA_FM2JSContext* pContext = | 1437 CXFA_FM2JSContext* pContext = |
| 1438 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1438 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1439 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1439 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1440 L"Num2Date"); | 1440 L"Num2Date"); |
| 1441 } | 1441 } |
| 1442 } | 1442 } |
| 1443 void CXFA_FM2JSContext::Num2GMTime(FXJSE_HOBJECT hThis, | 1443 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, |
| 1444 const CFX_ByteStringC& szFuncName, | 1444 const CFX_ByteStringC& szFuncName, |
| 1445 CFXJSE_Arguments& args) { | 1445 CFXJSE_Arguments& args) { |
| 1446 int32_t argc = args.GetLength(); | 1446 int32_t argc = args.GetLength(); |
| 1447 if ((argc > 0) && (argc < 4)) { | 1447 if ((argc > 0) && (argc < 4)) { |
| 1448 FX_BOOL bFlags = FALSE; | 1448 FX_BOOL bFlags = FALSE; |
| 1449 int32_t iTime = 0; | 1449 int32_t iTime = 0; |
| 1450 CFX_ByteString formatString; | 1450 CFX_ByteString formatString; |
| 1451 CFX_ByteString localString; | 1451 CFX_ByteString localString; |
| 1452 FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); | 1452 CFXJSE_Value* timeValue = GetSimpleValue(pThis, args, 0); |
| 1453 FXJSE_HVALUE formatValue = 0; | 1453 CFXJSE_Value* formatValue = nullptr; |
| 1454 FXJSE_HVALUE localValue = 0; | 1454 CFXJSE_Value* localValue = nullptr; |
| 1455 if (FXJSE_Value_IsNull(timeValue)) { | 1455 if (FXJSE_Value_IsNull(timeValue)) { |
| 1456 bFlags = TRUE; | 1456 bFlags = TRUE; |
| 1457 } else { | 1457 } else { |
| 1458 iTime = (int32_t)HValueToFloat(hThis, timeValue); | 1458 iTime = (int32_t)ValueToFloat(pThis, timeValue); |
| 1459 if (FXSYS_abs(iTime) < 1.0) { | 1459 if (FXSYS_abs(iTime) < 1.0) { |
| 1460 bFlags = TRUE; | 1460 bFlags = TRUE; |
| 1461 } | 1461 } |
| 1462 } | 1462 } |
| 1463 if (argc > 1) { | 1463 if (argc > 1) { |
| 1464 formatValue = GetSimpleHValue(hThis, args, 1); | 1464 formatValue = GetSimpleValue(pThis, args, 1); |
| 1465 if (FXJSE_Value_IsNull(formatValue)) { | 1465 if (FXJSE_Value_IsNull(formatValue)) { |
| 1466 bFlags = TRUE; | 1466 bFlags = TRUE; |
| 1467 } else { | 1467 } else { |
| 1468 HValueToUTF8String(formatValue, formatString); | 1468 ValueToUTF8String(formatValue, formatString); |
| 1469 } | 1469 } |
| 1470 } | 1470 } |
| 1471 if (argc == 3) { | 1471 if (argc == 3) { |
| 1472 localValue = GetSimpleHValue(hThis, args, 2); | 1472 localValue = GetSimpleValue(pThis, args, 2); |
| 1473 if (FXJSE_Value_IsNull(localValue)) { | 1473 if (FXJSE_Value_IsNull(localValue)) { |
| 1474 bFlags = TRUE; | 1474 bFlags = TRUE; |
| 1475 } else { | 1475 } else { |
| 1476 HValueToUTF8String(localValue, localString); | 1476 ValueToUTF8String(localValue, localString); |
| 1477 } | 1477 } |
| 1478 } | 1478 } |
| 1479 if (!bFlags) { | 1479 if (!bFlags) { |
| 1480 CFX_ByteString szGMTTimeString; | 1480 CFX_ByteString szGMTTimeString; |
| 1481 Num2AllTime(hThis, iTime, formatString.AsStringC(), | 1481 Num2AllTime(pThis, iTime, formatString.AsStringC(), |
| 1482 localString.AsStringC(), TRUE, szGMTTimeString); | 1482 localString.AsStringC(), TRUE, szGMTTimeString); |
| 1483 if (szGMTTimeString.IsEmpty()) { | 1483 if (szGMTTimeString.IsEmpty()) { |
| 1484 szGMTTimeString = ""; | 1484 szGMTTimeString = ""; |
| 1485 } | 1485 } |
| 1486 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1486 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 1487 szGMTTimeString.AsStringC()); | 1487 szGMTTimeString.AsStringC()); |
| 1488 } else { | 1488 } else { |
| 1489 FXJSE_Value_SetNull(args.GetReturnValue()); | 1489 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1490 } | 1490 } |
| 1491 FXJSE_Value_Release(timeValue); | 1491 FXJSE_Value_Release(timeValue); |
| 1492 if (argc > 1) { | 1492 if (argc > 1) { |
| 1493 FXJSE_Value_Release(formatValue); | 1493 FXJSE_Value_Release(formatValue); |
| 1494 if (argc == 3) { | 1494 if (argc == 3) { |
| 1495 FXJSE_Value_Release(localValue); | 1495 FXJSE_Value_Release(localValue); |
| 1496 } | 1496 } |
| 1497 } | 1497 } |
| 1498 } else { | 1498 } else { |
| 1499 CXFA_FM2JSContext* pContext = | 1499 CXFA_FM2JSContext* pContext = |
| 1500 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1500 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1501 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1501 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1502 L"Num2GMTime"); | 1502 L"Num2GMTime"); |
| 1503 } | 1503 } |
| 1504 } | 1504 } |
| 1505 void CXFA_FM2JSContext::Num2Time(FXJSE_HOBJECT hThis, | 1505 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, |
| 1506 const CFX_ByteStringC& szFuncName, | 1506 const CFX_ByteStringC& szFuncName, |
| 1507 CFXJSE_Arguments& args) { | 1507 CFXJSE_Arguments& args) { |
| 1508 int32_t argc = args.GetLength(); | 1508 int32_t argc = args.GetLength(); |
| 1509 if ((argc > 0) && (argc < 4)) { | 1509 if ((argc > 0) && (argc < 4)) { |
| 1510 FX_BOOL bFlags = FALSE; | 1510 FX_BOOL bFlags = FALSE; |
| 1511 FX_FLOAT fTime = 0.0f; | 1511 FX_FLOAT fTime = 0.0f; |
| 1512 CFX_ByteString formatString; | 1512 CFX_ByteString formatString; |
| 1513 CFX_ByteString localString; | 1513 CFX_ByteString localString; |
| 1514 FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); | 1514 CFXJSE_Value* timeValue = GetSimpleValue(pThis, args, 0); |
| 1515 FXJSE_HVALUE formatValue = 0; | 1515 CFXJSE_Value* formatValue = nullptr; |
| 1516 FXJSE_HVALUE localValue = 0; | 1516 CFXJSE_Value* localValue = nullptr; |
| 1517 if (FXJSE_Value_IsNull(timeValue)) { | 1517 if (FXJSE_Value_IsNull(timeValue)) { |
| 1518 bFlags = TRUE; | 1518 bFlags = TRUE; |
| 1519 } else { | 1519 } else { |
| 1520 fTime = HValueToFloat(hThis, timeValue); | 1520 fTime = ValueToFloat(pThis, timeValue); |
| 1521 if (FXSYS_fabs(fTime) < 1.0) { | 1521 if (FXSYS_fabs(fTime) < 1.0) { |
| 1522 bFlags = TRUE; | 1522 bFlags = TRUE; |
| 1523 } | 1523 } |
| 1524 } | 1524 } |
| 1525 if (argc > 1) { | 1525 if (argc > 1) { |
| 1526 formatValue = GetSimpleHValue(hThis, args, 1); | 1526 formatValue = GetSimpleValue(pThis, args, 1); |
| 1527 if (FXJSE_Value_IsNull(formatValue)) { | 1527 if (FXJSE_Value_IsNull(formatValue)) { |
| 1528 bFlags = TRUE; | 1528 bFlags = TRUE; |
| 1529 } else { | 1529 } else { |
| 1530 HValueToUTF8String(formatValue, formatString); | 1530 ValueToUTF8String(formatValue, formatString); |
| 1531 } | 1531 } |
| 1532 } | 1532 } |
| 1533 if (argc == 3) { | 1533 if (argc == 3) { |
| 1534 localValue = GetSimpleHValue(hThis, args, 2); | 1534 localValue = GetSimpleValue(pThis, args, 2); |
| 1535 if (FXJSE_Value_IsNull(localValue)) { | 1535 if (FXJSE_Value_IsNull(localValue)) { |
| 1536 bFlags = TRUE; | 1536 bFlags = TRUE; |
| 1537 } else { | 1537 } else { |
| 1538 HValueToUTF8String(localValue, localString); | 1538 ValueToUTF8String(localValue, localString); |
| 1539 } | 1539 } |
| 1540 } | 1540 } |
| 1541 if (!bFlags) { | 1541 if (!bFlags) { |
| 1542 CFX_ByteString szLocalTimeString; | 1542 CFX_ByteString szLocalTimeString; |
| 1543 Num2AllTime(hThis, (int32_t)fTime, formatString.AsStringC(), | 1543 Num2AllTime(pThis, (int32_t)fTime, formatString.AsStringC(), |
| 1544 localString.AsStringC(), FALSE, szLocalTimeString); | 1544 localString.AsStringC(), FALSE, szLocalTimeString); |
| 1545 if (szLocalTimeString.IsEmpty()) { | 1545 if (szLocalTimeString.IsEmpty()) { |
| 1546 szLocalTimeString = ""; | 1546 szLocalTimeString = ""; |
| 1547 } | 1547 } |
| 1548 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1548 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 1549 szLocalTimeString.AsStringC()); | 1549 szLocalTimeString.AsStringC()); |
| 1550 } else { | 1550 } else { |
| 1551 FXJSE_Value_SetNull(args.GetReturnValue()); | 1551 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1552 } | 1552 } |
| 1553 FXJSE_Value_Release(timeValue); | 1553 FXJSE_Value_Release(timeValue); |
| 1554 if (argc > 1) { | 1554 if (argc > 1) { |
| 1555 FXJSE_Value_Release(formatValue); | 1555 FXJSE_Value_Release(formatValue); |
| 1556 if (argc == 3) { | 1556 if (argc == 3) { |
| 1557 FXJSE_Value_Release(localValue); | 1557 FXJSE_Value_Release(localValue); |
| 1558 } | 1558 } |
| 1559 } | 1559 } |
| 1560 } else { | 1560 } else { |
| 1561 CXFA_FM2JSContext* pContext = | 1561 CXFA_FM2JSContext* pContext = |
| 1562 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1562 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1563 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1563 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1564 L"Num2Time"); | 1564 L"Num2Time"); |
| 1565 } | 1565 } |
| 1566 } | 1566 } |
| 1567 void CXFA_FM2JSContext::Time(FXJSE_HOBJECT hThis, | 1567 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, |
| 1568 const CFX_ByteStringC& szFuncName, | 1568 const CFX_ByteStringC& szFuncName, |
| 1569 CFXJSE_Arguments& args) { | 1569 CFXJSE_Arguments& args) { |
| 1570 if (args.GetLength() == 0) { | 1570 if (args.GetLength() == 0) { |
| 1571 time_t now; | 1571 time_t now; |
| 1572 time(&now); | 1572 time(&now); |
| 1573 struct tm* pGmt = gmtime(&now); | 1573 struct tm* pGmt = gmtime(&now); |
| 1574 int32_t iGMHour = pGmt->tm_hour; | 1574 int32_t iGMHour = pGmt->tm_hour; |
| 1575 int32_t iGMMin = pGmt->tm_min; | 1575 int32_t iGMMin = pGmt->tm_min; |
| 1576 int32_t iGMSec = pGmt->tm_sec; | 1576 int32_t iGMSec = pGmt->tm_sec; |
| 1577 FXJSE_Value_SetInteger(args.GetReturnValue(), | 1577 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 1578 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); | 1578 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); |
| 1579 } else { | 1579 } else { |
| 1580 CXFA_FM2JSContext* pContext = | 1580 CXFA_FM2JSContext* pContext = |
| 1581 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1581 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1582 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1582 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1583 L"Time"); | 1583 L"Time"); |
| 1584 } | 1584 } |
| 1585 } | 1585 } |
| 1586 void CXFA_FM2JSContext::Time2Num(FXJSE_HOBJECT hThis, | 1586 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, |
| 1587 const CFX_ByteStringC& szFuncName, | 1587 const CFX_ByteStringC& szFuncName, |
| 1588 CFXJSE_Arguments& args) { | 1588 CFXJSE_Arguments& args) { |
| 1589 int32_t argc = args.GetLength(); | 1589 int32_t argc = args.GetLength(); |
| 1590 if ((argc > 0) && (argc < 4)) { | 1590 if ((argc > 0) && (argc < 4)) { |
| 1591 FX_BOOL bFlags = FALSE; | 1591 FX_BOOL bFlags = FALSE; |
| 1592 CFX_ByteString timeString; | 1592 CFX_ByteString timeString; |
| 1593 CFX_ByteString formatString; | 1593 CFX_ByteString formatString; |
| 1594 CFX_ByteString localString; | 1594 CFX_ByteString localString; |
| 1595 FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); | 1595 CFXJSE_Value* timeValue = GetSimpleValue(pThis, args, 0); |
| 1596 FXJSE_HVALUE formatValue = 0; | 1596 CFXJSE_Value* formatValue = nullptr; |
| 1597 FXJSE_HVALUE localValue = 0; | 1597 CFXJSE_Value* localValue = nullptr; |
| 1598 if (HValueIsNull(hThis, timeValue)) { | 1598 if (ValueIsNull(pThis, timeValue)) { |
| 1599 bFlags = TRUE; | 1599 bFlags = TRUE; |
| 1600 } else { | 1600 } else { |
| 1601 HValueToUTF8String(timeValue, timeString); | 1601 ValueToUTF8String(timeValue, timeString); |
| 1602 } | 1602 } |
| 1603 if (argc > 1) { | 1603 if (argc > 1) { |
| 1604 formatValue = GetSimpleHValue(hThis, args, 1); | 1604 formatValue = GetSimpleValue(pThis, args, 1); |
| 1605 if (HValueIsNull(hThis, formatValue)) { | 1605 if (ValueIsNull(pThis, formatValue)) { |
| 1606 bFlags = TRUE; | 1606 bFlags = TRUE; |
| 1607 } else { | 1607 } else { |
| 1608 HValueToUTF8String(formatValue, formatString); | 1608 ValueToUTF8String(formatValue, formatString); |
| 1609 } | 1609 } |
| 1610 } | 1610 } |
| 1611 if (argc == 3) { | 1611 if (argc == 3) { |
| 1612 localValue = GetSimpleHValue(hThis, args, 2); | 1612 localValue = GetSimpleValue(pThis, args, 2); |
| 1613 if (HValueIsNull(hThis, localValue)) { | 1613 if (ValueIsNull(pThis, localValue)) { |
| 1614 bFlags = TRUE; | 1614 bFlags = TRUE; |
| 1615 } else { | 1615 } else { |
| 1616 HValueToUTF8String(localValue, localString); | 1616 ValueToUTF8String(localValue, localString); |
| 1617 } | 1617 } |
| 1618 } | 1618 } |
| 1619 if (!bFlags) { | 1619 if (!bFlags) { |
| 1620 CXFA_FM2JSContext* pContext = | 1620 CXFA_FM2JSContext* pContext = |
| 1621 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1621 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1622 CXFA_Document* pDoc = pContext->GetDocument(); | 1622 CXFA_Document* pDoc = pContext->GetDocument(); |
| 1623 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 1623 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 1624 IFX_Locale* pLocale = NULL; | 1624 IFX_Locale* pLocale = NULL; |
| 1625 if (localString.IsEmpty()) { | 1625 if (localString.IsEmpty()) { |
| 1626 CXFA_Node* pThisNode = | 1626 CXFA_Node* pThisNode = |
| 1627 ToNode(pDoc->GetScriptContext()->GetThisObject()); | 1627 ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 1628 ASSERT(pThisNode); | 1628 ASSERT(pThisNode); |
| 1629 CXFA_WidgetData widgetData(pThisNode); | 1629 CXFA_WidgetData widgetData(pThisNode); |
| 1630 pLocale = widgetData.GetLocal(); | 1630 pLocale = widgetData.GetLocal(); |
| 1631 } else { | 1631 } else { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 } | 1675 } |
| 1676 FXJSE_Value_Release(timeValue); | 1676 FXJSE_Value_Release(timeValue); |
| 1677 if (argc > 1) { | 1677 if (argc > 1) { |
| 1678 FXJSE_Value_Release(formatValue); | 1678 FXJSE_Value_Release(formatValue); |
| 1679 if (argc == 3) { | 1679 if (argc == 3) { |
| 1680 FXJSE_Value_Release(localValue); | 1680 FXJSE_Value_Release(localValue); |
| 1681 } | 1681 } |
| 1682 } | 1682 } |
| 1683 } else { | 1683 } else { |
| 1684 CXFA_FM2JSContext* pContext = | 1684 CXFA_FM2JSContext* pContext = |
| 1685 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1685 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1686 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1686 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1687 L"Time2Num"); | 1687 L"Time2Num"); |
| 1688 } | 1688 } |
| 1689 } | 1689 } |
| 1690 void CXFA_FM2JSContext::TimeFmt(FXJSE_HOBJECT hThis, | 1690 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, |
| 1691 const CFX_ByteStringC& szFuncName, | 1691 const CFX_ByteStringC& szFuncName, |
| 1692 CFXJSE_Arguments& args) { | 1692 CFXJSE_Arguments& args) { |
| 1693 int32_t argc = args.GetLength(); | 1693 int32_t argc = args.GetLength(); |
| 1694 if (argc < 3) { | 1694 if (argc < 3) { |
| 1695 FX_BOOL bFlags = FALSE; | 1695 FX_BOOL bFlags = FALSE; |
| 1696 int32_t iStyle = 0; | 1696 int32_t iStyle = 0; |
| 1697 CFX_ByteString szLocal; | 1697 CFX_ByteString szLocal; |
| 1698 FXJSE_HVALUE argStyle = 0; | 1698 CFXJSE_Value* argStyle = nullptr; |
| 1699 FXJSE_HVALUE argLocal = 0; | 1699 CFXJSE_Value* argLocal = nullptr; |
| 1700 if (argc > 0) { | 1700 if (argc > 0) { |
| 1701 argStyle = GetSimpleHValue(hThis, args, 0); | 1701 argStyle = GetSimpleValue(pThis, args, 0); |
| 1702 if (FXJSE_Value_IsNull(argStyle)) { | 1702 if (FXJSE_Value_IsNull(argStyle)) { |
| 1703 bFlags = TRUE; | 1703 bFlags = TRUE; |
| 1704 } | 1704 } |
| 1705 iStyle = (int32_t)HValueToFloat(hThis, argStyle); | 1705 iStyle = (int32_t)ValueToFloat(pThis, argStyle); |
| 1706 if (iStyle > 4 || iStyle < 0) { | 1706 if (iStyle > 4 || iStyle < 0) { |
| 1707 iStyle = 0; | 1707 iStyle = 0; |
| 1708 } | 1708 } |
| 1709 } | 1709 } |
| 1710 if (argc == 2) { | 1710 if (argc == 2) { |
| 1711 argLocal = GetSimpleHValue(hThis, args, 1); | 1711 argLocal = GetSimpleValue(pThis, args, 1); |
| 1712 if (FXJSE_Value_IsNull(argLocal)) { | 1712 if (FXJSE_Value_IsNull(argLocal)) { |
| 1713 bFlags = TRUE; | 1713 bFlags = TRUE; |
| 1714 } else { | 1714 } else { |
| 1715 HValueToUTF8String(argLocal, szLocal); | 1715 ValueToUTF8String(argLocal, szLocal); |
| 1716 } | 1716 } |
| 1717 } | 1717 } |
| 1718 if (!bFlags) { | 1718 if (!bFlags) { |
| 1719 CFX_ByteString formatStr; | 1719 CFX_ByteString formatStr; |
| 1720 GetStandardTimeFormat(hThis, iStyle, szLocal.AsStringC(), formatStr); | 1720 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); |
| 1721 if (formatStr.IsEmpty()) { | 1721 if (formatStr.IsEmpty()) { |
| 1722 formatStr = ""; | 1722 formatStr = ""; |
| 1723 } | 1723 } |
| 1724 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1724 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1725 } else { | 1725 } else { |
| 1726 FXJSE_Value_SetNull(args.GetReturnValue()); | 1726 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1727 } | 1727 } |
| 1728 if (argc > 0) { | 1728 if (argc > 0) { |
| 1729 FXJSE_Value_Release(argStyle); | 1729 FXJSE_Value_Release(argStyle); |
| 1730 if (argc == 2) { | 1730 if (argc == 2) { |
| 1731 FXJSE_Value_Release(argLocal); | 1731 FXJSE_Value_Release(argLocal); |
| 1732 } | 1732 } |
| 1733 } | 1733 } |
| 1734 } else { | 1734 } else { |
| 1735 CXFA_FM2JSContext* pContext = | 1735 CXFA_FM2JSContext* pContext = |
| 1736 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 1736 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1737 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1737 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1738 L"TimeFmt"); | 1738 L"TimeFmt"); |
| 1739 } | 1739 } |
| 1740 } | 1740 } |
| 1741 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, | 1741 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, |
| 1742 int32_t iLength, | 1742 int32_t iLength, |
| 1743 int32_t& iStyle, | 1743 int32_t& iStyle, |
| 1744 int32_t& iYear, | 1744 int32_t& iYear, |
| 1745 int32_t& iMonth, | 1745 int32_t& iMonth, |
| 1746 int32_t& iDay) { | 1746 int32_t& iDay) { |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 return iRet; | 2050 return iRet; |
| 2051 } | 2051 } |
| 2052 iRet = IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute, | 2052 iRet = IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute, |
| 2053 iSecond, iMillionSecond, iZoneHour, iZoneMinute); | 2053 iSecond, iMillionSecond, iZoneHour, iZoneMinute); |
| 2054 if (!iRet) { | 2054 if (!iRet) { |
| 2055 return iRet; | 2055 return iRet; |
| 2056 } | 2056 } |
| 2057 iRet = TRUE; | 2057 iRet = TRUE; |
| 2058 return iRet; | 2058 return iRet; |
| 2059 } | 2059 } |
| 2060 FX_BOOL CXFA_FM2JSContext::Local2IsoDate(FXJSE_HOBJECT hThis, | 2060 FX_BOOL CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis, |
| 2061 const CFX_ByteStringC& szDate, | 2061 const CFX_ByteStringC& szDate, |
| 2062 const CFX_ByteStringC& szFormat, | 2062 const CFX_ByteStringC& szFormat, |
| 2063 const CFX_ByteStringC& szLocale, | 2063 const CFX_ByteStringC& szLocale, |
| 2064 CFX_ByteString& strIsoDate) { | 2064 CFX_ByteString& strIsoDate) { |
| 2065 CXFA_FM2JSContext* pContext = | 2065 CXFA_FM2JSContext* pContext = |
| 2066 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2066 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2067 CXFA_Document* pDoc = pContext->GetDocument(); | 2067 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2068 if (!pDoc) { | 2068 if (!pDoc) { |
| 2069 return FALSE; | 2069 return FALSE; |
| 2070 } | 2070 } |
| 2071 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2071 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2072 IFX_Locale* pLocale = NULL; | 2072 IFX_Locale* pLocale = NULL; |
| 2073 if (szLocale.IsEmpty()) { | 2073 if (szLocale.IsEmpty()) { |
| 2074 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2074 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2075 ASSERT(pThisNode); | 2075 ASSERT(pThisNode); |
| 2076 CXFA_WidgetData widgetData(pThisNode); | 2076 CXFA_WidgetData widgetData(pThisNode); |
| 2077 pLocale = widgetData.GetLocal(); | 2077 pLocale = widgetData.GetLocal(); |
| 2078 } else { | 2078 } else { |
| 2079 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); | 2079 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); |
| 2080 } | 2080 } |
| 2081 if (!pLocale) { | 2081 if (!pLocale) { |
| 2082 return FALSE; | 2082 return FALSE; |
| 2083 } | 2083 } |
| 2084 CFX_WideString wsFormat; | 2084 CFX_WideString wsFormat; |
| 2085 if (szFormat.IsEmpty()) { | 2085 if (szFormat.IsEmpty()) { |
| 2086 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2086 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2087 } else { | 2087 } else { |
| 2088 wsFormat = CFX_WideString::FromUTF8(szFormat); | 2088 wsFormat = CFX_WideString::FromUTF8(szFormat); |
| 2089 } | 2089 } |
| 2090 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), | 2090 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), |
| 2091 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | 2091 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
| 2092 CFX_Unitime dt = widgetValue.GetDate(); | 2092 CFX_Unitime dt = widgetValue.GetDate(); |
| 2093 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); | 2093 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); |
| 2094 return TRUE; | 2094 return TRUE; |
| 2095 } | 2095 } |
| 2096 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis, | 2096 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis, |
| 2097 const CFX_ByteStringC& szTime, | 2097 const CFX_ByteStringC& szTime, |
| 2098 const CFX_ByteStringC& szFormat, | 2098 const CFX_ByteStringC& szFormat, |
| 2099 const CFX_ByteStringC& szLocale, | 2099 const CFX_ByteStringC& szLocale, |
| 2100 CFX_ByteString& strIsoTime) { | 2100 CFX_ByteString& strIsoTime) { |
| 2101 CXFA_FM2JSContext* pContext = | 2101 CXFA_FM2JSContext* pContext = |
| 2102 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2102 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2103 CXFA_Document* pDoc = pContext->GetDocument(); | 2103 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2104 if (!pDoc) { | 2104 if (!pDoc) { |
| 2105 return FALSE; | 2105 return FALSE; |
| 2106 } | 2106 } |
| 2107 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2107 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2108 IFX_Locale* pLocale = NULL; | 2108 IFX_Locale* pLocale = NULL; |
| 2109 if (szLocale.IsEmpty()) { | 2109 if (szLocale.IsEmpty()) { |
| 2110 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2110 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2111 ASSERT(pThisNode); | 2111 ASSERT(pThisNode); |
| 2112 CXFA_WidgetData widgetData(pThisNode); | 2112 CXFA_WidgetData widgetData(pThisNode); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2125 } | 2125 } |
| 2126 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2126 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2127 wsFormat += FX_WSTRC(L"}"); | 2127 wsFormat += FX_WSTRC(L"}"); |
| 2128 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), | 2128 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
| 2129 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | 2129 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
| 2130 CFX_Unitime utime = widgetValue.GetTime(); | 2130 CFX_Unitime utime = widgetValue.GetTime(); |
| 2131 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), | 2131 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), |
| 2132 utime.GetSecond(), utime.GetMillisecond()); | 2132 utime.GetSecond(), utime.GetMillisecond()); |
| 2133 return TRUE; | 2133 return TRUE; |
| 2134 } | 2134 } |
| 2135 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis, | 2135 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis, |
| 2136 const CFX_ByteStringC& szDate, | 2136 const CFX_ByteStringC& szDate, |
| 2137 const CFX_ByteStringC& szFormat, | 2137 const CFX_ByteStringC& szFormat, |
| 2138 const CFX_ByteStringC& szLocale, | 2138 const CFX_ByteStringC& szLocale, |
| 2139 CFX_ByteString& strLocalDate) { | 2139 CFX_ByteString& strLocalDate) { |
| 2140 CXFA_FM2JSContext* pContext = | 2140 CXFA_FM2JSContext* pContext = |
| 2141 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2141 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2142 CXFA_Document* pDoc = pContext->GetDocument(); | 2142 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2143 if (!pDoc) { | 2143 if (!pDoc) { |
| 2144 return FALSE; | 2144 return FALSE; |
| 2145 } | 2145 } |
| 2146 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2146 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2147 IFX_Locale* pLocale = NULL; | 2147 IFX_Locale* pLocale = NULL; |
| 2148 if (szLocale.IsEmpty()) { | 2148 if (szLocale.IsEmpty()) { |
| 2149 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2149 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2150 ASSERT(pThisNode); | 2150 ASSERT(pThisNode); |
| 2151 CXFA_WidgetData widgetData(pThisNode); | 2151 CXFA_WidgetData widgetData(pThisNode); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2163 wsFormat = CFX_WideString::FromUTF8(szFormat); | 2163 wsFormat = CFX_WideString::FromUTF8(szFormat); |
| 2164 } | 2164 } |
| 2165 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), | 2165 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), |
| 2166 (CXFA_LocaleMgr*)pMgr); | 2166 (CXFA_LocaleMgr*)pMgr); |
| 2167 CFX_WideString wsRet; | 2167 CFX_WideString wsRet; |
| 2168 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2168 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2169 XFA_VALUEPICTURE_Display); | 2169 XFA_VALUEPICTURE_Display); |
| 2170 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); | 2170 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); |
| 2171 return TRUE; | 2171 return TRUE; |
| 2172 } | 2172 } |
| 2173 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis, | 2173 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis, |
| 2174 const CFX_ByteStringC& szTime, | 2174 const CFX_ByteStringC& szTime, |
| 2175 const CFX_ByteStringC& szFormat, | 2175 const CFX_ByteStringC& szFormat, |
| 2176 const CFX_ByteStringC& szLocale, | 2176 const CFX_ByteStringC& szLocale, |
| 2177 CFX_ByteString& strLocalTime) { | 2177 CFX_ByteString& strLocalTime) { |
| 2178 CXFA_FM2JSContext* pContext = | 2178 CXFA_FM2JSContext* pContext = |
| 2179 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2179 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2180 CXFA_Document* pDoc = pContext->GetDocument(); | 2180 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2181 if (!pDoc) { | 2181 if (!pDoc) { |
| 2182 return FALSE; | 2182 return FALSE; |
| 2183 } | 2183 } |
| 2184 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2184 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2185 IFX_Locale* pLocale = NULL; | 2185 IFX_Locale* pLocale = NULL; |
| 2186 if (szLocale.IsEmpty()) { | 2186 if (szLocale.IsEmpty()) { |
| 2187 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2187 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2188 ASSERT(pThisNode); | 2188 ASSERT(pThisNode); |
| 2189 CXFA_WidgetData widgetData(pThisNode); | 2189 CXFA_WidgetData widgetData(pThisNode); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2203 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2203 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2204 wsFormat += FX_WSTRC(L"}"); | 2204 wsFormat += FX_WSTRC(L"}"); |
| 2205 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), | 2205 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
| 2206 (CXFA_LocaleMgr*)pMgr); | 2206 (CXFA_LocaleMgr*)pMgr); |
| 2207 CFX_WideString wsRet; | 2207 CFX_WideString wsRet; |
| 2208 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2208 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2209 XFA_VALUEPICTURE_Display); | 2209 XFA_VALUEPICTURE_Display); |
| 2210 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); | 2210 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); |
| 2211 return TRUE; | 2211 return TRUE; |
| 2212 } | 2212 } |
| 2213 FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis, | 2213 FX_BOOL CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis, |
| 2214 const CFX_ByteStringC& szTime, | 2214 const CFX_ByteStringC& szTime, |
| 2215 const CFX_ByteStringC& szFormat, | 2215 const CFX_ByteStringC& szFormat, |
| 2216 const CFX_ByteStringC& szLocale, | 2216 const CFX_ByteStringC& szLocale, |
| 2217 CFX_ByteString& strGMTTime) { | 2217 CFX_ByteString& strGMTTime) { |
| 2218 CXFA_FM2JSContext* pContext = | 2218 CXFA_FM2JSContext* pContext = |
| 2219 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2219 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2220 CXFA_Document* pDoc = pContext->GetDocument(); | 2220 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2221 if (!pDoc) { | 2221 if (!pDoc) { |
| 2222 return FALSE; | 2222 return FALSE; |
| 2223 } | 2223 } |
| 2224 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2224 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2225 IFX_Locale* pLocale = NULL; | 2225 IFX_Locale* pLocale = NULL; |
| 2226 if (szLocale.IsEmpty()) { | 2226 if (szLocale.IsEmpty()) { |
| 2227 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2227 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2228 ASSERT(pThisNode); | 2228 ASSERT(pThisNode); |
| 2229 CXFA_WidgetData widgetData(pThisNode); | 2229 CXFA_WidgetData widgetData(pThisNode); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 while (iDay - i > 0) { | 2316 while (iDay - i > 0) { |
| 2317 dDays += 1; | 2317 dDays += 1; |
| 2318 ++i; | 2318 ++i; |
| 2319 } | 2319 } |
| 2320 } else { | 2320 } else { |
| 2321 dDays = 0; | 2321 dDays = 0; |
| 2322 } | 2322 } |
| 2323 return (int32_t)dDays; | 2323 return (int32_t)dDays; |
| 2324 } | 2324 } |
| 2325 | 2325 |
| 2326 void CXFA_FM2JSContext::GetLocalDateFormat(FXJSE_HOBJECT hThis, | 2326 void CXFA_FM2JSContext::GetLocalDateFormat(CFXJSE_Value* pThis, |
| 2327 int32_t iStyle, | 2327 int32_t iStyle, |
| 2328 const CFX_ByteStringC& szLocalStr, | 2328 const CFX_ByteStringC& szLocalStr, |
| 2329 CFX_ByteString& strFormat, | 2329 CFX_ByteString& strFormat, |
| 2330 FX_BOOL bStandard) { | 2330 FX_BOOL bStandard) { |
| 2331 FX_LOCALEDATETIMESUBCATEGORY strStyle; | 2331 FX_LOCALEDATETIMESUBCATEGORY strStyle; |
| 2332 switch (iStyle) { | 2332 switch (iStyle) { |
| 2333 case 0: | 2333 case 0: |
| 2334 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2334 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2335 break; | 2335 break; |
| 2336 case 1: | 2336 case 1: |
| 2337 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; | 2337 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; |
| 2338 break; | 2338 break; |
| 2339 case 2: | 2339 case 2: |
| 2340 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2340 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2341 break; | 2341 break; |
| 2342 case 3: | 2342 case 3: |
| 2343 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; | 2343 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; |
| 2344 break; | 2344 break; |
| 2345 case 4: | 2345 case 4: |
| 2346 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; | 2346 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; |
| 2347 break; | 2347 break; |
| 2348 default: | 2348 default: |
| 2349 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2349 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2350 break; | 2350 break; |
| 2351 } | 2351 } |
| 2352 CXFA_FM2JSContext* pContext = | 2352 CXFA_FM2JSContext* pContext = |
| 2353 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2353 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2354 CXFA_Document* pDoc = pContext->GetDocument(); | 2354 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2355 if (!pDoc) { | 2355 if (!pDoc) { |
| 2356 return; | 2356 return; |
| 2357 } | 2357 } |
| 2358 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2358 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2359 IFX_Locale* pLocale = NULL; | 2359 IFX_Locale* pLocale = NULL; |
| 2360 if (szLocalStr.IsEmpty()) { | 2360 if (szLocalStr.IsEmpty()) { |
| 2361 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2361 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2362 ASSERT(pThisNode); | 2362 ASSERT(pThisNode); |
| 2363 CXFA_WidgetData widgetData(pThisNode); | 2363 CXFA_WidgetData widgetData(pThisNode); |
| 2364 pLocale = widgetData.GetLocal(); | 2364 pLocale = widgetData.GetLocal(); |
| 2365 } else { | 2365 } else { |
| 2366 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); | 2366 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); |
| 2367 } | 2367 } |
| 2368 if (!pLocale) { | 2368 if (!pLocale) { |
| 2369 return; | 2369 return; |
| 2370 } | 2370 } |
| 2371 CFX_WideString strRet; | 2371 CFX_WideString strRet; |
| 2372 pLocale->GetDatePattern(strStyle, strRet); | 2372 pLocale->GetDatePattern(strStyle, strRet); |
| 2373 if (!bStandard) { | 2373 if (!bStandard) { |
| 2374 CFX_WideString wsSymbols; | 2374 CFX_WideString wsSymbols; |
| 2375 pLocale->GetDateTimeSymbols(wsSymbols); | 2375 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2376 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); | 2376 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); |
| 2377 } | 2377 } |
| 2378 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); | 2378 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); |
| 2379 } | 2379 } |
| 2380 void CXFA_FM2JSContext::GetLocalTimeFormat(FXJSE_HOBJECT hThis, | 2380 void CXFA_FM2JSContext::GetLocalTimeFormat(CFXJSE_Value* pThis, |
| 2381 int32_t iStyle, | 2381 int32_t iStyle, |
| 2382 const CFX_ByteStringC& szLocalStr, | 2382 const CFX_ByteStringC& szLocalStr, |
| 2383 CFX_ByteString& strFormat, | 2383 CFX_ByteString& strFormat, |
| 2384 FX_BOOL bStandard) { | 2384 FX_BOOL bStandard) { |
| 2385 FX_LOCALEDATETIMESUBCATEGORY strStyle; | 2385 FX_LOCALEDATETIMESUBCATEGORY strStyle; |
| 2386 switch (iStyle) { | 2386 switch (iStyle) { |
| 2387 case 0: | 2387 case 0: |
| 2388 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2388 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2389 break; | 2389 break; |
| 2390 case 1: | 2390 case 1: |
| 2391 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; | 2391 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; |
| 2392 break; | 2392 break; |
| 2393 case 2: | 2393 case 2: |
| 2394 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2394 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2395 break; | 2395 break; |
| 2396 case 3: | 2396 case 3: |
| 2397 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; | 2397 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; |
| 2398 break; | 2398 break; |
| 2399 case 4: | 2399 case 4: |
| 2400 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; | 2400 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; |
| 2401 break; | 2401 break; |
| 2402 default: | 2402 default: |
| 2403 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2403 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2404 break; | 2404 break; |
| 2405 } | 2405 } |
| 2406 CXFA_FM2JSContext* pContext = | 2406 CXFA_FM2JSContext* pContext = |
| 2407 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2407 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2408 CXFA_Document* pDoc = pContext->GetDocument(); | 2408 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2409 if (!pDoc) { | 2409 if (!pDoc) { |
| 2410 return; | 2410 return; |
| 2411 } | 2411 } |
| 2412 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2412 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2413 IFX_Locale* pLocale = NULL; | 2413 IFX_Locale* pLocale = NULL; |
| 2414 if (szLocalStr.IsEmpty()) { | 2414 if (szLocalStr.IsEmpty()) { |
| 2415 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2415 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2416 ASSERT(pThisNode); | 2416 ASSERT(pThisNode); |
| 2417 CXFA_WidgetData widgetData(pThisNode); | 2417 CXFA_WidgetData widgetData(pThisNode); |
| 2418 pLocale = widgetData.GetLocal(); | 2418 pLocale = widgetData.GetLocal(); |
| 2419 } else { | 2419 } else { |
| 2420 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); | 2420 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); |
| 2421 } | 2421 } |
| 2422 if (!pLocale) { | 2422 if (!pLocale) { |
| 2423 return; | 2423 return; |
| 2424 } | 2424 } |
| 2425 CFX_WideString strRet; | 2425 CFX_WideString strRet; |
| 2426 pLocale->GetTimePattern(strStyle, strRet); | 2426 pLocale->GetTimePattern(strStyle, strRet); |
| 2427 if (!bStandard) { | 2427 if (!bStandard) { |
| 2428 CFX_WideString wsSymbols; | 2428 CFX_WideString wsSymbols; |
| 2429 pLocale->GetDateTimeSymbols(wsSymbols); | 2429 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2430 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); | 2430 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); |
| 2431 } | 2431 } |
| 2432 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); | 2432 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); |
| 2433 } | 2433 } |
| 2434 void CXFA_FM2JSContext::GetStandardDateFormat(FXJSE_HOBJECT hThis, | 2434 void CXFA_FM2JSContext::GetStandardDateFormat(CFXJSE_Value* pThis, |
| 2435 int32_t iStyle, | 2435 int32_t iStyle, |
| 2436 const CFX_ByteStringC& szLocalStr, | 2436 const CFX_ByteStringC& szLocalStr, |
| 2437 CFX_ByteString& strFormat) { | 2437 CFX_ByteString& strFormat) { |
| 2438 GetLocalDateFormat(hThis, iStyle, szLocalStr, strFormat, TRUE); | 2438 GetLocalDateFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); |
| 2439 } | 2439 } |
| 2440 void CXFA_FM2JSContext::GetStandardTimeFormat(FXJSE_HOBJECT hThis, | 2440 void CXFA_FM2JSContext::GetStandardTimeFormat(CFXJSE_Value* pThis, |
| 2441 int32_t iStyle, | 2441 int32_t iStyle, |
| 2442 const CFX_ByteStringC& szLocalStr, | 2442 const CFX_ByteStringC& szLocalStr, |
| 2443 CFX_ByteString& strFormat) { | 2443 CFX_ByteString& strFormat) { |
| 2444 GetLocalTimeFormat(hThis, iStyle, szLocalStr, strFormat, TRUE); | 2444 GetLocalTimeFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); |
| 2445 } | 2445 } |
| 2446 void CXFA_FM2JSContext::Num2AllTime(FXJSE_HOBJECT hThis, | 2446 void CXFA_FM2JSContext::Num2AllTime(CFXJSE_Value* pThis, |
| 2447 int32_t iTime, | 2447 int32_t iTime, |
| 2448 const CFX_ByteStringC& szFormat, | 2448 const CFX_ByteStringC& szFormat, |
| 2449 const CFX_ByteStringC& szLocale, | 2449 const CFX_ByteStringC& szLocale, |
| 2450 FX_BOOL bGM, | 2450 FX_BOOL bGM, |
| 2451 CFX_ByteString& strTime) { | 2451 CFX_ByteString& strTime) { |
| 2452 int32_t iHour = 0; | 2452 int32_t iHour = 0; |
| 2453 int32_t iMin = 0; | 2453 int32_t iMin = 0; |
| 2454 int32_t iSec = 0; | 2454 int32_t iSec = 0; |
| 2455 int32_t iZoneHour = 0; | 2455 int32_t iZoneHour = 0; |
| 2456 int32_t iZoneMin = 0; | 2456 int32_t iZoneMin = 0; |
| 2457 int32_t iZoneSec = 0; | 2457 int32_t iZoneSec = 0; |
| 2458 iHour = static_cast<int>(iTime) / 3600000; | 2458 iHour = static_cast<int>(iTime) / 3600000; |
| 2459 iMin = (static_cast<int>(iTime) - iHour * 3600000) / 60000; | 2459 iMin = (static_cast<int>(iTime) - iHour * 3600000) / 60000; |
| 2460 iSec = (static_cast<int>(iTime) - iHour * 3600000 - iMin * 60000) / 1000; | 2460 iSec = (static_cast<int>(iTime) - iHour * 3600000 - iMin * 60000) / 1000; |
| 2461 if (!bGM) { | 2461 if (!bGM) { |
| 2462 GetLocalTimeZone(iZoneHour, iZoneMin, iZoneSec); | 2462 GetLocalTimeZone(iZoneHour, iZoneMin, iZoneSec); |
| 2463 iHour += iZoneHour; | 2463 iHour += iZoneHour; |
| 2464 iMin += iZoneMin; | 2464 iMin += iZoneMin; |
| 2465 iSec += iZoneSec; | 2465 iSec += iZoneSec; |
| 2466 } | 2466 } |
| 2467 int32_t iRet = 0; | 2467 int32_t iRet = 0; |
| 2468 CFX_ByteString strIsoTime; | 2468 CFX_ByteString strIsoTime; |
| 2469 strIsoTime.Format("%02d:%02d:%02d", iHour, iMin, iSec); | 2469 strIsoTime.Format("%02d:%02d:%02d", iHour, iMin, iSec); |
| 2470 if (bGM) { | 2470 if (bGM) { |
| 2471 iRet = | 2471 iRet = |
| 2472 GetGMTTime(hThis, strIsoTime.AsStringC(), szFormat, szLocale, strTime); | 2472 GetGMTTime(pThis, strIsoTime.AsStringC(), szFormat, szLocale, strTime); |
| 2473 } else { | 2473 } else { |
| 2474 iRet = IsoTime2Local(hThis, strIsoTime.AsStringC(), szFormat, szLocale, | 2474 iRet = IsoTime2Local(pThis, strIsoTime.AsStringC(), szFormat, szLocale, |
| 2475 strTime); | 2475 strTime); |
| 2476 } | 2476 } |
| 2477 if (!iRet) { | 2477 if (!iRet) { |
| 2478 strTime = ""; | 2478 strTime = ""; |
| 2479 } | 2479 } |
| 2480 } | 2480 } |
| 2481 | 2481 |
| 2482 void CXFA_FM2JSContext::GetLocalTimeZone(int32_t& iHour, | 2482 void CXFA_FM2JSContext::GetLocalTimeZone(int32_t& iHour, |
| 2483 int32_t& iMin, | 2483 int32_t& iMin, |
| 2484 int32_t& iSec) { | 2484 int32_t& iSec) { |
| 2485 time_t now; | 2485 time_t now; |
| 2486 time(&now); | 2486 time(&now); |
| 2487 struct tm* pGmt = gmtime(&now); | 2487 struct tm* pGmt = gmtime(&now); |
| 2488 int32_t iGMHour = pGmt->tm_hour; | 2488 int32_t iGMHour = pGmt->tm_hour; |
| 2489 int32_t iGMMin = pGmt->tm_min; | 2489 int32_t iGMMin = pGmt->tm_min; |
| 2490 int32_t iGMSec = pGmt->tm_sec; | 2490 int32_t iGMSec = pGmt->tm_sec; |
| 2491 struct tm* pLocal = localtime(&now); | 2491 struct tm* pLocal = localtime(&now); |
| 2492 int32_t iLocalHour = pLocal->tm_hour; | 2492 int32_t iLocalHour = pLocal->tm_hour; |
| 2493 int32_t iLocalMin = pLocal->tm_min; | 2493 int32_t iLocalMin = pLocal->tm_min; |
| 2494 int32_t iLocalSec = pLocal->tm_sec; | 2494 int32_t iLocalSec = pLocal->tm_sec; |
| 2495 iHour = iLocalHour - iGMHour; | 2495 iHour = iLocalHour - iGMHour; |
| 2496 iMin = iLocalMin - iGMMin; | 2496 iMin = iLocalMin - iGMMin; |
| 2497 iSec = iLocalSec - iGMSec; | 2497 iSec = iLocalSec - iGMSec; |
| 2498 } | 2498 } |
| 2499 void CXFA_FM2JSContext::Apr(FXJSE_HOBJECT hThis, | 2499 void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis, |
| 2500 const CFX_ByteStringC& szFuncName, | 2500 const CFX_ByteStringC& szFuncName, |
| 2501 CFXJSE_Arguments& args) { | 2501 CFXJSE_Arguments& args) { |
| 2502 CXFA_FM2JSContext* pContext = | 2502 CXFA_FM2JSContext* pContext = |
| 2503 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2503 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2504 if (args.GetLength() == 3) { | 2504 if (args.GetLength() == 3) { |
| 2505 FX_BOOL bFlags = FALSE; | 2505 FX_BOOL bFlags = FALSE; |
| 2506 FX_DOUBLE nPrincipal = 0; | 2506 FX_DOUBLE nPrincipal = 0; |
| 2507 FX_DOUBLE nPayment = 0; | 2507 FX_DOUBLE nPayment = 0; |
| 2508 FX_DOUBLE nPeriods = 0; | 2508 FX_DOUBLE nPeriods = 0; |
| 2509 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2509 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2510 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2510 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2511 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2511 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2512 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2512 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2513 HValueIsNull(hThis, argThree)); | 2513 ValueIsNull(pThis, argThree)); |
| 2514 if (bFlags) { | 2514 if (bFlags) { |
| 2515 FXJSE_Value_SetNull(args.GetReturnValue()); | 2515 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2516 } else { | 2516 } else { |
| 2517 nPrincipal = HValueToDouble(hThis, argOne); | 2517 nPrincipal = ValueToDouble(pThis, argOne); |
| 2518 nPayment = HValueToDouble(hThis, argTwo); | 2518 nPayment = ValueToDouble(pThis, argTwo); |
| 2519 nPeriods = HValueToDouble(hThis, argThree); | 2519 nPeriods = ValueToDouble(pThis, argThree); |
| 2520 bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0)); | 2520 bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0)); |
| 2521 if (bFlags) { | 2521 if (bFlags) { |
| 2522 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2522 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2523 } else { | 2523 } else { |
| 2524 FX_DOUBLE r = | 2524 FX_DOUBLE r = |
| 2525 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); | 2525 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); |
| 2526 FX_DOUBLE nTemp = 1; | 2526 FX_DOUBLE nTemp = 1; |
| 2527 for (int32_t i = 0; i < nPeriods; ++i) { | 2527 for (int32_t i = 0; i < nPeriods; ++i) { |
| 2528 nTemp *= (1 + r); | 2528 nTemp *= (1 + r); |
| 2529 } | 2529 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2555 } | 2555 } |
| 2556 } | 2556 } |
| 2557 FXJSE_Value_Release(argOne); | 2557 FXJSE_Value_Release(argOne); |
| 2558 FXJSE_Value_Release(argTwo); | 2558 FXJSE_Value_Release(argTwo); |
| 2559 FXJSE_Value_Release(argThree); | 2559 FXJSE_Value_Release(argThree); |
| 2560 } else { | 2560 } else { |
| 2561 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2561 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2562 L"Apr"); | 2562 L"Apr"); |
| 2563 } | 2563 } |
| 2564 } | 2564 } |
| 2565 void CXFA_FM2JSContext::CTerm(FXJSE_HOBJECT hThis, | 2565 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, |
| 2566 const CFX_ByteStringC& szFuncName, | 2566 const CFX_ByteStringC& szFuncName, |
| 2567 CFXJSE_Arguments& args) { | 2567 CFXJSE_Arguments& args) { |
| 2568 CXFA_FM2JSContext* pContext = | 2568 CXFA_FM2JSContext* pContext = |
| 2569 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2569 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2570 if (args.GetLength() == 3) { | 2570 if (args.GetLength() == 3) { |
| 2571 FX_BOOL bFlags = FALSE; | 2571 FX_BOOL bFlags = FALSE; |
| 2572 FX_FLOAT nRate = 0; | 2572 FX_FLOAT nRate = 0; |
| 2573 FX_FLOAT nFutureValue = 0; | 2573 FX_FLOAT nFutureValue = 0; |
| 2574 FX_FLOAT nInitAmount = 0; | 2574 FX_FLOAT nInitAmount = 0; |
| 2575 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2575 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2576 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2576 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2577 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2577 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2578 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2578 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2579 HValueIsNull(hThis, argThree)); | 2579 ValueIsNull(pThis, argThree)); |
| 2580 if (bFlags) { | 2580 if (bFlags) { |
| 2581 FXJSE_Value_SetNull(args.GetReturnValue()); | 2581 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2582 } else { | 2582 } else { |
| 2583 nRate = HValueToFloat(hThis, argOne); | 2583 nRate = ValueToFloat(pThis, argOne); |
| 2584 nFutureValue = HValueToFloat(hThis, argTwo); | 2584 nFutureValue = ValueToFloat(pThis, argTwo); |
| 2585 nInitAmount = HValueToFloat(hThis, argThree); | 2585 nInitAmount = ValueToFloat(pThis, argThree); |
| 2586 bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)); | 2586 bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)); |
| 2587 if (bFlags) { | 2587 if (bFlags) { |
| 2588 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2588 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2589 } else { | 2589 } else { |
| 2590 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2590 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2591 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / | 2591 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / |
| 2592 FXSYS_log((FX_FLOAT)(1 + nRate))); | 2592 FXSYS_log((FX_FLOAT)(1 + nRate))); |
| 2593 } | 2593 } |
| 2594 } | 2594 } |
| 2595 FXJSE_Value_Release(argOne); | 2595 FXJSE_Value_Release(argOne); |
| 2596 FXJSE_Value_Release(argTwo); | 2596 FXJSE_Value_Release(argTwo); |
| 2597 FXJSE_Value_Release(argThree); | 2597 FXJSE_Value_Release(argThree); |
| 2598 } else { | 2598 } else { |
| 2599 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2599 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2600 L"CTerm"); | 2600 L"CTerm"); |
| 2601 } | 2601 } |
| 2602 } | 2602 } |
| 2603 void CXFA_FM2JSContext::FV(FXJSE_HOBJECT hThis, | 2603 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, |
| 2604 const CFX_ByteStringC& szFuncName, | 2604 const CFX_ByteStringC& szFuncName, |
| 2605 CFXJSE_Arguments& args) { | 2605 CFXJSE_Arguments& args) { |
| 2606 CXFA_FM2JSContext* pContext = | 2606 CXFA_FM2JSContext* pContext = |
| 2607 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2607 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2608 if (args.GetLength() == 3) { | 2608 if (args.GetLength() == 3) { |
| 2609 FX_BOOL bFlags = FALSE; | 2609 FX_BOOL bFlags = FALSE; |
| 2610 FX_DOUBLE nAmount = 0; | 2610 FX_DOUBLE nAmount = 0; |
| 2611 FX_DOUBLE nRate = 0; | 2611 FX_DOUBLE nRate = 0; |
| 2612 FX_DOUBLE nPeriod = 0; | 2612 FX_DOUBLE nPeriod = 0; |
| 2613 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2613 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2614 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2614 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2615 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2615 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2616 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2616 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2617 HValueIsNull(hThis, argThree)); | 2617 ValueIsNull(pThis, argThree)); |
| 2618 if (bFlags) { | 2618 if (bFlags) { |
| 2619 FXJSE_Value_SetNull(args.GetReturnValue()); | 2619 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2620 } else { | 2620 } else { |
| 2621 nAmount = HValueToDouble(hThis, argOne); | 2621 nAmount = ValueToDouble(pThis, argOne); |
| 2622 nRate = HValueToDouble(hThis, argTwo); | 2622 nRate = ValueToDouble(pThis, argTwo); |
| 2623 nPeriod = HValueToDouble(hThis, argThree); | 2623 nPeriod = ValueToDouble(pThis, argThree); |
| 2624 bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)); | 2624 bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)); |
| 2625 if (bFlags) { | 2625 if (bFlags) { |
| 2626 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2626 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2627 } else { | 2627 } else { |
| 2628 FX_DOUBLE dResult = 0; | 2628 FX_DOUBLE dResult = 0; |
| 2629 if (!nRate) { | 2629 if (!nRate) { |
| 2630 dResult = nAmount * nPeriod; | 2630 dResult = nAmount * nPeriod; |
| 2631 } else { | 2631 } else { |
| 2632 FX_DOUBLE nTemp = 1; | 2632 FX_DOUBLE nTemp = 1; |
| 2633 for (int i = 0; i < nPeriod; ++i) { | 2633 for (int i = 0; i < nPeriod; ++i) { |
| 2634 nTemp *= 1 + nRate; | 2634 nTemp *= 1 + nRate; |
| 2635 } | 2635 } |
| 2636 dResult = nAmount * (nTemp - 1) / nRate; | 2636 dResult = nAmount * (nTemp - 1) / nRate; |
| 2637 } | 2637 } |
| 2638 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); | 2638 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); |
| 2639 } | 2639 } |
| 2640 } | 2640 } |
| 2641 FXJSE_Value_Release(argOne); | 2641 FXJSE_Value_Release(argOne); |
| 2642 FXJSE_Value_Release(argTwo); | 2642 FXJSE_Value_Release(argTwo); |
| 2643 FXJSE_Value_Release(argThree); | 2643 FXJSE_Value_Release(argThree); |
| 2644 } else { | 2644 } else { |
| 2645 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2645 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2646 L"FV"); | 2646 L"FV"); |
| 2647 } | 2647 } |
| 2648 } | 2648 } |
| 2649 void CXFA_FM2JSContext::IPmt(FXJSE_HOBJECT hThis, | 2649 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, |
| 2650 const CFX_ByteStringC& szFuncName, | 2650 const CFX_ByteStringC& szFuncName, |
| 2651 CFXJSE_Arguments& args) { | 2651 CFXJSE_Arguments& args) { |
| 2652 CXFA_FM2JSContext* pContext = | 2652 CXFA_FM2JSContext* pContext = |
| 2653 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2653 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2654 if (args.GetLength() == 5) { | 2654 if (args.GetLength() == 5) { |
| 2655 FX_BOOL bFlags = FALSE; | 2655 FX_BOOL bFlags = FALSE; |
| 2656 FX_FLOAT nPrincpalAmount = 0; | 2656 FX_FLOAT nPrincpalAmount = 0; |
| 2657 FX_FLOAT nRate = 0; | 2657 FX_FLOAT nRate = 0; |
| 2658 FX_FLOAT nPayment = 0; | 2658 FX_FLOAT nPayment = 0; |
| 2659 FX_FLOAT nFirstMonth = 0; | 2659 FX_FLOAT nFirstMonth = 0; |
| 2660 FX_FLOAT nNumberOfMonths = 0; | 2660 FX_FLOAT nNumberOfMonths = 0; |
| 2661 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2661 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2662 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2662 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2663 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2663 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2664 FXJSE_HVALUE argFour = GetSimpleHValue(hThis, args, 3); | 2664 CFXJSE_Value* argFour = GetSimpleValue(pThis, args, 3); |
| 2665 FXJSE_HVALUE argFive = GetSimpleHValue(hThis, args, 4); | 2665 CFXJSE_Value* argFive = GetSimpleValue(pThis, args, 4); |
| 2666 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2666 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2667 HValueIsNull(hThis, argThree) || HValueIsNull(hThis, argFour) || | 2667 ValueIsNull(pThis, argThree) || ValueIsNull(pThis, argFour) || |
| 2668 HValueIsNull(hThis, argFive)); | 2668 ValueIsNull(pThis, argFive)); |
| 2669 if (bFlags) { | 2669 if (bFlags) { |
| 2670 FXJSE_Value_SetNull(args.GetReturnValue()); | 2670 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2671 } else { | 2671 } else { |
| 2672 nPrincpalAmount = HValueToFloat(hThis, argOne); | 2672 nPrincpalAmount = ValueToFloat(pThis, argOne); |
| 2673 nRate = HValueToFloat(hThis, argTwo); | 2673 nRate = ValueToFloat(pThis, argTwo); |
| 2674 nPayment = HValueToFloat(hThis, argThree); | 2674 nPayment = ValueToFloat(pThis, argThree); |
| 2675 nFirstMonth = HValueToFloat(hThis, argFour); | 2675 nFirstMonth = ValueToFloat(pThis, argFour); |
| 2676 nNumberOfMonths = HValueToFloat(hThis, argFive); | 2676 nNumberOfMonths = ValueToFloat(pThis, argFive); |
| 2677 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || | 2677 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || |
| 2678 (nFirstMonth < 0) || (nNumberOfMonths < 0)); | 2678 (nFirstMonth < 0) || (nNumberOfMonths < 0)); |
| 2679 if (bFlags) { | 2679 if (bFlags) { |
| 2680 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2680 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2681 } else { | 2681 } else { |
| 2682 FX_FLOAT fResult = 0; | 2682 FX_FLOAT fResult = 0; |
| 2683 FX_FLOAT nRateOfMonth = nRate / 12; | 2683 FX_FLOAT nRateOfMonth = nRate / 12; |
| 2684 int32_t iNums = | 2684 int32_t iNums = |
| 2685 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - | 2685 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - |
| 2686 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - | 2686 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2712 FXJSE_Value_Release(argOne); | 2712 FXJSE_Value_Release(argOne); |
| 2713 FXJSE_Value_Release(argTwo); | 2713 FXJSE_Value_Release(argTwo); |
| 2714 FXJSE_Value_Release(argThree); | 2714 FXJSE_Value_Release(argThree); |
| 2715 FXJSE_Value_Release(argFour); | 2715 FXJSE_Value_Release(argFour); |
| 2716 FXJSE_Value_Release(argFive); | 2716 FXJSE_Value_Release(argFive); |
| 2717 } else { | 2717 } else { |
| 2718 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2718 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2719 L"IPmt"); | 2719 L"IPmt"); |
| 2720 } | 2720 } |
| 2721 } | 2721 } |
| 2722 void CXFA_FM2JSContext::NPV(FXJSE_HOBJECT hThis, | 2722 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, |
| 2723 const CFX_ByteStringC& szFuncName, | 2723 const CFX_ByteStringC& szFuncName, |
| 2724 CFXJSE_Arguments& args) { | 2724 CFXJSE_Arguments& args) { |
| 2725 CXFA_FM2JSContext* pContext = | 2725 CXFA_FM2JSContext* pContext = |
| 2726 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2726 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2727 int32_t argc = args.GetLength(); | 2727 int32_t argc = args.GetLength(); |
| 2728 if (argc > 2) { | 2728 if (argc > 2) { |
| 2729 FX_BOOL bFlags = FALSE; | 2729 FX_BOOL bFlags = FALSE; |
| 2730 FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argc); | 2730 CFXJSE_Value** argValues = FX_Alloc(CFXJSE_Value*, argc); |
| 2731 for (int32_t i = 0; i < argc; i++) { | 2731 for (int32_t i = 0; i < argc; i++) { |
| 2732 argValues[i] = GetSimpleHValue(hThis, args, i); | 2732 argValues[i] = GetSimpleValue(pThis, args, i); |
| 2733 if (HValueIsNull(hThis, argValues[i])) { | 2733 if (ValueIsNull(pThis, argValues[i])) { |
| 2734 bFlags = TRUE; | 2734 bFlags = TRUE; |
| 2735 } | 2735 } |
| 2736 } | 2736 } |
| 2737 if (!bFlags) { | 2737 if (!bFlags) { |
| 2738 FX_DOUBLE nRate = 0; | 2738 FX_DOUBLE nRate = 0; |
| 2739 nRate = HValueToDouble(hThis, argValues[0]); | 2739 nRate = ValueToDouble(pThis, argValues[0]); |
| 2740 if (nRate <= 0) { | 2740 if (nRate <= 0) { |
| 2741 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2741 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2742 } else { | 2742 } else { |
| 2743 FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1); | 2743 FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1); |
| 2744 for (int32_t i = 1; i < argc; i++) { | 2744 for (int32_t i = 1; i < argc; i++) { |
| 2745 pData[i - 1] = HValueToDouble(hThis, argValues[i]); | 2745 pData[i - 1] = ValueToDouble(pThis, argValues[i]); |
| 2746 } | 2746 } |
| 2747 FX_DOUBLE nSum = 0; | 2747 FX_DOUBLE nSum = 0; |
| 2748 int32_t iIndex = 0; | 2748 int32_t iIndex = 0; |
| 2749 for (int32_t i = 0; i < argc - 1; i++) { | 2749 for (int32_t i = 0; i < argc - 1; i++) { |
| 2750 FX_DOUBLE nTemp = 1; | 2750 FX_DOUBLE nTemp = 1; |
| 2751 for (int32_t j = 0; j <= i; j++) { | 2751 for (int32_t j = 0; j <= i; j++) { |
| 2752 nTemp *= 1 + nRate; | 2752 nTemp *= 1 + nRate; |
| 2753 } | 2753 } |
| 2754 FX_DOUBLE nNum = *(pData + iIndex++); | 2754 FX_DOUBLE nNum = *(pData + iIndex++); |
| 2755 nSum += nNum / nTemp; | 2755 nSum += nNum / nTemp; |
| 2756 } | 2756 } |
| 2757 FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); | 2757 FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); |
| 2758 FX_Free(pData); | 2758 FX_Free(pData); |
| 2759 pData = 0; | 2759 pData = 0; |
| 2760 } | 2760 } |
| 2761 } else { | 2761 } else { |
| 2762 FXJSE_Value_SetNull(args.GetReturnValue()); | 2762 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2763 } | 2763 } |
| 2764 for (int32_t i = 0; i < argc; i++) { | 2764 for (int32_t i = 0; i < argc; i++) { |
| 2765 FXJSE_Value_Release(argValues[i]); | 2765 FXJSE_Value_Release(argValues[i]); |
| 2766 } | 2766 } |
| 2767 FX_Free(argValues); | 2767 FX_Free(argValues); |
| 2768 } else { | 2768 } else { |
| 2769 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2769 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2770 L"NPV"); | 2770 L"NPV"); |
| 2771 } | 2771 } |
| 2772 } | 2772 } |
| 2773 void CXFA_FM2JSContext::Pmt(FXJSE_HOBJECT hThis, | 2773 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, |
| 2774 const CFX_ByteStringC& szFuncName, | 2774 const CFX_ByteStringC& szFuncName, |
| 2775 CFXJSE_Arguments& args) { | 2775 CFXJSE_Arguments& args) { |
| 2776 CXFA_FM2JSContext* pContext = | 2776 CXFA_FM2JSContext* pContext = |
| 2777 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2777 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2778 if (args.GetLength() == 3) { | 2778 if (args.GetLength() == 3) { |
| 2779 FX_BOOL bFlags = FALSE; | 2779 FX_BOOL bFlags = FALSE; |
| 2780 FX_FLOAT nPrincipal = 0; | 2780 FX_FLOAT nPrincipal = 0; |
| 2781 FX_FLOAT nRate = 0; | 2781 FX_FLOAT nRate = 0; |
| 2782 FX_FLOAT nPeriods = 0; | 2782 FX_FLOAT nPeriods = 0; |
| 2783 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2783 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2784 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2784 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2785 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2785 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2786 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2786 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2787 HValueIsNull(hThis, argThree)); | 2787 ValueIsNull(pThis, argThree)); |
| 2788 if (bFlags) { | 2788 if (bFlags) { |
| 2789 FXJSE_Value_SetNull(args.GetReturnValue()); | 2789 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2790 } else { | 2790 } else { |
| 2791 nPrincipal = HValueToFloat(hThis, argOne); | 2791 nPrincipal = ValueToFloat(pThis, argOne); |
| 2792 nRate = HValueToFloat(hThis, argTwo); | 2792 nRate = ValueToFloat(pThis, argTwo); |
| 2793 nPeriods = HValueToFloat(hThis, argThree); | 2793 nPeriods = ValueToFloat(pThis, argThree); |
| 2794 bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)); | 2794 bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)); |
| 2795 if (bFlags) { | 2795 if (bFlags) { |
| 2796 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2796 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2797 } else { | 2797 } else { |
| 2798 FX_FLOAT nSum = 0; | 2798 FX_FLOAT nSum = 0; |
| 2799 FX_FLOAT nTmp = 1 + nRate; | 2799 FX_FLOAT nTmp = 1 + nRate; |
| 2800 nSum = nTmp; | 2800 nSum = nTmp; |
| 2801 for (int32_t i = 0; i < nPeriods - 1; ++i) { | 2801 for (int32_t i = 0; i < nPeriods - 1; ++i) { |
| 2802 nSum *= nTmp; | 2802 nSum *= nTmp; |
| 2803 } | 2803 } |
| 2804 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2804 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2805 (nPrincipal * nRate * nSum) / (nSum - 1)); | 2805 (nPrincipal * nRate * nSum) / (nSum - 1)); |
| 2806 } | 2806 } |
| 2807 } | 2807 } |
| 2808 FXJSE_Value_Release(argOne); | 2808 FXJSE_Value_Release(argOne); |
| 2809 FXJSE_Value_Release(argTwo); | 2809 FXJSE_Value_Release(argTwo); |
| 2810 FXJSE_Value_Release(argThree); | 2810 FXJSE_Value_Release(argThree); |
| 2811 } else { | 2811 } else { |
| 2812 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2812 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2813 L"Pmt"); | 2813 L"Pmt"); |
| 2814 } | 2814 } |
| 2815 } | 2815 } |
| 2816 void CXFA_FM2JSContext::PPmt(FXJSE_HOBJECT hThis, | 2816 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, |
| 2817 const CFX_ByteStringC& szFuncName, | 2817 const CFX_ByteStringC& szFuncName, |
| 2818 CFXJSE_Arguments& args) { | 2818 CFXJSE_Arguments& args) { |
| 2819 CXFA_FM2JSContext* pContext = | 2819 CXFA_FM2JSContext* pContext = |
| 2820 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2820 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2821 if (args.GetLength() == 5) { | 2821 if (args.GetLength() == 5) { |
| 2822 FX_BOOL bFlags = FALSE; | 2822 FX_BOOL bFlags = FALSE; |
| 2823 FX_FLOAT nPrincpalAmount = 0; | 2823 FX_FLOAT nPrincpalAmount = 0; |
| 2824 FX_FLOAT nRate = 0; | 2824 FX_FLOAT nRate = 0; |
| 2825 FX_FLOAT nPayment = 0; | 2825 FX_FLOAT nPayment = 0; |
| 2826 FX_FLOAT nFirstMonth = 0; | 2826 FX_FLOAT nFirstMonth = 0; |
| 2827 FX_FLOAT nNumberOfMonths = 0; | 2827 FX_FLOAT nNumberOfMonths = 0; |
| 2828 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2828 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2829 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2829 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2830 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2830 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2831 FXJSE_HVALUE argFour = GetSimpleHValue(hThis, args, 3); | 2831 CFXJSE_Value* argFour = GetSimpleValue(pThis, args, 3); |
| 2832 FXJSE_HVALUE argFive = GetSimpleHValue(hThis, args, 4); | 2832 CFXJSE_Value* argFive = GetSimpleValue(pThis, args, 4); |
| 2833 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2833 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2834 HValueIsNull(hThis, argThree) || HValueIsNull(hThis, argFour) || | 2834 ValueIsNull(pThis, argThree) || ValueIsNull(pThis, argFour) || |
| 2835 HValueIsNull(hThis, argFive)); | 2835 ValueIsNull(pThis, argFive)); |
| 2836 if (bFlags) { | 2836 if (bFlags) { |
| 2837 FXJSE_Value_SetNull(args.GetReturnValue()); | 2837 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2838 } else { | 2838 } else { |
| 2839 nPrincpalAmount = HValueToFloat(hThis, argOne); | 2839 nPrincpalAmount = ValueToFloat(pThis, argOne); |
| 2840 nRate = HValueToFloat(hThis, argTwo); | 2840 nRate = ValueToFloat(pThis, argTwo); |
| 2841 nPayment = HValueToFloat(hThis, argThree); | 2841 nPayment = ValueToFloat(pThis, argThree); |
| 2842 nFirstMonth = HValueToFloat(hThis, argFour); | 2842 nFirstMonth = ValueToFloat(pThis, argFour); |
| 2843 nNumberOfMonths = HValueToFloat(hThis, argFive); | 2843 nNumberOfMonths = ValueToFloat(pThis, argFive); |
| 2844 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || | 2844 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || |
| 2845 (nFirstMonth < 0) || (nNumberOfMonths < 0)); | 2845 (nFirstMonth < 0) || (nNumberOfMonths < 0)); |
| 2846 if (bFlags) { | 2846 if (bFlags) { |
| 2847 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2847 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2848 } else { | 2848 } else { |
| 2849 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); | 2849 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); |
| 2850 FX_FLOAT nSum = 0; | 2850 FX_FLOAT nSum = 0; |
| 2851 FX_FLOAT nRateOfMonth = nRate / 12; | 2851 FX_FLOAT nRateOfMonth = nRate / 12; |
| 2852 int32_t iNums = | 2852 int32_t iNums = |
| 2853 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - | 2853 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2880 FXJSE_Value_Release(argOne); | 2880 FXJSE_Value_Release(argOne); |
| 2881 FXJSE_Value_Release(argTwo); | 2881 FXJSE_Value_Release(argTwo); |
| 2882 FXJSE_Value_Release(argThree); | 2882 FXJSE_Value_Release(argThree); |
| 2883 FXJSE_Value_Release(argFour); | 2883 FXJSE_Value_Release(argFour); |
| 2884 FXJSE_Value_Release(argFive); | 2884 FXJSE_Value_Release(argFive); |
| 2885 } else { | 2885 } else { |
| 2886 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2886 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2887 L"PPmt"); | 2887 L"PPmt"); |
| 2888 } | 2888 } |
| 2889 } | 2889 } |
| 2890 void CXFA_FM2JSContext::PV(FXJSE_HOBJECT hThis, | 2890 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, |
| 2891 const CFX_ByteStringC& szFuncName, | 2891 const CFX_ByteStringC& szFuncName, |
| 2892 CFXJSE_Arguments& args) { | 2892 CFXJSE_Arguments& args) { |
| 2893 CXFA_FM2JSContext* pContext = | 2893 CXFA_FM2JSContext* pContext = |
| 2894 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2894 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2895 if (args.GetLength() == 3) { | 2895 if (args.GetLength() == 3) { |
| 2896 FX_BOOL bFlags = FALSE; | 2896 FX_BOOL bFlags = FALSE; |
| 2897 FX_DOUBLE nAmount = 0; | 2897 FX_DOUBLE nAmount = 0; |
| 2898 FX_DOUBLE nRate = 0; | 2898 FX_DOUBLE nRate = 0; |
| 2899 FX_DOUBLE nPeriod = 0; | 2899 FX_DOUBLE nPeriod = 0; |
| 2900 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2900 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2901 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2901 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2902 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2902 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2903 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2903 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2904 HValueIsNull(hThis, argThree)); | 2904 ValueIsNull(pThis, argThree)); |
| 2905 if (bFlags) { | 2905 if (bFlags) { |
| 2906 FXJSE_Value_SetNull(args.GetReturnValue()); | 2906 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2907 } else { | 2907 } else { |
| 2908 nAmount = HValueToDouble(hThis, argOne); | 2908 nAmount = ValueToDouble(pThis, argOne); |
| 2909 nRate = HValueToDouble(hThis, argTwo); | 2909 nRate = ValueToDouble(pThis, argTwo); |
| 2910 nPeriod = HValueToDouble(hThis, argThree); | 2910 nPeriod = ValueToDouble(pThis, argThree); |
| 2911 bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)); | 2911 bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)); |
| 2912 if (bFlags) { | 2912 if (bFlags) { |
| 2913 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2913 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2914 } else { | 2914 } else { |
| 2915 FX_DOUBLE nTemp = 1; | 2915 FX_DOUBLE nTemp = 1; |
| 2916 for (int32_t i = 0; i < nPeriod; ++i) { | 2916 for (int32_t i = 0; i < nPeriod; ++i) { |
| 2917 nTemp *= 1 + nRate; | 2917 nTemp *= 1 + nRate; |
| 2918 } | 2918 } |
| 2919 nTemp = 1 / nTemp; | 2919 nTemp = 1 / nTemp; |
| 2920 FXJSE_Value_SetDouble(args.GetReturnValue(), | 2920 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 2921 nAmount * ((1 - nTemp) / nRate)); | 2921 nAmount * ((1 - nTemp) / nRate)); |
| 2922 } | 2922 } |
| 2923 } | 2923 } |
| 2924 FXJSE_Value_Release(argOne); | 2924 FXJSE_Value_Release(argOne); |
| 2925 FXJSE_Value_Release(argTwo); | 2925 FXJSE_Value_Release(argTwo); |
| 2926 FXJSE_Value_Release(argThree); | 2926 FXJSE_Value_Release(argThree); |
| 2927 } else { | 2927 } else { |
| 2928 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2928 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2929 L"PV"); | 2929 L"PV"); |
| 2930 } | 2930 } |
| 2931 } | 2931 } |
| 2932 void CXFA_FM2JSContext::Rate(FXJSE_HOBJECT hThis, | 2932 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, |
| 2933 const CFX_ByteStringC& szFuncName, | 2933 const CFX_ByteStringC& szFuncName, |
| 2934 CFXJSE_Arguments& args) { | 2934 CFXJSE_Arguments& args) { |
| 2935 CXFA_FM2JSContext* pContext = | 2935 CXFA_FM2JSContext* pContext = |
| 2936 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2936 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2937 if (args.GetLength() == 3) { | 2937 if (args.GetLength() == 3) { |
| 2938 FX_BOOL bFlags = FALSE; | 2938 FX_BOOL bFlags = FALSE; |
| 2939 FX_FLOAT nFuture = 0; | 2939 FX_FLOAT nFuture = 0; |
| 2940 FX_FLOAT nPresent = 0; | 2940 FX_FLOAT nPresent = 0; |
| 2941 FX_FLOAT nTotalNumber = 0; | 2941 FX_FLOAT nTotalNumber = 0; |
| 2942 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2942 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2943 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2943 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2944 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2944 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2945 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2945 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2946 HValueIsNull(hThis, argThree)); | 2946 ValueIsNull(pThis, argThree)); |
| 2947 if (bFlags) { | 2947 if (bFlags) { |
| 2948 FXJSE_Value_SetNull(args.GetReturnValue()); | 2948 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2949 } else { | 2949 } else { |
| 2950 nFuture = HValueToFloat(hThis, argOne); | 2950 nFuture = ValueToFloat(pThis, argOne); |
| 2951 nPresent = HValueToFloat(hThis, argTwo); | 2951 nPresent = ValueToFloat(pThis, argTwo); |
| 2952 nTotalNumber = HValueToFloat(hThis, argThree); | 2952 nTotalNumber = ValueToFloat(pThis, argThree); |
| 2953 bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)); | 2953 bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)); |
| 2954 if (bFlags) { | 2954 if (bFlags) { |
| 2955 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2955 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2956 } else { | 2956 } else { |
| 2957 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2957 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2958 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), | 2958 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), |
| 2959 (FX_FLOAT)(1 / nTotalNumber)) - | 2959 (FX_FLOAT)(1 / nTotalNumber)) - |
| 2960 1)); | 2960 1)); |
| 2961 } | 2961 } |
| 2962 } | 2962 } |
| 2963 FXJSE_Value_Release(argOne); | 2963 FXJSE_Value_Release(argOne); |
| 2964 FXJSE_Value_Release(argTwo); | 2964 FXJSE_Value_Release(argTwo); |
| 2965 FXJSE_Value_Release(argThree); | 2965 FXJSE_Value_Release(argThree); |
| 2966 } else { | 2966 } else { |
| 2967 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2967 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2968 L"Rate"); | 2968 L"Rate"); |
| 2969 } | 2969 } |
| 2970 } | 2970 } |
| 2971 void CXFA_FM2JSContext::Term(FXJSE_HOBJECT hThis, | 2971 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, |
| 2972 const CFX_ByteStringC& szFuncName, | 2972 const CFX_ByteStringC& szFuncName, |
| 2973 CFXJSE_Arguments& args) { | 2973 CFXJSE_Arguments& args) { |
| 2974 CXFA_FM2JSContext* pContext = | 2974 CXFA_FM2JSContext* pContext = |
| 2975 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 2975 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2976 if (args.GetLength() == 3) { | 2976 if (args.GetLength() == 3) { |
| 2977 FX_BOOL bFlags = FALSE; | 2977 FX_BOOL bFlags = FALSE; |
| 2978 FX_FLOAT nMount = 0; | 2978 FX_FLOAT nMount = 0; |
| 2979 FX_FLOAT nRate = 0; | 2979 FX_FLOAT nRate = 0; |
| 2980 FX_FLOAT nFuture = 0; | 2980 FX_FLOAT nFuture = 0; |
| 2981 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2981 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2982 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2982 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2983 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2983 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2984 bFlags = (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo) || | 2984 bFlags = (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo) || |
| 2985 FXJSE_Value_IsNull(argThree)); | 2985 FXJSE_Value_IsNull(argThree)); |
| 2986 if (bFlags) { | 2986 if (bFlags) { |
| 2987 FXJSE_Value_SetNull(args.GetReturnValue()); | 2987 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2988 } else { | 2988 } else { |
| 2989 nMount = HValueToFloat(hThis, argOne); | 2989 nMount = ValueToFloat(pThis, argOne); |
| 2990 nRate = HValueToFloat(hThis, argTwo); | 2990 nRate = ValueToFloat(pThis, argTwo); |
| 2991 nFuture = HValueToFloat(hThis, argThree); | 2991 nFuture = ValueToFloat(pThis, argThree); |
| 2992 bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)); | 2992 bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)); |
| 2993 if (bFlags) { | 2993 if (bFlags) { |
| 2994 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2994 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2995 } else { | 2995 } else { |
| 2996 FXJSE_Value_SetFloat( | 2996 FXJSE_Value_SetFloat( |
| 2997 args.GetReturnValue(), | 2997 args.GetReturnValue(), |
| 2998 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / | 2998 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / |
| 2999 FXSYS_log((FX_FLOAT)(1 + nRate)))); | 2999 FXSYS_log((FX_FLOAT)(1 + nRate)))); |
| 3000 } | 3000 } |
| 3001 } | 3001 } |
| 3002 FXJSE_Value_Release(argOne); | 3002 FXJSE_Value_Release(argOne); |
| 3003 FXJSE_Value_Release(argTwo); | 3003 FXJSE_Value_Release(argTwo); |
| 3004 FXJSE_Value_Release(argThree); | 3004 FXJSE_Value_Release(argThree); |
| 3005 } else { | 3005 } else { |
| 3006 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3006 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3007 L"Term"); | 3007 L"Term"); |
| 3008 } | 3008 } |
| 3009 } | 3009 } |
| 3010 void CXFA_FM2JSContext::Choose(FXJSE_HOBJECT hThis, | 3010 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, |
| 3011 const CFX_ByteStringC& szFuncName, | 3011 const CFX_ByteStringC& szFuncName, |
| 3012 CFXJSE_Arguments& args) { | 3012 CFXJSE_Arguments& args) { |
| 3013 CXFA_FM2JSContext* pContext = | 3013 CXFA_FM2JSContext* pContext = |
| 3014 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3014 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3015 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3015 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3016 int32_t argc = args.GetLength(); | 3016 int32_t argc = args.GetLength(); |
| 3017 if (argc > 1) { | 3017 if (argc > 1) { |
| 3018 FXJSE_HVALUE argOne = args.GetValue(0); | 3018 CFXJSE_Value* argOne = args.GetValue(0); |
| 3019 FX_BOOL argOneIsNull = FALSE; | 3019 FX_BOOL argOneIsNull = FALSE; |
| 3020 int32_t iIndex = 0; | 3020 int32_t iIndex = 0; |
| 3021 argOneIsNull = HValueIsNull(hThis, argOne); | 3021 argOneIsNull = ValueIsNull(pThis, argOne); |
| 3022 if (!argOneIsNull) { | 3022 if (!argOneIsNull) { |
| 3023 iIndex = (int32_t)HValueToFloat(hThis, argOne); | 3023 iIndex = (int32_t)ValueToFloat(pThis, argOne); |
| 3024 } | 3024 } |
| 3025 FXJSE_Value_Release(argOne); | 3025 FXJSE_Value_Release(argOne); |
| 3026 if (argOneIsNull) { | 3026 if (argOneIsNull) { |
| 3027 FXJSE_Value_SetNull(args.GetReturnValue()); | 3027 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3028 } else if (iIndex < 1) { | 3028 } else if (iIndex < 1) { |
| 3029 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 3029 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 3030 } else { | 3030 } else { |
| 3031 FX_BOOL bFound = FALSE; | 3031 FX_BOOL bFound = FALSE; |
| 3032 FX_BOOL bStopCounterFlags = FALSE; | 3032 FX_BOOL bStopCounterFlags = FALSE; |
| 3033 int32_t iArgIndex = 1; | 3033 int32_t iArgIndex = 1; |
| 3034 int32_t iValueIndex = 0; | 3034 int32_t iValueIndex = 0; |
| 3035 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { | 3035 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { |
| 3036 FXJSE_HVALUE argIndexValue = args.GetValue(iArgIndex); | 3036 CFXJSE_Value* argIndexValue = args.GetValue(iArgIndex); |
| 3037 if (FXJSE_Value_IsArray(argIndexValue)) { | 3037 if (FXJSE_Value_IsArray(argIndexValue)) { |
| 3038 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 3038 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 3039 FXJSE_Value_GetObjectProp(argIndexValue, "length", lengthValue); | 3039 FXJSE_Value_GetObjectProp(argIndexValue, "length", lengthValue); |
| 3040 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 3040 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 3041 FXJSE_Value_Release(lengthValue); | 3041 FXJSE_Value_Release(lengthValue); |
| 3042 if (iLength > 3) { | 3042 if (iLength > 3) { |
| 3043 bStopCounterFlags = TRUE; | 3043 bStopCounterFlags = TRUE; |
| 3044 } | 3044 } |
| 3045 iValueIndex += (iLength - 2); | 3045 iValueIndex += (iLength - 2); |
| 3046 if (iValueIndex >= iIndex) { | 3046 if (iValueIndex >= iIndex) { |
| 3047 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 3047 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 3048 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 3048 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 3049 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 3049 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 3050 FXJSE_Value_GetObjectPropByIdx(argIndexValue, 1, propertyValue); | 3050 FXJSE_Value_GetObjectPropByIdx(argIndexValue, 1, propertyValue); |
| 3051 FXJSE_Value_GetObjectPropByIdx( | 3051 FXJSE_Value_GetObjectPropByIdx( |
| 3052 argIndexValue, ((iLength - 1) - (iValueIndex - iIndex)), | 3052 argIndexValue, ((iLength - 1) - (iValueIndex - iIndex)), |
| 3053 jsobjectValue); | 3053 jsobjectValue); |
| 3054 if (FXJSE_Value_IsNull(propertyValue)) { | 3054 if (FXJSE_Value_IsNull(propertyValue)) { |
| 3055 GetObjectDefaultValue(jsobjectValue, newProperty); | 3055 GetObjectDefaultValue(jsobjectValue, newProperty); |
| 3056 } else { | 3056 } else { |
| 3057 CFX_ByteString propStr; | 3057 CFX_ByteString propStr; |
| 3058 FXJSE_Value_ToUTF8String(propertyValue, propStr); | 3058 FXJSE_Value_ToUTF8String(propertyValue, propStr); |
| 3059 FXJSE_Value_GetObjectProp(jsobjectValue, propStr.AsStringC(), | 3059 FXJSE_Value_GetObjectProp(jsobjectValue, propStr.AsStringC(), |
| 3060 newProperty); | 3060 newProperty); |
| 3061 } | 3061 } |
| 3062 CFX_ByteString bsChoosed; | 3062 CFX_ByteString bsChoosed; |
| 3063 HValueToUTF8String(newProperty, bsChoosed); | 3063 ValueToUTF8String(newProperty, bsChoosed); |
| 3064 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 3064 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 3065 bsChoosed.AsStringC()); | 3065 bsChoosed.AsStringC()); |
| 3066 FXJSE_Value_Release(newProperty); | 3066 FXJSE_Value_Release(newProperty); |
| 3067 FXJSE_Value_Release(jsobjectValue); | 3067 FXJSE_Value_Release(jsobjectValue); |
| 3068 FXJSE_Value_Release(propertyValue); | 3068 FXJSE_Value_Release(propertyValue); |
| 3069 bFound = TRUE; | 3069 bFound = TRUE; |
| 3070 } | 3070 } |
| 3071 } else { | 3071 } else { |
| 3072 iValueIndex++; | 3072 iValueIndex++; |
| 3073 if (iValueIndex == iIndex) { | 3073 if (iValueIndex == iIndex) { |
| 3074 CFX_ByteString bsChoosed; | 3074 CFX_ByteString bsChoosed; |
| 3075 HValueToUTF8String(argIndexValue, bsChoosed); | 3075 ValueToUTF8String(argIndexValue, bsChoosed); |
| 3076 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 3076 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 3077 bsChoosed.AsStringC()); | 3077 bsChoosed.AsStringC()); |
| 3078 bFound = TRUE; | 3078 bFound = TRUE; |
| 3079 } | 3079 } |
| 3080 } | 3080 } |
| 3081 FXJSE_Value_Release(argIndexValue); | 3081 FXJSE_Value_Release(argIndexValue); |
| 3082 iArgIndex++; | 3082 iArgIndex++; |
| 3083 } | 3083 } |
| 3084 if (!bFound) { | 3084 if (!bFound) { |
| 3085 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 3085 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 3086 } | 3086 } |
| 3087 } | 3087 } |
| 3088 } else { | 3088 } else { |
| 3089 CXFA_FM2JSContext* pContext = | 3089 CXFA_FM2JSContext* pContext = |
| 3090 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3090 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3091 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3091 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3092 L"Choose"); | 3092 L"Choose"); |
| 3093 } | 3093 } |
| 3094 } | 3094 } |
| 3095 void CXFA_FM2JSContext::Exists(FXJSE_HOBJECT hThis, | 3095 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, |
| 3096 const CFX_ByteStringC& szFuncName, | 3096 const CFX_ByteStringC& szFuncName, |
| 3097 CFXJSE_Arguments& args) { | 3097 CFXJSE_Arguments& args) { |
| 3098 if (args.GetLength() == 1) { | 3098 if (args.GetLength() == 1) { |
| 3099 FXJSE_HVALUE argOne = args.GetValue(0); | 3099 CFXJSE_Value* argOne = args.GetValue(0); |
| 3100 FXJSE_Value_SetInteger(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); | 3100 FXJSE_Value_SetInteger(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); |
| 3101 FXJSE_Value_Release(argOne); | 3101 FXJSE_Value_Release(argOne); |
| 3102 } else { | 3102 } else { |
| 3103 CXFA_FM2JSContext* pContext = | 3103 CXFA_FM2JSContext* pContext = |
| 3104 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3104 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3105 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3105 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3106 L"Exists"); | 3106 L"Exists"); |
| 3107 } | 3107 } |
| 3108 } | 3108 } |
| 3109 void CXFA_FM2JSContext::HasValue(FXJSE_HOBJECT hThis, | 3109 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, |
| 3110 const CFX_ByteStringC& szFuncName, | 3110 const CFX_ByteStringC& szFuncName, |
| 3111 CFXJSE_Arguments& args) { | 3111 CFXJSE_Arguments& args) { |
| 3112 if (args.GetLength() == 1) { | 3112 if (args.GetLength() == 1) { |
| 3113 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3113 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3114 if (FXJSE_Value_IsUTF8String(argOne)) { | 3114 if (FXJSE_Value_IsUTF8String(argOne)) { |
| 3115 CFX_ByteString valueStr; | 3115 CFX_ByteString valueStr; |
| 3116 FXJSE_Value_ToUTF8String(argOne, valueStr); | 3116 FXJSE_Value_ToUTF8String(argOne, valueStr); |
| 3117 valueStr.TrimLeft(); | 3117 valueStr.TrimLeft(); |
| 3118 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); | 3118 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); |
| 3119 } else if (FXJSE_Value_IsNumber(argOne) || FXJSE_Value_IsBoolean(argOne)) { | 3119 } else if (FXJSE_Value_IsNumber(argOne) || FXJSE_Value_IsBoolean(argOne)) { |
| 3120 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); | 3120 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); |
| 3121 } else { | 3121 } else { |
| 3122 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); | 3122 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); |
| 3123 } | 3123 } |
| 3124 FXJSE_Value_Release(argOne); | 3124 FXJSE_Value_Release(argOne); |
| 3125 } else { | 3125 } else { |
| 3126 CXFA_FM2JSContext* pContext = | 3126 CXFA_FM2JSContext* pContext = |
| 3127 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3127 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3128 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3128 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3129 L"HasValue"); | 3129 L"HasValue"); |
| 3130 } | 3130 } |
| 3131 } | 3131 } |
| 3132 void CXFA_FM2JSContext::Oneof(FXJSE_HOBJECT hThis, | 3132 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, |
| 3133 const CFX_ByteStringC& szFuncName, | 3133 const CFX_ByteStringC& szFuncName, |
| 3134 CFXJSE_Arguments& args) { | 3134 CFXJSE_Arguments& args) { |
| 3135 int32_t argc = args.GetLength(); | 3135 int32_t argc = args.GetLength(); |
| 3136 if (argc > 1) { | 3136 if (argc > 1) { |
| 3137 FX_BOOL bFlags = FALSE; | 3137 FX_BOOL bFlags = FALSE; |
| 3138 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3138 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3139 FXJSE_HVALUE* parametersValue = 0; | 3139 CFXJSE_Value** parametersValue = nullptr; |
| 3140 int32_t iCount = 0; | 3140 int32_t iCount = 0; |
| 3141 unfoldArgs(hThis, args, parametersValue, iCount, 1); | 3141 unfoldArgs(pThis, args, parametersValue, iCount, 1); |
| 3142 for (int32_t i = 0; i < iCount; i++) { | 3142 for (int32_t i = 0; i < iCount; i++) { |
| 3143 if (simpleValueCompare(hThis, argOne, parametersValue[i])) { | 3143 if (simpleValueCompare(pThis, argOne, parametersValue[i])) { |
| 3144 bFlags = TRUE; | 3144 bFlags = TRUE; |
| 3145 break; | 3145 break; |
| 3146 } | 3146 } |
| 3147 } | 3147 } |
| 3148 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); | 3148 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); |
| 3149 FXJSE_Value_Release(argOne); | 3149 FXJSE_Value_Release(argOne); |
| 3150 for (int32_t i = 0; i < iCount; i++) { | 3150 for (int32_t i = 0; i < iCount; i++) { |
| 3151 FXJSE_Value_Release(parametersValue[i]); | 3151 FXJSE_Value_Release(parametersValue[i]); |
| 3152 } | 3152 } |
| 3153 FX_Free(parametersValue); | 3153 FX_Free(parametersValue); |
| 3154 parametersValue = 0; | 3154 parametersValue = 0; |
| 3155 } else { | 3155 } else { |
| 3156 CXFA_FM2JSContext* pContext = | 3156 CXFA_FM2JSContext* pContext = |
| 3157 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3157 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3158 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3158 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3159 L"Oneof"); | 3159 L"Oneof"); |
| 3160 } | 3160 } |
| 3161 } | 3161 } |
| 3162 void CXFA_FM2JSContext::Within(FXJSE_HOBJECT hThis, | 3162 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, |
| 3163 const CFX_ByteStringC& szFuncName, | 3163 const CFX_ByteStringC& szFuncName, |
| 3164 CFXJSE_Arguments& args) { | 3164 CFXJSE_Arguments& args) { |
| 3165 int32_t argc = args.GetLength(); | 3165 int32_t argc = args.GetLength(); |
| 3166 if (argc == 3) { | 3166 if (argc == 3) { |
| 3167 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3167 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3168 if (FXJSE_Value_IsNull(argOne)) { | 3168 if (FXJSE_Value_IsNull(argOne)) { |
| 3169 FXJSE_Value_SetUndefined(args.GetReturnValue()); | 3169 FXJSE_Value_SetUndefined(args.GetReturnValue()); |
| 3170 } else { | 3170 } else { |
| 3171 FXJSE_HVALUE argLow = GetSimpleHValue(hThis, args, 1); | 3171 CFXJSE_Value* argLow = GetSimpleValue(pThis, args, 1); |
| 3172 FXJSE_HVALUE argHeight = GetSimpleHValue(hThis, args, 2); | 3172 CFXJSE_Value* argHeight = GetSimpleValue(pThis, args, 2); |
| 3173 if (FXJSE_Value_IsNumber(argOne)) { | 3173 if (FXJSE_Value_IsNumber(argOne)) { |
| 3174 FX_FLOAT oneNumber = HValueToFloat(hThis, argOne); | 3174 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne); |
| 3175 FX_FLOAT lowNumber = HValueToFloat(hThis, argLow); | 3175 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow); |
| 3176 FX_FLOAT heightNumber = HValueToFloat(hThis, argHeight); | 3176 FX_FLOAT heightNumber = ValueToFloat(pThis, argHeight); |
| 3177 FXJSE_Value_SetInteger( | 3177 FXJSE_Value_SetInteger( |
| 3178 args.GetReturnValue(), | 3178 args.GetReturnValue(), |
| 3179 ((oneNumber >= lowNumber) && (oneNumber <= heightNumber))); | 3179 ((oneNumber >= lowNumber) && (oneNumber <= heightNumber))); |
| 3180 } else { | 3180 } else { |
| 3181 CFX_ByteString oneString; | 3181 CFX_ByteString oneString; |
| 3182 CFX_ByteString lowString; | 3182 CFX_ByteString lowString; |
| 3183 CFX_ByteString heightString; | 3183 CFX_ByteString heightString; |
| 3184 HValueToUTF8String(argOne, oneString); | 3184 ValueToUTF8String(argOne, oneString); |
| 3185 HValueToUTF8String(argLow, lowString); | 3185 ValueToUTF8String(argLow, lowString); |
| 3186 HValueToUTF8String(argHeight, heightString); | 3186 ValueToUTF8String(argHeight, heightString); |
| 3187 FXJSE_Value_SetInteger( | 3187 FXJSE_Value_SetInteger( |
| 3188 args.GetReturnValue(), | 3188 args.GetReturnValue(), |
| 3189 ((oneString.Compare(lowString.AsStringC()) >= 0) && | 3189 ((oneString.Compare(lowString.AsStringC()) >= 0) && |
| 3190 (oneString.Compare(heightString.AsStringC()) <= 0))); | 3190 (oneString.Compare(heightString.AsStringC()) <= 0))); |
| 3191 } | 3191 } |
| 3192 FXJSE_Value_Release(argLow); | 3192 FXJSE_Value_Release(argLow); |
| 3193 FXJSE_Value_Release(argHeight); | 3193 FXJSE_Value_Release(argHeight); |
| 3194 } | 3194 } |
| 3195 FXJSE_Value_Release(argOne); | 3195 FXJSE_Value_Release(argOne); |
| 3196 } else { | 3196 } else { |
| 3197 CXFA_FM2JSContext* pContext = | 3197 CXFA_FM2JSContext* pContext = |
| 3198 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3198 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3199 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3199 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3200 L"Within"); | 3200 L"Within"); |
| 3201 } | 3201 } |
| 3202 } | 3202 } |
| 3203 void CXFA_FM2JSContext::If(FXJSE_HOBJECT hThis, | 3203 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, |
| 3204 const CFX_ByteStringC& szFuncName, | 3204 const CFX_ByteStringC& szFuncName, |
| 3205 CFXJSE_Arguments& args) { | 3205 CFXJSE_Arguments& args) { |
| 3206 if (args.GetLength() == 3) { | 3206 if (args.GetLength() == 3) { |
| 3207 FXJSE_HVALUE argCondition = GetSimpleHValue(hThis, args, 0); | 3207 CFXJSE_Value* argCondition = GetSimpleValue(pThis, args, 0); |
| 3208 FXJSE_HVALUE argFirstValue = GetSimpleHValue(hThis, args, 1); | 3208 CFXJSE_Value* argFirstValue = GetSimpleValue(pThis, args, 1); |
| 3209 FXJSE_HVALUE argSecondValue = GetSimpleHValue(hThis, args, 2); | 3209 CFXJSE_Value* argSecondValue = GetSimpleValue(pThis, args, 2); |
| 3210 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition); | 3210 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition); |
| 3211 FXJSE_Value_Set(args.GetReturnValue(), | 3211 FXJSE_Value_Set(args.GetReturnValue(), |
| 3212 bCondition ? argFirstValue : argSecondValue); | 3212 bCondition ? argFirstValue : argSecondValue); |
| 3213 FXJSE_Value_Release(argSecondValue); | 3213 FXJSE_Value_Release(argSecondValue); |
| 3214 FXJSE_Value_Release(argFirstValue); | 3214 FXJSE_Value_Release(argFirstValue); |
| 3215 FXJSE_Value_Release(argCondition); | 3215 FXJSE_Value_Release(argCondition); |
| 3216 } else { | 3216 } else { |
| 3217 CXFA_FM2JSContext* pContext = | 3217 CXFA_FM2JSContext* pContext = |
| 3218 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3218 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3219 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3219 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3220 L"If"); | 3220 L"If"); |
| 3221 } | 3221 } |
| 3222 } | 3222 } |
| 3223 void CXFA_FM2JSContext::Eval(FXJSE_HOBJECT hThis, | 3223 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, |
| 3224 const CFX_ByteStringC& szFuncName, | 3224 const CFX_ByteStringC& szFuncName, |
| 3225 CFXJSE_Arguments& args) { | 3225 CFXJSE_Arguments& args) { |
| 3226 CXFA_FM2JSContext* pContext = | 3226 CXFA_FM2JSContext* pContext = |
| 3227 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3227 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3228 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3228 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3229 if (args.GetLength() == 1) { | 3229 if (args.GetLength() == 1) { |
| 3230 FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); | 3230 CFXJSE_Value* scriptValue = GetSimpleValue(pThis, args, 0); |
| 3231 CFX_ByteString utf8ScriptString; | 3231 CFX_ByteString utf8ScriptString; |
| 3232 HValueToUTF8String(scriptValue, utf8ScriptString); | 3232 ValueToUTF8String(scriptValue, utf8ScriptString); |
| 3233 if (utf8ScriptString.IsEmpty()) { | 3233 if (utf8ScriptString.IsEmpty()) { |
| 3234 FXJSE_Value_SetNull(args.GetReturnValue()); | 3234 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3235 } else { | 3235 } else { |
| 3236 CFX_WideTextBuf wsJavaScriptBuf; | 3236 CFX_WideTextBuf wsJavaScriptBuf; |
| 3237 CFX_WideString javaScript; | 3237 CFX_WideString javaScript; |
| 3238 CFX_WideString wsError; | 3238 CFX_WideString wsError; |
| 3239 XFA_FM2JS_Translate( | 3239 XFA_FM2JS_Translate( |
| 3240 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), | 3240 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), |
| 3241 wsJavaScriptBuf, wsError); | 3241 wsJavaScriptBuf, wsError); |
| 3242 CFXJSE_Context* pContext = FXJSE_Context_Create(pIsolate); | 3242 CFXJSE_Context* pContext = FXJSE_Context_Create(pIsolate); |
| 3243 FXJSE_HVALUE returnValue = FXJSE_Value_Create(pIsolate); | 3243 CFXJSE_Value* returnValue = FXJSE_Value_Create(pIsolate); |
| 3244 javaScript = wsJavaScriptBuf.AsStringC(); | 3244 javaScript = wsJavaScriptBuf.AsStringC(); |
| 3245 FXJSE_ExecuteScript( | 3245 FXJSE_ExecuteScript( |
| 3246 pContext, | 3246 pContext, |
| 3247 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), | 3247 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), |
| 3248 returnValue); | 3248 returnValue); |
| 3249 FXJSE_Value_Set(args.GetReturnValue(), returnValue); | 3249 FXJSE_Value_Set(args.GetReturnValue(), returnValue); |
| 3250 FXJSE_Value_Release(returnValue); | 3250 FXJSE_Value_Release(returnValue); |
| 3251 FXJSE_Context_Release(pContext); | 3251 FXJSE_Context_Release(pContext); |
| 3252 } | 3252 } |
| 3253 FXJSE_Value_Release(scriptValue); | 3253 FXJSE_Value_Release(scriptValue); |
| 3254 } else { | 3254 } else { |
| 3255 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3255 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3256 L"Eval"); | 3256 L"Eval"); |
| 3257 } | 3257 } |
| 3258 } | 3258 } |
| 3259 void CXFA_FM2JSContext::Ref(FXJSE_HOBJECT hThis, | 3259 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, |
| 3260 const CFX_ByteStringC& szFuncName, | 3260 const CFX_ByteStringC& szFuncName, |
| 3261 CFXJSE_Arguments& args) { | 3261 CFXJSE_Arguments& args) { |
| 3262 CXFA_FM2JSContext* pContext = | 3262 CXFA_FM2JSContext* pContext = |
| 3263 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3263 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3264 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3264 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3265 if (args.GetLength() == 1) { | 3265 if (args.GetLength() == 1) { |
| 3266 FXJSE_HVALUE argOne = args.GetValue(0); | 3266 CFXJSE_Value* argOne = args.GetValue(0); |
| 3267 if (FXJSE_Value_IsNull(argOne)) { | 3267 if (FXJSE_Value_IsNull(argOne)) { |
| 3268 FXJSE_HVALUE rgValues[3]; | 3268 CFXJSE_Value* rgValues[3]; |
| 3269 for (int32_t i = 0; i < 3; i++) { | 3269 for (int32_t i = 0; i < 3; i++) { |
| 3270 rgValues[i] = FXJSE_Value_Create(pIsolate); | 3270 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 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 #ifndef NDEBUG | 3280 #ifndef NDEBUG |
| 3281 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 3281 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 3282 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 3282 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
| 3283 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); | 3283 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(pIsolate); | 3286 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 3287 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 3287 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 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)) { |
| 3291 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3291 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 3292 } else if (FXJSE_Value_IsNull(propertyValue) && | 3292 } else if (FXJSE_Value_IsNull(propertyValue) && |
| 3293 (!FXJSE_Value_IsNull(jsObjectValue))) { | 3293 (!FXJSE_Value_IsNull(jsObjectValue))) { |
| 3294 FXJSE_HVALUE rgValues[3]; | 3294 CFXJSE_Value* rgValues[3]; |
| 3295 for (int32_t i = 0; i < 3; i++) { | 3295 for (int32_t i = 0; i < 3; i++) { |
| 3296 rgValues[i] = FXJSE_Value_Create(pIsolate); | 3296 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 3297 } | 3297 } |
| 3298 FXJSE_Value_SetInteger(rgValues[0], 3); | 3298 FXJSE_Value_SetInteger(rgValues[0], 3); |
| 3299 FXJSE_Value_SetNull(rgValues[1]); | 3299 FXJSE_Value_SetNull(rgValues[1]); |
| 3300 FXJSE_Value_Set(rgValues[2], jsObjectValue); | 3300 FXJSE_Value_Set(rgValues[2], jsObjectValue); |
| 3301 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 3301 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 3302 for (int32_t i = 0; i < 3; i++) { | 3302 for (int32_t i = 0; i < 3; i++) { |
| 3303 FXJSE_Value_Release(rgValues[i]); | 3303 FXJSE_Value_Release(rgValues[i]); |
| 3304 } | 3304 } |
| 3305 } else { | 3305 } else { |
| 3306 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3306 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 3307 } | 3307 } |
| 3308 FXJSE_Value_Release(jsObjectValue); | 3308 FXJSE_Value_Release(jsObjectValue); |
| 3309 FXJSE_Value_Release(propertyValue); | 3309 FXJSE_Value_Release(propertyValue); |
| 3310 } else if (FXJSE_Value_IsObject(argOne)) { | 3310 } else if (FXJSE_Value_IsObject(argOne)) { |
| 3311 FXJSE_HVALUE rgValues[3]; | 3311 CFXJSE_Value* rgValues[3]; |
| 3312 for (int32_t i = 0; i < 3; i++) { | 3312 for (int32_t i = 0; i < 3; i++) { |
| 3313 rgValues[i] = FXJSE_Value_Create(pIsolate); | 3313 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 3314 } | 3314 } |
| 3315 FXJSE_Value_SetInteger(rgValues[0], 3); | 3315 FXJSE_Value_SetInteger(rgValues[0], 3); |
| 3316 FXJSE_Value_SetNull(rgValues[1]); | 3316 FXJSE_Value_SetNull(rgValues[1]); |
| 3317 FXJSE_Value_Set(rgValues[2], argOne); | 3317 FXJSE_Value_Set(rgValues[2], argOne); |
| 3318 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 3318 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 3319 for (int32_t i = 0; i < 3; i++) { | 3319 for (int32_t i = 0; i < 3; i++) { |
| 3320 FXJSE_Value_Release(rgValues[i]); | 3320 FXJSE_Value_Release(rgValues[i]); |
| 3321 } | 3321 } |
| 3322 } else if (FXJSE_Value_IsBoolean(argOne) || | 3322 } else if (FXJSE_Value_IsBoolean(argOne) || |
| 3323 FXJSE_Value_IsUTF8String(argOne) || | 3323 FXJSE_Value_IsUTF8String(argOne) || |
| 3324 FXJSE_Value_IsNumber(argOne)) { | 3324 FXJSE_Value_IsNumber(argOne)) { |
| 3325 FXJSE_Value_Set(args.GetReturnValue(), argOne); | 3325 FXJSE_Value_Set(args.GetReturnValue(), argOne); |
| 3326 } else { | 3326 } else { |
| 3327 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3327 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 3328 } | 3328 } |
| 3329 FXJSE_Value_Release(argOne); | 3329 FXJSE_Value_Release(argOne); |
| 3330 } else { | 3330 } else { |
| 3331 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3331 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3332 L"Ref"); | 3332 L"Ref"); |
| 3333 } | 3333 } |
| 3334 } | 3334 } |
| 3335 void CXFA_FM2JSContext::UnitType(FXJSE_HOBJECT hThis, | 3335 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, |
| 3336 const CFX_ByteStringC& szFuncName, | 3336 const CFX_ByteStringC& szFuncName, |
| 3337 CFXJSE_Arguments& args) { | 3337 CFXJSE_Arguments& args) { |
| 3338 if (args.GetLength() == 1) { | 3338 if (args.GetLength() == 1) { |
| 3339 FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0); | 3339 CFXJSE_Value* unitspanValue = GetSimpleValue(pThis, args, 0); |
| 3340 if (FXJSE_Value_IsNull(unitspanValue)) { | 3340 if (FXJSE_Value_IsNull(unitspanValue)) { |
| 3341 FXJSE_Value_SetNull(args.GetReturnValue()); | 3341 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3342 FXJSE_Value_Release(unitspanValue); | 3342 FXJSE_Value_Release(unitspanValue); |
| 3343 return; | 3343 return; |
| 3344 } | 3344 } |
| 3345 CFX_ByteString unitspanString; | 3345 CFX_ByteString unitspanString; |
| 3346 HValueToUTF8String(unitspanValue, unitspanString); | 3346 ValueToUTF8String(unitspanValue, unitspanString); |
| 3347 if (unitspanString.IsEmpty()) { | 3347 if (unitspanString.IsEmpty()) { |
| 3348 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); | 3348 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); |
| 3349 } else { | 3349 } else { |
| 3350 enum XFA_FM2JS_VALUETYPE_ParserStatus { | 3350 enum XFA_FM2JS_VALUETYPE_ParserStatus { |
| 3351 VALUETYPE_START, | 3351 VALUETYPE_START, |
| 3352 VALUETYPE_HAVEINVALIDCHAR, | 3352 VALUETYPE_HAVEINVALIDCHAR, |
| 3353 VALUETYPE_HAVEDIGIT, | 3353 VALUETYPE_HAVEDIGIT, |
| 3354 VALUETYPE_HAVEDIGITWHITE, | 3354 VALUETYPE_HAVEDIGITWHITE, |
| 3355 VALUETYPE_ISCM, | 3355 VALUETYPE_ISCM, |
| 3356 VALUETYPE_ISMM, | 3356 VALUETYPE_ISMM, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3437 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); | 3437 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); |
| 3438 break; | 3438 break; |
| 3439 default: | 3439 default: |
| 3440 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); | 3440 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); |
| 3441 break; | 3441 break; |
| 3442 } | 3442 } |
| 3443 } | 3443 } |
| 3444 FXJSE_Value_Release(unitspanValue); | 3444 FXJSE_Value_Release(unitspanValue); |
| 3445 } else { | 3445 } else { |
| 3446 CXFA_FM2JSContext* pContext = | 3446 CXFA_FM2JSContext* pContext = |
| 3447 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3447 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3448 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3448 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3449 L"UnitType"); | 3449 L"UnitType"); |
| 3450 } | 3450 } |
| 3451 } | 3451 } |
| 3452 void CXFA_FM2JSContext::UnitValue(FXJSE_HOBJECT hThis, | 3452 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, |
| 3453 const CFX_ByteStringC& szFuncName, | 3453 const CFX_ByteStringC& szFuncName, |
| 3454 CFXJSE_Arguments& args) { | 3454 CFXJSE_Arguments& args) { |
| 3455 int32_t argc = args.GetLength(); | 3455 int32_t argc = args.GetLength(); |
| 3456 if ((argc == 1) || (argc == 2)) { | 3456 if ((argc == 1) || (argc == 2)) { |
| 3457 FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0); | 3457 CFXJSE_Value* unitspanValue = GetSimpleValue(pThis, args, 0); |
| 3458 FXJSE_HVALUE unitValue = 0; | 3458 CFXJSE_Value* unitValue = nullptr; |
| 3459 CFX_ByteString unitspanString; | 3459 CFX_ByteString unitspanString; |
| 3460 FX_DOUBLE dFirstNumber = 0; | 3460 FX_DOUBLE dFirstNumber = 0; |
| 3461 CFX_ByteString strFirstUnit; | 3461 CFX_ByteString strFirstUnit; |
| 3462 CFX_ByteString strUnit; | 3462 CFX_ByteString strUnit; |
| 3463 if (FXJSE_Value_IsNull(unitspanValue)) { | 3463 if (FXJSE_Value_IsNull(unitspanValue)) { |
| 3464 FXJSE_Value_SetNull(args.GetReturnValue()); | 3464 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3465 } else { | 3465 } else { |
| 3466 HValueToUTF8String(unitspanValue, unitspanString); | 3466 ValueToUTF8String(unitspanValue, unitspanString); |
| 3467 const FX_CHAR* pData = unitspanString.c_str(); | 3467 const FX_CHAR* pData = unitspanString.c_str(); |
| 3468 if (pData) { | 3468 if (pData) { |
| 3469 int32_t u = 0; | 3469 int32_t u = 0; |
| 3470 while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || | 3470 while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || |
| 3471 *(pData + u) == 0x0B || *(pData + u) == 0x0C || | 3471 *(pData + u) == 0x0B || *(pData + u) == 0x0C || |
| 3472 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3472 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { |
| 3473 ++u; | 3473 ++u; |
| 3474 } | 3474 } |
| 3475 while (u < unitspanString.GetLength()) { | 3475 while (u < unitspanString.GetLength()) { |
| 3476 if ((*(pData + u) > '9' || *(pData + u) < '0') && | 3476 if ((*(pData + u) > '9' || *(pData + u) < '0') && |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3489 int32_t uLen = unitspanString.GetLength(); | 3489 int32_t uLen = unitspanString.GetLength(); |
| 3490 while (u < uLen) { | 3490 while (u < uLen) { |
| 3491 if (*(pData + u) == ' ') { | 3491 if (*(pData + u) == ' ') { |
| 3492 break; | 3492 break; |
| 3493 } | 3493 } |
| 3494 strFirstUnit += (*(pData + u)); | 3494 strFirstUnit += (*(pData + u)); |
| 3495 ++u; | 3495 ++u; |
| 3496 } | 3496 } |
| 3497 strFirstUnit.MakeLower(); | 3497 strFirstUnit.MakeLower(); |
| 3498 if (argc == 2) { | 3498 if (argc == 2) { |
| 3499 unitValue = GetSimpleHValue(hThis, args, 1); | 3499 unitValue = GetSimpleValue(pThis, args, 1); |
| 3500 CFX_ByteString unitTempString; | 3500 CFX_ByteString unitTempString; |
| 3501 HValueToUTF8String(unitValue, unitTempString); | 3501 ValueToUTF8String(unitValue, unitTempString); |
| 3502 const FX_CHAR* pData = unitTempString.c_str(); | 3502 const FX_CHAR* pData = unitTempString.c_str(); |
| 3503 int32_t u = 0; | 3503 int32_t u = 0; |
| 3504 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || | 3504 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || |
| 3505 *(pData + u) == 0x0B || *(pData + u) == 0x0C || | 3505 *(pData + u) == 0x0B || *(pData + u) == 0x0C || |
| 3506 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3506 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { |
| 3507 ++u; | 3507 ++u; |
| 3508 } | 3508 } |
| 3509 while (u < unitTempString.GetLength()) { | 3509 while (u < unitTempString.GetLength()) { |
| 3510 if ((*(pData + u) > '9' || *(pData + u) < '0') && | 3510 if ((*(pData + u) > '9' || *(pData + u) < '0') && |
| 3511 *(pData + u) != '.') { | 3511 *(pData + u) != '.') { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3596 } else { | 3596 } else { |
| 3597 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 3597 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 3598 } | 3598 } |
| 3599 } | 3599 } |
| 3600 FXJSE_Value_Release(unitspanValue); | 3600 FXJSE_Value_Release(unitspanValue); |
| 3601 if (argc == 2) { | 3601 if (argc == 2) { |
| 3602 FXJSE_Value_Release(unitValue); | 3602 FXJSE_Value_Release(unitValue); |
| 3603 } | 3603 } |
| 3604 } else { | 3604 } else { |
| 3605 CXFA_FM2JSContext* pContext = | 3605 CXFA_FM2JSContext* pContext = |
| 3606 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3606 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3607 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3607 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3608 L"UnitValue"); | 3608 L"UnitValue"); |
| 3609 } | 3609 } |
| 3610 } | 3610 } |
| 3611 void CXFA_FM2JSContext::At(FXJSE_HOBJECT hThis, | 3611 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, |
| 3612 const CFX_ByteStringC& szFuncName, | 3612 const CFX_ByteStringC& szFuncName, |
| 3613 CFXJSE_Arguments& args) { | 3613 CFXJSE_Arguments& args) { |
| 3614 CXFA_FM2JSContext* pContext = | 3614 CXFA_FM2JSContext* pContext = |
| 3615 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3615 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3616 if (args.GetLength() == 2) { | 3616 if (args.GetLength() == 2) { |
| 3617 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3617 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3618 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 3618 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 3619 if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { | 3619 if (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo)) { |
| 3620 FXJSE_Value_SetNull(args.GetReturnValue()); | 3620 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3621 } else { | 3621 } else { |
| 3622 CFX_ByteString stringTwo; | 3622 CFX_ByteString stringTwo; |
| 3623 HValueToUTF8String(argTwo, stringTwo); | 3623 ValueToUTF8String(argTwo, stringTwo); |
| 3624 if (stringTwo.IsEmpty()) { | 3624 if (stringTwo.IsEmpty()) { |
| 3625 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 3625 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
| 3626 } else { | 3626 } else { |
| 3627 CFX_ByteString stringOne; | 3627 CFX_ByteString stringOne; |
| 3628 HValueToUTF8String(argOne, stringOne); | 3628 ValueToUTF8String(argOne, stringOne); |
| 3629 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); | 3629 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); |
| 3630 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); | 3630 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); |
| 3631 } | 3631 } |
| 3632 } | 3632 } |
| 3633 FXJSE_Value_Release(argOne); | 3633 FXJSE_Value_Release(argOne); |
| 3634 FXJSE_Value_Release(argTwo); | 3634 FXJSE_Value_Release(argTwo); |
| 3635 } else { | 3635 } else { |
| 3636 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3636 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3637 L"At"); | 3637 L"At"); |
| 3638 } | 3638 } |
| 3639 } | 3639 } |
| 3640 void CXFA_FM2JSContext::Concat(FXJSE_HOBJECT hThis, | 3640 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, |
| 3641 const CFX_ByteStringC& szFuncName, | 3641 const CFX_ByteStringC& szFuncName, |
| 3642 CFXJSE_Arguments& args) { | 3642 CFXJSE_Arguments& args) { |
| 3643 CXFA_FM2JSContext* pContext = | 3643 CXFA_FM2JSContext* pContext = |
| 3644 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3644 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3645 int32_t argc = args.GetLength(); | 3645 int32_t argc = args.GetLength(); |
| 3646 if (argc >= 1) { | 3646 if (argc >= 1) { |
| 3647 CFX_ByteString resultString; | 3647 CFX_ByteString resultString; |
| 3648 FX_BOOL bAllNull = TRUE; | 3648 FX_BOOL bAllNull = TRUE; |
| 3649 FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argc); | 3649 CFXJSE_Value** argValues = FX_Alloc(CFXJSE_Value*, argc); |
| 3650 for (int32_t i = 0; i < argc; i++) { | 3650 for (int32_t i = 0; i < argc; i++) { |
| 3651 argValues[i] = GetSimpleHValue(hThis, args, i); | 3651 argValues[i] = GetSimpleValue(pThis, args, i); |
| 3652 if (!HValueIsNull(hThis, argValues[i])) { | 3652 if (!ValueIsNull(pThis, argValues[i])) { |
| 3653 CFX_ByteString valueStr; | 3653 CFX_ByteString valueStr; |
| 3654 HValueToUTF8String(argValues[i], valueStr); | 3654 ValueToUTF8String(argValues[i], valueStr); |
| 3655 resultString += valueStr; | 3655 resultString += valueStr; |
| 3656 bAllNull = FALSE; | 3656 bAllNull = FALSE; |
| 3657 } | 3657 } |
| 3658 } | 3658 } |
| 3659 for (int32_t i = 0; i < argc; i++) { | 3659 for (int32_t i = 0; i < argc; i++) { |
| 3660 FXJSE_Value_Release(argValues[i]); | 3660 FXJSE_Value_Release(argValues[i]); |
| 3661 } | 3661 } |
| 3662 FX_Free(argValues); | 3662 FX_Free(argValues); |
| 3663 if (bAllNull) { | 3663 if (bAllNull) { |
| 3664 FXJSE_Value_SetNull(args.GetReturnValue()); | 3664 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3665 } else { | 3665 } else { |
| 3666 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 3666 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 3667 resultString.AsStringC()); | 3667 resultString.AsStringC()); |
| 3668 } | 3668 } |
| 3669 } else { | 3669 } else { |
| 3670 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3670 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3671 L"Concat"); | 3671 L"Concat"); |
| 3672 } | 3672 } |
| 3673 } | 3673 } |
| 3674 void CXFA_FM2JSContext::Decode(FXJSE_HOBJECT hThis, | 3674 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, |
| 3675 const CFX_ByteStringC& szFuncName, | 3675 const CFX_ByteStringC& szFuncName, |
| 3676 CFXJSE_Arguments& args) { | 3676 CFXJSE_Arguments& args) { |
| 3677 CXFA_FM2JSContext* pContext = | 3677 CXFA_FM2JSContext* pContext = |
| 3678 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3678 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3679 int32_t argc = args.GetLength(); | 3679 int32_t argc = args.GetLength(); |
| 3680 if (argc == 1) { | 3680 if (argc == 1) { |
| 3681 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3681 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3682 if (HValueIsNull(hThis, argOne)) { | 3682 if (ValueIsNull(pThis, argOne)) { |
| 3683 FXJSE_Value_SetNull(args.GetReturnValue()); | 3683 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3684 } else { | 3684 } else { |
| 3685 CFX_ByteString toDecodeString; | 3685 CFX_ByteString toDecodeString; |
| 3686 HValueToUTF8String(argOne, toDecodeString); | 3686 ValueToUTF8String(argOne, toDecodeString); |
| 3687 CFX_ByteTextBuf resultBuf; | 3687 CFX_ByteTextBuf resultBuf; |
| 3688 DecodeURL(toDecodeString.AsStringC(), resultBuf); | 3688 DecodeURL(toDecodeString.AsStringC(), resultBuf); |
| 3689 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3689 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3690 } | 3690 } |
| 3691 FXJSE_Value_Release(argOne); | 3691 FXJSE_Value_Release(argOne); |
| 3692 } else if (argc == 2) { | 3692 } else if (argc == 2) { |
| 3693 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3693 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3694 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 3694 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 3695 if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { | 3695 if (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo)) { |
| 3696 FXJSE_Value_SetNull(args.GetReturnValue()); | 3696 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3697 } else { | 3697 } else { |
| 3698 CFX_ByteString toDecodeString; | 3698 CFX_ByteString toDecodeString; |
| 3699 HValueToUTF8String(argOne, toDecodeString); | 3699 ValueToUTF8String(argOne, toDecodeString); |
| 3700 CFX_ByteString identifyString; | 3700 CFX_ByteString identifyString; |
| 3701 HValueToUTF8String(argTwo, identifyString); | 3701 ValueToUTF8String(argTwo, identifyString); |
| 3702 CFX_ByteTextBuf resultBuf; | 3702 CFX_ByteTextBuf resultBuf; |
| 3703 if (identifyString.EqualNoCase("html")) { | 3703 if (identifyString.EqualNoCase("html")) { |
| 3704 DecodeHTML(toDecodeString.AsStringC(), resultBuf); | 3704 DecodeHTML(toDecodeString.AsStringC(), resultBuf); |
| 3705 } else if (identifyString.EqualNoCase("xml")) { | 3705 } else if (identifyString.EqualNoCase("xml")) { |
| 3706 DecodeXML(toDecodeString.AsStringC(), resultBuf); | 3706 DecodeXML(toDecodeString.AsStringC(), resultBuf); |
| 3707 } else { | 3707 } else { |
| 3708 DecodeURL(toDecodeString.AsStringC(), resultBuf); | 3708 DecodeURL(toDecodeString.AsStringC(), resultBuf); |
| 3709 } | 3709 } |
| 3710 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3710 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3711 } | 3711 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3935 iStrIndex = 0; | 3935 iStrIndex = 0; |
| 3936 strString[iStrIndex] = 0; | 3936 strString[iStrIndex] = 0; |
| 3937 ++i; | 3937 ++i; |
| 3938 iCode = 0; | 3938 iCode = 0; |
| 3939 } | 3939 } |
| 3940 wsXMLBuf.AppendChar(0); | 3940 wsXMLBuf.AppendChar(0); |
| 3941 szResultString.Clear(); | 3941 szResultString.Clear(); |
| 3942 szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()) | 3942 szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()) |
| 3943 .AsStringC(); | 3943 .AsStringC(); |
| 3944 } | 3944 } |
| 3945 void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis, | 3945 void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis, |
| 3946 const CFX_ByteStringC& szFuncName, | 3946 const CFX_ByteStringC& szFuncName, |
| 3947 CFXJSE_Arguments& args) { | 3947 CFXJSE_Arguments& args) { |
| 3948 CXFA_FM2JSContext* pContext = | 3948 CXFA_FM2JSContext* pContext = |
| 3949 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 3949 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3950 int32_t argc = args.GetLength(); | 3950 int32_t argc = args.GetLength(); |
| 3951 if (argc == 1) { | 3951 if (argc == 1) { |
| 3952 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3952 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3953 if (HValueIsNull(hThis, argOne)) { | 3953 if (ValueIsNull(pThis, argOne)) { |
| 3954 FXJSE_Value_SetNull(args.GetReturnValue()); | 3954 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3955 } else { | 3955 } else { |
| 3956 CFX_ByteString toEncodeString; | 3956 CFX_ByteString toEncodeString; |
| 3957 HValueToUTF8String(argOne, toEncodeString); | 3957 ValueToUTF8String(argOne, toEncodeString); |
| 3958 CFX_ByteTextBuf resultBuf; | 3958 CFX_ByteTextBuf resultBuf; |
| 3959 EncodeURL(toEncodeString.AsStringC(), resultBuf); | 3959 EncodeURL(toEncodeString.AsStringC(), resultBuf); |
| 3960 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3960 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3961 } | 3961 } |
| 3962 FXJSE_Value_Release(argOne); | 3962 FXJSE_Value_Release(argOne); |
| 3963 } else if (argc == 2) { | 3963 } else if (argc == 2) { |
| 3964 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3964 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3965 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 3965 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 3966 if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { | 3966 if (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo)) { |
| 3967 FXJSE_Value_SetNull(args.GetReturnValue()); | 3967 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3968 } else { | 3968 } else { |
| 3969 CFX_ByteString toEncodeString; | 3969 CFX_ByteString toEncodeString; |
| 3970 HValueToUTF8String(argOne, toEncodeString); | 3970 ValueToUTF8String(argOne, toEncodeString); |
| 3971 CFX_ByteString identifyString; | 3971 CFX_ByteString identifyString; |
| 3972 HValueToUTF8String(argTwo, identifyString); | 3972 ValueToUTF8String(argTwo, identifyString); |
| 3973 CFX_ByteTextBuf resultBuf; | 3973 CFX_ByteTextBuf resultBuf; |
| 3974 if (identifyString.EqualNoCase("html")) { | 3974 if (identifyString.EqualNoCase("html")) { |
| 3975 EncodeHTML(toEncodeString.AsStringC(), resultBuf); | 3975 EncodeHTML(toEncodeString.AsStringC(), resultBuf); |
| 3976 } else if (identifyString.EqualNoCase("xml")) { | 3976 } else if (identifyString.EqualNoCase("xml")) { |
| 3977 EncodeXML(toEncodeString.AsStringC(), resultBuf); | 3977 EncodeXML(toEncodeString.AsStringC(), resultBuf); |
| 3978 } else { | 3978 } else { |
| 3979 EncodeURL(toEncodeString.AsStringC(), resultBuf); | 3979 EncodeURL(toEncodeString.AsStringC(), resultBuf); |
| 3980 } | 3980 } |
| 3981 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3981 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3982 } | 3982 } |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4346 break; | 4346 break; |
| 4347 } | 4347 } |
| 4348 } | 4348 } |
| 4349 iIndex++; | 4349 iIndex++; |
| 4350 } | 4350 } |
| 4351 if (patternType == XFA_VT_NULL) { | 4351 if (patternType == XFA_VT_NULL) { |
| 4352 patternType = XFA_VT_TEXT | XFA_VT_FLOAT; | 4352 patternType = XFA_VT_TEXT | XFA_VT_FLOAT; |
| 4353 } | 4353 } |
| 4354 return FALSE; | 4354 return FALSE; |
| 4355 } | 4355 } |
| 4356 void CXFA_FM2JSContext::Format(FXJSE_HOBJECT hThis, | 4356 void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis, |
| 4357 const CFX_ByteStringC& szFuncName, | 4357 const CFX_ByteStringC& szFuncName, |
| 4358 CFXJSE_Arguments& args) { | 4358 CFXJSE_Arguments& args) { |
| 4359 CXFA_FM2JSContext* pContext = | 4359 CXFA_FM2JSContext* pContext = |
| 4360 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4360 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4361 int32_t argc = args.GetLength(); | 4361 int32_t argc = args.GetLength(); |
| 4362 if (argc >= 2) { | 4362 if (argc >= 2) { |
| 4363 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4363 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4364 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4364 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4365 CFX_ByteString szPattern; | 4365 CFX_ByteString szPattern; |
| 4366 HValueToUTF8String(argOne, szPattern); | 4366 ValueToUTF8String(argOne, szPattern); |
| 4367 CFX_ByteString szValue; | 4367 CFX_ByteString szValue; |
| 4368 HValueToUTF8String(argTwo, szValue); | 4368 ValueToUTF8String(argTwo, szValue); |
| 4369 CXFA_Document* pDoc = pContext->GetDocument(); | 4369 CXFA_Document* pDoc = pContext->GetDocument(); |
| 4370 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4370 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 4371 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4371 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 4372 ASSERT(pThisNode); | 4372 ASSERT(pThisNode); |
| 4373 CXFA_WidgetData widgetData(pThisNode); | 4373 CXFA_WidgetData widgetData(pThisNode); |
| 4374 IFX_Locale* pLocale = widgetData.GetLocal(); | 4374 IFX_Locale* pLocale = widgetData.GetLocal(); |
| 4375 uint32_t patternType; | 4375 uint32_t patternType; |
| 4376 FX_BOOL bCompelte = | 4376 FX_BOOL bCompelte = |
| 4377 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); | 4377 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); |
| 4378 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern.AsStringC()); | 4378 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern.AsStringC()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4434 } else { | 4434 } else { |
| 4435 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4435 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 4436 } | 4436 } |
| 4437 FXJSE_Value_Release(argOne); | 4437 FXJSE_Value_Release(argOne); |
| 4438 FXJSE_Value_Release(argTwo); | 4438 FXJSE_Value_Release(argTwo); |
| 4439 } else { | 4439 } else { |
| 4440 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4440 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4441 L"Format"); | 4441 L"Format"); |
| 4442 } | 4442 } |
| 4443 } | 4443 } |
| 4444 void CXFA_FM2JSContext::Left(FXJSE_HOBJECT hThis, | 4444 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, |
| 4445 const CFX_ByteStringC& szFuncName, | 4445 const CFX_ByteStringC& szFuncName, |
| 4446 CFXJSE_Arguments& args) { | 4446 CFXJSE_Arguments& args) { |
| 4447 CXFA_FM2JSContext* pContext = | 4447 CXFA_FM2JSContext* pContext = |
| 4448 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4448 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4449 if (args.GetLength() == 2) { | 4449 if (args.GetLength() == 2) { |
| 4450 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4450 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4451 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4451 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4452 FX_BOOL argIsNull = FALSE; | 4452 FX_BOOL argIsNull = FALSE; |
| 4453 if ((HValueIsNull(hThis, argOne)) || (HValueIsNull(hThis, argTwo))) { | 4453 if ((ValueIsNull(pThis, argOne)) || (ValueIsNull(pThis, argTwo))) { |
| 4454 argIsNull = TRUE; | 4454 argIsNull = TRUE; |
| 4455 } | 4455 } |
| 4456 if (argIsNull) { | 4456 if (argIsNull) { |
| 4457 FXJSE_Value_SetNull(args.GetReturnValue()); | 4457 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4458 } else { | 4458 } else { |
| 4459 CFX_ByteString sourceString; | 4459 CFX_ByteString sourceString; |
| 4460 HValueToUTF8String(argOne, sourceString); | 4460 ValueToUTF8String(argOne, sourceString); |
| 4461 int32_t count = HValueToInteger(hThis, argTwo); | 4461 int32_t count = ValueToInteger(pThis, argTwo); |
| 4462 if (count < 0) { | 4462 if (count < 0) { |
| 4463 count = 0; | 4463 count = 0; |
| 4464 } | 4464 } |
| 4465 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4465 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4466 sourceString.Left(count).AsStringC()); | 4466 sourceString.Left(count).AsStringC()); |
| 4467 } | 4467 } |
| 4468 FXJSE_Value_Release(argOne); | 4468 FXJSE_Value_Release(argOne); |
| 4469 FXJSE_Value_Release(argTwo); | 4469 FXJSE_Value_Release(argTwo); |
| 4470 } else { | 4470 } else { |
| 4471 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4471 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4472 L"Left"); | 4472 L"Left"); |
| 4473 } | 4473 } |
| 4474 } | 4474 } |
| 4475 void CXFA_FM2JSContext::Len(FXJSE_HOBJECT hThis, | 4475 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, |
| 4476 const CFX_ByteStringC& szFuncName, | 4476 const CFX_ByteStringC& szFuncName, |
| 4477 CFXJSE_Arguments& args) { | 4477 CFXJSE_Arguments& args) { |
| 4478 CXFA_FM2JSContext* pContext = | 4478 CXFA_FM2JSContext* pContext = |
| 4479 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4479 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4480 if (args.GetLength() == 1) { | 4480 if (args.GetLength() == 1) { |
| 4481 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4481 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4482 if (HValueIsNull(hThis, argOne)) { | 4482 if (ValueIsNull(pThis, argOne)) { |
| 4483 FXJSE_Value_SetNull(args.GetReturnValue()); | 4483 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4484 } else { | 4484 } else { |
| 4485 CFX_ByteString sourceString; | 4485 CFX_ByteString sourceString; |
| 4486 HValueToUTF8String(argOne, sourceString); | 4486 ValueToUTF8String(argOne, sourceString); |
| 4487 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); | 4487 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); |
| 4488 } | 4488 } |
| 4489 FXJSE_Value_Release(argOne); | 4489 FXJSE_Value_Release(argOne); |
| 4490 } else { | 4490 } else { |
| 4491 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4491 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4492 L"Len"); | 4492 L"Len"); |
| 4493 } | 4493 } |
| 4494 } | 4494 } |
| 4495 void CXFA_FM2JSContext::Lower(FXJSE_HOBJECT hThis, | 4495 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, |
| 4496 const CFX_ByteStringC& szFuncName, | 4496 const CFX_ByteStringC& szFuncName, |
| 4497 CFXJSE_Arguments& args) { | 4497 CFXJSE_Arguments& args) { |
| 4498 int32_t argc = args.GetLength(); | 4498 int32_t argc = args.GetLength(); |
| 4499 if ((argc > 0) && (argc < 3)) { | 4499 if ((argc > 0) && (argc < 3)) { |
| 4500 CFX_ByteString argString; | 4500 CFX_ByteString argString; |
| 4501 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4501 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4502 FXJSE_HVALUE localeValue = 0; | 4502 CFXJSE_Value* localeValue = nullptr; |
| 4503 if (HValueIsNull(hThis, argOne)) { | 4503 if (ValueIsNull(pThis, argOne)) { |
| 4504 FXJSE_Value_SetNull(args.GetReturnValue()); | 4504 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4505 } else { | 4505 } else { |
| 4506 if (argc == 2) { | 4506 if (argc == 2) { |
| 4507 localeValue = GetSimpleHValue(hThis, args, 1); | 4507 localeValue = GetSimpleValue(pThis, args, 1); |
| 4508 } | 4508 } |
| 4509 HValueToUTF8String(argOne, argString); | 4509 ValueToUTF8String(argOne, argString); |
| 4510 CFX_WideTextBuf lowStringBuf; | 4510 CFX_WideTextBuf lowStringBuf; |
| 4511 CFX_WideString wsArgString = | 4511 CFX_WideString wsArgString = |
| 4512 CFX_WideString::FromUTF8(argString.AsStringC()); | 4512 CFX_WideString::FromUTF8(argString.AsStringC()); |
| 4513 const FX_WCHAR* pData = wsArgString.c_str(); | 4513 const FX_WCHAR* pData = wsArgString.c_str(); |
| 4514 int32_t iLen = argString.GetLength(); | 4514 int32_t iLen = argString.GetLength(); |
| 4515 int32_t i = 0; | 4515 int32_t i = 0; |
| 4516 int32_t ch = 0; | 4516 int32_t ch = 0; |
| 4517 while (i < iLen) { | 4517 while (i < iLen) { |
| 4518 ch = *(pData + i); | 4518 ch = *(pData + i); |
| 4519 if (ch >= 0x41 && ch <= 0x5A) { | 4519 if (ch >= 0x41 && ch <= 0x5A) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4531 args.GetReturnValue(), | 4531 args.GetReturnValue(), |
| 4532 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) | 4532 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) |
| 4533 .AsStringC()); | 4533 .AsStringC()); |
| 4534 if (argc == 2) { | 4534 if (argc == 2) { |
| 4535 FXJSE_Value_Release(localeValue); | 4535 FXJSE_Value_Release(localeValue); |
| 4536 } | 4536 } |
| 4537 } | 4537 } |
| 4538 FXJSE_Value_Release(argOne); | 4538 FXJSE_Value_Release(argOne); |
| 4539 } else { | 4539 } else { |
| 4540 CXFA_FM2JSContext* pContext = | 4540 CXFA_FM2JSContext* pContext = |
| 4541 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4541 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4542 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4542 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4543 L"Lower"); | 4543 L"Lower"); |
| 4544 } | 4544 } |
| 4545 } | 4545 } |
| 4546 void CXFA_FM2JSContext::Ltrim(FXJSE_HOBJECT hThis, | 4546 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, |
| 4547 const CFX_ByteStringC& szFuncName, | 4547 const CFX_ByteStringC& szFuncName, |
| 4548 CFXJSE_Arguments& args) { | 4548 CFXJSE_Arguments& args) { |
| 4549 CXFA_FM2JSContext* pContext = | 4549 CXFA_FM2JSContext* pContext = |
| 4550 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4550 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4551 if (args.GetLength() == 1) { | 4551 if (args.GetLength() == 1) { |
| 4552 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4552 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4553 if (HValueIsNull(hThis, argOne)) { | 4553 if (ValueIsNull(pThis, argOne)) { |
| 4554 FXJSE_Value_SetNull(args.GetReturnValue()); | 4554 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4555 } else { | 4555 } else { |
| 4556 CFX_ByteString sourceString; | 4556 CFX_ByteString sourceString; |
| 4557 HValueToUTF8String(argOne, sourceString); | 4557 ValueToUTF8String(argOne, sourceString); |
| 4558 sourceString.TrimLeft(); | 4558 sourceString.TrimLeft(); |
| 4559 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4559 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4560 sourceString.AsStringC()); | 4560 sourceString.AsStringC()); |
| 4561 } | 4561 } |
| 4562 FXJSE_Value_Release(argOne); | 4562 FXJSE_Value_Release(argOne); |
| 4563 } else { | 4563 } else { |
| 4564 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4564 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4565 L"Ltrim"); | 4565 L"Ltrim"); |
| 4566 } | 4566 } |
| 4567 } | 4567 } |
| 4568 void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis, | 4568 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, |
| 4569 const CFX_ByteStringC& szFuncName, | 4569 const CFX_ByteStringC& szFuncName, |
| 4570 CFXJSE_Arguments& args) { | 4570 CFXJSE_Arguments& args) { |
| 4571 CXFA_FM2JSContext* pContext = | 4571 CXFA_FM2JSContext* pContext = |
| 4572 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4572 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4573 if (args.GetLength() == 2) { | 4573 if (args.GetLength() == 2) { |
| 4574 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4574 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4575 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4575 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4576 if (HValueIsNull(hThis, argTwo)) { | 4576 if (ValueIsNull(pThis, argTwo)) { |
| 4577 FXJSE_Value_SetNull(args.GetReturnValue()); | 4577 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4578 } else { | 4578 } else { |
| 4579 CFX_ByteString szPattern; | 4579 CFX_ByteString szPattern; |
| 4580 HValueToUTF8String(argOne, szPattern); | 4580 ValueToUTF8String(argOne, szPattern); |
| 4581 CFX_ByteString szValue; | 4581 CFX_ByteString szValue; |
| 4582 HValueToUTF8String(argTwo, szValue); | 4582 ValueToUTF8String(argTwo, szValue); |
| 4583 CXFA_Document* pDoc = pContext->GetDocument(); | 4583 CXFA_Document* pDoc = pContext->GetDocument(); |
| 4584 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4584 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 4585 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4585 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 4586 ASSERT(pThisNode); | 4586 ASSERT(pThisNode); |
| 4587 CXFA_WidgetData widgetData(pThisNode); | 4587 CXFA_WidgetData widgetData(pThisNode); |
| 4588 IFX_Locale* pLocale = widgetData.GetLocal(); | 4588 IFX_Locale* pLocale = widgetData.GetLocal(); |
| 4589 uint32_t patternType; | 4589 uint32_t patternType; |
| 4590 FX_BOOL bCompletePattern = | 4590 FX_BOOL bCompletePattern = |
| 4591 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); | 4591 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); |
| 4592 CFX_WideString wsPattern = | 4592 CFX_WideString wsPattern = |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4701 } | 4701 } |
| 4702 } | 4702 } |
| 4703 } | 4703 } |
| 4704 FXJSE_Value_Release(argOne); | 4704 FXJSE_Value_Release(argOne); |
| 4705 FXJSE_Value_Release(argTwo); | 4705 FXJSE_Value_Release(argTwo); |
| 4706 } else { | 4706 } else { |
| 4707 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4707 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4708 L"Parse"); | 4708 L"Parse"); |
| 4709 } | 4709 } |
| 4710 } | 4710 } |
| 4711 void CXFA_FM2JSContext::Replace(FXJSE_HOBJECT hThis, | 4711 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, |
| 4712 const CFX_ByteStringC& szFuncName, | 4712 const CFX_ByteStringC& szFuncName, |
| 4713 CFXJSE_Arguments& args) { | 4713 CFXJSE_Arguments& args) { |
| 4714 int32_t argc = args.GetLength(); | 4714 int32_t argc = args.GetLength(); |
| 4715 if ((argc == 2) || (argc == 3)) { | 4715 if ((argc == 2) || (argc == 3)) { |
| 4716 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4716 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4717 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4717 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4718 FXJSE_HVALUE argThree = 0; | 4718 CFXJSE_Value* argThree = nullptr; |
| 4719 CFX_ByteString oneString; | 4719 CFX_ByteString oneString; |
| 4720 CFX_ByteString twoString; | 4720 CFX_ByteString twoString; |
| 4721 CFX_ByteString threeString; | 4721 CFX_ByteString threeString; |
| 4722 if (!HValueIsNull(hThis, argOne) && !HValueIsNull(hThis, argTwo)) { | 4722 if (!ValueIsNull(pThis, argOne) && !ValueIsNull(pThis, argTwo)) { |
| 4723 HValueToUTF8String(argOne, oneString); | 4723 ValueToUTF8String(argOne, oneString); |
| 4724 HValueToUTF8String(argTwo, twoString); | 4724 ValueToUTF8String(argTwo, twoString); |
| 4725 } | 4725 } |
| 4726 if (argc == 3) { | 4726 if (argc == 3) { |
| 4727 argThree = GetSimpleHValue(hThis, args, 2); | 4727 argThree = GetSimpleValue(pThis, args, 2); |
| 4728 HValueToUTF8String(argThree, threeString); | 4728 ValueToUTF8String(argThree, threeString); |
| 4729 } | 4729 } |
| 4730 int32_t iSrcLen = oneString.GetLength(); | 4730 int32_t iSrcLen = oneString.GetLength(); |
| 4731 int32_t iFindLen = twoString.GetLength(); | 4731 int32_t iFindLen = twoString.GetLength(); |
| 4732 CFX_ByteTextBuf resultString; | 4732 CFX_ByteTextBuf resultString; |
| 4733 int32_t iFindIndex = 0; | 4733 int32_t iFindIndex = 0; |
| 4734 uint8_t ch = 0; | 4734 uint8_t ch = 0; |
| 4735 for (int32_t u = 0; u < iSrcLen; ++u) { | 4735 for (int32_t u = 0; u < iSrcLen; ++u) { |
| 4736 ch = oneString.GetAt(u); | 4736 ch = oneString.GetAt(u); |
| 4737 if (ch == twoString.GetAt(iFindIndex)) { | 4737 if (ch == twoString.GetAt(iFindIndex)) { |
| 4738 int32_t iTemp = u + 1; | 4738 int32_t iTemp = u + 1; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4761 } | 4761 } |
| 4762 resultString.AppendChar(0); | 4762 resultString.AppendChar(0); |
| 4763 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 4763 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
| 4764 FXJSE_Value_Release(argOne); | 4764 FXJSE_Value_Release(argOne); |
| 4765 FXJSE_Value_Release(argTwo); | 4765 FXJSE_Value_Release(argTwo); |
| 4766 if (argc == 3) { | 4766 if (argc == 3) { |
| 4767 FXJSE_Value_Release(argThree); | 4767 FXJSE_Value_Release(argThree); |
| 4768 } | 4768 } |
| 4769 } else { | 4769 } else { |
| 4770 CXFA_FM2JSContext* pContext = | 4770 CXFA_FM2JSContext* pContext = |
| 4771 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4771 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4772 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4772 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4773 L"Replace"); | 4773 L"Replace"); |
| 4774 } | 4774 } |
| 4775 } | 4775 } |
| 4776 void CXFA_FM2JSContext::Right(FXJSE_HOBJECT hThis, | 4776 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, |
| 4777 const CFX_ByteStringC& szFuncName, | 4777 const CFX_ByteStringC& szFuncName, |
| 4778 CFXJSE_Arguments& args) { | 4778 CFXJSE_Arguments& args) { |
| 4779 CXFA_FM2JSContext* pContext = | 4779 CXFA_FM2JSContext* pContext = |
| 4780 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4780 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4781 if (args.GetLength() == 2) { | 4781 if (args.GetLength() == 2) { |
| 4782 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4782 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4783 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4783 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4784 FX_BOOL argIsNull = FALSE; | 4784 FX_BOOL argIsNull = FALSE; |
| 4785 if ((HValueIsNull(hThis, argOne)) || (HValueIsNull(hThis, argTwo))) { | 4785 if ((ValueIsNull(pThis, argOne)) || (ValueIsNull(pThis, argTwo))) { |
| 4786 argIsNull = TRUE; | 4786 argIsNull = TRUE; |
| 4787 } | 4787 } |
| 4788 if (argIsNull) { | 4788 if (argIsNull) { |
| 4789 FXJSE_Value_SetNull(args.GetReturnValue()); | 4789 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4790 } else { | 4790 } else { |
| 4791 CFX_ByteString sourceString; | 4791 CFX_ByteString sourceString; |
| 4792 HValueToUTF8String(argOne, sourceString); | 4792 ValueToUTF8String(argOne, sourceString); |
| 4793 int32_t count = HValueToInteger(hThis, argTwo); | 4793 int32_t count = ValueToInteger(pThis, argTwo); |
| 4794 if (count < 0) { | 4794 if (count < 0) { |
| 4795 count = 0; | 4795 count = 0; |
| 4796 } | 4796 } |
| 4797 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4797 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4798 sourceString.Right(count).AsStringC()); | 4798 sourceString.Right(count).AsStringC()); |
| 4799 } | 4799 } |
| 4800 FXJSE_Value_Release(argOne); | 4800 FXJSE_Value_Release(argOne); |
| 4801 FXJSE_Value_Release(argTwo); | 4801 FXJSE_Value_Release(argTwo); |
| 4802 } else { | 4802 } else { |
| 4803 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4803 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4804 L"Right"); | 4804 L"Right"); |
| 4805 } | 4805 } |
| 4806 } | 4806 } |
| 4807 void CXFA_FM2JSContext::Rtrim(FXJSE_HOBJECT hThis, | 4807 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, |
| 4808 const CFX_ByteStringC& szFuncName, | 4808 const CFX_ByteStringC& szFuncName, |
| 4809 CFXJSE_Arguments& args) { | 4809 CFXJSE_Arguments& args) { |
| 4810 CXFA_FM2JSContext* pContext = | 4810 CXFA_FM2JSContext* pContext = |
| 4811 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4811 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4812 if (args.GetLength() == 1) { | 4812 if (args.GetLength() == 1) { |
| 4813 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4813 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4814 if (HValueIsNull(hThis, argOne)) { | 4814 if (ValueIsNull(pThis, argOne)) { |
| 4815 FXJSE_Value_SetNull(args.GetReturnValue()); | 4815 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4816 } else { | 4816 } else { |
| 4817 CFX_ByteString sourceString; | 4817 CFX_ByteString sourceString; |
| 4818 HValueToUTF8String(argOne, sourceString); | 4818 ValueToUTF8String(argOne, sourceString); |
| 4819 sourceString.TrimRight(); | 4819 sourceString.TrimRight(); |
| 4820 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4820 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4821 sourceString.AsStringC()); | 4821 sourceString.AsStringC()); |
| 4822 } | 4822 } |
| 4823 FXJSE_Value_Release(argOne); | 4823 FXJSE_Value_Release(argOne); |
| 4824 } else { | 4824 } else { |
| 4825 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4825 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4826 L"Rtrim"); | 4826 L"Rtrim"); |
| 4827 } | 4827 } |
| 4828 } | 4828 } |
| 4829 void CXFA_FM2JSContext::Space(FXJSE_HOBJECT hThis, | 4829 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, |
| 4830 const CFX_ByteStringC& szFuncName, | 4830 const CFX_ByteStringC& szFuncName, |
| 4831 CFXJSE_Arguments& args) { | 4831 CFXJSE_Arguments& args) { |
| 4832 CXFA_FM2JSContext* pContext = | 4832 CXFA_FM2JSContext* pContext = |
| 4833 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4833 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4834 if (args.GetLength() == 1) { | 4834 if (args.GetLength() == 1) { |
| 4835 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4835 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4836 if (FXJSE_Value_IsNull(argOne)) { | 4836 if (FXJSE_Value_IsNull(argOne)) { |
| 4837 FXJSE_Value_SetNull(args.GetReturnValue()); | 4837 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4838 } else { | 4838 } else { |
| 4839 int32_t count = 0; | 4839 int32_t count = 0; |
| 4840 count = HValueToInteger(hThis, argOne); | 4840 count = ValueToInteger(pThis, argOne); |
| 4841 count = (count < 0) ? 0 : count; | 4841 count = (count < 0) ? 0 : count; |
| 4842 CFX_ByteTextBuf spaceString; | 4842 CFX_ByteTextBuf spaceString; |
| 4843 int32_t index = 0; | 4843 int32_t index = 0; |
| 4844 while (index < count) { | 4844 while (index < count) { |
| 4845 spaceString.AppendByte(' '); | 4845 spaceString.AppendByte(' '); |
| 4846 index++; | 4846 index++; |
| 4847 } | 4847 } |
| 4848 spaceString.AppendByte(0); | 4848 spaceString.AppendByte(0); |
| 4849 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); | 4849 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); |
| 4850 } | 4850 } |
| 4851 FXJSE_Value_Release(argOne); | 4851 FXJSE_Value_Release(argOne); |
| 4852 } else { | 4852 } else { |
| 4853 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4853 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4854 L"Space"); | 4854 L"Space"); |
| 4855 } | 4855 } |
| 4856 } | 4856 } |
| 4857 void CXFA_FM2JSContext::Str(FXJSE_HOBJECT hThis, | 4857 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, |
| 4858 const CFX_ByteStringC& szFuncName, | 4858 const CFX_ByteStringC& szFuncName, |
| 4859 CFXJSE_Arguments& args) { | 4859 CFXJSE_Arguments& args) { |
| 4860 int32_t argc = args.GetLength(); | 4860 int32_t argc = args.GetLength(); |
| 4861 if ((argc > 0) && (argc < 4)) { | 4861 if ((argc > 0) && (argc < 4)) { |
| 4862 FX_BOOL bFlags = FALSE; | 4862 FX_BOOL bFlags = FALSE; |
| 4863 FX_FLOAT fNumber = 0.0f; | 4863 FX_FLOAT fNumber = 0.0f; |
| 4864 int32_t iWidth = 10; | 4864 int32_t iWidth = 10; |
| 4865 int32_t iPrecision = 0; | 4865 int32_t iPrecision = 0; |
| 4866 FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0); | 4866 CFXJSE_Value* numberValue = GetSimpleValue(pThis, args, 0); |
| 4867 FXJSE_HVALUE widthValue = 0; | 4867 CFXJSE_Value* widthValue = nullptr; |
| 4868 FXJSE_HVALUE precisionValue = 0; | 4868 CFXJSE_Value* precisionValue = nullptr; |
| 4869 if (FXJSE_Value_IsNull(numberValue)) { | 4869 if (FXJSE_Value_IsNull(numberValue)) { |
| 4870 bFlags = TRUE; | 4870 bFlags = TRUE; |
| 4871 } else { | 4871 } else { |
| 4872 fNumber = HValueToFloat(hThis, numberValue); | 4872 fNumber = ValueToFloat(pThis, numberValue); |
| 4873 } | 4873 } |
| 4874 if (argc > 1) { | 4874 if (argc > 1) { |
| 4875 widthValue = GetSimpleHValue(hThis, args, 1); | 4875 widthValue = GetSimpleValue(pThis, args, 1); |
| 4876 iWidth = (int32_t)HValueToFloat(hThis, widthValue); | 4876 iWidth = (int32_t)ValueToFloat(pThis, widthValue); |
| 4877 } | 4877 } |
| 4878 if (argc == 3) { | 4878 if (argc == 3) { |
| 4879 precisionValue = GetSimpleHValue(hThis, args, 2); | 4879 precisionValue = GetSimpleValue(pThis, args, 2); |
| 4880 iPrecision = (int32_t)HValueToFloat(hThis, precisionValue); | 4880 iPrecision = (int32_t)ValueToFloat(pThis, precisionValue); |
| 4881 if (iPrecision < 0) { | 4881 if (iPrecision < 0) { |
| 4882 iPrecision = 0; | 4882 iPrecision = 0; |
| 4883 } | 4883 } |
| 4884 } | 4884 } |
| 4885 if (!bFlags) { | 4885 if (!bFlags) { |
| 4886 CFX_ByteString numberString; | 4886 CFX_ByteString numberString; |
| 4887 CFX_ByteString formatStr = "%"; | 4887 CFX_ByteString formatStr = "%"; |
| 4888 if (iPrecision) { | 4888 if (iPrecision) { |
| 4889 formatStr += "."; | 4889 formatStr += "."; |
| 4890 formatStr += CFX_ByteString::FormatInteger(iPrecision); | 4890 formatStr += CFX_ByteString::FormatInteger(iPrecision); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4968 } | 4968 } |
| 4969 FXJSE_Value_Release(numberValue); | 4969 FXJSE_Value_Release(numberValue); |
| 4970 if (argc > 1) { | 4970 if (argc > 1) { |
| 4971 FXJSE_Value_Release(widthValue); | 4971 FXJSE_Value_Release(widthValue); |
| 4972 if (argc == 3) { | 4972 if (argc == 3) { |
| 4973 FXJSE_Value_Release(precisionValue); | 4973 FXJSE_Value_Release(precisionValue); |
| 4974 } | 4974 } |
| 4975 } | 4975 } |
| 4976 } else { | 4976 } else { |
| 4977 CXFA_FM2JSContext* pContext = | 4977 CXFA_FM2JSContext* pContext = |
| 4978 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4978 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4979 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4979 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4980 L"Str"); | 4980 L"Str"); |
| 4981 } | 4981 } |
| 4982 } | 4982 } |
| 4983 void CXFA_FM2JSContext::Stuff(FXJSE_HOBJECT hThis, | 4983 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, |
| 4984 const CFX_ByteStringC& szFuncName, | 4984 const CFX_ByteStringC& szFuncName, |
| 4985 CFXJSE_Arguments& args) { | 4985 CFXJSE_Arguments& args) { |
| 4986 int32_t argc = args.GetLength(); | 4986 int32_t argc = args.GetLength(); |
| 4987 if ((argc == 3) || (argc == 4)) { | 4987 if ((argc == 3) || (argc == 4)) { |
| 4988 CFX_ByteString sourceString; | 4988 CFX_ByteString sourceString; |
| 4989 CFX_ByteString insertString; | 4989 CFX_ByteString insertString; |
| 4990 int32_t iLength = 0; | 4990 int32_t iLength = 0; |
| 4991 int32_t iStart = 0; | 4991 int32_t iStart = 0; |
| 4992 int32_t iDelete = 0; | 4992 int32_t iDelete = 0; |
| 4993 FXJSE_HVALUE sourceValue = GetSimpleHValue(hThis, args, 0); | 4993 CFXJSE_Value* sourceValue = GetSimpleValue(pThis, args, 0); |
| 4994 FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); | 4994 CFXJSE_Value* startValue = GetSimpleValue(pThis, args, 1); |
| 4995 FXJSE_HVALUE deleteValue = GetSimpleHValue(hThis, args, 2); | 4995 CFXJSE_Value* deleteValue = GetSimpleValue(pThis, args, 2); |
| 4996 FXJSE_HVALUE insertValue = 0; | 4996 CFXJSE_Value* insertValue = nullptr; |
| 4997 if (!FXJSE_Value_IsNull(sourceValue) && !FXJSE_Value_IsNull(startValue) && | 4997 if (!FXJSE_Value_IsNull(sourceValue) && !FXJSE_Value_IsNull(startValue) && |
| 4998 !FXJSE_Value_IsNull(deleteValue)) { | 4998 !FXJSE_Value_IsNull(deleteValue)) { |
| 4999 HValueToUTF8String(sourceValue, sourceString); | 4999 ValueToUTF8String(sourceValue, sourceString); |
| 5000 iLength = sourceString.GetLength(); | 5000 iLength = sourceString.GetLength(); |
| 5001 iStart = (int32_t)HValueToFloat(hThis, startValue); | 5001 iStart = (int32_t)ValueToFloat(pThis, startValue); |
| 5002 if (iStart < 1) { | 5002 if (iStart < 1) { |
| 5003 iStart = 1; | 5003 iStart = 1; |
| 5004 } | 5004 } |
| 5005 if (iStart > iLength) { | 5005 if (iStart > iLength) { |
| 5006 iStart = iLength; | 5006 iStart = iLength; |
| 5007 } | 5007 } |
| 5008 iDelete = (int32_t)HValueToFloat(hThis, deleteValue); | 5008 iDelete = (int32_t)ValueToFloat(pThis, deleteValue); |
| 5009 if (iDelete <= 0) { | 5009 if (iDelete <= 0) { |
| 5010 iDelete = 0; | 5010 iDelete = 0; |
| 5011 } | 5011 } |
| 5012 } | 5012 } |
| 5013 if (argc == 4) { | 5013 if (argc == 4) { |
| 5014 insertValue = GetSimpleHValue(hThis, args, 3); | 5014 insertValue = GetSimpleValue(pThis, args, 3); |
| 5015 HValueToUTF8String(insertValue, insertString); | 5015 ValueToUTF8String(insertValue, insertString); |
| 5016 } | 5016 } |
| 5017 iStart -= 1; | 5017 iStart -= 1; |
| 5018 CFX_ByteTextBuf resultString; | 5018 CFX_ByteTextBuf resultString; |
| 5019 int32_t i = 0; | 5019 int32_t i = 0; |
| 5020 while (i < iStart) { | 5020 while (i < iStart) { |
| 5021 resultString.AppendChar(sourceString.GetAt(i)); | 5021 resultString.AppendChar(sourceString.GetAt(i)); |
| 5022 ++i; | 5022 ++i; |
| 5023 } | 5023 } |
| 5024 resultString << insertString.AsStringC(); | 5024 resultString << insertString.AsStringC(); |
| 5025 i = iStart + iDelete; | 5025 i = iStart + iDelete; |
| 5026 while (i < iLength) { | 5026 while (i < iLength) { |
| 5027 resultString.AppendChar(sourceString.GetAt(i)); | 5027 resultString.AppendChar(sourceString.GetAt(i)); |
| 5028 ++i; | 5028 ++i; |
| 5029 } | 5029 } |
| 5030 resultString.AppendChar(0); | 5030 resultString.AppendChar(0); |
| 5031 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 5031 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
| 5032 FXJSE_Value_Release(sourceValue); | 5032 FXJSE_Value_Release(sourceValue); |
| 5033 FXJSE_Value_Release(startValue); | 5033 FXJSE_Value_Release(startValue); |
| 5034 FXJSE_Value_Release(deleteValue); | 5034 FXJSE_Value_Release(deleteValue); |
| 5035 if (argc == 4) { | 5035 if (argc == 4) { |
| 5036 FXJSE_Value_Release(insertValue); | 5036 FXJSE_Value_Release(insertValue); |
| 5037 } | 5037 } |
| 5038 } else { | 5038 } else { |
| 5039 CXFA_FM2JSContext* pContext = | 5039 CXFA_FM2JSContext* pContext = |
| 5040 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5040 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5041 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5041 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5042 L"Stuff"); | 5042 L"Stuff"); |
| 5043 } | 5043 } |
| 5044 } | 5044 } |
| 5045 void CXFA_FM2JSContext::Substr(FXJSE_HOBJECT hThis, | 5045 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, |
| 5046 const CFX_ByteStringC& szFuncName, | 5046 const CFX_ByteStringC& szFuncName, |
| 5047 CFXJSE_Arguments& args) { | 5047 CFXJSE_Arguments& args) { |
| 5048 int32_t argc = args.GetLength(); | 5048 int32_t argc = args.GetLength(); |
| 5049 if (argc == 3) { | 5049 if (argc == 3) { |
| 5050 FXJSE_HVALUE stringValue = GetSimpleHValue(hThis, args, 0); | 5050 CFXJSE_Value* stringValue = GetSimpleValue(pThis, args, 0); |
| 5051 FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); | 5051 CFXJSE_Value* startValue = GetSimpleValue(pThis, args, 1); |
| 5052 FXJSE_HVALUE endValue = GetSimpleHValue(hThis, args, 2); | 5052 CFXJSE_Value* endValue = GetSimpleValue(pThis, args, 2); |
| 5053 if (HValueIsNull(hThis, stringValue) || (HValueIsNull(hThis, startValue)) || | 5053 if (ValueIsNull(pThis, stringValue) || (ValueIsNull(pThis, startValue)) || |
| 5054 (HValueIsNull(hThis, endValue))) { | 5054 (ValueIsNull(pThis, endValue))) { |
| 5055 FXJSE_Value_SetNull(args.GetReturnValue()); | 5055 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5056 } else { | 5056 } else { |
| 5057 CFX_ByteString szSourceStr; | 5057 CFX_ByteString szSourceStr; |
| 5058 int32_t iStart = 0; | 5058 int32_t iStart = 0; |
| 5059 int32_t iCount = 0; | 5059 int32_t iCount = 0; |
| 5060 HValueToUTF8String(stringValue, szSourceStr); | 5060 ValueToUTF8String(stringValue, szSourceStr); |
| 5061 int32_t iLength = szSourceStr.GetLength(); | 5061 int32_t iLength = szSourceStr.GetLength(); |
| 5062 if (iLength == 0) { | 5062 if (iLength == 0) { |
| 5063 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5063 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 5064 } else { | 5064 } else { |
| 5065 iStart = (int32_t)HValueToFloat(hThis, startValue); | 5065 iStart = (int32_t)ValueToFloat(pThis, startValue); |
| 5066 iCount = (int32_t)HValueToFloat(hThis, endValue); | 5066 iCount = (int32_t)ValueToFloat(pThis, endValue); |
| 5067 if (iStart < 1) { | 5067 if (iStart < 1) { |
| 5068 iStart = 1; | 5068 iStart = 1; |
| 5069 } | 5069 } |
| 5070 if (iStart > iLength) { | 5070 if (iStart > iLength) { |
| 5071 iStart = iLength; | 5071 iStart = iLength; |
| 5072 } | 5072 } |
| 5073 if (iCount <= 0) { | 5073 if (iCount <= 0) { |
| 5074 iCount = 0; | 5074 iCount = 0; |
| 5075 } | 5075 } |
| 5076 iStart -= 1; | 5076 iStart -= 1; |
| 5077 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5077 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 5078 szSourceStr.Mid(iStart, iCount).AsStringC()); | 5078 szSourceStr.Mid(iStart, iCount).AsStringC()); |
| 5079 } | 5079 } |
| 5080 } | 5080 } |
| 5081 FXJSE_Value_Release(stringValue); | 5081 FXJSE_Value_Release(stringValue); |
| 5082 FXJSE_Value_Release(startValue); | 5082 FXJSE_Value_Release(startValue); |
| 5083 FXJSE_Value_Release(endValue); | 5083 FXJSE_Value_Release(endValue); |
| 5084 } else { | 5084 } else { |
| 5085 CXFA_FM2JSContext* pContext = | 5085 CXFA_FM2JSContext* pContext = |
| 5086 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5086 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5087 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5087 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5088 L"Substr"); | 5088 L"Substr"); |
| 5089 } | 5089 } |
| 5090 } | 5090 } |
| 5091 void CXFA_FM2JSContext::Uuid(FXJSE_HOBJECT hThis, | 5091 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, |
| 5092 const CFX_ByteStringC& szFuncName, | 5092 const CFX_ByteStringC& szFuncName, |
| 5093 CFXJSE_Arguments& args) { | 5093 CFXJSE_Arguments& args) { |
| 5094 int32_t argc = args.GetLength(); | 5094 int32_t argc = args.GetLength(); |
| 5095 if ((argc == 0) || (argc == 1)) { | 5095 if ((argc == 0) || (argc == 1)) { |
| 5096 int32_t iNum = 0; | 5096 int32_t iNum = 0; |
| 5097 FXJSE_HVALUE argOne = 0; | 5097 CFXJSE_Value* argOne = nullptr; |
| 5098 if (argc == 1) { | 5098 if (argc == 1) { |
| 5099 argOne = GetSimpleHValue(hThis, args, 0); | 5099 argOne = GetSimpleValue(pThis, args, 0); |
| 5100 iNum = (int32_t)HValueToFloat(hThis, argOne); | 5100 iNum = (int32_t)ValueToFloat(pThis, argOne); |
| 5101 } | 5101 } |
| 5102 FX_GUID guid; | 5102 FX_GUID guid; |
| 5103 FX_GUID_CreateV4(&guid); | 5103 FX_GUID_CreateV4(&guid); |
| 5104 CFX_ByteString bsUId; | 5104 CFX_ByteString bsUId; |
| 5105 FX_GUID_ToString(&guid, bsUId, iNum); | 5105 FX_GUID_ToString(&guid, bsUId, iNum); |
| 5106 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); | 5106 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); |
| 5107 if (argc == 1) { | 5107 if (argc == 1) { |
| 5108 FXJSE_Value_Release(argOne); | 5108 FXJSE_Value_Release(argOne); |
| 5109 } | 5109 } |
| 5110 } else { | 5110 } else { |
| 5111 CXFA_FM2JSContext* pContext = | 5111 CXFA_FM2JSContext* pContext = |
| 5112 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5112 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5113 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5113 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5114 L"Uuid"); | 5114 L"Uuid"); |
| 5115 } | 5115 } |
| 5116 } | 5116 } |
| 5117 void CXFA_FM2JSContext::Upper(FXJSE_HOBJECT hThis, | 5117 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, |
| 5118 const CFX_ByteStringC& szFuncName, | 5118 const CFX_ByteStringC& szFuncName, |
| 5119 CFXJSE_Arguments& args) { | 5119 CFXJSE_Arguments& args) { |
| 5120 int32_t argc = args.GetLength(); | 5120 int32_t argc = args.GetLength(); |
| 5121 if ((argc > 0) && (argc < 3)) { | 5121 if ((argc > 0) && (argc < 3)) { |
| 5122 CFX_ByteString argString; | 5122 CFX_ByteString argString; |
| 5123 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5123 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5124 FXJSE_HVALUE localeValue = 0; | 5124 CFXJSE_Value* localeValue = nullptr; |
| 5125 if (HValueIsNull(hThis, argOne)) { | 5125 if (ValueIsNull(pThis, argOne)) { |
| 5126 FXJSE_Value_SetNull(args.GetReturnValue()); | 5126 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5127 } else { | 5127 } else { |
| 5128 if (argc == 2) { | 5128 if (argc == 2) { |
| 5129 localeValue = GetSimpleHValue(hThis, args, 1); | 5129 localeValue = GetSimpleValue(pThis, args, 1); |
| 5130 } | 5130 } |
| 5131 HValueToUTF8String(argOne, argString); | 5131 ValueToUTF8String(argOne, argString); |
| 5132 CFX_WideTextBuf upperStringBuf; | 5132 CFX_WideTextBuf upperStringBuf; |
| 5133 CFX_WideString wsArgString = | 5133 CFX_WideString wsArgString = |
| 5134 CFX_WideString::FromUTF8(argString.AsStringC()); | 5134 CFX_WideString::FromUTF8(argString.AsStringC()); |
| 5135 const FX_WCHAR* pData = wsArgString.c_str(); | 5135 const FX_WCHAR* pData = wsArgString.c_str(); |
| 5136 int32_t iLen = wsArgString.GetLength(); | 5136 int32_t iLen = wsArgString.GetLength(); |
| 5137 int32_t i = 0; | 5137 int32_t i = 0; |
| 5138 int32_t ch = 0; | 5138 int32_t ch = 0; |
| 5139 while (i < iLen) { | 5139 while (i < iLen) { |
| 5140 ch = *(pData + i); | 5140 ch = *(pData + i); |
| 5141 if (ch >= 0x61 && ch <= 0x7A) { | 5141 if (ch >= 0x61 && ch <= 0x7A) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5153 args.GetReturnValue(), | 5153 args.GetReturnValue(), |
| 5154 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) | 5154 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) |
| 5155 .AsStringC()); | 5155 .AsStringC()); |
| 5156 if (argc == 2) { | 5156 if (argc == 2) { |
| 5157 FXJSE_Value_Release(localeValue); | 5157 FXJSE_Value_Release(localeValue); |
| 5158 } | 5158 } |
| 5159 } | 5159 } |
| 5160 FXJSE_Value_Release(argOne); | 5160 FXJSE_Value_Release(argOne); |
| 5161 } else { | 5161 } else { |
| 5162 CXFA_FM2JSContext* pContext = | 5162 CXFA_FM2JSContext* pContext = |
| 5163 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5163 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5164 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5164 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5165 L"Upper"); | 5165 L"Upper"); |
| 5166 } | 5166 } |
| 5167 } | 5167 } |
| 5168 void CXFA_FM2JSContext::WordNum(FXJSE_HOBJECT hThis, | 5168 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, |
| 5169 const CFX_ByteStringC& szFuncName, | 5169 const CFX_ByteStringC& szFuncName, |
| 5170 CFXJSE_Arguments& args) { | 5170 CFXJSE_Arguments& args) { |
| 5171 int32_t argc = args.GetLength(); | 5171 int32_t argc = args.GetLength(); |
| 5172 if ((argc > 0) && (argc < 4)) { | 5172 if ((argc > 0) && (argc < 4)) { |
| 5173 FX_BOOL bFlags = FALSE; | 5173 FX_BOOL bFlags = FALSE; |
| 5174 FX_FLOAT fNumber = 0.0f; | 5174 FX_FLOAT fNumber = 0.0f; |
| 5175 int32_t iIdentifier = 0; | 5175 int32_t iIdentifier = 0; |
| 5176 CFX_ByteString localeString; | 5176 CFX_ByteString localeString; |
| 5177 FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0); | 5177 CFXJSE_Value* numberValue = GetSimpleValue(pThis, args, 0); |
| 5178 FXJSE_HVALUE identifierValue = 0; | 5178 CFXJSE_Value* identifierValue = nullptr; |
| 5179 FXJSE_HVALUE localeValue = 0; | 5179 CFXJSE_Value* localeValue = nullptr; |
| 5180 if (FXJSE_Value_IsNull(numberValue)) { | 5180 if (FXJSE_Value_IsNull(numberValue)) { |
| 5181 bFlags = TRUE; | 5181 bFlags = TRUE; |
| 5182 } else { | 5182 } else { |
| 5183 fNumber = HValueToFloat(hThis, numberValue); | 5183 fNumber = ValueToFloat(pThis, numberValue); |
| 5184 } | 5184 } |
| 5185 if (argc > 1) { | 5185 if (argc > 1) { |
| 5186 identifierValue = GetSimpleHValue(hThis, args, 1); | 5186 identifierValue = GetSimpleValue(pThis, args, 1); |
| 5187 if (FXJSE_Value_IsNull(identifierValue)) { | 5187 if (FXJSE_Value_IsNull(identifierValue)) { |
| 5188 bFlags = TRUE; | 5188 bFlags = TRUE; |
| 5189 } else { | 5189 } else { |
| 5190 iIdentifier = (int32_t)HValueToFloat(hThis, identifierValue); | 5190 iIdentifier = (int32_t)ValueToFloat(pThis, identifierValue); |
| 5191 } | 5191 } |
| 5192 } | 5192 } |
| 5193 if (argc == 3) { | 5193 if (argc == 3) { |
| 5194 localeValue = GetSimpleHValue(hThis, args, 2); | 5194 localeValue = GetSimpleValue(pThis, args, 2); |
| 5195 if (FXJSE_Value_IsNull(localeValue)) { | 5195 if (FXJSE_Value_IsNull(localeValue)) { |
| 5196 bFlags = TRUE; | 5196 bFlags = TRUE; |
| 5197 } else { | 5197 } else { |
| 5198 HValueToUTF8String(localeValue, localeString); | 5198 ValueToUTF8String(localeValue, localeString); |
| 5199 } | 5199 } |
| 5200 } | 5200 } |
| 5201 if (!bFlags) { | 5201 if (!bFlags) { |
| 5202 if ((fNumber < 0) || (fNumber > 922337203685477550)) { | 5202 if ((fNumber < 0) || (fNumber > 922337203685477550)) { |
| 5203 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "*"); | 5203 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "*"); |
| 5204 } else { | 5204 } else { |
| 5205 CFX_ByteTextBuf resultBuf; | 5205 CFX_ByteTextBuf resultBuf; |
| 5206 CFX_ByteString numberString; | 5206 CFX_ByteString numberString; |
| 5207 numberString.Format("%.2f", fNumber); | 5207 numberString.Format("%.2f", fNumber); |
| 5208 WordUS(numberString.AsStringC(), iIdentifier, resultBuf); | 5208 WordUS(numberString.AsStringC(), iIdentifier, resultBuf); |
| 5209 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 5209 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 5210 } | 5210 } |
| 5211 } else { | 5211 } else { |
| 5212 FXJSE_Value_SetNull(args.GetReturnValue()); | 5212 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5213 } | 5213 } |
| 5214 FXJSE_Value_Release(numberValue); | 5214 FXJSE_Value_Release(numberValue); |
| 5215 if (argc > 1) { | 5215 if (argc > 1) { |
| 5216 FXJSE_Value_Release(identifierValue); | 5216 FXJSE_Value_Release(identifierValue); |
| 5217 if (argc == 3) { | 5217 if (argc == 3) { |
| 5218 FXJSE_Value_Release(localeValue); | 5218 FXJSE_Value_Release(localeValue); |
| 5219 } | 5219 } |
| 5220 } | 5220 } |
| 5221 } else { | 5221 } else { |
| 5222 CXFA_FM2JSContext* pContext = | 5222 CXFA_FM2JSContext* pContext = |
| 5223 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5223 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5224 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5224 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5225 L"WordNum"); | 5225 L"WordNum"); |
| 5226 } | 5226 } |
| 5227 } | 5227 } |
| 5228 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, | 5228 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, |
| 5229 CFX_ByteTextBuf& strBuf) { | 5229 CFX_ByteTextBuf& strBuf) { |
| 5230 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", | 5230 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", |
| 5231 "five", "six", "seven", "eight", "nine"}; | 5231 "five", "six", "seven", "eight", "nine"}; |
| 5232 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", | 5232 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", |
| 5233 "Five", "Six", "Seven", "Eight", "Nine"}; | 5233 "Five", "Six", "Seven", "Eight", "Nine"}; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5413 strBuf << " Trillion "; | 5413 strBuf << " Trillion "; |
| 5414 } | 5414 } |
| 5415 } | 5415 } |
| 5416 strBuf << " Cents"; | 5416 strBuf << " Cents"; |
| 5417 } | 5417 } |
| 5418 } break; | 5418 } break; |
| 5419 default: | 5419 default: |
| 5420 break; | 5420 break; |
| 5421 } | 5421 } |
| 5422 } | 5422 } |
| 5423 void CXFA_FM2JSContext::Get(FXJSE_HOBJECT hThis, | 5423 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, |
| 5424 const CFX_ByteStringC& szFuncName, | 5424 const CFX_ByteStringC& szFuncName, |
| 5425 CFXJSE_Arguments& args) { | 5425 CFXJSE_Arguments& args) { |
| 5426 CXFA_FM2JSContext* pContext = | 5426 CXFA_FM2JSContext* pContext = |
| 5427 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5427 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5428 int32_t argc = args.GetLength(); | 5428 int32_t argc = args.GetLength(); |
| 5429 if (argc == 1) { | 5429 if (argc == 1) { |
| 5430 CXFA_Document* pDoc = pContext->GetDocument(); | 5430 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5431 if (!pDoc) { | 5431 if (!pDoc) { |
| 5432 return; | 5432 return; |
| 5433 } | 5433 } |
| 5434 IXFA_AppProvider* pAppProvider = | 5434 IXFA_AppProvider* pAppProvider = |
| 5435 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5435 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5436 if (!pAppProvider) { | 5436 if (!pAppProvider) { |
| 5437 return; | 5437 return; |
| 5438 } | 5438 } |
| 5439 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5439 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5440 CFX_ByteString urlString; | 5440 CFX_ByteString urlString; |
| 5441 HValueToUTF8String(argOne, urlString); | 5441 ValueToUTF8String(argOne, urlString); |
| 5442 IFX_FileRead* pFile = pAppProvider->DownloadURL( | 5442 IFX_FileRead* pFile = pAppProvider->DownloadURL( |
| 5443 CFX_WideString::FromUTF8(urlString.AsStringC())); | 5443 CFX_WideString::FromUTF8(urlString.AsStringC())); |
| 5444 if (pFile) { | 5444 if (pFile) { |
| 5445 int32_t size = pFile->GetSize(); | 5445 int32_t size = pFile->GetSize(); |
| 5446 uint8_t* pData = FX_Alloc(uint8_t, size); | 5446 uint8_t* pData = FX_Alloc(uint8_t, size); |
| 5447 pFile->ReadBlock(pData, size); | 5447 pFile->ReadBlock(pData, size); |
| 5448 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5448 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 5449 CFX_ByteStringC(pData, size)); | 5449 CFX_ByteStringC(pData, size)); |
| 5450 FX_Free(pData); | 5450 FX_Free(pData); |
| 5451 pFile->Release(); | 5451 pFile->Release(); |
| 5452 } | 5452 } |
| 5453 FXJSE_Value_Release(argOne); | 5453 FXJSE_Value_Release(argOne); |
| 5454 } else { | 5454 } else { |
| 5455 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5455 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5456 L"Get"); | 5456 L"Get"); |
| 5457 } | 5457 } |
| 5458 } | 5458 } |
| 5459 void CXFA_FM2JSContext::Post(FXJSE_HOBJECT hThis, | 5459 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, |
| 5460 const CFX_ByteStringC& szFuncName, | 5460 const CFX_ByteStringC& szFuncName, |
| 5461 CFXJSE_Arguments& args) { | 5461 CFXJSE_Arguments& args) { |
| 5462 CXFA_FM2JSContext* pContext = | 5462 CXFA_FM2JSContext* pContext = |
| 5463 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5463 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5464 int32_t argc = args.GetLength(); | 5464 int32_t argc = args.GetLength(); |
| 5465 if ((argc >= 2) && (argc <= 5)) { | 5465 if ((argc >= 2) && (argc <= 5)) { |
| 5466 CXFA_Document* pDoc = pContext->GetDocument(); | 5466 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5467 if (!pDoc) { | 5467 if (!pDoc) { |
| 5468 return; | 5468 return; |
| 5469 } | 5469 } |
| 5470 IXFA_AppProvider* pAppProvider = | 5470 IXFA_AppProvider* pAppProvider = |
| 5471 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5471 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5472 if (!pAppProvider) { | 5472 if (!pAppProvider) { |
| 5473 return; | 5473 return; |
| 5474 } | 5474 } |
| 5475 CFX_ByteString bsURL; | 5475 CFX_ByteString bsURL; |
| 5476 CFX_ByteString bsData; | 5476 CFX_ByteString bsData; |
| 5477 CFX_ByteString bsContentType; | 5477 CFX_ByteString bsContentType; |
| 5478 CFX_ByteString bsEncode; | 5478 CFX_ByteString bsEncode; |
| 5479 CFX_ByteString bsHeader; | 5479 CFX_ByteString bsHeader; |
| 5480 FXJSE_HVALUE argThree = nullptr; | 5480 CFXJSE_Value* argThree = nullptr; |
| 5481 FXJSE_HVALUE argFour = nullptr; | 5481 CFXJSE_Value* argFour = nullptr; |
| 5482 FXJSE_HVALUE argFive = nullptr; | 5482 CFXJSE_Value* argFive = nullptr; |
| 5483 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5483 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5484 HValueToUTF8String(argOne, bsURL); | 5484 ValueToUTF8String(argOne, bsURL); |
| 5485 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 5485 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 5486 HValueToUTF8String(argTwo, bsData); | 5486 ValueToUTF8String(argTwo, bsData); |
| 5487 if (argc > 2) { | 5487 if (argc > 2) { |
| 5488 argThree = GetSimpleHValue(hThis, args, 2); | 5488 argThree = GetSimpleValue(pThis, args, 2); |
| 5489 HValueToUTF8String(argThree, bsContentType); | 5489 ValueToUTF8String(argThree, bsContentType); |
| 5490 } | 5490 } |
| 5491 if (argc > 3) { | 5491 if (argc > 3) { |
| 5492 argFour = GetSimpleHValue(hThis, args, 3); | 5492 argFour = GetSimpleValue(pThis, args, 3); |
| 5493 HValueToUTF8String(argFour, bsEncode); | 5493 ValueToUTF8String(argFour, bsEncode); |
| 5494 } | 5494 } |
| 5495 if (argc > 4) { | 5495 if (argc > 4) { |
| 5496 argFive = GetSimpleHValue(hThis, args, 4); | 5496 argFive = GetSimpleValue(pThis, args, 4); |
| 5497 HValueToUTF8String(argFive, bsHeader); | 5497 ValueToUTF8String(argFive, bsHeader); |
| 5498 } | 5498 } |
| 5499 CFX_WideString decodedResponse; | 5499 CFX_WideString decodedResponse; |
| 5500 FX_BOOL bFlags = pAppProvider->PostRequestURL( | 5500 FX_BOOL bFlags = pAppProvider->PostRequestURL( |
| 5501 CFX_WideString::FromUTF8(bsURL.AsStringC()), | 5501 CFX_WideString::FromUTF8(bsURL.AsStringC()), |
| 5502 CFX_WideString::FromUTF8(bsData.AsStringC()), | 5502 CFX_WideString::FromUTF8(bsData.AsStringC()), |
| 5503 CFX_WideString::FromUTF8(bsContentType.AsStringC()), | 5503 CFX_WideString::FromUTF8(bsContentType.AsStringC()), |
| 5504 CFX_WideString::FromUTF8(bsEncode.AsStringC()), | 5504 CFX_WideString::FromUTF8(bsEncode.AsStringC()), |
| 5505 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse); | 5505 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse); |
| 5506 FXJSE_Value_Release(argOne); | 5506 FXJSE_Value_Release(argOne); |
| 5507 FXJSE_Value_Release(argTwo); | 5507 FXJSE_Value_Release(argTwo); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5520 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) | 5520 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) |
| 5521 .AsStringC()); | 5521 .AsStringC()); |
| 5522 } else { | 5522 } else { |
| 5523 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5523 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
| 5524 } | 5524 } |
| 5525 } else { | 5525 } else { |
| 5526 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5526 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5527 L"Post"); | 5527 L"Post"); |
| 5528 } | 5528 } |
| 5529 } | 5529 } |
| 5530 void CXFA_FM2JSContext::Put(FXJSE_HOBJECT hThis, | 5530 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, |
| 5531 const CFX_ByteStringC& szFuncName, | 5531 const CFX_ByteStringC& szFuncName, |
| 5532 CFXJSE_Arguments& args) { | 5532 CFXJSE_Arguments& args) { |
| 5533 CXFA_FM2JSContext* pContext = | 5533 CXFA_FM2JSContext* pContext = |
| 5534 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5534 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5535 int32_t argc = args.GetLength(); | 5535 int32_t argc = args.GetLength(); |
| 5536 if ((argc == 2) || (argc == 3)) { | 5536 if ((argc == 2) || (argc == 3)) { |
| 5537 CXFA_Document* pDoc = pContext->GetDocument(); | 5537 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5538 if (!pDoc) { | 5538 if (!pDoc) { |
| 5539 return; | 5539 return; |
| 5540 } | 5540 } |
| 5541 IXFA_AppProvider* pAppProvider = | 5541 IXFA_AppProvider* pAppProvider = |
| 5542 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5542 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5543 if (!pAppProvider) { | 5543 if (!pAppProvider) { |
| 5544 return; | 5544 return; |
| 5545 } | 5545 } |
| 5546 CFX_ByteString bsURL; | 5546 CFX_ByteString bsURL; |
| 5547 CFX_ByteString bsData; | 5547 CFX_ByteString bsData; |
| 5548 CFX_ByteString bsEncode; | 5548 CFX_ByteString bsEncode; |
| 5549 FXJSE_HVALUE argThree = nullptr; | 5549 CFXJSE_Value* argThree = nullptr; |
| 5550 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5550 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5551 HValueToUTF8String(argOne, bsURL); | 5551 ValueToUTF8String(argOne, bsURL); |
| 5552 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 5552 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 5553 HValueToUTF8String(argTwo, bsData); | 5553 ValueToUTF8String(argTwo, bsData); |
| 5554 if (argc > 2) { | 5554 if (argc > 2) { |
| 5555 argThree = GetSimpleHValue(hThis, args, 2); | 5555 argThree = GetSimpleValue(pThis, args, 2); |
| 5556 HValueToUTF8String(argThree, bsEncode); | 5556 ValueToUTF8String(argThree, bsEncode); |
| 5557 } | 5557 } |
| 5558 FX_BOOL bFlags = pAppProvider->PutRequestURL( | 5558 FX_BOOL bFlags = pAppProvider->PutRequestURL( |
| 5559 CFX_WideString::FromUTF8(bsURL.AsStringC()), | 5559 CFX_WideString::FromUTF8(bsURL.AsStringC()), |
| 5560 CFX_WideString::FromUTF8(bsData.AsStringC()), | 5560 CFX_WideString::FromUTF8(bsData.AsStringC()), |
| 5561 CFX_WideString::FromUTF8(bsEncode.AsStringC())); | 5561 CFX_WideString::FromUTF8(bsEncode.AsStringC())); |
| 5562 FXJSE_Value_Release(argOne); | 5562 FXJSE_Value_Release(argOne); |
| 5563 FXJSE_Value_Release(argTwo); | 5563 FXJSE_Value_Release(argTwo); |
| 5564 if (argc > 2) { | 5564 if (argc > 2) { |
| 5565 FXJSE_Value_Release(argThree); | 5565 FXJSE_Value_Release(argThree); |
| 5566 } | 5566 } |
| 5567 if (bFlags) { | 5567 if (bFlags) { |
| 5568 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5568 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 5569 } else { | 5569 } else { |
| 5570 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5570 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
| 5571 } | 5571 } |
| 5572 } else { | 5572 } else { |
| 5573 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5573 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5574 L"Put"); | 5574 L"Put"); |
| 5575 } | 5575 } |
| 5576 } | 5576 } |
| 5577 void CXFA_FM2JSContext::assign_value_operator(FXJSE_HOBJECT hThis, | 5577 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, |
| 5578 const CFX_ByteStringC& szFuncName, | 5578 const CFX_ByteStringC& szFuncName, |
| 5579 CFXJSE_Arguments& args) { | 5579 CFXJSE_Arguments& args) { |
| 5580 CXFA_FM2JSContext* pContext = | 5580 CXFA_FM2JSContext* pContext = |
| 5581 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5581 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5582 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5582 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5583 if (args.GetLength() == 2) { | 5583 if (args.GetLength() == 2) { |
| 5584 FXJSE_HVALUE lValue = args.GetValue(0); | 5584 CFXJSE_Value* lValue = args.GetValue(0); |
| 5585 FXJSE_HVALUE rValue = GetSimpleHValue(hThis, args, 1); | 5585 CFXJSE_Value* rValue = GetSimpleValue(pThis, args, 1); |
| 5586 FX_BOOL bSetStatus = TRUE; | 5586 FX_BOOL bSetStatus = TRUE; |
| 5587 if (FXJSE_Value_IsArray(lValue)) { | 5587 if (FXJSE_Value_IsArray(lValue)) { |
| 5588 FXJSE_HVALUE leftLengthValue = FXJSE_Value_Create(pIsolate); | 5588 CFXJSE_Value* leftLengthValue = FXJSE_Value_Create(pIsolate); |
| 5589 FXJSE_Value_GetObjectProp(lValue, "length", leftLengthValue); | 5589 FXJSE_Value_GetObjectProp(lValue, "length", leftLengthValue); |
| 5590 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue); | 5590 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue); |
| 5591 FXJSE_Value_Release(leftLengthValue); | 5591 FXJSE_Value_Release(leftLengthValue); |
| 5592 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 5592 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 5593 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 5593 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 5594 FXJSE_Value_GetObjectPropByIdx(lValue, 1, propertyValue); | 5594 FXJSE_Value_GetObjectPropByIdx(lValue, 1, propertyValue); |
| 5595 if (FXJSE_Value_IsNull(propertyValue)) { | 5595 if (FXJSE_Value_IsNull(propertyValue)) { |
| 5596 for (int32_t i = 2; i < iLeftLength; i++) { | 5596 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5597 FXJSE_Value_GetObjectPropByIdx(lValue, i, jsObjectValue); | 5597 FXJSE_Value_GetObjectPropByIdx(lValue, i, jsObjectValue); |
| 5598 bSetStatus = SetObjectDefaultValue(jsObjectValue, rValue); | 5598 bSetStatus = SetObjectDefaultValue(jsObjectValue, rValue); |
| 5599 if (!bSetStatus) { | 5599 if (!bSetStatus) { |
| 5600 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); | 5600 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5601 break; | 5601 break; |
| 5602 } | 5602 } |
| 5603 } | 5603 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5618 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); | 5618 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5619 } | 5619 } |
| 5620 } | 5620 } |
| 5621 FXJSE_Value_Set(args.GetReturnValue(), rValue); | 5621 FXJSE_Value_Set(args.GetReturnValue(), rValue); |
| 5622 FXJSE_Value_Release(lValue); | 5622 FXJSE_Value_Release(lValue); |
| 5623 FXJSE_Value_Release(rValue); | 5623 FXJSE_Value_Release(rValue); |
| 5624 } else { | 5624 } else { |
| 5625 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5625 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5626 } | 5626 } |
| 5627 } | 5627 } |
| 5628 void CXFA_FM2JSContext::logical_or_operator(FXJSE_HOBJECT hThis, | 5628 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, |
| 5629 const CFX_ByteStringC& szFuncName, | 5629 const CFX_ByteStringC& szFuncName, |
| 5630 CFXJSE_Arguments& args) { | 5630 CFXJSE_Arguments& args) { |
| 5631 if (args.GetLength() == 2) { | 5631 if (args.GetLength() == 2) { |
| 5632 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5632 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5633 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5633 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5634 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5634 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5635 FXJSE_Value_SetNull(args.GetReturnValue()); | 5635 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5636 } else { | 5636 } else { |
| 5637 FX_FLOAT first = HValueToFloat(hThis, argFirst); | 5637 FX_FLOAT first = ValueToFloat(pThis, argFirst); |
| 5638 FX_FLOAT second = HValueToFloat(hThis, argSecond); | 5638 FX_FLOAT second = ValueToFloat(pThis, argSecond); |
| 5639 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); | 5639 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); |
| 5640 } | 5640 } |
| 5641 FXJSE_Value_Release(argFirst); | 5641 FXJSE_Value_Release(argFirst); |
| 5642 FXJSE_Value_Release(argSecond); | 5642 FXJSE_Value_Release(argSecond); |
| 5643 } else { | 5643 } else { |
| 5644 CXFA_FM2JSContext* pContext = | 5644 CXFA_FM2JSContext* pContext = |
| 5645 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5645 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5646 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5646 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5647 } | 5647 } |
| 5648 } | 5648 } |
| 5649 void CXFA_FM2JSContext::logical_and_operator(FXJSE_HOBJECT hThis, | 5649 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, |
| 5650 const CFX_ByteStringC& szFuncName, | 5650 const CFX_ByteStringC& szFuncName, |
| 5651 CFXJSE_Arguments& args) { | 5651 CFXJSE_Arguments& args) { |
| 5652 if (args.GetLength() == 2) { | 5652 if (args.GetLength() == 2) { |
| 5653 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5653 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5654 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5654 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5655 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5655 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5656 FXJSE_Value_SetNull(args.GetReturnValue()); | 5656 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5657 } else { | 5657 } else { |
| 5658 FX_FLOAT first = HValueToFloat(hThis, argFirst); | 5658 FX_FLOAT first = ValueToFloat(pThis, argFirst); |
| 5659 FX_FLOAT second = HValueToFloat(hThis, argSecond); | 5659 FX_FLOAT second = ValueToFloat(pThis, argSecond); |
| 5660 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); | 5660 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); |
| 5661 } | 5661 } |
| 5662 FXJSE_Value_Release(argFirst); | 5662 FXJSE_Value_Release(argFirst); |
| 5663 FXJSE_Value_Release(argSecond); | 5663 FXJSE_Value_Release(argSecond); |
| 5664 } else { | 5664 } else { |
| 5665 CXFA_FM2JSContext* pContext = | 5665 CXFA_FM2JSContext* pContext = |
| 5666 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5666 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5667 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5667 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5668 } | 5668 } |
| 5669 } | 5669 } |
| 5670 void CXFA_FM2JSContext::equality_operator(FXJSE_HOBJECT hThis, | 5670 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, |
| 5671 const CFX_ByteStringC& szFuncName, | 5671 const CFX_ByteStringC& szFuncName, |
| 5672 CFXJSE_Arguments& args) { | 5672 CFXJSE_Arguments& args) { |
| 5673 if (args.GetLength() == 2) { | 5673 if (args.GetLength() == 2) { |
| 5674 if (fm_ref_equal(hThis, args)) { | 5674 if (fm_ref_equal(pThis, args)) { |
| 5675 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 5675 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
| 5676 } else { | 5676 } else { |
| 5677 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5677 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5678 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5678 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5679 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5679 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5680 FXJSE_Value_SetInteger( | 5680 FXJSE_Value_SetInteger( |
| 5681 args.GetReturnValue(), | 5681 args.GetReturnValue(), |
| 5682 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) | 5682 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) |
| 5683 ? 1 | 5683 ? 1 |
| 5684 : 0); | 5684 : 0); |
| 5685 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5685 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5686 FXJSE_Value_IsUTF8String(argSecond)) { | 5686 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5687 CFX_ByteString firstOutput; | 5687 CFX_ByteString firstOutput; |
| 5688 CFX_ByteString secondOutput; | 5688 CFX_ByteString secondOutput; |
| 5689 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5689 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5690 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5690 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5691 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5691 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5692 firstOutput == secondOutput); | 5692 firstOutput == secondOutput); |
| 5693 } else { | 5693 } else { |
| 5694 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5694 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5695 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5695 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5696 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5696 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5697 (first == second) ? 1 : 0); | 5697 (first == second) ? 1 : 0); |
| 5698 } | 5698 } |
| 5699 FXJSE_Value_Release(argFirst); | 5699 FXJSE_Value_Release(argFirst); |
| 5700 FXJSE_Value_Release(argSecond); | 5700 FXJSE_Value_Release(argSecond); |
| 5701 } | 5701 } |
| 5702 } else { | 5702 } else { |
| 5703 CXFA_FM2JSContext* pContext = | 5703 CXFA_FM2JSContext* pContext = |
| 5704 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5704 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5705 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5705 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5706 } | 5706 } |
| 5707 } | 5707 } |
| 5708 void CXFA_FM2JSContext::notequality_operator(FXJSE_HOBJECT hThis, | 5708 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, |
| 5709 const CFX_ByteStringC& szFuncName, | 5709 const CFX_ByteStringC& szFuncName, |
| 5710 CFXJSE_Arguments& args) { | 5710 CFXJSE_Arguments& args) { |
| 5711 if (args.GetLength() == 2) { | 5711 if (args.GetLength() == 2) { |
| 5712 if (fm_ref_equal(hThis, args)) { | 5712 if (fm_ref_equal(pThis, args)) { |
| 5713 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5713 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5714 } else { | 5714 } else { |
| 5715 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5715 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5716 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5716 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5717 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5717 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5718 FXJSE_Value_SetInteger( | 5718 FXJSE_Value_SetInteger( |
| 5719 args.GetReturnValue(), | 5719 args.GetReturnValue(), |
| 5720 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) | 5720 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) |
| 5721 ? 0 | 5721 ? 0 |
| 5722 : 1); | 5722 : 1); |
| 5723 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5723 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5724 FXJSE_Value_IsUTF8String(argSecond)) { | 5724 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5725 CFX_ByteString firstOutput; | 5725 CFX_ByteString firstOutput; |
| 5726 CFX_ByteString secondOutput; | 5726 CFX_ByteString secondOutput; |
| 5727 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5727 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5728 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5728 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5729 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5729 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5730 firstOutput != secondOutput); | 5730 firstOutput != secondOutput); |
| 5731 } else { | 5731 } else { |
| 5732 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5732 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5733 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5733 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5734 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); | 5734 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); |
| 5735 } | 5735 } |
| 5736 FXJSE_Value_Release(argFirst); | 5736 FXJSE_Value_Release(argFirst); |
| 5737 FXJSE_Value_Release(argSecond); | 5737 FXJSE_Value_Release(argSecond); |
| 5738 } | 5738 } |
| 5739 } else { | 5739 } else { |
| 5740 CXFA_FM2JSContext* pContext = | 5740 CXFA_FM2JSContext* pContext = |
| 5741 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5741 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5742 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5742 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5743 } | 5743 } |
| 5744 } | 5744 } |
| 5745 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(FXJSE_HOBJECT hThis, | 5745 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, |
| 5746 CFXJSE_Arguments& args) { | 5746 CFXJSE_Arguments& args) { |
| 5747 FX_BOOL bRet = FALSE; | 5747 FX_BOOL bRet = FALSE; |
| 5748 CXFA_FM2JSContext* pContext = | 5748 CXFA_FM2JSContext* pContext = |
| 5749 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5749 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5750 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5750 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5751 FXJSE_HVALUE argFirst = args.GetValue(0); | 5751 CFXJSE_Value* argFirst = args.GetValue(0); |
| 5752 FXJSE_HVALUE argSecond = args.GetValue(0); | 5752 CFXJSE_Value* argSecond = args.GetValue(0); |
| 5753 if (FXJSE_Value_IsArray(argFirst) && FXJSE_Value_IsArray(argSecond)) { | 5753 if (FXJSE_Value_IsArray(argFirst) && FXJSE_Value_IsArray(argSecond)) { |
| 5754 FXJSE_HVALUE firstFlagValue = FXJSE_Value_Create(pIsolate); | 5754 CFXJSE_Value* firstFlagValue = FXJSE_Value_Create(pIsolate); |
| 5755 FXJSE_HVALUE secondFlagValue = FXJSE_Value_Create(pIsolate); | 5755 CFXJSE_Value* secondFlagValue = FXJSE_Value_Create(pIsolate); |
| 5756 FXJSE_Value_GetObjectPropByIdx(argFirst, 0, firstFlagValue); | 5756 FXJSE_Value_GetObjectPropByIdx(argFirst, 0, firstFlagValue); |
| 5757 FXJSE_Value_GetObjectPropByIdx(argSecond, 0, secondFlagValue); | 5757 FXJSE_Value_GetObjectPropByIdx(argSecond, 0, secondFlagValue); |
| 5758 if ((FXJSE_Value_ToInteger(firstFlagValue) == 3) && | 5758 if ((FXJSE_Value_ToInteger(firstFlagValue) == 3) && |
| 5759 (FXJSE_Value_ToInteger(secondFlagValue) == 3)) { | 5759 (FXJSE_Value_ToInteger(secondFlagValue) == 3)) { |
| 5760 FXJSE_HVALUE firstJSObject = FXJSE_Value_Create(pIsolate); | 5760 CFXJSE_Value* firstJSObject = FXJSE_Value_Create(pIsolate); |
| 5761 FXJSE_HVALUE secondJSObject = FXJSE_Value_Create(pIsolate); | 5761 CFXJSE_Value* secondJSObject = FXJSE_Value_Create(pIsolate); |
| 5762 FXJSE_Value_GetObjectPropByIdx(argFirst, 2, firstJSObject); | 5762 FXJSE_Value_GetObjectPropByIdx(argFirst, 2, firstJSObject); |
| 5763 FXJSE_Value_GetObjectPropByIdx(argSecond, 2, secondJSObject); | 5763 FXJSE_Value_GetObjectPropByIdx(argSecond, 2, secondJSObject); |
| 5764 if (!FXJSE_Value_IsNull(firstJSObject) && | 5764 if (!FXJSE_Value_IsNull(firstJSObject) && |
| 5765 !FXJSE_Value_IsNull(secondJSObject)) { | 5765 !FXJSE_Value_IsNull(secondJSObject)) { |
| 5766 bRet = (FXJSE_Value_ToObject(firstJSObject, NULL) == | 5766 bRet = (FXJSE_Value_ToObject(firstJSObject, NULL) == |
| 5767 FXJSE_Value_ToObject(secondJSObject, NULL)); | 5767 FXJSE_Value_ToObject(secondJSObject, NULL)); |
| 5768 } | 5768 } |
| 5769 FXJSE_Value_Release(firstJSObject); | 5769 FXJSE_Value_Release(firstJSObject); |
| 5770 FXJSE_Value_Release(secondJSObject); | 5770 FXJSE_Value_Release(secondJSObject); |
| 5771 } | 5771 } |
| 5772 FXJSE_Value_Release(firstFlagValue); | 5772 FXJSE_Value_Release(firstFlagValue); |
| 5773 FXJSE_Value_Release(secondFlagValue); | 5773 FXJSE_Value_Release(secondFlagValue); |
| 5774 } | 5774 } |
| 5775 FXJSE_Value_Release(argFirst); | 5775 FXJSE_Value_Release(argFirst); |
| 5776 FXJSE_Value_Release(argSecond); | 5776 FXJSE_Value_Release(argSecond); |
| 5777 return bRet; | 5777 return bRet; |
| 5778 } | 5778 } |
| 5779 void CXFA_FM2JSContext::less_operator(FXJSE_HOBJECT hThis, | 5779 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, |
| 5780 const CFX_ByteStringC& szFuncName, | 5780 const CFX_ByteStringC& szFuncName, |
| 5781 CFXJSE_Arguments& args) { | 5781 CFXJSE_Arguments& args) { |
| 5782 if (args.GetLength() == 2) { | 5782 if (args.GetLength() == 2) { |
| 5783 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5783 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5784 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5784 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5785 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5785 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5786 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5786 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5787 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5787 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5788 FXJSE_Value_IsUTF8String(argSecond)) { | 5788 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5789 CFX_ByteString firstOutput; | 5789 CFX_ByteString firstOutput; |
| 5790 CFX_ByteString secondOutput; | 5790 CFX_ByteString secondOutput; |
| 5791 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5791 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5792 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5792 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5793 FXJSE_Value_SetInteger( | 5793 FXJSE_Value_SetInteger( |
| 5794 args.GetReturnValue(), | 5794 args.GetReturnValue(), |
| 5795 firstOutput.Compare(secondOutput.AsStringC()) == -1); | 5795 firstOutput.Compare(secondOutput.AsStringC()) == -1); |
| 5796 } else { | 5796 } else { |
| 5797 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5797 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5798 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5798 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5799 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); | 5799 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); |
| 5800 } | 5800 } |
| 5801 FXJSE_Value_Release(argFirst); | 5801 FXJSE_Value_Release(argFirst); |
| 5802 FXJSE_Value_Release(argSecond); | 5802 FXJSE_Value_Release(argSecond); |
| 5803 } else { | 5803 } else { |
| 5804 CXFA_FM2JSContext* pContext = | 5804 CXFA_FM2JSContext* pContext = |
| 5805 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5805 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5806 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5806 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5807 } | 5807 } |
| 5808 } | 5808 } |
| 5809 void CXFA_FM2JSContext::lessequal_operator(FXJSE_HOBJECT hThis, | 5809 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, |
| 5810 const CFX_ByteStringC& szFuncName, | 5810 const CFX_ByteStringC& szFuncName, |
| 5811 CFXJSE_Arguments& args) { | 5811 CFXJSE_Arguments& args) { |
| 5812 if (args.GetLength() == 2) { | 5812 if (args.GetLength() == 2) { |
| 5813 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5813 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5814 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5814 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5815 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5815 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5816 FXJSE_Value_SetInteger( | 5816 FXJSE_Value_SetInteger( |
| 5817 args.GetReturnValue(), | 5817 args.GetReturnValue(), |
| 5818 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 | 5818 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 |
| 5819 : 0); | 5819 : 0); |
| 5820 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5820 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5821 FXJSE_Value_IsUTF8String(argSecond)) { | 5821 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5822 CFX_ByteString firstOutput; | 5822 CFX_ByteString firstOutput; |
| 5823 CFX_ByteString secondOutput; | 5823 CFX_ByteString secondOutput; |
| 5824 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5824 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5825 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5825 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5826 FXJSE_Value_SetInteger( | 5826 FXJSE_Value_SetInteger( |
| 5827 args.GetReturnValue(), | 5827 args.GetReturnValue(), |
| 5828 firstOutput.Compare(secondOutput.AsStringC()) != 1); | 5828 firstOutput.Compare(secondOutput.AsStringC()) != 1); |
| 5829 } else { | 5829 } else { |
| 5830 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5830 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5831 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5831 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5832 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); | 5832 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); |
| 5833 } | 5833 } |
| 5834 FXJSE_Value_Release(argFirst); | 5834 FXJSE_Value_Release(argFirst); |
| 5835 FXJSE_Value_Release(argSecond); | 5835 FXJSE_Value_Release(argSecond); |
| 5836 } else { | 5836 } else { |
| 5837 CXFA_FM2JSContext* pContext = | 5837 CXFA_FM2JSContext* pContext = |
| 5838 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5838 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5839 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5839 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5840 } | 5840 } |
| 5841 } | 5841 } |
| 5842 void CXFA_FM2JSContext::greater_operator(FXJSE_HOBJECT hThis, | 5842 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, |
| 5843 const CFX_ByteStringC& szFuncName, | 5843 const CFX_ByteStringC& szFuncName, |
| 5844 CFXJSE_Arguments& args) { | 5844 CFXJSE_Arguments& args) { |
| 5845 if (args.GetLength() == 2) { | 5845 if (args.GetLength() == 2) { |
| 5846 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5846 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5847 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5847 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5848 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5848 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5849 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5849 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5850 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5850 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5851 FXJSE_Value_IsUTF8String(argSecond)) { | 5851 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5852 CFX_ByteString firstOutput; | 5852 CFX_ByteString firstOutput; |
| 5853 CFX_ByteString secondOutput; | 5853 CFX_ByteString secondOutput; |
| 5854 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5854 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5855 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5855 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5856 FXJSE_Value_SetInteger( | 5856 FXJSE_Value_SetInteger( |
| 5857 args.GetReturnValue(), | 5857 args.GetReturnValue(), |
| 5858 firstOutput.Compare(secondOutput.AsStringC()) == 1); | 5858 firstOutput.Compare(secondOutput.AsStringC()) == 1); |
| 5859 } else { | 5859 } else { |
| 5860 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5860 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5861 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5861 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5862 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); | 5862 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); |
| 5863 } | 5863 } |
| 5864 FXJSE_Value_Release(argFirst); | 5864 FXJSE_Value_Release(argFirst); |
| 5865 FXJSE_Value_Release(argSecond); | 5865 FXJSE_Value_Release(argSecond); |
| 5866 } else { | 5866 } else { |
| 5867 CXFA_FM2JSContext* pContext = | 5867 CXFA_FM2JSContext* pContext = |
| 5868 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5868 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5869 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5869 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5870 } | 5870 } |
| 5871 } | 5871 } |
| 5872 void CXFA_FM2JSContext::greaterequal_operator(FXJSE_HOBJECT hThis, | 5872 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, |
| 5873 const CFX_ByteStringC& szFuncName, | 5873 const CFX_ByteStringC& szFuncName, |
| 5874 CFXJSE_Arguments& args) { | 5874 CFXJSE_Arguments& args) { |
| 5875 if (args.GetLength() == 2) { | 5875 if (args.GetLength() == 2) { |
| 5876 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5876 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5877 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5877 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5878 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5878 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5879 FXJSE_Value_SetInteger( | 5879 FXJSE_Value_SetInteger( |
| 5880 args.GetReturnValue(), | 5880 args.GetReturnValue(), |
| 5881 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 | 5881 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 |
| 5882 : 0); | 5882 : 0); |
| 5883 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5883 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5884 FXJSE_Value_IsUTF8String(argSecond)) { | 5884 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5885 CFX_ByteString firstOutput; | 5885 CFX_ByteString firstOutput; |
| 5886 CFX_ByteString secondOutput; | 5886 CFX_ByteString secondOutput; |
| 5887 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5887 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5888 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5888 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5889 FXJSE_Value_SetInteger( | 5889 FXJSE_Value_SetInteger( |
| 5890 args.GetReturnValue(), | 5890 args.GetReturnValue(), |
| 5891 firstOutput.Compare(secondOutput.AsStringC()) != -1); | 5891 firstOutput.Compare(secondOutput.AsStringC()) != -1); |
| 5892 } else { | 5892 } else { |
| 5893 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5893 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5894 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5894 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5895 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); | 5895 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); |
| 5896 } | 5896 } |
| 5897 FXJSE_Value_Release(argFirst); | 5897 FXJSE_Value_Release(argFirst); |
| 5898 FXJSE_Value_Release(argSecond); | 5898 FXJSE_Value_Release(argSecond); |
| 5899 } else { | 5899 } else { |
| 5900 CXFA_FM2JSContext* pContext = | 5900 CXFA_FM2JSContext* pContext = |
| 5901 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5901 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5902 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5902 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5903 } | 5903 } |
| 5904 } | 5904 } |
| 5905 void CXFA_FM2JSContext::plus_operator(FXJSE_HOBJECT hThis, | 5905 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, |
| 5906 const CFX_ByteStringC& szFuncName, | 5906 const CFX_ByteStringC& szFuncName, |
| 5907 CFXJSE_Arguments& args) { | 5907 CFXJSE_Arguments& args) { |
| 5908 if (args.GetLength() == 2) { | 5908 if (args.GetLength() == 2) { |
| 5909 FXJSE_HVALUE argFirst = args.GetValue(0); | 5909 CFXJSE_Value* argFirst = args.GetValue(0); |
| 5910 FXJSE_HVALUE argSecond = args.GetValue(1); | 5910 CFXJSE_Value* argSecond = args.GetValue(1); |
| 5911 if (HValueIsNull(hThis, argFirst) && HValueIsNull(hThis, argSecond)) { | 5911 if (ValueIsNull(pThis, argFirst) && ValueIsNull(pThis, argSecond)) { |
| 5912 FXJSE_Value_SetNull(args.GetReturnValue()); | 5912 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5913 } else { | 5913 } else { |
| 5914 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5914 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5915 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5915 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5916 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); | 5916 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); |
| 5917 } | 5917 } |
| 5918 FXJSE_Value_Release(argFirst); | 5918 FXJSE_Value_Release(argFirst); |
| 5919 FXJSE_Value_Release(argSecond); | 5919 FXJSE_Value_Release(argSecond); |
| 5920 } else { | 5920 } else { |
| 5921 CXFA_FM2JSContext* pContext = | 5921 CXFA_FM2JSContext* pContext = |
| 5922 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5922 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5923 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5923 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5924 } | 5924 } |
| 5925 } | 5925 } |
| 5926 void CXFA_FM2JSContext::minus_operator(FXJSE_HOBJECT hThis, | 5926 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, |
| 5927 const CFX_ByteStringC& szFuncName, | 5927 const CFX_ByteStringC& szFuncName, |
| 5928 CFXJSE_Arguments& args) { | 5928 CFXJSE_Arguments& args) { |
| 5929 if (args.GetLength() == 2) { | 5929 if (args.GetLength() == 2) { |
| 5930 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5930 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5931 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5931 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5932 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5932 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5933 FXJSE_Value_SetNull(args.GetReturnValue()); | 5933 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5934 } else { | 5934 } else { |
| 5935 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5935 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5936 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5936 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5937 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); | 5937 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); |
| 5938 } | 5938 } |
| 5939 FXJSE_Value_Release(argFirst); | 5939 FXJSE_Value_Release(argFirst); |
| 5940 FXJSE_Value_Release(argSecond); | 5940 FXJSE_Value_Release(argSecond); |
| 5941 } else { | 5941 } else { |
| 5942 CXFA_FM2JSContext* pContext = | 5942 CXFA_FM2JSContext* pContext = |
| 5943 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5943 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5944 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5944 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5945 } | 5945 } |
| 5946 } | 5946 } |
| 5947 void CXFA_FM2JSContext::multiple_operator(FXJSE_HOBJECT hThis, | 5947 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, |
| 5948 const CFX_ByteStringC& szFuncName, | 5948 const CFX_ByteStringC& szFuncName, |
| 5949 CFXJSE_Arguments& args) { | 5949 CFXJSE_Arguments& args) { |
| 5950 if (args.GetLength() == 2) { | 5950 if (args.GetLength() == 2) { |
| 5951 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5951 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5952 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5952 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5953 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5953 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5954 FXJSE_Value_SetNull(args.GetReturnValue()); | 5954 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5955 } else { | 5955 } else { |
| 5956 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5956 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5957 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5957 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5958 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); | 5958 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); |
| 5959 } | 5959 } |
| 5960 FXJSE_Value_Release(argFirst); | 5960 FXJSE_Value_Release(argFirst); |
| 5961 FXJSE_Value_Release(argSecond); | 5961 FXJSE_Value_Release(argSecond); |
| 5962 } else { | 5962 } else { |
| 5963 CXFA_FM2JSContext* pContext = | 5963 CXFA_FM2JSContext* pContext = |
| 5964 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5964 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5965 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5965 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5966 } | 5966 } |
| 5967 } | 5967 } |
| 5968 void CXFA_FM2JSContext::divide_operator(FXJSE_HOBJECT hThis, | 5968 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, |
| 5969 const CFX_ByteStringC& szFuncName, | 5969 const CFX_ByteStringC& szFuncName, |
| 5970 CFXJSE_Arguments& args) { | 5970 CFXJSE_Arguments& args) { |
| 5971 CXFA_FM2JSContext* pContext = | 5971 CXFA_FM2JSContext* pContext = |
| 5972 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 5972 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5973 if (args.GetLength() == 2) { | 5973 if (args.GetLength() == 2) { |
| 5974 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5974 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5975 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5975 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5976 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5976 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5977 FXJSE_Value_SetNull(args.GetReturnValue()); | 5977 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5978 } else { | 5978 } else { |
| 5979 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5979 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5980 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5980 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5981 if (second == 0.0) { | 5981 if (second == 0.0) { |
| 5982 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); | 5982 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); |
| 5983 } else { | 5983 } else { |
| 5984 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); | 5984 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); |
| 5985 } | 5985 } |
| 5986 } | 5986 } |
| 5987 FXJSE_Value_Release(argFirst); | 5987 FXJSE_Value_Release(argFirst); |
| 5988 FXJSE_Value_Release(argSecond); | 5988 FXJSE_Value_Release(argSecond); |
| 5989 } else { | 5989 } else { |
| 5990 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5990 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5991 } | 5991 } |
| 5992 } | 5992 } |
| 5993 void CXFA_FM2JSContext::positive_operator(FXJSE_HOBJECT hThis, | 5993 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, |
| 5994 const CFX_ByteStringC& szFuncName, | 5994 const CFX_ByteStringC& szFuncName, |
| 5995 CFXJSE_Arguments& args) { | 5995 CFXJSE_Arguments& args) { |
| 5996 int32_t iLength = args.GetLength(); | 5996 int32_t iLength = args.GetLength(); |
| 5997 if (iLength == 1) { | 5997 if (iLength == 1) { |
| 5998 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5998 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5999 if (FXJSE_Value_IsNull(argOne)) { | 5999 if (FXJSE_Value_IsNull(argOne)) { |
| 6000 FXJSE_Value_SetNull(args.GetReturnValue()); | 6000 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 6001 } else { | 6001 } else { |
| 6002 FXJSE_Value_SetDouble(args.GetReturnValue(), | 6002 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 6003 0.0 + HValueToDouble(hThis, argOne)); | 6003 0.0 + ValueToDouble(pThis, argOne)); |
| 6004 } | 6004 } |
| 6005 FXJSE_Value_Release(argOne); | 6005 FXJSE_Value_Release(argOne); |
| 6006 } else { | 6006 } else { |
| 6007 CXFA_FM2JSContext* pContext = | 6007 CXFA_FM2JSContext* pContext = |
| 6008 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6008 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6009 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6009 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6010 } | 6010 } |
| 6011 } | 6011 } |
| 6012 void CXFA_FM2JSContext::negative_operator(FXJSE_HOBJECT hThis, | 6012 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, |
| 6013 const CFX_ByteStringC& szFuncName, | 6013 const CFX_ByteStringC& szFuncName, |
| 6014 CFXJSE_Arguments& args) { | 6014 CFXJSE_Arguments& args) { |
| 6015 int32_t iLength = args.GetLength(); | 6015 int32_t iLength = args.GetLength(); |
| 6016 if (iLength == 1) { | 6016 if (iLength == 1) { |
| 6017 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 6017 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 6018 if (FXJSE_Value_IsNull(argOne)) { | 6018 if (FXJSE_Value_IsNull(argOne)) { |
| 6019 FXJSE_Value_SetNull(args.GetReturnValue()); | 6019 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 6020 } else { | 6020 } else { |
| 6021 FXJSE_Value_SetDouble(args.GetReturnValue(), | 6021 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 6022 0.0 - HValueToDouble(hThis, argOne)); | 6022 0.0 - ValueToDouble(pThis, argOne)); |
| 6023 } | 6023 } |
| 6024 FXJSE_Value_Release(argOne); | 6024 FXJSE_Value_Release(argOne); |
| 6025 } else { | 6025 } else { |
| 6026 CXFA_FM2JSContext* pContext = | 6026 CXFA_FM2JSContext* pContext = |
| 6027 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6027 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6028 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6028 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6029 } | 6029 } |
| 6030 } | 6030 } |
| 6031 void CXFA_FM2JSContext::logical_not_operator(FXJSE_HOBJECT hThis, | 6031 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, |
| 6032 const CFX_ByteStringC& szFuncName, | 6032 const CFX_ByteStringC& szFuncName, |
| 6033 CFXJSE_Arguments& args) { | 6033 CFXJSE_Arguments& args) { |
| 6034 int32_t iLength = args.GetLength(); | 6034 int32_t iLength = args.GetLength(); |
| 6035 if (iLength == 1) { | 6035 if (iLength == 1) { |
| 6036 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 6036 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 6037 if (FXJSE_Value_IsNull(argOne)) { | 6037 if (FXJSE_Value_IsNull(argOne)) { |
| 6038 FXJSE_Value_SetNull(args.GetReturnValue()); | 6038 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 6039 } else { | 6039 } else { |
| 6040 FX_DOUBLE first = HValueToDouble(hThis, argOne); | 6040 FX_DOUBLE first = ValueToDouble(pThis, argOne); |
| 6041 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); | 6041 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); |
| 6042 } | 6042 } |
| 6043 FXJSE_Value_Release(argOne); | 6043 FXJSE_Value_Release(argOne); |
| 6044 } else { | 6044 } else { |
| 6045 CXFA_FM2JSContext* pContext = | 6045 CXFA_FM2JSContext* pContext = |
| 6046 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6046 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6047 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6047 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6048 } | 6048 } |
| 6049 } | 6049 } |
| 6050 void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis, | 6050 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, |
| 6051 const CFX_ByteStringC& szFuncName, | 6051 const CFX_ByteStringC& szFuncName, |
| 6052 CFXJSE_Arguments& args) { | 6052 CFXJSE_Arguments& args) { |
| 6053 CXFA_FM2JSContext* pContext = | 6053 CXFA_FM2JSContext* pContext = |
| 6054 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6054 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6055 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6055 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6056 int32_t argc = args.GetLength(); | 6056 int32_t argc = args.GetLength(); |
| 6057 if ((argc == 4) || (argc == 5)) { | 6057 if ((argc == 4) || (argc == 5)) { |
| 6058 FX_BOOL bIsStar = TRUE; | 6058 FX_BOOL bIsStar = TRUE; |
| 6059 FXJSE_HVALUE argAccessor = args.GetValue(0); | 6059 CFXJSE_Value* argAccessor = args.GetValue(0); |
| 6060 CFX_ByteString bsAccessorName = args.GetUTF8String(1); | 6060 CFX_ByteString bsAccessorName = args.GetUTF8String(1); |
| 6061 CFX_ByteString szName = args.GetUTF8String(2); | 6061 CFX_ByteString szName = args.GetUTF8String(2); |
| 6062 int32_t iIndexFlags = args.GetInt32(3); | 6062 int32_t iIndexFlags = args.GetInt32(3); |
| 6063 int32_t iIndexValue = 0; | 6063 int32_t iIndexValue = 0; |
| 6064 FXJSE_HVALUE argIndex = NULL; | 6064 CFXJSE_Value* argIndex = NULL; |
| 6065 if (argc == 5) { | 6065 if (argc == 5) { |
| 6066 bIsStar = FALSE; | 6066 bIsStar = FALSE; |
| 6067 argIndex = args.GetValue(4); | 6067 argIndex = args.GetValue(4); |
| 6068 iIndexValue = HValueToInteger(hThis, argIndex); | 6068 iIndexValue = ValueToInteger(pThis, argIndex); |
| 6069 } | 6069 } |
| 6070 CFX_ByteString szSomExp; | 6070 CFX_ByteString szSomExp; |
| 6071 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, | 6071 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, |
| 6072 szSomExp); | 6072 szSomExp); |
| 6073 if (FXJSE_Value_IsArray(argAccessor)) { | 6073 if (FXJSE_Value_IsArray(argAccessor)) { |
| 6074 FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(pIsolate); | 6074 CFXJSE_Value* pLengthValue = FXJSE_Value_Create(pIsolate); |
| 6075 FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue); | 6075 FXJSE_Value_GetObjectProp(argAccessor, "length", pLengthValue); |
| 6076 int32_t iLength = FXJSE_Value_ToInteger(hLengthValue); | 6076 int32_t iLength = FXJSE_Value_ToInteger(pLengthValue); |
| 6077 FXJSE_Value_Release(hLengthValue); | 6077 FXJSE_Value_Release(pLengthValue); |
| 6078 int32_t iCounter = 0; | 6078 int32_t iCounter = 0; |
| 6079 FXJSE_HVALUE** hResolveValues = FX_Alloc(FXJSE_HVALUE*, iLength - 2); | 6079 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); |
| 6080 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); | 6080 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); |
| 6081 for (int32_t i = 0; i < (iLength - 2); i++) { | 6081 for (int32_t i = 0; i < (iLength - 2); i++) { |
| 6082 iSizes[i] = 0; | 6082 iSizes[i] = 0; |
| 6083 } | 6083 } |
| 6084 FXJSE_HVALUE hJSObjValue = FXJSE_Value_Create(pIsolate); | 6084 CFXJSE_Value* hJSObjValue = FXJSE_Value_Create(pIsolate); |
| 6085 FX_BOOL bAttribute = FALSE; | 6085 FX_BOOL bAttribute = FALSE; |
| 6086 for (int32_t i = 2; i < iLength; i++) { | 6086 for (int32_t i = 2; i < iLength; i++) { |
| 6087 FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue); | 6087 FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue); |
| 6088 XFA_RESOLVENODE_RS resoveNodeRS; | 6088 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6089 int32_t iRet = ResolveObjects(hThis, hJSObjValue, szSomExp.AsStringC(), | 6089 int32_t iRet = ResolveObjects(pThis, hJSObjValue, szSomExp.AsStringC(), |
| 6090 resoveNodeRS, TRUE, szName.IsEmpty()); | 6090 resoveNodeRS, TRUE, szName.IsEmpty()); |
| 6091 if (iRet > 0) { | 6091 if (iRet > 0) { |
| 6092 ParseResolveResult(hThis, resoveNodeRS, hJSObjValue, | 6092 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue, |
| 6093 hResolveValues[i - 2], iSizes[i - 2], bAttribute); | 6093 hResolveValues[i - 2], iSizes[i - 2], bAttribute); |
| 6094 iCounter += iSizes[i - 2]; | 6094 iCounter += iSizes[i - 2]; |
| 6095 } | 6095 } |
| 6096 } | 6096 } |
| 6097 FXJSE_Value_Release(hJSObjValue); | 6097 FXJSE_Value_Release(hJSObjValue); |
| 6098 if (iCounter > 0) { | 6098 if (iCounter > 0) { |
| 6099 FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iCounter + 2); | 6099 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2); |
| 6100 for (int32_t i = 0; i < (iCounter + 2); i++) { | 6100 for (int32_t i = 0; i < (iCounter + 2); i++) { |
| 6101 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6101 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6102 } | 6102 } |
| 6103 FXJSE_Value_SetInteger(rgValues[0], 1); | 6103 FXJSE_Value_SetInteger(rgValues[0], 1); |
| 6104 if (bAttribute) { | 6104 if (bAttribute) { |
| 6105 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); | 6105 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); |
| 6106 } else { | 6106 } else { |
| 6107 FXJSE_Value_SetNull(rgValues[1]); | 6107 FXJSE_Value_SetNull(rgValues[1]); |
| 6108 } | 6108 } |
| 6109 int32_t iIndex = 2; | 6109 int32_t iIndex = 2; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6135 FX_Free(hResolveValues[i]); | 6135 FX_Free(hResolveValues[i]); |
| 6136 } | 6136 } |
| 6137 } | 6137 } |
| 6138 FX_Free(hResolveValues); | 6138 FX_Free(hResolveValues); |
| 6139 FX_Free(iSizes); | 6139 FX_Free(iSizes); |
| 6140 } else { | 6140 } else { |
| 6141 XFA_RESOLVENODE_RS resoveNodeRS; | 6141 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6142 int32_t iRet = 0; | 6142 int32_t iRet = 0; |
| 6143 if (FXJSE_Value_IsObject(argAccessor) || | 6143 if (FXJSE_Value_IsObject(argAccessor) || |
| 6144 (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { | 6144 (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { |
| 6145 iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(), | 6145 iRet = ResolveObjects(pThis, argAccessor, szSomExp.AsStringC(), |
| 6146 resoveNodeRS, TRUE, szName.IsEmpty()); | 6146 resoveNodeRS, TRUE, szName.IsEmpty()); |
| 6147 } else if (!FXJSE_Value_IsObject(argAccessor) && | 6147 } else if (!FXJSE_Value_IsObject(argAccessor) && |
| 6148 !bsAccessorName.IsEmpty()) { | 6148 !bsAccessorName.IsEmpty()) { |
| 6149 FX_BOOL bGetObject = | 6149 FX_BOOL bGetObject = |
| 6150 GetObjectByName(hThis, argAccessor, bsAccessorName.AsStringC()); | 6150 GetObjectByName(pThis, argAccessor, bsAccessorName.AsStringC()); |
| 6151 if (bGetObject) { | 6151 if (bGetObject) { |
| 6152 iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(), | 6152 iRet = ResolveObjects(pThis, argAccessor, szSomExp.AsStringC(), |
| 6153 resoveNodeRS, TRUE, szName.IsEmpty()); | 6153 resoveNodeRS, TRUE, szName.IsEmpty()); |
| 6154 } | 6154 } |
| 6155 } | 6155 } |
| 6156 if (iRet > 0) { | 6156 if (iRet > 0) { |
| 6157 FXJSE_HVALUE* hResolveValues; | 6157 CFXJSE_Value** hResolveValues; |
| 6158 int32_t iSize = 0; | 6158 int32_t iSize = 0; |
| 6159 FX_BOOL bAttribute = FALSE; | 6159 FX_BOOL bAttribute = FALSE; |
| 6160 ParseResolveResult(hThis, resoveNodeRS, argAccessor, hResolveValues, | 6160 ParseResolveResult(pThis, resoveNodeRS, argAccessor, hResolveValues, |
| 6161 iSize, bAttribute); | 6161 iSize, bAttribute); |
| 6162 FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iSize + 2); | 6162 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2); |
| 6163 for (int32_t i = 0; i < (iSize + 2); i++) { | 6163 for (int32_t i = 0; i < (iSize + 2); i++) { |
| 6164 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6164 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6165 } | 6165 } |
| 6166 FXJSE_Value_SetInteger(rgValues[0], 1); | 6166 FXJSE_Value_SetInteger(rgValues[0], 1); |
| 6167 if (bAttribute) { | 6167 if (bAttribute) { |
| 6168 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); | 6168 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); |
| 6169 } else { | 6169 } else { |
| 6170 FXJSE_Value_SetNull(rgValues[1]); | 6170 FXJSE_Value_SetNull(rgValues[1]); |
| 6171 } | 6171 } |
| 6172 for (int32_t i = 0; i < iSize; i++) { | 6172 for (int32_t i = 0; i < iSize; i++) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6192 } | 6192 } |
| 6193 } | 6193 } |
| 6194 if (argc == 5) { | 6194 if (argc == 5) { |
| 6195 FXJSE_Value_Release(argIndex); | 6195 FXJSE_Value_Release(argIndex); |
| 6196 } | 6196 } |
| 6197 FXJSE_Value_Release(argAccessor); | 6197 FXJSE_Value_Release(argAccessor); |
| 6198 } else { | 6198 } else { |
| 6199 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6199 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6200 } | 6200 } |
| 6201 } | 6201 } |
| 6202 void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis, | 6202 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, |
| 6203 const CFX_ByteStringC& szFuncName, | 6203 const CFX_ByteStringC& szFuncName, |
| 6204 CFXJSE_Arguments& args) { | 6204 CFXJSE_Arguments& args) { |
| 6205 CXFA_FM2JSContext* pContext = | 6205 CXFA_FM2JSContext* pContext = |
| 6206 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6206 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6207 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6207 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6208 int32_t argc = args.GetLength(); | 6208 int32_t argc = args.GetLength(); |
| 6209 if ((argc == 4) || (argc == 5)) { | 6209 if ((argc == 4) || (argc == 5)) { |
| 6210 FX_BOOL bIsStar = TRUE; | 6210 FX_BOOL bIsStar = TRUE; |
| 6211 FXJSE_HVALUE argAccessor = args.GetValue(0); | 6211 CFXJSE_Value* argAccessor = args.GetValue(0); |
| 6212 CFX_ByteString bsAccessorName = args.GetUTF8String(1); | 6212 CFX_ByteString bsAccessorName = args.GetUTF8String(1); |
| 6213 CFX_ByteString szName = args.GetUTF8String(2); | 6213 CFX_ByteString szName = args.GetUTF8String(2); |
| 6214 int32_t iIndexFlags = args.GetInt32(3); | 6214 int32_t iIndexFlags = args.GetInt32(3); |
| 6215 int32_t iIndexValue = 0; | 6215 int32_t iIndexValue = 0; |
| 6216 FXJSE_HVALUE argIndex = NULL; | 6216 CFXJSE_Value* argIndex = NULL; |
| 6217 if (argc == 5) { | 6217 if (argc == 5) { |
| 6218 bIsStar = FALSE; | 6218 bIsStar = FALSE; |
| 6219 argIndex = args.GetValue(4); | 6219 argIndex = args.GetValue(4); |
| 6220 iIndexValue = HValueToInteger(hThis, argIndex); | 6220 iIndexValue = ValueToInteger(pThis, argIndex); |
| 6221 } | 6221 } |
| 6222 CFX_ByteString szSomExp; | 6222 CFX_ByteString szSomExp; |
| 6223 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, | 6223 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, |
| 6224 szSomExp); | 6224 szSomExp); |
| 6225 if (FXJSE_Value_IsArray(argAccessor)) { | 6225 if (FXJSE_Value_IsArray(argAccessor)) { |
| 6226 FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(pIsolate); | 6226 CFXJSE_Value* pLengthValue = FXJSE_Value_Create(pIsolate); |
| 6227 FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue); | 6227 FXJSE_Value_GetObjectProp(argAccessor, "length", pLengthValue); |
| 6228 int32_t iLength = FXJSE_Value_ToInteger(hLengthValue); | 6228 int32_t iLength = FXJSE_Value_ToInteger(pLengthValue); |
| 6229 int32_t iCounter = 0; | 6229 int32_t iCounter = 0; |
| 6230 FXJSE_HVALUE** hResolveValues = FX_Alloc(FXJSE_HVALUE*, iLength - 2); | 6230 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); |
| 6231 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); | 6231 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); |
| 6232 FXJSE_HVALUE hJSObjValue = FXJSE_Value_Create(pIsolate); | 6232 CFXJSE_Value* hJSObjValue = FXJSE_Value_Create(pIsolate); |
| 6233 FX_BOOL bAttribute = FALSE; | 6233 FX_BOOL bAttribute = FALSE; |
| 6234 for (int32_t i = 2; i < iLength; i++) { | 6234 for (int32_t i = 2; i < iLength; i++) { |
| 6235 FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue); | 6235 FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue); |
| 6236 XFA_RESOLVENODE_RS resoveNodeRS; | 6236 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6237 int32_t iRet = ResolveObjects(hThis, hJSObjValue, szSomExp.AsStringC(), | 6237 int32_t iRet = ResolveObjects(pThis, hJSObjValue, szSomExp.AsStringC(), |
| 6238 resoveNodeRS, FALSE); | 6238 resoveNodeRS, FALSE); |
| 6239 if (iRet > 0) { | 6239 if (iRet > 0) { |
| 6240 ParseResolveResult(hThis, resoveNodeRS, hJSObjValue, | 6240 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue, |
| 6241 hResolveValues[i - 2], iSizes[i - 2], bAttribute); | 6241 hResolveValues[i - 2], iSizes[i - 2], bAttribute); |
| 6242 iCounter += iSizes[i - 2]; | 6242 iCounter += iSizes[i - 2]; |
| 6243 } | 6243 } |
| 6244 } | 6244 } |
| 6245 FXJSE_Value_Release(hJSObjValue); | 6245 FXJSE_Value_Release(hJSObjValue); |
| 6246 if (iCounter > 0) { | 6246 if (iCounter > 0) { |
| 6247 FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iCounter + 2); | 6247 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2); |
| 6248 for (int32_t i = 0; i < (iCounter + 2); i++) { | 6248 for (int32_t i = 0; i < (iCounter + 2); i++) { |
| 6249 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6249 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6250 } | 6250 } |
| 6251 FXJSE_Value_SetInteger(rgValues[0], 1); | 6251 FXJSE_Value_SetInteger(rgValues[0], 1); |
| 6252 if (bAttribute) { | 6252 if (bAttribute) { |
| 6253 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); | 6253 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); |
| 6254 } else { | 6254 } else { |
| 6255 FXJSE_Value_SetNull(rgValues[1]); | 6255 FXJSE_Value_SetNull(rgValues[1]); |
| 6256 } | 6256 } |
| 6257 int32_t iIndex = 2; | 6257 int32_t iIndex = 2; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6276 wsSomExpression.c_str()); | 6276 wsSomExpression.c_str()); |
| 6277 } | 6277 } |
| 6278 for (int32_t i = 0; i < iLength - 2; i++) { | 6278 for (int32_t i = 0; i < iLength - 2; i++) { |
| 6279 for (int32_t j = 0; j < iSizes[i]; j++) { | 6279 for (int32_t j = 0; j < iSizes[i]; j++) { |
| 6280 FXJSE_Value_Release(hResolveValues[i][j]); | 6280 FXJSE_Value_Release(hResolveValues[i][j]); |
| 6281 } | 6281 } |
| 6282 FX_Free(hResolveValues[i]); | 6282 FX_Free(hResolveValues[i]); |
| 6283 } | 6283 } |
| 6284 FX_Free(hResolveValues); | 6284 FX_Free(hResolveValues); |
| 6285 FX_Free(iSizes); | 6285 FX_Free(iSizes); |
| 6286 FXJSE_Value_Release(hLengthValue); | 6286 FXJSE_Value_Release(pLengthValue); |
| 6287 } else { | 6287 } else { |
| 6288 XFA_RESOLVENODE_RS resoveNodeRS; | 6288 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6289 int32_t iRet = 0; | 6289 int32_t iRet = 0; |
| 6290 if (FXJSE_Value_IsObject(argAccessor) || | 6290 if (FXJSE_Value_IsObject(argAccessor) || |
| 6291 (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { | 6291 (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { |
| 6292 iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(), | 6292 iRet = ResolveObjects(pThis, argAccessor, szSomExp.AsStringC(), |
| 6293 resoveNodeRS, FALSE); | 6293 resoveNodeRS, FALSE); |
| 6294 } else if (!FXJSE_Value_IsObject(argAccessor) && | 6294 } else if (!FXJSE_Value_IsObject(argAccessor) && |
| 6295 !bsAccessorName.IsEmpty()) { | 6295 !bsAccessorName.IsEmpty()) { |
| 6296 FX_BOOL bGetObject = | 6296 FX_BOOL bGetObject = |
| 6297 GetObjectByName(hThis, argAccessor, bsAccessorName.AsStringC()); | 6297 GetObjectByName(pThis, argAccessor, bsAccessorName.AsStringC()); |
| 6298 if (bGetObject) { | 6298 if (bGetObject) { |
| 6299 iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(), | 6299 iRet = ResolveObjects(pThis, argAccessor, szSomExp.AsStringC(), |
| 6300 resoveNodeRS, FALSE); | 6300 resoveNodeRS, FALSE); |
| 6301 } | 6301 } |
| 6302 } | 6302 } |
| 6303 if (iRet > 0) { | 6303 if (iRet > 0) { |
| 6304 FXJSE_HVALUE* hResolveValues; | 6304 CFXJSE_Value** hResolveValues; |
| 6305 int32_t iSize = 0; | 6305 int32_t iSize = 0; |
| 6306 FX_BOOL bAttribute = FALSE; | 6306 FX_BOOL bAttribute = FALSE; |
| 6307 ParseResolveResult(hThis, resoveNodeRS, argAccessor, hResolveValues, | 6307 ParseResolveResult(pThis, resoveNodeRS, argAccessor, hResolveValues, |
| 6308 iSize, bAttribute); | 6308 iSize, bAttribute); |
| 6309 FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iSize + 2); | 6309 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2); |
| 6310 for (int32_t i = 0; i < (iSize + 2); i++) { | 6310 for (int32_t i = 0; i < (iSize + 2); i++) { |
| 6311 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6311 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6312 } | 6312 } |
| 6313 FXJSE_Value_SetInteger(rgValues[0], 1); | 6313 FXJSE_Value_SetInteger(rgValues[0], 1); |
| 6314 if (bAttribute) { | 6314 if (bAttribute) { |
| 6315 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); | 6315 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); |
| 6316 } else { | 6316 } else { |
| 6317 FXJSE_Value_SetNull(rgValues[1]); | 6317 FXJSE_Value_SetNull(rgValues[1]); |
| 6318 } | 6318 } |
| 6319 for (int32_t i = 0; i < iSize; i++) { | 6319 for (int32_t i = 0; i < iSize; i++) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6339 } | 6339 } |
| 6340 } | 6340 } |
| 6341 if (argc == 5) { | 6341 if (argc == 5) { |
| 6342 FXJSE_Value_Release(argIndex); | 6342 FXJSE_Value_Release(argIndex); |
| 6343 } | 6343 } |
| 6344 FXJSE_Value_Release(argAccessor); | 6344 FXJSE_Value_Release(argAccessor); |
| 6345 } else { | 6345 } else { |
| 6346 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6346 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6347 } | 6347 } |
| 6348 } | 6348 } |
| 6349 void CXFA_FM2JSContext::eval_translation(FXJSE_HOBJECT hThis, | 6349 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, |
| 6350 const CFX_ByteStringC& szFuncName, | 6350 const CFX_ByteStringC& szFuncName, |
| 6351 CFXJSE_Arguments& args) { | 6351 CFXJSE_Arguments& args) { |
| 6352 CXFA_FM2JSContext* pContext = | 6352 CXFA_FM2JSContext* pContext = |
| 6353 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6353 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6354 int32_t argc = args.GetLength(); | 6354 int32_t argc = args.GetLength(); |
| 6355 if (argc == 1) { | 6355 if (argc == 1) { |
| 6356 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 6356 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 6357 CFX_ByteString argString; | 6357 CFX_ByteString argString; |
| 6358 HValueToUTF8String(argOne, argString); | 6358 ValueToUTF8String(argOne, argString); |
| 6359 if (argString.IsEmpty()) { | 6359 if (argString.IsEmpty()) { |
| 6360 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 6360 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 6361 } else { | 6361 } else { |
| 6362 CFX_WideString scriptString = | 6362 CFX_WideString scriptString = |
| 6363 CFX_WideString::FromUTF8(argString.AsStringC()); | 6363 CFX_WideString::FromUTF8(argString.AsStringC()); |
| 6364 CFX_WideTextBuf wsJavaScriptBuf; | 6364 CFX_WideTextBuf wsJavaScriptBuf; |
| 6365 CFX_WideString wsError; | 6365 CFX_WideString wsError; |
| 6366 XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError); | 6366 XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError); |
| 6367 if (wsError.IsEmpty()) { | 6367 if (wsError.IsEmpty()) { |
| 6368 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); | 6368 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); |
| 6369 FXJSE_Value_SetUTF8String( | 6369 FXJSE_Value_SetUTF8String( |
| 6370 args.GetReturnValue(), | 6370 args.GetReturnValue(), |
| 6371 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) | 6371 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) |
| 6372 .AsStringC()); | 6372 .AsStringC()); |
| 6373 } else { | 6373 } else { |
| 6374 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6374 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6375 } | 6375 } |
| 6376 } | 6376 } |
| 6377 FXJSE_Value_Release(argOne); | 6377 FXJSE_Value_Release(argOne); |
| 6378 } else { | 6378 } else { |
| 6379 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 6379 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 6380 L"Eval"); | 6380 L"Eval"); |
| 6381 } | 6381 } |
| 6382 } | 6382 } |
| 6383 void CXFA_FM2JSContext::is_fm_object(FXJSE_HOBJECT hThis, | 6383 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, |
| 6384 const CFX_ByteStringC& szFuncName, | 6384 const CFX_ByteStringC& szFuncName, |
| 6385 CFXJSE_Arguments& args) { | 6385 CFXJSE_Arguments& args) { |
| 6386 int32_t iLength = args.GetLength(); | 6386 int32_t iLength = args.GetLength(); |
| 6387 if (iLength == 1) { | 6387 if (iLength == 1) { |
| 6388 FXJSE_HVALUE argOne = args.GetValue(0); | 6388 CFXJSE_Value* argOne = args.GetValue(0); |
| 6389 FXJSE_Value_SetBoolean(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); | 6389 FXJSE_Value_SetBoolean(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); |
| 6390 FXJSE_Value_Release(argOne); | 6390 FXJSE_Value_Release(argOne); |
| 6391 } else { | 6391 } else { |
| 6392 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); | 6392 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); |
| 6393 } | 6393 } |
| 6394 } | 6394 } |
| 6395 void CXFA_FM2JSContext::is_fm_array(FXJSE_HOBJECT hThis, | 6395 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, |
| 6396 const CFX_ByteStringC& szFuncName, | 6396 const CFX_ByteStringC& szFuncName, |
| 6397 CFXJSE_Arguments& args) { | 6397 CFXJSE_Arguments& args) { |
| 6398 int32_t iLength = args.GetLength(); | 6398 int32_t iLength = args.GetLength(); |
| 6399 if (iLength == 1) { | 6399 if (iLength == 1) { |
| 6400 FXJSE_HVALUE argOne = args.GetValue(0); | 6400 CFXJSE_Value* argOne = args.GetValue(0); |
| 6401 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne); | 6401 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne); |
| 6402 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); | 6402 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); |
| 6403 FXJSE_Value_Release(argOne); | 6403 FXJSE_Value_Release(argOne); |
| 6404 } else { | 6404 } else { |
| 6405 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); | 6405 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); |
| 6406 } | 6406 } |
| 6407 } | 6407 } |
| 6408 void CXFA_FM2JSContext::get_fm_value(FXJSE_HOBJECT hThis, | 6408 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, |
| 6409 const CFX_ByteStringC& szFuncName, | 6409 const CFX_ByteStringC& szFuncName, |
| 6410 CFXJSE_Arguments& args) { | 6410 CFXJSE_Arguments& args) { |
| 6411 CXFA_FM2JSContext* pContext = | 6411 CXFA_FM2JSContext* pContext = |
| 6412 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6412 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6413 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6413 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6414 int32_t iLength = args.GetLength(); | 6414 int32_t iLength = args.GetLength(); |
| 6415 if (iLength == 1) { | 6415 if (iLength == 1) { |
| 6416 FXJSE_HVALUE argOne = args.GetValue(0); | 6416 CFXJSE_Value* argOne = args.GetValue(0); |
| 6417 if (FXJSE_Value_IsArray(argOne)) { | 6417 if (FXJSE_Value_IsArray(argOne)) { |
| 6418 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6418 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6419 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 6419 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 6420 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 6420 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
| 6421 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsobjectValue); | 6421 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsobjectValue); |
| 6422 if (FXJSE_Value_IsNull(propertyValue)) { | 6422 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6423 GetObjectDefaultValue(jsobjectValue, args.GetReturnValue()); | 6423 GetObjectDefaultValue(jsobjectValue, args.GetReturnValue()); |
| 6424 } else { | 6424 } else { |
| 6425 CFX_ByteString propertyStr; | 6425 CFX_ByteString propertyStr; |
| 6426 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6426 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6427 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 6427 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 6428 args.GetReturnValue()); | 6428 args.GetReturnValue()); |
| 6429 } | 6429 } |
| 6430 FXJSE_Value_Release(propertyValue); | 6430 FXJSE_Value_Release(propertyValue); |
| 6431 FXJSE_Value_Release(jsobjectValue); | 6431 FXJSE_Value_Release(jsobjectValue); |
| 6432 } else if (FXJSE_Value_IsObject(argOne)) { | 6432 } else if (FXJSE_Value_IsObject(argOne)) { |
| 6433 GetObjectDefaultValue(argOne, args.GetReturnValue()); | 6433 GetObjectDefaultValue(argOne, args.GetReturnValue()); |
| 6434 } else { | 6434 } else { |
| 6435 FXJSE_Value_Set(args.GetReturnValue(), argOne); | 6435 FXJSE_Value_Set(args.GetReturnValue(), argOne); |
| 6436 } | 6436 } |
| 6437 FXJSE_Value_Release(argOne); | 6437 FXJSE_Value_Release(argOne); |
| 6438 } else { | 6438 } else { |
| 6439 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6439 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6440 } | 6440 } |
| 6441 } | 6441 } |
| 6442 void CXFA_FM2JSContext::get_fm_jsobj(FXJSE_HOBJECT hThis, | 6442 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, |
| 6443 const CFX_ByteStringC& szFuncName, | 6443 const CFX_ByteStringC& szFuncName, |
| 6444 CFXJSE_Arguments& args) { | 6444 CFXJSE_Arguments& args) { |
| 6445 CXFA_FM2JSContext* pContext = | 6445 CXFA_FM2JSContext* pContext = |
| 6446 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(hThis, nullptr)); | 6446 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); |
| 6447 int32_t argc = args.GetLength(); | 6447 int32_t argc = args.GetLength(); |
| 6448 if (argc == 1) { | 6448 if (argc == 1) { |
| 6449 FXJSE_HVALUE argOne = args.GetValue(0); | 6449 CFXJSE_Value* argOne = args.GetValue(0); |
| 6450 if (FXJSE_Value_IsArray(argOne)) { | 6450 if (FXJSE_Value_IsArray(argOne)) { |
| 6451 #ifndef NDEBUG | 6451 #ifndef NDEBUG |
| 6452 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6452 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6453 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6453 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6454 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 6454 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
| 6455 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); | 6455 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); |
| 6456 FXJSE_Value_Release(lengthValue); | 6456 FXJSE_Value_Release(lengthValue); |
| 6457 #endif | 6457 #endif |
| 6458 FXJSE_Value_GetObjectPropByIdx(argOne, 2, args.GetReturnValue()); | 6458 FXJSE_Value_GetObjectPropByIdx(argOne, 2, args.GetReturnValue()); |
| 6459 } else { | 6459 } else { |
| 6460 FXJSE_Value_Set(args.GetReturnValue(), argOne); | 6460 FXJSE_Value_Set(args.GetReturnValue(), argOne); |
| 6461 } | 6461 } |
| 6462 FXJSE_Value_Release(argOne); | 6462 FXJSE_Value_Release(argOne); |
| 6463 } else { | 6463 } else { |
| 6464 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6464 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6465 } | 6465 } |
| 6466 } | 6466 } |
| 6467 void CXFA_FM2JSContext::fm_var_filter(FXJSE_HOBJECT hThis, | 6467 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, |
| 6468 const CFX_ByteStringC& szFuncName, | 6468 const CFX_ByteStringC& szFuncName, |
| 6469 CFXJSE_Arguments& args) { | 6469 CFXJSE_Arguments& args) { |
| 6470 CXFA_FM2JSContext* pContext = | 6470 CXFA_FM2JSContext* pContext = |
| 6471 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6471 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6472 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6472 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6473 int32_t argc = args.GetLength(); | 6473 int32_t argc = args.GetLength(); |
| 6474 if (argc == 1) { | 6474 if (argc == 1) { |
| 6475 FXJSE_HVALUE argOne = args.GetValue(0); | 6475 CFXJSE_Value* argOne = args.GetValue(0); |
| 6476 if (FXJSE_Value_IsArray(argOne)) { | 6476 if (FXJSE_Value_IsArray(argOne)) { |
| 6477 #ifndef NDEBUG | 6477 #ifndef NDEBUG |
| 6478 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6478 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6479 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 6479 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
| 6480 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); | 6480 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); |
| 6481 FXJSE_Value_Release(lengthValue); | 6481 FXJSE_Value_Release(lengthValue); |
| 6482 #endif | 6482 #endif |
| 6483 FXJSE_HVALUE flagsValue = FXJSE_Value_Create(pIsolate); | 6483 CFXJSE_Value* flagsValue = FXJSE_Value_Create(pIsolate); |
| 6484 FXJSE_Value_GetObjectPropByIdx(argOne, 0, flagsValue); | 6484 FXJSE_Value_GetObjectPropByIdx(argOne, 0, flagsValue); |
| 6485 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue); | 6485 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue); |
| 6486 FXJSE_Value_Release(flagsValue); | 6486 FXJSE_Value_Release(flagsValue); |
| 6487 if (iFlags == 4) { | 6487 if (iFlags == 4) { |
| 6488 FXJSE_HVALUE rgValues[3]; | 6488 CFXJSE_Value* rgValues[3]; |
| 6489 for (int32_t i = 0; i < 3; i++) { | 6489 for (int32_t i = 0; i < 3; i++) { |
| 6490 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6490 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6491 } | 6491 } |
| 6492 FXJSE_Value_SetInteger(rgValues[0], 3); | 6492 FXJSE_Value_SetInteger(rgValues[0], 3); |
| 6493 FXJSE_Value_SetNull(rgValues[1]); | 6493 FXJSE_Value_SetNull(rgValues[1]); |
| 6494 FXJSE_Value_SetNull(rgValues[2]); | 6494 FXJSE_Value_SetNull(rgValues[2]); |
| 6495 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 6495 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 6496 for (int32_t i = 0; i < 3; i++) { | 6496 for (int32_t i = 0; i < 3; i++) { |
| 6497 FXJSE_Value_Release(rgValues[i]); | 6497 FXJSE_Value_Release(rgValues[i]); |
| 6498 } | 6498 } |
| 6499 } else if (iFlags == 3) { | 6499 } else if (iFlags == 3) { |
| 6500 FXJSE_HVALUE objectValue = FXJSE_Value_Create(pIsolate); | 6500 CFXJSE_Value* objectValue = FXJSE_Value_Create(pIsolate); |
| 6501 FXJSE_Value_GetObjectPropByIdx(argOne, 2, objectValue); | 6501 FXJSE_Value_GetObjectPropByIdx(argOne, 2, objectValue); |
| 6502 if (!FXJSE_Value_IsNull(objectValue)) { | 6502 if (!FXJSE_Value_IsNull(objectValue)) { |
| 6503 FXJSE_Value_Set(args.GetReturnValue(), argOne); | 6503 FXJSE_Value_Set(args.GetReturnValue(), argOne); |
| 6504 } else { | 6504 } else { |
| 6505 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6505 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6506 } | 6506 } |
| 6507 FXJSE_Value_Release(objectValue); | 6507 FXJSE_Value_Release(objectValue); |
| 6508 } else { | 6508 } else { |
| 6509 FXJSE_HVALUE simpleValue = GetSimpleHValue(hThis, args, 0); | 6509 CFXJSE_Value* simpleValue = GetSimpleValue(pThis, args, 0); |
| 6510 FXJSE_Value_Set(args.GetReturnValue(), simpleValue); | 6510 FXJSE_Value_Set(args.GetReturnValue(), simpleValue); |
| 6511 FXJSE_Value_Release(simpleValue); | 6511 FXJSE_Value_Release(simpleValue); |
| 6512 } | 6512 } |
| 6513 } else { | 6513 } else { |
| 6514 FXJSE_HVALUE simpleValue = GetSimpleHValue(hThis, args, 0); | 6514 CFXJSE_Value* simpleValue = GetSimpleValue(pThis, args, 0); |
| 6515 FXJSE_Value_Set(args.GetReturnValue(), simpleValue); | 6515 FXJSE_Value_Set(args.GetReturnValue(), simpleValue); |
| 6516 FXJSE_Value_Release(simpleValue); | 6516 FXJSE_Value_Release(simpleValue); |
| 6517 } | 6517 } |
| 6518 FXJSE_Value_Release(argOne); | 6518 FXJSE_Value_Release(argOne); |
| 6519 } else { | 6519 } else { |
| 6520 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6520 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6521 } | 6521 } |
| 6522 } | 6522 } |
| 6523 void CXFA_FM2JSContext::concat_fm_object(FXJSE_HOBJECT hThis, | 6523 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, |
| 6524 const CFX_ByteStringC& szFuncName, | 6524 const CFX_ByteStringC& szFuncName, |
| 6525 CFXJSE_Arguments& args) { | 6525 CFXJSE_Arguments& args) { |
| 6526 CXFA_FM2JSContext* pContext = | 6526 CXFA_FM2JSContext* pContext = |
| 6527 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6527 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6528 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6528 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6529 uint32_t iLength = 0; | 6529 uint32_t iLength = 0; |
| 6530 int32_t argCount = args.GetLength(); | 6530 int32_t argCount = args.GetLength(); |
| 6531 FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argCount); | 6531 CFXJSE_Value** argValues = FX_Alloc(CFXJSE_Value*, argCount); |
| 6532 for (int32_t i = 0; i < argCount; i++) { | 6532 for (int32_t i = 0; i < argCount; i++) { |
| 6533 argValues[i] = args.GetValue(i); | 6533 argValues[i] = args.GetValue(i); |
| 6534 if (FXJSE_Value_IsArray(argValues[i])) { | 6534 if (FXJSE_Value_IsArray(argValues[i])) { |
| 6535 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6535 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6536 FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); | 6536 FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); |
| 6537 int32_t length = FXJSE_Value_ToInteger(lengthValue); | 6537 int32_t length = FXJSE_Value_ToInteger(lengthValue); |
| 6538 iLength = iLength + ((length > 2) ? (length - 2) : 0); | 6538 iLength = iLength + ((length > 2) ? (length - 2) : 0); |
| 6539 FXJSE_Value_Release(lengthValue); | 6539 FXJSE_Value_Release(lengthValue); |
| 6540 } | 6540 } |
| 6541 iLength += 1; | 6541 iLength += 1; |
| 6542 } | 6542 } |
| 6543 FXJSE_HVALUE* returnValues = FX_Alloc(FXJSE_HVALUE, iLength); | 6543 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); |
| 6544 for (int32_t i = 0; i < (int32_t)iLength; i++) { | 6544 for (int32_t i = 0; i < (int32_t)iLength; i++) { |
| 6545 returnValues[i] = FXJSE_Value_Create(pIsolate); | 6545 returnValues[i] = FXJSE_Value_Create(pIsolate); |
| 6546 } | 6546 } |
| 6547 int32_t index = 0; | 6547 int32_t index = 0; |
| 6548 for (int32_t i = 0; i < argCount; i++) { | 6548 for (int32_t i = 0; i < argCount; i++) { |
| 6549 if (FXJSE_Value_IsArray(argValues[i])) { | 6549 if (FXJSE_Value_IsArray(argValues[i])) { |
| 6550 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6550 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6551 FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); | 6551 FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); |
| 6552 int32_t length = FXJSE_Value_ToInteger(lengthValue); | 6552 int32_t length = FXJSE_Value_ToInteger(lengthValue); |
| 6553 for (int32_t j = 2; j < length; j++) { | 6553 for (int32_t j = 2; j < length; j++) { |
| 6554 FXJSE_Value_GetObjectPropByIdx(argValues[i], j, returnValues[index]); | 6554 FXJSE_Value_GetObjectPropByIdx(argValues[i], j, returnValues[index]); |
| 6555 index++; | 6555 index++; |
| 6556 } | 6556 } |
| 6557 FXJSE_Value_Release(lengthValue); | 6557 FXJSE_Value_Release(lengthValue); |
| 6558 } | 6558 } |
| 6559 FXJSE_Value_Set(returnValues[index], argValues[i]); | 6559 FXJSE_Value_Set(returnValues[index], argValues[i]); |
| 6560 index++; | 6560 index++; |
| 6561 } | 6561 } |
| 6562 FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); | 6562 FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); |
| 6563 for (int32_t i = 0; i < argCount; i++) { | 6563 for (int32_t i = 0; i < argCount; i++) { |
| 6564 FXJSE_Value_Release(argValues[i]); | 6564 FXJSE_Value_Release(argValues[i]); |
| 6565 } | 6565 } |
| 6566 FX_Free(argValues); | 6566 FX_Free(argValues); |
| 6567 for (int32_t i = 0; i < (int32_t)iLength; i++) { | 6567 for (int32_t i = 0; i < (int32_t)iLength; i++) { |
| 6568 FXJSE_Value_Release(returnValues[i]); | 6568 FXJSE_Value_Release(returnValues[i]); |
| 6569 } | 6569 } |
| 6570 FX_Free(returnValues); | 6570 FX_Free(returnValues); |
| 6571 } | 6571 } |
| 6572 FXJSE_HVALUE CXFA_FM2JSContext::GetSimpleHValue(FXJSE_HOBJECT hThis, | 6572 CFXJSE_Value* CXFA_FM2JSContext::GetSimpleValue(CFXJSE_Value* pThis, |
| 6573 CFXJSE_Arguments& args, | 6573 CFXJSE_Arguments& args, |
| 6574 uint32_t index) { | 6574 uint32_t index) { |
| 6575 CXFA_FM2JSContext* pContext = | 6575 CXFA_FM2JSContext* pContext = |
| 6576 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6576 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6577 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6577 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6578 ASSERT(index < (uint32_t)args.GetLength()); | 6578 ASSERT(index < (uint32_t)args.GetLength()); |
| 6579 FXJSE_HVALUE argIndex = args.GetValue(index); | 6579 CFXJSE_Value* argIndex = args.GetValue(index); |
| 6580 if (FXJSE_Value_IsArray(argIndex)) { | 6580 if (FXJSE_Value_IsArray(argIndex)) { |
| 6581 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6581 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6582 FXJSE_Value_GetObjectProp(argIndex, "length", lengthValue); | 6582 FXJSE_Value_GetObjectProp(argIndex, "length", lengthValue); |
| 6583 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 6583 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 6584 FXJSE_Value_Release(lengthValue); | 6584 FXJSE_Value_Release(lengthValue); |
| 6585 FXJSE_HVALUE simpleValue = FXJSE_Value_Create(pIsolate); | 6585 CFXJSE_Value* simpleValue = FXJSE_Value_Create(pIsolate); |
| 6586 if (iLength > 2) { | 6586 if (iLength > 2) { |
| 6587 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6587 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6588 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 6588 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 6589 FXJSE_Value_GetObjectPropByIdx(argIndex, 1, propertyValue); | 6589 FXJSE_Value_GetObjectPropByIdx(argIndex, 1, propertyValue); |
| 6590 FXJSE_Value_GetObjectPropByIdx(argIndex, 2, jsobjectValue); | 6590 FXJSE_Value_GetObjectPropByIdx(argIndex, 2, jsobjectValue); |
| 6591 if (FXJSE_Value_IsNull(propertyValue)) { | 6591 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6592 GetObjectDefaultValue(jsobjectValue, simpleValue); | 6592 GetObjectDefaultValue(jsobjectValue, simpleValue); |
| 6593 } else { | 6593 } else { |
| 6594 CFX_ByteString propertyStr; | 6594 CFX_ByteString propertyStr; |
| 6595 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6595 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6596 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 6596 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 6597 simpleValue); | 6597 simpleValue); |
| 6598 } | 6598 } |
| 6599 FXJSE_Value_Release(propertyValue); | 6599 FXJSE_Value_Release(propertyValue); |
| 6600 FXJSE_Value_Release(jsobjectValue); | 6600 FXJSE_Value_Release(jsobjectValue); |
| 6601 } else { | 6601 } else { |
| 6602 FXJSE_Value_SetUndefined(simpleValue); | 6602 FXJSE_Value_SetUndefined(simpleValue); |
| 6603 } | 6603 } |
| 6604 FXJSE_Value_Release(argIndex); | 6604 FXJSE_Value_Release(argIndex); |
| 6605 return simpleValue; | 6605 return simpleValue; |
| 6606 } else if (FXJSE_Value_IsObject(argIndex)) { | 6606 } else if (FXJSE_Value_IsObject(argIndex)) { |
| 6607 FXJSE_HVALUE defaultValue = FXJSE_Value_Create(pIsolate); | 6607 CFXJSE_Value* defaultValue = FXJSE_Value_Create(pIsolate); |
| 6608 GetObjectDefaultValue(argIndex, defaultValue); | 6608 GetObjectDefaultValue(argIndex, defaultValue); |
| 6609 FXJSE_Value_Release(argIndex); | 6609 FXJSE_Value_Release(argIndex); |
| 6610 return defaultValue; | 6610 return defaultValue; |
| 6611 } else { | 6611 } else { |
| 6612 return argIndex; | 6612 return argIndex; |
| 6613 } | 6613 } |
| 6614 } | 6614 } |
| 6615 FX_BOOL CXFA_FM2JSContext::HValueIsNull(FXJSE_HOBJECT hThis, FXJSE_HVALUE arg) { | 6615 |
| 6616 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { |
| 6616 CXFA_FM2JSContext* pContext = | 6617 CXFA_FM2JSContext* pContext = |
| 6617 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6618 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6618 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6619 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6619 FX_BOOL isNull = FALSE; | 6620 FX_BOOL isNull = FALSE; |
| 6620 if (FXJSE_Value_IsNull(arg)) { | 6621 if (FXJSE_Value_IsNull(arg)) { |
| 6621 isNull = TRUE; | 6622 isNull = TRUE; |
| 6622 } else if (FXJSE_Value_IsArray(arg)) { | 6623 } else if (FXJSE_Value_IsArray(arg)) { |
| 6623 int32_t iLength = hvalue_get_array_length(hThis, arg); | 6624 int32_t iLength = hvalue_get_array_length(pThis, arg); |
| 6624 if (iLength > 2) { | 6625 if (iLength > 2) { |
| 6625 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6626 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6626 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 6627 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 6627 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); | 6628 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); |
| 6628 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue); | 6629 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue); |
| 6629 if (FXJSE_Value_IsNull(propertyValue)) { | 6630 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6630 FXJSE_HVALUE defaultValue = FXJSE_Value_Create(pIsolate); | 6631 CFXJSE_Value* defaultValue = FXJSE_Value_Create(pIsolate); |
| 6631 GetObjectDefaultValue(jsObjectValue, defaultValue); | 6632 GetObjectDefaultValue(jsObjectValue, defaultValue); |
| 6632 if (FXJSE_Value_IsNull(defaultValue)) { | 6633 if (FXJSE_Value_IsNull(defaultValue)) { |
| 6633 isNull = TRUE; | 6634 isNull = TRUE; |
| 6634 } | 6635 } |
| 6635 FXJSE_Value_Release(defaultValue); | 6636 FXJSE_Value_Release(defaultValue); |
| 6636 } else { | 6637 } else { |
| 6637 CFX_ByteString propertyStr; | 6638 CFX_ByteString propertyStr; |
| 6638 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6639 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6639 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 6640 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 6640 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 6641 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 6641 newPropertyValue); | 6642 newPropertyValue); |
| 6642 if (FXJSE_Value_IsNull(newPropertyValue)) { | 6643 if (FXJSE_Value_IsNull(newPropertyValue)) { |
| 6643 isNull = TRUE; | 6644 isNull = TRUE; |
| 6644 } | 6645 } |
| 6645 FXJSE_Value_Release(newPropertyValue); | 6646 FXJSE_Value_Release(newPropertyValue); |
| 6646 } | 6647 } |
| 6647 FXJSE_Value_Release(propertyValue); | 6648 FXJSE_Value_Release(propertyValue); |
| 6648 FXJSE_Value_Release(jsObjectValue); | 6649 FXJSE_Value_Release(jsObjectValue); |
| 6649 } else { | 6650 } else { |
| 6650 isNull = TRUE; | 6651 isNull = TRUE; |
| 6651 } | 6652 } |
| 6652 } else if (FXJSE_Value_IsObject(arg)) { | 6653 } else if (FXJSE_Value_IsObject(arg)) { |
| 6653 FXJSE_HVALUE defaultValue = FXJSE_Value_Create(pIsolate); | 6654 CFXJSE_Value* defaultValue = FXJSE_Value_Create(pIsolate); |
| 6654 GetObjectDefaultValue(arg, defaultValue); | 6655 GetObjectDefaultValue(arg, defaultValue); |
| 6655 if (FXJSE_Value_IsNull(defaultValue)) { | 6656 if (FXJSE_Value_IsNull(defaultValue)) { |
| 6656 isNull = TRUE; | 6657 isNull = TRUE; |
| 6657 } | 6658 } |
| 6658 FXJSE_Value_Release(defaultValue); | 6659 FXJSE_Value_Release(defaultValue); |
| 6659 } | 6660 } |
| 6660 return isNull; | 6661 return isNull; |
| 6661 } | 6662 } |
| 6662 int32_t CXFA_FM2JSContext::hvalue_get_array_length(FXJSE_HOBJECT hThis, | 6663 |
| 6663 FXJSE_HVALUE arg) { | 6664 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, |
| 6665 CFXJSE_Value* arg) { |
| 6664 CXFA_FM2JSContext* pContext = | 6666 CXFA_FM2JSContext* pContext = |
| 6665 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6667 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6666 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6668 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6667 int32_t iLength = 0; | 6669 int32_t iLength = 0; |
| 6668 if (FXJSE_Value_IsArray(arg)) { | 6670 if (FXJSE_Value_IsArray(arg)) { |
| 6669 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6671 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6670 FXJSE_Value_GetObjectProp(arg, "length", lengthValue); | 6672 FXJSE_Value_GetObjectProp(arg, "length", lengthValue); |
| 6671 iLength = FXJSE_Value_ToInteger(lengthValue); | 6673 iLength = FXJSE_Value_ToInteger(lengthValue); |
| 6672 FXJSE_Value_Release(lengthValue); | 6674 FXJSE_Value_Release(lengthValue); |
| 6673 } | 6675 } |
| 6674 return iLength; | 6676 return iLength; |
| 6675 } | 6677 } |
| 6676 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(FXJSE_HOBJECT hThis, | 6678 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, |
| 6677 FXJSE_HVALUE firstValue, | 6679 CFXJSE_Value* firstValue, |
| 6678 FXJSE_HVALUE secondValue) { | 6680 CFXJSE_Value* secondValue) { |
| 6679 FX_BOOL bReturn = FALSE; | 6681 FX_BOOL bReturn = FALSE; |
| 6680 if (FXJSE_Value_IsUTF8String(firstValue)) { | 6682 if (FXJSE_Value_IsUTF8String(firstValue)) { |
| 6681 CFX_ByteString firstString, secondString; | 6683 CFX_ByteString firstString, secondString; |
| 6682 HValueToUTF8String(firstValue, firstString); | 6684 ValueToUTF8String(firstValue, firstString); |
| 6683 HValueToUTF8String(secondValue, secondString); | 6685 ValueToUTF8String(secondValue, secondString); |
| 6684 bReturn = firstString == secondString; | 6686 bReturn = firstString == secondString; |
| 6685 } else if (FXJSE_Value_IsNumber(firstValue)) { | 6687 } else if (FXJSE_Value_IsNumber(firstValue)) { |
| 6686 FX_FLOAT first = HValueToFloat(hThis, firstValue); | 6688 FX_FLOAT first = ValueToFloat(pThis, firstValue); |
| 6687 FX_FLOAT second = HValueToFloat(hThis, secondValue); | 6689 FX_FLOAT second = ValueToFloat(pThis, secondValue); |
| 6688 bReturn = (first == second); | 6690 bReturn = (first == second); |
| 6689 } else if (FXJSE_Value_IsBoolean(firstValue)) { | 6691 } else if (FXJSE_Value_IsBoolean(firstValue)) { |
| 6690 bReturn = (FXJSE_Value_ToBoolean(firstValue) == | 6692 bReturn = (FXJSE_Value_ToBoolean(firstValue) == |
| 6691 FXJSE_Value_ToBoolean(secondValue)); | 6693 FXJSE_Value_ToBoolean(secondValue)); |
| 6692 } else if (FXJSE_Value_IsNull(firstValue) && | 6694 } else if (FXJSE_Value_IsNull(firstValue) && |
| 6693 FXJSE_Value_IsNull(secondValue)) { | 6695 FXJSE_Value_IsNull(secondValue)) { |
| 6694 bReturn = TRUE; | 6696 bReturn = TRUE; |
| 6695 } | 6697 } |
| 6696 return bReturn; | 6698 return bReturn; |
| 6697 } | 6699 } |
| 6698 void CXFA_FM2JSContext::unfoldArgs(FXJSE_HOBJECT hThis, | 6700 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, |
| 6699 CFXJSE_Arguments& args, | 6701 CFXJSE_Arguments& args, |
| 6700 FXJSE_HVALUE*& resultValues, | 6702 CFXJSE_Value**& resultValues, |
| 6701 int32_t& iCount, | 6703 int32_t& iCount, |
| 6702 int32_t iStart) { | 6704 int32_t iStart) { |
| 6703 CXFA_FM2JSContext* pContext = | 6705 CXFA_FM2JSContext* pContext = |
| 6704 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6706 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6705 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6707 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6706 iCount = 0; | 6708 iCount = 0; |
| 6707 int32_t argc = args.GetLength(); | 6709 int32_t argc = args.GetLength(); |
| 6708 FXJSE_HVALUE* argsValue = FX_Alloc(FXJSE_HVALUE, argc); | 6710 CFXJSE_Value** argsValue = FX_Alloc(CFXJSE_Value*, argc); |
| 6709 for (int32_t i = iStart; i < argc; i++) { | 6711 for (int32_t i = iStart; i < argc; i++) { |
| 6710 argsValue[i] = args.GetValue(i); | 6712 argsValue[i] = args.GetValue(i); |
| 6711 if (FXJSE_Value_IsArray(argsValue[i])) { | 6713 if (FXJSE_Value_IsArray(argsValue[i])) { |
| 6712 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6714 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6713 FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); | 6715 FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); |
| 6714 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 6716 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 6715 FXJSE_Value_Release(lengthValue); | 6717 FXJSE_Value_Release(lengthValue); |
| 6716 iCount += ((iLength > 2) ? (iLength - 2) : 0); | 6718 iCount += ((iLength > 2) ? (iLength - 2) : 0); |
| 6717 } else { | 6719 } else { |
| 6718 iCount += 1; | 6720 iCount += 1; |
| 6719 } | 6721 } |
| 6720 } | 6722 } |
| 6721 resultValues = FX_Alloc(FXJSE_HVALUE, iCount); | 6723 resultValues = FX_Alloc(CFXJSE_Value*, iCount); |
| 6722 for (int32_t i = 0; i < iCount; i++) { | 6724 for (int32_t i = 0; i < iCount; i++) { |
| 6723 resultValues[i] = FXJSE_Value_Create(pIsolate); | 6725 resultValues[i] = FXJSE_Value_Create(pIsolate); |
| 6724 } | 6726 } |
| 6725 int32_t index = 0; | 6727 int32_t index = 0; |
| 6726 for (int32_t i = iStart; i < argc; i++) { | 6728 for (int32_t i = iStart; i < argc; i++) { |
| 6727 if (FXJSE_Value_IsArray(argsValue[i])) { | 6729 if (FXJSE_Value_IsArray(argsValue[i])) { |
| 6728 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6730 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6729 FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); | 6731 FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); |
| 6730 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 6732 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 6731 FXJSE_Value_Release(lengthValue); | 6733 FXJSE_Value_Release(lengthValue); |
| 6732 if (iLength > 2) { | 6734 if (iLength > 2) { |
| 6733 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6735 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6734 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 6736 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 6735 FXJSE_Value_GetObjectPropByIdx(argsValue[i], 1, propertyValue); | 6737 FXJSE_Value_GetObjectPropByIdx(argsValue[i], 1, propertyValue); |
| 6736 if (FXJSE_Value_IsNull(propertyValue)) { | 6738 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6737 for (int32_t j = 2; j < iLength; j++) { | 6739 for (int32_t j = 2; j < iLength; j++) { |
| 6738 FXJSE_Value_GetObjectPropByIdx(argsValue[i], j, jsObjectValue); | 6740 FXJSE_Value_GetObjectPropByIdx(argsValue[i], j, jsObjectValue); |
| 6739 GetObjectDefaultValue(jsObjectValue, resultValues[index]); | 6741 GetObjectDefaultValue(jsObjectValue, resultValues[index]); |
| 6740 index++; | 6742 index++; |
| 6741 } | 6743 } |
| 6742 } else { | 6744 } else { |
| 6743 CFX_ByteString propertyString; | 6745 CFX_ByteString propertyString; |
| 6744 FXJSE_Value_ToUTF8String(propertyValue, propertyString); | 6746 FXJSE_Value_ToUTF8String(propertyValue, propertyString); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6758 } else { | 6760 } else { |
| 6759 FXJSE_Value_Set(resultValues[index], argsValue[i]); | 6761 FXJSE_Value_Set(resultValues[index], argsValue[i]); |
| 6760 index++; | 6762 index++; |
| 6761 } | 6763 } |
| 6762 } | 6764 } |
| 6763 for (int32_t i = iStart; i < argc; i++) { | 6765 for (int32_t i = iStart; i < argc; i++) { |
| 6764 FXJSE_Value_Release(argsValue[i]); | 6766 FXJSE_Value_Release(argsValue[i]); |
| 6765 } | 6767 } |
| 6766 FX_Free(argsValue); | 6768 FX_Free(argsValue); |
| 6767 } | 6769 } |
| 6768 void CXFA_FM2JSContext::GetObjectDefaultValue(FXJSE_HVALUE hObjectValue, | 6770 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
| 6769 FXJSE_HVALUE hDefaultValue) { | 6771 CFXJSE_Value* pDefaultValue) { |
| 6770 CXFA_Node* pNode = | 6772 CXFA_Node* pNode = |
| 6771 ToNode((CXFA_Object*)FXJSE_Value_ToObject(hObjectValue, NULL)); | 6773 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); |
| 6772 if (pNode) { | 6774 if (pNode) { |
| 6773 pNode->Script_Som_DefaultValue(hDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); | 6775 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); |
| 6774 } else { | 6776 } else { |
| 6775 FXJSE_Value_SetNull(hDefaultValue); | 6777 FXJSE_Value_SetNull(pDefaultValue); |
| 6776 } | 6778 } |
| 6777 } | 6779 } |
| 6778 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(FXJSE_HVALUE hObjectValue, | 6780 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
| 6779 FXJSE_HVALUE hNewValue) { | 6781 CFXJSE_Value* hNewValue) { |
| 6780 CXFA_Node* pNode = | 6782 CXFA_Node* pNode = |
| 6781 ToNode((CXFA_Object*)FXJSE_Value_ToObject(hObjectValue, NULL)); | 6783 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); |
| 6782 if (pNode) { | 6784 if (pNode) { |
| 6783 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); | 6785 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); |
| 6784 return TRUE; | 6786 return TRUE; |
| 6785 } | 6787 } |
| 6786 return FALSE; | 6788 return FALSE; |
| 6787 } | 6789 } |
| 6788 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, | 6790 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, |
| 6789 int32_t iIndexFlags, | 6791 int32_t iIndexFlags, |
| 6790 int32_t iIndexValue, | 6792 int32_t iIndexValue, |
| 6791 FX_BOOL bIsStar, | 6793 FX_BOOL bIsStar, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6808 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); | 6810 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); |
| 6809 szSomExp += "]"; | 6811 szSomExp += "]"; |
| 6810 } else { | 6812 } else { |
| 6811 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); | 6813 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); |
| 6812 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; | 6814 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; |
| 6813 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); | 6815 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); |
| 6814 szSomExp += "]"; | 6816 szSomExp += "]"; |
| 6815 } | 6817 } |
| 6816 } | 6818 } |
| 6817 FX_BOOL CXFA_FM2JSContext::GetObjectByName( | 6819 FX_BOOL CXFA_FM2JSContext::GetObjectByName( |
| 6818 FXJSE_HOBJECT hThis, | 6820 CFXJSE_Value* pThis, |
| 6819 FXJSE_HVALUE accessorValue, | 6821 CFXJSE_Value* accessorValue, |
| 6820 const CFX_ByteStringC& szAccessorName) { | 6822 const CFX_ByteStringC& szAccessorName) { |
| 6821 FX_BOOL bFlags = FALSE; | 6823 FX_BOOL bFlags = FALSE; |
| 6822 CXFA_FM2JSContext* pContext = | 6824 CXFA_FM2JSContext* pContext = |
| 6823 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6825 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6824 CXFA_Document* pDoc = pContext->GetDocument(); | 6826 CXFA_Document* pDoc = pContext->GetDocument(); |
| 6825 if (!pDoc) { | 6827 if (!pDoc) { |
| 6826 return bFlags; | 6828 return bFlags; |
| 6827 } | 6829 } |
| 6828 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6830 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6829 XFA_RESOLVENODE_RS resoveNodeRS; | 6831 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6830 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6832 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
| 6831 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6833 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6832 int32_t iRet = pScriptContext->ResolveObjects( | 6834 int32_t iRet = pScriptContext->ResolveObjects( |
| 6833 pScriptContext->GetThisObject(), | 6835 pScriptContext->GetThisObject(), |
| 6834 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, | 6836 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, |
| 6835 dwFlags); | 6837 dwFlags); |
| 6836 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6838 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 6837 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6839 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
| 6838 resoveNodeRS.nodes.GetAt(0))); | 6840 resoveNodeRS.nodes.GetAt(0))); |
| 6839 bFlags = TRUE; | 6841 bFlags = TRUE; |
| 6840 } | 6842 } |
| 6841 return bFlags; | 6843 return bFlags; |
| 6842 } | 6844 } |
| 6843 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, | 6845 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, |
| 6844 FXJSE_HVALUE hRefValue, | 6846 CFXJSE_Value* pRefValue, |
| 6845 const CFX_ByteStringC& bsSomExp, | 6847 const CFX_ByteStringC& bsSomExp, |
| 6846 XFA_RESOLVENODE_RS& resoveNodeRS, | 6848 XFA_RESOLVENODE_RS& resoveNodeRS, |
| 6847 FX_BOOL bdotAccessor, | 6849 FX_BOOL bdotAccessor, |
| 6848 FX_BOOL bHasNoResolveName) { | 6850 FX_BOOL bHasNoResolveName) { |
| 6849 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); | 6851 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); |
| 6850 int32_t iRet = -1; | 6852 int32_t iRet = -1; |
| 6851 CXFA_FM2JSContext* pContext = | 6853 CXFA_FM2JSContext* pContext = |
| 6852 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6854 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6853 CXFA_Document* pDoc = pContext->GetDocument(); | 6855 CXFA_Document* pDoc = pContext->GetDocument(); |
| 6854 if (!pDoc) { | 6856 if (!pDoc) { |
| 6855 return iRet; | 6857 return iRet; |
| 6856 } | 6858 } |
| 6857 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6859 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6858 CXFA_Object* pNode = NULL; | 6860 CXFA_Object* pNode = NULL; |
| 6859 uint32_t dFlags = 0UL; | 6861 uint32_t dFlags = 0UL; |
| 6860 if (bdotAccessor) { | 6862 if (bdotAccessor) { |
| 6861 if (FXJSE_Value_IsNull(hRefValue)) { | 6863 if (FXJSE_Value_IsNull(pRefValue)) { |
| 6862 pNode = pScriptContext->GetThisObject(); | 6864 pNode = pScriptContext->GetThisObject(); |
| 6863 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6865 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6864 } else { | 6866 } else { |
| 6865 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); | 6867 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); |
| 6866 ASSERT(pNode); | 6868 ASSERT(pNode); |
| 6867 if (bHasNoResolveName) { | 6869 if (bHasNoResolveName) { |
| 6868 CFX_WideString wsName; | 6870 CFX_WideString wsName; |
| 6869 if (CXFA_Node* pXFANode = pNode->AsNode()) { | 6871 if (CXFA_Node* pXFANode = pNode->AsNode()) { |
| 6870 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); | 6872 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); |
| 6871 } | 6873 } |
| 6872 if (wsName.IsEmpty()) { | 6874 if (wsName.IsEmpty()) { |
| 6873 CFX_WideStringC className; | 6875 CFX_WideStringC className; |
| 6874 pNode->GetClassName(className); | 6876 pNode->GetClassName(className); |
| 6875 wsName = FX_WSTRC(L"#") + className; | 6877 wsName = FX_WSTRC(L"#") + className; |
| 6876 } | 6878 } |
| 6877 wsSomExpression = wsName + wsSomExpression; | 6879 wsSomExpression = wsName + wsSomExpression; |
| 6878 dFlags = XFA_RESOLVENODE_Siblings; | 6880 dFlags = XFA_RESOLVENODE_Siblings; |
| 6879 } else { | 6881 } else { |
| 6880 dFlags = (bsSomExp == "*") | 6882 dFlags = (bsSomExp == "*") |
| 6881 ? (XFA_RESOLVENODE_Children) | 6883 ? (XFA_RESOLVENODE_Children) |
| 6882 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | | 6884 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | |
| 6883 XFA_RESOLVENODE_Properties); | 6885 XFA_RESOLVENODE_Properties); |
| 6884 } | 6886 } |
| 6885 } | 6887 } |
| 6886 } else { | 6888 } else { |
| 6887 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); | 6889 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); |
| 6888 dFlags = XFA_RESOLVENODE_AnyChild; | 6890 dFlags = XFA_RESOLVENODE_AnyChild; |
| 6889 } | 6891 } |
| 6890 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), | 6892 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), |
| 6891 resoveNodeRS, dFlags); | 6893 resoveNodeRS, dFlags); |
| 6892 return iRet; | 6894 return iRet; |
| 6893 } | 6895 } |
| 6894 void CXFA_FM2JSContext::ParseResolveResult( | 6896 void CXFA_FM2JSContext::ParseResolveResult( |
| 6895 FXJSE_HOBJECT hThis, | 6897 CFXJSE_Value* pThis, |
| 6896 const XFA_RESOLVENODE_RS& resoveNodeRS, | 6898 const XFA_RESOLVENODE_RS& resoveNodeRS, |
| 6897 FXJSE_HVALUE hParentValue, | 6899 CFXJSE_Value* pParentValue, |
| 6898 FXJSE_HVALUE*& resultValues, | 6900 CFXJSE_Value**& resultValues, |
| 6899 int32_t& iSize, | 6901 int32_t& iSize, |
| 6900 FX_BOOL& bAttribute) { | 6902 FX_BOOL& bAttribute) { |
| 6901 CXFA_FM2JSContext* pContext = | 6903 CXFA_FM2JSContext* pContext = |
| 6902 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6904 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6903 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6905 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6904 iSize = 0; | 6906 iSize = 0; |
| 6905 resultValues = NULL; | 6907 resultValues = NULL; |
| 6906 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6908 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 6907 bAttribute = FALSE; | 6909 bAttribute = FALSE; |
| 6908 iSize = resoveNodeRS.nodes.GetSize(); | 6910 iSize = resoveNodeRS.nodes.GetSize(); |
| 6909 resultValues = FX_Alloc(FXJSE_HVALUE, iSize); | 6911 resultValues = FX_Alloc(CFXJSE_Value*, iSize); |
| 6910 for (int32_t i = 0; i < iSize; i++) { | 6912 for (int32_t i = 0; i < iSize; i++) { |
| 6911 resultValues[i] = FXJSE_Value_Create(pIsolate); | 6913 resultValues[i] = FXJSE_Value_Create(pIsolate); |
| 6912 FXJSE_Value_Set( | 6914 FXJSE_Value_Set( |
| 6913 resultValues[i], | 6915 resultValues[i], |
| 6914 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( | 6916 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( |
| 6915 resoveNodeRS.nodes.GetAt(i))); | 6917 resoveNodeRS.nodes.GetAt(i))); |
| 6916 } | 6918 } |
| 6917 } else { | 6919 } else { |
| 6918 CXFA_HVALUEArray objectProperties(pIsolate); | 6920 CXFA_ValueArray objectProperties(pIsolate); |
| 6919 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); | 6921 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); |
| 6920 bAttribute = (iRet == 0); | 6922 bAttribute = (iRet == 0); |
| 6921 if (bAttribute) { | 6923 if (bAttribute) { |
| 6922 if (FXJSE_Value_IsObject(hParentValue)) { | 6924 if (FXJSE_Value_IsObject(pParentValue)) { |
| 6923 iSize = 1; | 6925 iSize = 1; |
| 6924 resultValues = FX_Alloc(FXJSE_HVALUE, 1); | 6926 resultValues = FX_Alloc(CFXJSE_Value*, 1); |
| 6925 resultValues[0] = FXJSE_Value_Create(pIsolate); | 6927 resultValues[0] = FXJSE_Value_Create(pIsolate); |
| 6926 FXJSE_Value_Set(resultValues[0], hParentValue); | 6928 FXJSE_Value_Set(resultValues[0], pParentValue); |
| 6927 } | 6929 } |
| 6928 } else { | 6930 } else { |
| 6929 iSize = iRet; | 6931 iSize = iRet; |
| 6930 resultValues = FX_Alloc(FXJSE_HVALUE, iSize); | 6932 resultValues = FX_Alloc(CFXJSE_Value*, iSize); |
| 6931 for (int32_t i = 0; i < iSize; i++) { | 6933 for (int32_t i = 0; i < iSize; i++) { |
| 6932 resultValues[i] = FXJSE_Value_Create(pIsolate); | 6934 resultValues[i] = FXJSE_Value_Create(pIsolate); |
| 6933 FXJSE_Value_Set(resultValues[i], objectProperties[i]); | 6935 FXJSE_Value_Set(resultValues[i], objectProperties[i]); |
| 6934 } | 6936 } |
| 6935 } | 6937 } |
| 6936 } | 6938 } |
| 6937 } | 6939 } |
| 6938 int32_t CXFA_FM2JSContext::HValueToInteger(FXJSE_HOBJECT hThis, | 6940 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, |
| 6939 FXJSE_HVALUE hValue) { | 6941 CFXJSE_Value* pValue) { |
| 6940 CXFA_FM2JSContext* pContext = | 6942 CXFA_FM2JSContext* pContext = |
| 6941 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6943 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6942 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6944 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6943 int32_t iValue = 0; | 6945 int32_t iValue = 0; |
| 6944 if (FXJSE_Value_IsArray(hValue)) { | 6946 if (FXJSE_Value_IsArray(pValue)) { |
| 6945 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6947 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6946 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 6948 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 6947 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 6949 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 6948 FXJSE_Value_GetObjectPropByIdx(hValue, 1, propertyValue); | 6950 FXJSE_Value_GetObjectPropByIdx(pValue, 1, propertyValue); |
| 6949 FXJSE_Value_GetObjectPropByIdx(hValue, 2, jsobjectValue); | 6951 FXJSE_Value_GetObjectPropByIdx(pValue, 2, jsobjectValue); |
| 6950 if (FXJSE_Value_IsNull(propertyValue)) { | 6952 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6951 GetObjectDefaultValue(jsobjectValue, newProperty); | 6953 GetObjectDefaultValue(jsobjectValue, newProperty); |
| 6952 } else { | 6954 } else { |
| 6953 CFX_ByteString propertyStr; | 6955 CFX_ByteString propertyStr; |
| 6954 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6956 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6955 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 6957 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 6956 newProperty); | 6958 newProperty); |
| 6957 } | 6959 } |
| 6958 iValue = HValueToInteger(hThis, newProperty); | 6960 iValue = ValueToInteger(pThis, newProperty); |
| 6959 FXJSE_Value_Release(newProperty); | 6961 FXJSE_Value_Release(newProperty); |
| 6960 FXJSE_Value_Release(jsobjectValue); | 6962 FXJSE_Value_Release(jsobjectValue); |
| 6961 FXJSE_Value_Release(propertyValue); | 6963 FXJSE_Value_Release(propertyValue); |
| 6962 return iValue; | 6964 return iValue; |
| 6963 } else if (FXJSE_Value_IsObject(hValue)) { | 6965 } else if (FXJSE_Value_IsObject(pValue)) { |
| 6964 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 6966 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 6965 GetObjectDefaultValue(hValue, newProperty); | 6967 GetObjectDefaultValue(pValue, newProperty); |
| 6966 iValue = HValueToInteger(hThis, newProperty); | 6968 iValue = ValueToInteger(pThis, newProperty); |
| 6967 FXJSE_Value_Release(newProperty); | 6969 FXJSE_Value_Release(newProperty); |
| 6968 return iValue; | 6970 return iValue; |
| 6969 } else if (FXJSE_Value_IsUTF8String(hValue)) { | 6971 } else if (FXJSE_Value_IsUTF8String(pValue)) { |
| 6970 CFX_ByteString szValue; | 6972 CFX_ByteString szValue; |
| 6971 FXJSE_Value_ToUTF8String(hValue, szValue); | 6973 FXJSE_Value_ToUTF8String(pValue, szValue); |
| 6972 iValue = FXSYS_atoi(szValue.c_str()); | 6974 iValue = FXSYS_atoi(szValue.c_str()); |
| 6973 } else { | 6975 } else { |
| 6974 iValue = FXJSE_Value_ToInteger(hValue); | 6976 iValue = FXJSE_Value_ToInteger(pValue); |
| 6975 } | 6977 } |
| 6976 return iValue; | 6978 return iValue; |
| 6977 } | 6979 } |
| 6978 FX_DOUBLE CXFA_FM2JSContext::StringToDouble( | 6980 FX_DOUBLE CXFA_FM2JSContext::StringToDouble( |
| 6979 const CFX_ByteStringC& szStringVal) { | 6981 const CFX_ByteStringC& szStringVal) { |
| 6980 return XFA_ByteStringToDouble(szStringVal); | 6982 return XFA_ByteStringToDouble(szStringVal); |
| 6981 } | 6983 } |
| 6982 FX_FLOAT CXFA_FM2JSContext::HValueToFloat(FXJSE_HOBJECT hThis, | 6984 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, |
| 6983 FXJSE_HVALUE arg) { | 6985 CFXJSE_Value* arg) { |
| 6984 CXFA_FM2JSContext* pContext = | 6986 CXFA_FM2JSContext* pContext = |
| 6985 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6987 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6986 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6988 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6987 FX_FLOAT fRet = 0.0f; | 6989 FX_FLOAT fRet = 0.0f; |
| 6988 if (FXJSE_Value_IsArray(arg)) { | 6990 if (FXJSE_Value_IsArray(arg)) { |
| 6989 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6991 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6990 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 6992 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 6991 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 6993 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 6992 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); | 6994 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); |
| 6993 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); | 6995 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); |
| 6994 if (FXJSE_Value_IsNull(propertyValue)) { | 6996 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6995 GetObjectDefaultValue(jsobjectValue, newProperty); | 6997 GetObjectDefaultValue(jsobjectValue, newProperty); |
| 6996 } else { | 6998 } else { |
| 6997 CFX_ByteString propertyStr; | 6999 CFX_ByteString propertyStr; |
| 6998 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 7000 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6999 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 7001 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 7000 newProperty); | 7002 newProperty); |
| 7001 } | 7003 } |
| 7002 fRet = HValueToFloat(hThis, newProperty); | 7004 fRet = ValueToFloat(pThis, newProperty); |
| 7003 FXJSE_Value_Release(newProperty); | 7005 FXJSE_Value_Release(newProperty); |
| 7004 FXJSE_Value_Release(jsobjectValue); | 7006 FXJSE_Value_Release(jsobjectValue); |
| 7005 FXJSE_Value_Release(propertyValue); | 7007 FXJSE_Value_Release(propertyValue); |
| 7006 } else if (FXJSE_Value_IsObject(arg)) { | 7008 } else if (FXJSE_Value_IsObject(arg)) { |
| 7007 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 7009 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 7008 GetObjectDefaultValue(arg, newProperty); | 7010 GetObjectDefaultValue(arg, newProperty); |
| 7009 fRet = HValueToFloat(hThis, newProperty); | 7011 fRet = ValueToFloat(pThis, newProperty); |
| 7010 FXJSE_Value_Release(newProperty); | 7012 FXJSE_Value_Release(newProperty); |
| 7011 } else if (FXJSE_Value_IsUTF8String(arg)) { | 7013 } else if (FXJSE_Value_IsUTF8String(arg)) { |
| 7012 CFX_ByteString bsOutput; | 7014 CFX_ByteString bsOutput; |
| 7013 FXJSE_Value_ToUTF8String(arg, bsOutput); | 7015 FXJSE_Value_ToUTF8String(arg, bsOutput); |
| 7014 fRet = (FX_FLOAT)StringToDouble(bsOutput.AsStringC()); | 7016 fRet = (FX_FLOAT)StringToDouble(bsOutput.AsStringC()); |
| 7015 } else if (FXJSE_Value_IsUndefined(arg)) { | 7017 } else if (FXJSE_Value_IsUndefined(arg)) { |
| 7016 fRet = 0; | 7018 fRet = 0; |
| 7017 } else { | 7019 } else { |
| 7018 fRet = FXJSE_Value_ToFloat(arg); | 7020 fRet = FXJSE_Value_ToFloat(arg); |
| 7019 } | 7021 } |
| 7020 return fRet; | 7022 return fRet; |
| 7021 } | 7023 } |
| 7022 FX_DOUBLE CXFA_FM2JSContext::HValueToDouble(FXJSE_HOBJECT hThis, | 7024 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, |
| 7023 FXJSE_HVALUE arg) { | 7025 CFXJSE_Value* arg) { |
| 7024 CXFA_FM2JSContext* pContext = | 7026 CXFA_FM2JSContext* pContext = |
| 7025 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 7027 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 7026 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 7028 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 7027 FX_DOUBLE dRet = 0; | 7029 FX_DOUBLE dRet = 0; |
| 7028 if (FXJSE_Value_IsArray(arg)) { | 7030 if (FXJSE_Value_IsArray(arg)) { |
| 7029 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 7031 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 7030 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 7032 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 7031 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 7033 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 7032 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); | 7034 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); |
| 7033 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); | 7035 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); |
| 7034 if (FXJSE_Value_IsNull(propertyValue)) { | 7036 if (FXJSE_Value_IsNull(propertyValue)) { |
| 7035 GetObjectDefaultValue(jsobjectValue, newProperty); | 7037 GetObjectDefaultValue(jsobjectValue, newProperty); |
| 7036 } else { | 7038 } else { |
| 7037 CFX_ByteString propertyStr; | 7039 CFX_ByteString propertyStr; |
| 7038 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 7040 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 7039 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 7041 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 7040 newProperty); | 7042 newProperty); |
| 7041 } | 7043 } |
| 7042 dRet = HValueToDouble(hThis, newProperty); | 7044 dRet = ValueToDouble(pThis, newProperty); |
| 7043 FXJSE_Value_Release(newProperty); | 7045 FXJSE_Value_Release(newProperty); |
| 7044 FXJSE_Value_Release(jsobjectValue); | 7046 FXJSE_Value_Release(jsobjectValue); |
| 7045 FXJSE_Value_Release(propertyValue); | 7047 FXJSE_Value_Release(propertyValue); |
| 7046 } else if (FXJSE_Value_IsObject(arg)) { | 7048 } else if (FXJSE_Value_IsObject(arg)) { |
| 7047 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 7049 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 7048 GetObjectDefaultValue(arg, newProperty); | 7050 GetObjectDefaultValue(arg, newProperty); |
| 7049 dRet = HValueToDouble(hThis, newProperty); | 7051 dRet = ValueToDouble(pThis, newProperty); |
| 7050 FXJSE_Value_Release(newProperty); | 7052 FXJSE_Value_Release(newProperty); |
| 7051 } else if (FXJSE_Value_IsUTF8String(arg)) { | 7053 } else if (FXJSE_Value_IsUTF8String(arg)) { |
| 7052 CFX_ByteString bsOutput; | 7054 CFX_ByteString bsOutput; |
| 7053 FXJSE_Value_ToUTF8String(arg, bsOutput); | 7055 FXJSE_Value_ToUTF8String(arg, bsOutput); |
| 7054 dRet = StringToDouble(bsOutput.AsStringC()); | 7056 dRet = StringToDouble(bsOutput.AsStringC()); |
| 7055 } else if (FXJSE_Value_IsUndefined(arg)) { | 7057 } else if (FXJSE_Value_IsUndefined(arg)) { |
| 7056 dRet = 0; | 7058 dRet = 0; |
| 7057 } else { | 7059 } else { |
| 7058 dRet = FXJSE_Value_ToDouble(arg); | 7060 dRet = FXJSE_Value_ToDouble(arg); |
| 7059 } | 7061 } |
| 7060 return dRet; | 7062 return dRet; |
| 7061 } | 7063 } |
| 7062 void CXFA_FM2JSContext::HValueToUTF8String(FXJSE_HVALUE arg, | 7064 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, |
| 7063 CFX_ByteString& szOutputString) { | 7065 CFX_ByteString& szOutputString) { |
| 7064 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { | 7066 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { |
| 7065 szOutputString = ""; | 7067 szOutputString = ""; |
| 7066 } else if (FXJSE_Value_IsBoolean(arg)) { | 7068 } else if (FXJSE_Value_IsBoolean(arg)) { |
| 7067 szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; | 7069 szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; |
| 7068 } else { | 7070 } else { |
| 7069 szOutputString = ""; | 7071 szOutputString = ""; |
| 7070 FXJSE_Value_ToUTF8String(arg, szOutputString); | 7072 FXJSE_Value_ToUTF8String(arg, szOutputString); |
| 7071 } | 7073 } |
| 7072 } | 7074 } |
| 7073 static FXJSE_FUNCTION formcalc_fm2js_functions[] = { | 7075 static FXJSE_FUNCTION formcalc_fm2js_functions[] = { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7160 {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, | 7162 {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, |
| 7161 {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, | 7163 {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, |
| 7162 {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, | 7164 {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, |
| 7163 {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, | 7165 {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, |
| 7164 {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, | 7166 {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, |
| 7165 }; | 7167 }; |
| 7166 CXFA_FM2JSContext::CXFA_FM2JSContext() | 7168 CXFA_FM2JSContext::CXFA_FM2JSContext() |
| 7167 : m_pFMClass(nullptr), m_pDocument(nullptr) { | 7169 : m_pFMClass(nullptr), m_pDocument(nullptr) { |
| 7168 FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); | 7170 FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); |
| 7169 } | 7171 } |
| 7172 |
| 7170 CXFA_FM2JSContext::~CXFA_FM2JSContext() { | 7173 CXFA_FM2JSContext::~CXFA_FM2JSContext() { |
| 7171 m_pDocument = NULL; | 7174 if (m_pValue) |
| 7172 if (m_hValue) { | 7175 FXJSE_Value_Release(m_pValue); |
| 7173 FXJSE_Value_Release(m_hValue); | |
| 7174 m_hValue = NULL; | |
| 7175 } | |
| 7176 m_pIsolate = NULL; | |
| 7177 } | 7176 } |
| 7177 |
| 7178 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, | 7178 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, |
| 7179 CFXJSE_Context* pScriptContext, | 7179 CFXJSE_Context* pScriptContext, |
| 7180 CXFA_Document* pDoc) { | 7180 CXFA_Document* pDoc) { |
| 7181 m_pDocument = pDoc; | 7181 m_pDocument = pDoc; |
| 7182 m_pIsolate = pScriptIsolate; | 7182 m_pIsolate = pScriptIsolate; |
| 7183 m_fmClass.name = "XFA_FM2JS_FormCalcClass"; | 7183 m_fmClass.name = "XFA_FM2JS_FormCalcClass"; |
| 7184 m_fmClass.constructor = NULL; | 7184 m_fmClass.constructor = NULL; |
| 7185 m_fmClass.properties = NULL; | 7185 m_fmClass.properties = NULL; |
| 7186 m_fmClass.methods = formcalc_fm2js_functions; | 7186 m_fmClass.methods = formcalc_fm2js_functions; |
| 7187 m_fmClass.propNum = 0; | 7187 m_fmClass.propNum = 0; |
| 7188 m_fmClass.methNum = | 7188 m_fmClass.methNum = |
| 7189 sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); | 7189 sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); |
| 7190 m_pFMClass = FXJSE_DefineClass(pScriptContext, &m_fmClass); | 7190 m_pFMClass = FXJSE_DefineClass(pScriptContext, &m_fmClass); |
| 7191 m_hValue = FXJSE_Value_Create(pScriptIsolate); | 7191 m_pValue = FXJSE_Value_Create(pScriptIsolate); |
| 7192 FXJSE_Value_SetNull(m_hValue); | 7192 FXJSE_Value_SetNull(m_pValue); |
| 7193 FXJSE_Value_SetObject(m_hValue, this, m_pFMClass); | 7193 FXJSE_Value_SetObject(m_pValue, this, m_pFMClass); |
| 7194 } | 7194 } |
| 7195 void CXFA_FM2JSContext::GlobalPropertyGetter(FXJSE_HVALUE hValue) { | 7195 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { |
| 7196 FXJSE_Value_Set(hValue, m_hValue); | 7196 FXJSE_Value_Set(pValue, m_pValue); |
| 7197 } | 7197 } |
| 7198 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { | 7198 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { |
| 7199 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 7199 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
| 7200 ASSERT(pAppProvider); | 7200 ASSERT(pAppProvider); |
| 7201 CFX_WideString wsFormat; | 7201 CFX_WideString wsFormat; |
| 7202 pAppProvider->LoadString(iStringID, wsFormat); | 7202 pAppProvider->LoadString(iStringID, wsFormat); |
| 7203 CFX_WideString wsMessage; | 7203 CFX_WideString wsMessage; |
| 7204 va_list arg_ptr; | 7204 va_list arg_ptr; |
| 7205 va_start(arg_ptr, iStringID); | 7205 va_start(arg_ptr, iStringID); |
| 7206 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7206 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 7207 va_end(arg_ptr); | 7207 va_end(arg_ptr); |
| 7208 FXJSE_ThrowMessage( | 7208 FXJSE_ThrowMessage( |
| 7209 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7209 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 7210 } | 7210 } |
| OLD | NEW |