| 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); | 318 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 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 = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 326 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 327 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 327 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 328 int32_t argc = args.GetLength(); | 328 int32_t argc = args.GetLength(); |
| 329 uint32_t uCount = 0; | 329 uint32_t uCount = 0; |
| 330 FX_DOUBLE dSum = 0.0; | 330 FX_DOUBLE dSum = 0.0; |
| 331 if (argc >= 1) { | 331 if (argc >= 1) { |
| 332 FXJSE_HVALUE argValue = 0; | 332 CFXJSE_Value* argValue = nullptr; |
| 333 for (int32_t i = 0; i < argc; i++) { | 333 for (int32_t i = 0; i < argc; i++) { |
| 334 argValue = args.GetValue(i); | 334 argValue = args.GetValue(i); |
| 335 if (FXJSE_Value_IsNull(argValue)) { | 335 if (FXJSE_Value_IsNull(argValue)) { |
| 336 FXJSE_Value_Release(argValue); | 336 FXJSE_Value_Release(argValue); |
| 337 continue; | 337 continue; |
| 338 } else if (FXJSE_Value_IsArray(argValue)) { | 338 } else if (FXJSE_Value_IsArray(argValue)) { |
| 339 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 339 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 340 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 340 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 341 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 341 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 342 FXJSE_Value_Release(lengthValue); | 342 FXJSE_Value_Release(lengthValue); |
| 343 if (iLength > 2) { | 343 if (iLength > 2) { |
| 344 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 344 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 345 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 345 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 346 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 346 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 347 if (FXJSE_Value_IsNull(propertyValue)) { | 347 if (FXJSE_Value_IsNull(propertyValue)) { |
| 348 for (int32_t j = 2; j < iLength; j++) { | 348 for (int32_t j = 2; j < iLength; j++) { |
| 349 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); | 349 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); |
| 350 FXJSE_HVALUE defaultPropValue = FXJSE_Value_Create(pIsolate); | 350 CFXJSE_Value* defaultPropValue = FXJSE_Value_Create(pIsolate); |
| 351 GetObjectDefaultValue(jsObjectValue, defaultPropValue); | 351 GetObjectDefaultValue(jsObjectValue, defaultPropValue); |
| 352 if (!FXJSE_Value_IsNull(defaultPropValue)) { | 352 if (!FXJSE_Value_IsNull(defaultPropValue)) { |
| 353 dSum += HValueToDouble(hThis, defaultPropValue); | 353 dSum += ValueToDouble(pThis, defaultPropValue); |
| 354 uCount++; | 354 uCount++; |
| 355 } | 355 } |
| 356 FXJSE_Value_Release(defaultPropValue); | 356 FXJSE_Value_Release(defaultPropValue); |
| 357 } | 357 } |
| 358 } else { | 358 } else { |
| 359 CFX_ByteString propertyStr; | 359 CFX_ByteString propertyStr; |
| 360 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 360 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 361 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 361 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 362 for (int32_t j = 2; j < iLength; j++) { | 362 for (int32_t j = 2; j < iLength; j++) { |
| 363 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); | 363 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); |
| 364 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 364 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 365 newPropertyValue); | 365 newPropertyValue); |
| 366 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 366 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 367 dSum += HValueToDouble(hThis, newPropertyValue); | 367 dSum += ValueToDouble(pThis, newPropertyValue); |
| 368 uCount++; | 368 uCount++; |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 FXJSE_Value_Release(newPropertyValue); | 371 FXJSE_Value_Release(newPropertyValue); |
| 372 } | 372 } |
| 373 FXJSE_Value_Release(jsObjectValue); | 373 FXJSE_Value_Release(jsObjectValue); |
| 374 FXJSE_Value_Release(propertyValue); | 374 FXJSE_Value_Release(propertyValue); |
| 375 } | 375 } |
| 376 } else { | 376 } else { |
| 377 dSum += HValueToDouble(hThis, argValue); | 377 dSum += ValueToDouble(pThis, argValue); |
| 378 uCount++; | 378 uCount++; |
| 379 } | 379 } |
| 380 FXJSE_Value_Release(argValue); | 380 FXJSE_Value_Release(argValue); |
| 381 } | 381 } |
| 382 argValue = 0; | 382 argValue = nullptr; |
| 383 } | 383 } |
| 384 if (0 == uCount) { | 384 if (0 == uCount) { |
| 385 FXJSE_Value_SetNull(args.GetReturnValue()); | 385 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 386 } else { | 386 } else { |
| 387 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); | 387 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 void CXFA_FM2JSContext::Ceil(FXJSE_HOBJECT hThis, | 390 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, |
| 391 const CFX_ByteStringC& szFuncName, | 391 const CFX_ByteStringC& szFuncName, |
| 392 CFXJSE_Arguments& args) { | 392 CFXJSE_Arguments& args) { |
| 393 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 393 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 394 if (args.GetLength() == 1) { | 394 if (args.GetLength() == 1) { |
| 395 FXJSE_HVALUE argValue = GetSimpleHValue(hThis, args, 0); | 395 CFXJSE_Value* argValue = GetSimpleValue(pThis, args, 0); |
| 396 if (HValueIsNull(hThis, argValue)) { | 396 if (ValueIsNull(pThis, argValue)) { |
| 397 FXJSE_Value_SetNull(args.GetReturnValue()); | 397 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 398 } else { | 398 } else { |
| 399 FXJSE_Value_SetFloat(args.GetReturnValue(), | 399 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 400 FXSYS_ceil(HValueToFloat(hThis, argValue))); | 400 FXSYS_ceil(ValueToFloat(pThis, argValue))); |
| 401 } | 401 } |
| 402 FXJSE_Value_Release(argValue); | 402 FXJSE_Value_Release(argValue); |
| 403 } else { | 403 } else { |
| 404 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 404 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 405 L"Ceil"); | 405 L"Ceil"); |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 void CXFA_FM2JSContext::Count(FXJSE_HOBJECT hThis, | 408 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, |
| 409 const CFX_ByteStringC& szFuncName, | 409 const CFX_ByteStringC& szFuncName, |
| 410 CFXJSE_Arguments& args) { | 410 CFXJSE_Arguments& args) { |
| 411 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 411 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 412 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 412 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 413 int32_t argc = args.GetLength(); | 413 int32_t argc = args.GetLength(); |
| 414 uint32_t uCount = 0; | 414 uint32_t uCount = 0; |
| 415 FXJSE_HVALUE argValue = 0; | 415 CFXJSE_Value* argValue = nullptr; |
| 416 for (int32_t i = 0; i < argc; i++) { | 416 for (int32_t i = 0; i < argc; i++) { |
| 417 argValue = args.GetValue(i); | 417 argValue = args.GetValue(i); |
| 418 if (FXJSE_Value_IsNull(argValue)) { | 418 if (FXJSE_Value_IsNull(argValue)) { |
| 419 FXJSE_Value_Release(argValue); | 419 FXJSE_Value_Release(argValue); |
| 420 continue; | 420 continue; |
| 421 } else if (FXJSE_Value_IsArray(argValue)) { | 421 } else if (FXJSE_Value_IsArray(argValue)) { |
| 422 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 422 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 423 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 423 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 424 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 424 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 425 FXJSE_Value_Release(lengthValue); | 425 FXJSE_Value_Release(lengthValue); |
| 426 if (iLength > 2) { | 426 if (iLength > 2) { |
| 427 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 427 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 428 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 428 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 429 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 429 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 430 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 430 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 431 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); | 431 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); |
| 432 if (FXJSE_Value_IsNull(propertyValue)) { | 432 if (FXJSE_Value_IsNull(propertyValue)) { |
| 433 for (int32_t i = 2; i < iLength; i++) { | 433 for (int32_t i = 2; i < iLength; i++) { |
| 434 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 434 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 435 GetObjectDefaultValue(jsObjectValue, newPropertyValue); | 435 GetObjectDefaultValue(jsObjectValue, newPropertyValue); |
| 436 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 436 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 437 uCount++; | 437 uCount++; |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 } else { | 440 } else { |
| 441 CFX_ByteString propertyStr; | 441 CFX_ByteString propertyStr; |
| 442 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 442 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 443 for (int32_t i = 2; i < iLength; i++) { | 443 for (int32_t i = 2; i < iLength; i++) { |
| 444 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 444 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 445 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 445 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 446 newPropertyValue); | 446 newPropertyValue); |
| 447 uCount += (FXJSE_Value_IsNull(newPropertyValue) ? 0 : 1); | 447 uCount += (FXJSE_Value_IsNull(newPropertyValue) ? 0 : 1); |
| 448 } | 448 } |
| 449 } | 449 } |
| 450 FXJSE_Value_Release(propertyValue); | 450 FXJSE_Value_Release(propertyValue); |
| 451 FXJSE_Value_Release(jsObjectValue); | 451 FXJSE_Value_Release(jsObjectValue); |
| 452 FXJSE_Value_Release(newPropertyValue); | 452 FXJSE_Value_Release(newPropertyValue); |
| 453 } else { | 453 } else { |
| 454 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 454 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 455 } | 455 } |
| 456 } else if (FXJSE_Value_IsObject(argValue)) { | 456 } else if (FXJSE_Value_IsObject(argValue)) { |
| 457 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 457 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 458 GetObjectDefaultValue(argValue, newPropertyValue); | 458 GetObjectDefaultValue(argValue, newPropertyValue); |
| 459 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 459 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 460 uCount++; | 460 uCount++; |
| 461 } | 461 } |
| 462 FXJSE_Value_Release(newPropertyValue); | 462 FXJSE_Value_Release(newPropertyValue); |
| 463 } else { | 463 } else { |
| 464 uCount++; | 464 uCount++; |
| 465 } | 465 } |
| 466 FXJSE_Value_Release(argValue); | 466 FXJSE_Value_Release(argValue); |
| 467 } | 467 } |
| 468 argValue = 0; | 468 argValue = nullptr; |
| 469 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)uCount); | 469 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)uCount); |
| 470 } | 470 } |
| 471 void CXFA_FM2JSContext::Floor(FXJSE_HOBJECT hThis, | 471 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, |
| 472 const CFX_ByteStringC& szFuncName, | 472 const CFX_ByteStringC& szFuncName, |
| 473 CFXJSE_Arguments& args) { | 473 CFXJSE_Arguments& args) { |
| 474 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 474 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 475 if (args.GetLength() == 1) { | 475 if (args.GetLength() == 1) { |
| 476 FXJSE_HVALUE argValue = GetSimpleHValue(hThis, args, 0); | 476 CFXJSE_Value* argValue = GetSimpleValue(pThis, args, 0); |
| 477 if (HValueIsNull(hThis, argValue)) { | 477 if (ValueIsNull(pThis, argValue)) { |
| 478 FXJSE_Value_SetNull(args.GetReturnValue()); | 478 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 479 } else { | 479 } else { |
| 480 FXJSE_Value_SetFloat(args.GetReturnValue(), | 480 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 481 FXSYS_floor(HValueToFloat(hThis, argValue))); | 481 FXSYS_floor(ValueToFloat(pThis, argValue))); |
| 482 } | 482 } |
| 483 FXJSE_Value_Release(argValue); | 483 FXJSE_Value_Release(argValue); |
| 484 } else { | 484 } else { |
| 485 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 485 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 486 L"Floor"); | 486 L"Floor"); |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 void CXFA_FM2JSContext::Max(FXJSE_HOBJECT hThis, | 489 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, |
| 490 const CFX_ByteStringC& szFuncName, | 490 const CFX_ByteStringC& szFuncName, |
| 491 CFXJSE_Arguments& args) { | 491 CFXJSE_Arguments& args) { |
| 492 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 492 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 493 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 493 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 494 int32_t argc = args.GetLength(); | 494 int32_t argc = args.GetLength(); |
| 495 uint32_t uCount = 0; | 495 uint32_t uCount = 0; |
| 496 FX_DOUBLE dMaxValue = 0.0; | 496 FX_DOUBLE dMaxValue = 0.0; |
| 497 FXJSE_HVALUE argValue = 0; | 497 CFXJSE_Value* argValue = nullptr; |
| 498 for (int32_t i = 0; i < argc; i++) { | 498 for (int32_t i = 0; i < argc; i++) { |
| 499 argValue = args.GetValue(i); | 499 argValue = args.GetValue(i); |
| 500 if (FXJSE_Value_IsNull(argValue)) { | 500 if (FXJSE_Value_IsNull(argValue)) { |
| 501 FXJSE_Value_Release(argValue); | 501 FXJSE_Value_Release(argValue); |
| 502 continue; | 502 continue; |
| 503 } else if (FXJSE_Value_IsArray(argValue)) { | 503 } else if (FXJSE_Value_IsArray(argValue)) { |
| 504 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 504 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 505 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 505 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 506 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 506 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 507 FXJSE_Value_Release(lengthValue); | 507 FXJSE_Value_Release(lengthValue); |
| 508 if (iLength > 2) { | 508 if (iLength > 2) { |
| 509 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 509 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 510 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 510 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 511 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 511 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 512 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 512 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 513 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); | 513 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); |
| 514 if (FXJSE_Value_IsNull(propertyValue)) { | 514 if (FXJSE_Value_IsNull(propertyValue)) { |
| 515 for (int32_t i = 2; i < iLength; i++) { | 515 for (int32_t i = 2; i < iLength; i++) { |
| 516 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 516 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 517 GetObjectDefaultValue(jsObjectValue, newPropertyValue); | 517 GetObjectDefaultValue(jsObjectValue, newPropertyValue); |
| 518 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 518 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 519 uCount++; | 519 uCount++; |
| 520 if (uCount == 1) { | 520 if (uCount == 1) { |
| 521 dMaxValue = HValueToDouble(hThis, newPropertyValue); | 521 dMaxValue = ValueToDouble(pThis, newPropertyValue); |
| 522 } else { | 522 } else { |
| 523 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 523 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 524 if (dMaxValue < dValue) { | 524 if (dMaxValue < dValue) { |
| 525 dMaxValue = dValue; | 525 dMaxValue = dValue; |
| 526 } | 526 } |
| 527 } | 527 } |
| 528 } | 528 } |
| 529 } | 529 } |
| 530 } else { | 530 } else { |
| 531 CFX_ByteString propertyStr; | 531 CFX_ByteString propertyStr; |
| 532 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 532 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 533 for (int32_t i = 2; i < iLength; i++) { | 533 for (int32_t i = 2; i < iLength; i++) { |
| 534 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 534 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 535 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 535 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 536 newPropertyValue); | 536 newPropertyValue); |
| 537 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 537 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 538 uCount++; | 538 uCount++; |
| 539 if (uCount == 1) { | 539 if (uCount == 1) { |
| 540 dMaxValue = HValueToDouble(hThis, newPropertyValue); | 540 dMaxValue = ValueToDouble(pThis, newPropertyValue); |
| 541 } else { | 541 } else { |
| 542 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 542 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 543 if (dMaxValue < dValue) { | 543 if (dMaxValue < dValue) { |
| 544 dMaxValue = dValue; | 544 dMaxValue = dValue; |
| 545 } | 545 } |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 FXJSE_Value_Release(propertyValue); | 550 FXJSE_Value_Release(propertyValue); |
| 551 FXJSE_Value_Release(jsObjectValue); | 551 FXJSE_Value_Release(jsObjectValue); |
| 552 FXJSE_Value_Release(newPropertyValue); | 552 FXJSE_Value_Release(newPropertyValue); |
| 553 } else { | 553 } else { |
| 554 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 554 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 555 } | 555 } |
| 556 } else if (FXJSE_Value_IsObject(argValue)) { | 556 } else if (FXJSE_Value_IsObject(argValue)) { |
| 557 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 557 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 558 GetObjectDefaultValue(argValue, newPropertyValue); | 558 GetObjectDefaultValue(argValue, newPropertyValue); |
| 559 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 559 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 560 uCount++; | 560 uCount++; |
| 561 if (uCount == 1) { | 561 if (uCount == 1) { |
| 562 dMaxValue = HValueToDouble(hThis, newPropertyValue); | 562 dMaxValue = ValueToDouble(pThis, newPropertyValue); |
| 563 } else { | 563 } else { |
| 564 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 564 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 565 if (dMaxValue < dValue) { | 565 if (dMaxValue < dValue) { |
| 566 dMaxValue = dValue; | 566 dMaxValue = dValue; |
| 567 } | 567 } |
| 568 } | 568 } |
| 569 } | 569 } |
| 570 FXJSE_Value_Release(newPropertyValue); | 570 FXJSE_Value_Release(newPropertyValue); |
| 571 } else { | 571 } else { |
| 572 uCount++; | 572 uCount++; |
| 573 if (uCount == 1) { | 573 if (uCount == 1) { |
| 574 dMaxValue = HValueToDouble(hThis, argValue); | 574 dMaxValue = ValueToDouble(pThis, argValue); |
| 575 } else { | 575 } else { |
| 576 FX_DOUBLE dValue = HValueToDouble(hThis, argValue); | 576 FX_DOUBLE dValue = ValueToDouble(pThis, argValue); |
| 577 if (dMaxValue < dValue) { | 577 if (dMaxValue < dValue) { |
| 578 dMaxValue = dValue; | 578 dMaxValue = dValue; |
| 579 } | 579 } |
| 580 } | 580 } |
| 581 } | 581 } |
| 582 FXJSE_Value_Release(argValue); | 582 FXJSE_Value_Release(argValue); |
| 583 } | 583 } |
| 584 argValue = 0; | 584 argValue = nullptr; |
| 585 if (uCount) { | 585 if (uCount) { |
| 586 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); | 586 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); |
| 587 } else { | 587 } else { |
| 588 FXJSE_Value_SetNull(args.GetReturnValue()); | 588 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 589 } | 589 } |
| 590 } | 590 } |
| 591 void CXFA_FM2JSContext::Min(FXJSE_HOBJECT hThis, | 591 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, |
| 592 const CFX_ByteStringC& szFuncName, | 592 const CFX_ByteStringC& szFuncName, |
| 593 CFXJSE_Arguments& args) { | 593 CFXJSE_Arguments& args) { |
| 594 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 594 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 595 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 595 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 596 int32_t argc = args.GetLength(); | 596 int32_t argc = args.GetLength(); |
| 597 uint32_t uCount = 0; | 597 uint32_t uCount = 0; |
| 598 FX_DOUBLE dMinValue = 0.0; | 598 FX_DOUBLE dMinValue = 0.0; |
| 599 FXJSE_HVALUE argValue = 0; | 599 CFXJSE_Value* argValue = nullptr; |
| 600 for (int32_t i = 0; i < argc; i++) { | 600 for (int32_t i = 0; i < argc; i++) { |
| 601 argValue = args.GetValue(i); | 601 argValue = args.GetValue(i); |
| 602 if (FXJSE_Value_IsNull(argValue)) { | 602 if (FXJSE_Value_IsNull(argValue)) { |
| 603 FXJSE_Value_Release(argValue); | 603 FXJSE_Value_Release(argValue); |
| 604 continue; | 604 continue; |
| 605 } else if (FXJSE_Value_IsArray(argValue)) { | 605 } else if (FXJSE_Value_IsArray(argValue)) { |
| 606 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 606 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 607 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 607 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 608 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 608 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 609 FXJSE_Value_Release(lengthValue); | 609 FXJSE_Value_Release(lengthValue); |
| 610 if (iLength > 2) { | 610 if (iLength > 2) { |
| 611 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 611 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 612 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 612 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 613 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 613 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 614 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 614 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 615 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); | 615 FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); |
| 616 if (FXJSE_Value_IsNull(propertyValue)) { | 616 if (FXJSE_Value_IsNull(propertyValue)) { |
| 617 for (int32_t i = 2; i < iLength; i++) { | 617 for (int32_t i = 2; i < iLength; i++) { |
| 618 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 618 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 619 GetObjectDefaultValue(jsObjectValue, newPropertyValue); | 619 GetObjectDefaultValue(jsObjectValue, newPropertyValue); |
| 620 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 620 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 621 uCount++; | 621 uCount++; |
| 622 if (uCount == 1) { | 622 if (uCount == 1) { |
| 623 dMinValue = HValueToDouble(hThis, newPropertyValue); | 623 dMinValue = ValueToDouble(pThis, newPropertyValue); |
| 624 } else { | 624 } else { |
| 625 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 625 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 626 if (dMinValue > dValue) { | 626 if (dMinValue > dValue) { |
| 627 dMinValue = dValue; | 627 dMinValue = dValue; |
| 628 } | 628 } |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 } else { | 632 } else { |
| 633 CFX_ByteString propertyStr; | 633 CFX_ByteString propertyStr; |
| 634 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 634 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 635 for (int32_t i = 2; i < iLength; i++) { | 635 for (int32_t i = 2; i < iLength; i++) { |
| 636 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); | 636 FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); |
| 637 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 637 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 638 newPropertyValue); | 638 newPropertyValue); |
| 639 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 639 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 640 uCount++; | 640 uCount++; |
| 641 if (uCount == 1) { | 641 if (uCount == 1) { |
| 642 dMinValue = HValueToDouble(hThis, newPropertyValue); | 642 dMinValue = ValueToDouble(pThis, newPropertyValue); |
| 643 } else { | 643 } else { |
| 644 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 644 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 645 if (dMinValue > dValue) { | 645 if (dMinValue > dValue) { |
| 646 dMinValue = dValue; | 646 dMinValue = dValue; |
| 647 } | 647 } |
| 648 } | 648 } |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 } | 651 } |
| 652 FXJSE_Value_Release(propertyValue); | 652 FXJSE_Value_Release(propertyValue); |
| 653 FXJSE_Value_Release(jsObjectValue); | 653 FXJSE_Value_Release(jsObjectValue); |
| 654 FXJSE_Value_Release(newPropertyValue); | 654 FXJSE_Value_Release(newPropertyValue); |
| 655 } else { | 655 } else { |
| 656 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 656 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 657 } | 657 } |
| 658 } else if (FXJSE_Value_IsObject(argValue)) { | 658 } else if (FXJSE_Value_IsObject(argValue)) { |
| 659 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 659 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 660 GetObjectDefaultValue(argValue, newPropertyValue); | 660 GetObjectDefaultValue(argValue, newPropertyValue); |
| 661 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 661 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 662 uCount++; | 662 uCount++; |
| 663 if (uCount == 1) { | 663 if (uCount == 1) { |
| 664 dMinValue = HValueToDouble(hThis, newPropertyValue); | 664 dMinValue = ValueToDouble(pThis, newPropertyValue); |
| 665 } else { | 665 } else { |
| 666 FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); | 666 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue); |
| 667 if (dMinValue > dValue) { | 667 if (dMinValue > dValue) { |
| 668 dMinValue = dValue; | 668 dMinValue = dValue; |
| 669 } | 669 } |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 FXJSE_Value_Release(newPropertyValue); | 672 FXJSE_Value_Release(newPropertyValue); |
| 673 } else { | 673 } else { |
| 674 uCount++; | 674 uCount++; |
| 675 if (uCount == 1) { | 675 if (uCount == 1) { |
| 676 dMinValue = HValueToDouble(hThis, argValue); | 676 dMinValue = ValueToDouble(pThis, argValue); |
| 677 } else { | 677 } else { |
| 678 FX_DOUBLE dValue = HValueToDouble(hThis, argValue); | 678 FX_DOUBLE dValue = ValueToDouble(pThis, argValue); |
| 679 if (dMinValue > dValue) { | 679 if (dMinValue > dValue) { |
| 680 dMinValue = dValue; | 680 dMinValue = dValue; |
| 681 } | 681 } |
| 682 } | 682 } |
| 683 } | 683 } |
| 684 FXJSE_Value_Release(argValue); | 684 FXJSE_Value_Release(argValue); |
| 685 } | 685 } |
| 686 argValue = 0; | 686 argValue = nullptr; |
| 687 if (uCount) { | 687 if (uCount) { |
| 688 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); | 688 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); |
| 689 } else { | 689 } else { |
| 690 FXJSE_Value_SetNull(args.GetReturnValue()); | 690 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 691 } | 691 } |
| 692 } | 692 } |
| 693 void CXFA_FM2JSContext::Mod(FXJSE_HOBJECT hThis, | 693 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis, |
| 694 const CFX_ByteStringC& szFuncName, | 694 const CFX_ByteStringC& szFuncName, |
| 695 CFXJSE_Arguments& args) { | 695 CFXJSE_Arguments& args) { |
| 696 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 696 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 697 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 697 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 698 if (args.GetLength() == 2) { | 698 if (args.GetLength() == 2) { |
| 699 FXJSE_HVALUE argOne = args.GetValue(0); | 699 CFXJSE_Value* argOne = args.GetValue(0); |
| 700 FXJSE_HVALUE argTwo = args.GetValue(1); | 700 CFXJSE_Value* argTwo = args.GetValue(1); |
| 701 if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { | 701 if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { |
| 702 FXJSE_Value_SetNull(args.GetReturnValue()); | 702 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 703 } else { | 703 } else { |
| 704 FX_DOUBLE dDividend = 0.0; | 704 FX_DOUBLE dDividend = 0.0; |
| 705 FX_DOUBLE dDividor = 0.0; | 705 FX_DOUBLE dDividor = 0.0; |
| 706 if (FXJSE_Value_IsArray(argOne)) { | 706 if (FXJSE_Value_IsArray(argOne)) { |
| 707 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 707 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 708 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 708 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
| 709 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 709 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 710 FXJSE_Value_Release(lengthValue); | 710 FXJSE_Value_Release(lengthValue); |
| 711 if (iLength > 2) { | 711 if (iLength > 2) { |
| 712 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 712 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 713 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 713 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 714 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 714 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
| 715 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); | 715 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); |
| 716 if (FXJSE_Value_IsNull(propertyValue)) { | 716 if (FXJSE_Value_IsNull(propertyValue)) { |
| 717 dDividend = HValueToDouble(hThis, jsObjectValue); | 717 dDividend = ValueToDouble(pThis, jsObjectValue); |
| 718 } else { | 718 } else { |
| 719 CFX_ByteString propertyStr; | 719 CFX_ByteString propertyStr; |
| 720 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 720 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 721 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 721 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 722 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 722 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 723 newPropertyValue); | 723 newPropertyValue); |
| 724 dDividend = HValueToDouble(hThis, newPropertyValue); | 724 dDividend = ValueToDouble(pThis, newPropertyValue); |
| 725 FXJSE_Value_Release(newPropertyValue); | 725 FXJSE_Value_Release(newPropertyValue); |
| 726 } | 726 } |
| 727 FXJSE_Value_Release(propertyValue); | 727 FXJSE_Value_Release(propertyValue); |
| 728 FXJSE_Value_Release(jsObjectValue); | 728 FXJSE_Value_Release(jsObjectValue); |
| 729 } else { | 729 } else { |
| 730 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 730 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 731 } | 731 } |
| 732 } else { | 732 } else { |
| 733 dDividend = HValueToDouble(hThis, argOne); | 733 dDividend = ValueToDouble(pThis, argOne); |
| 734 } | 734 } |
| 735 if (FXJSE_Value_IsArray(argTwo)) { | 735 if (FXJSE_Value_IsArray(argTwo)) { |
| 736 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 736 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 737 FXJSE_Value_GetObjectProp(argTwo, "length", lengthValue); | 737 FXJSE_Value_GetObjectProp(argTwo, "length", lengthValue); |
| 738 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 738 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 739 FXJSE_Value_Release(lengthValue); | 739 FXJSE_Value_Release(lengthValue); |
| 740 if (iLength > 2) { | 740 if (iLength > 2) { |
| 741 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 741 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 742 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 742 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 743 FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); | 743 FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); |
| 744 FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); | 744 FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); |
| 745 if (FXJSE_Value_IsNull(propertyValue)) { | 745 if (FXJSE_Value_IsNull(propertyValue)) { |
| 746 dDividor = HValueToDouble(hThis, jsObjectValue); | 746 dDividor = ValueToDouble(pThis, jsObjectValue); |
| 747 } else { | 747 } else { |
| 748 CFX_ByteString propertyStr; | 748 CFX_ByteString propertyStr; |
| 749 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 749 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 750 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 750 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 751 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 751 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 752 newPropertyValue); | 752 newPropertyValue); |
| 753 dDividor = HValueToDouble(hThis, newPropertyValue); | 753 dDividor = ValueToDouble(pThis, newPropertyValue); |
| 754 FXJSE_Value_Release(newPropertyValue); | 754 FXJSE_Value_Release(newPropertyValue); |
| 755 } | 755 } |
| 756 FXJSE_Value_Release(propertyValue); | 756 FXJSE_Value_Release(propertyValue); |
| 757 FXJSE_Value_Release(jsObjectValue); | 757 FXJSE_Value_Release(jsObjectValue); |
| 758 } else { | 758 } else { |
| 759 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 759 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 760 } | 760 } |
| 761 } else { | 761 } else { |
| 762 dDividor = HValueToDouble(hThis, argTwo); | 762 dDividor = ValueToDouble(pThis, argTwo); |
| 763 } | 763 } |
| 764 if (dDividor) { | 764 if (dDividor) { |
| 765 FXJSE_Value_SetDouble( | 765 FXJSE_Value_SetDouble( |
| 766 args.GetReturnValue(), | 766 args.GetReturnValue(), |
| 767 dDividend - dDividor * (int32_t)(dDividend / dDividor)); | 767 dDividend - dDividor * (int32_t)(dDividend / dDividor)); |
| 768 } else { | 768 } else { |
| 769 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); | 769 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); |
| 770 } | 770 } |
| 771 } | 771 } |
| 772 FXJSE_Value_Release(argOne); | 772 FXJSE_Value_Release(argOne); |
| 773 FXJSE_Value_Release(argTwo); | 773 FXJSE_Value_Release(argTwo); |
| 774 } else { | 774 } else { |
| 775 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 775 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 776 L"Mod"); | 776 L"Mod"); |
| 777 } | 777 } |
| 778 } | 778 } |
| 779 void CXFA_FM2JSContext::Round(FXJSE_HOBJECT hThis, | 779 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis, |
| 780 const CFX_ByteStringC& szFuncName, | 780 const CFX_ByteStringC& szFuncName, |
| 781 CFXJSE_Arguments& args) { | 781 CFXJSE_Arguments& args) { |
| 782 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 782 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 783 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 783 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 784 int32_t argc = args.GetLength(); | 784 int32_t argc = args.GetLength(); |
| 785 uint8_t uPrecision = 0; | 785 uint8_t uPrecision = 0; |
| 786 if (argc == 1) { | 786 if (argc == 1) { |
| 787 FXJSE_HVALUE argOne = args.GetValue(0); | 787 CFXJSE_Value* argOne = args.GetValue(0); |
| 788 if (FXJSE_Value_IsNull(argOne)) { | 788 if (FXJSE_Value_IsNull(argOne)) { |
| 789 FXJSE_Value_SetNull(args.GetReturnValue()); | 789 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 790 } else { | 790 } else { |
| 791 FX_DOUBLE dValue = 0.0; | 791 FX_DOUBLE dValue = 0.0; |
| 792 if (FXJSE_Value_IsArray(argOne)) { | 792 if (FXJSE_Value_IsArray(argOne)) { |
| 793 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 793 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 794 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 794 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 795 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 795 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
| 796 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); | 796 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); |
| 797 if (FXJSE_Value_IsNull(propertyValue)) { | 797 if (FXJSE_Value_IsNull(propertyValue)) { |
| 798 dValue = HValueToDouble(hThis, jsObjectValue); | 798 dValue = ValueToDouble(pThis, jsObjectValue); |
| 799 } else { | 799 } else { |
| 800 CFX_ByteString propertyStr; | 800 CFX_ByteString propertyStr; |
| 801 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 801 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 802 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 802 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 803 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 803 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 804 newPropertyValue); | 804 newPropertyValue); |
| 805 dValue = HValueToDouble(hThis, newPropertyValue); | 805 dValue = ValueToDouble(pThis, newPropertyValue); |
| 806 FXJSE_Value_Release(newPropertyValue); | 806 FXJSE_Value_Release(newPropertyValue); |
| 807 } | 807 } |
| 808 FXJSE_Value_Release(propertyValue); | 808 FXJSE_Value_Release(propertyValue); |
| 809 FXJSE_Value_Release(jsObjectValue); | 809 FXJSE_Value_Release(jsObjectValue); |
| 810 } else { | 810 } else { |
| 811 dValue = HValueToDouble(hThis, argOne); | 811 dValue = ValueToDouble(pThis, argOne); |
| 812 } | 812 } |
| 813 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); | 813 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); |
| 814 CFX_WideString wsValue = decimalValue; | 814 CFX_WideString wsValue = decimalValue; |
| 815 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 815 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 816 wsValue.UTF8Encode().AsStringC()); | 816 wsValue.UTF8Encode().AsStringC()); |
| 817 } | 817 } |
| 818 FXJSE_Value_Release(argOne); | 818 FXJSE_Value_Release(argOne); |
| 819 } else if (argc == 2) { | 819 } else if (argc == 2) { |
| 820 FXJSE_HVALUE argOne = args.GetValue(0); | 820 CFXJSE_Value* argOne = args.GetValue(0); |
| 821 FXJSE_HVALUE argTwo = args.GetValue(1); | 821 CFXJSE_Value* argTwo = args.GetValue(1); |
| 822 if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { | 822 if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { |
| 823 FXJSE_Value_SetNull(args.GetReturnValue()); | 823 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 824 } else { | 824 } else { |
| 825 FX_DOUBLE dValue = 0.0; | 825 FX_DOUBLE dValue = 0.0; |
| 826 if (FXJSE_Value_IsArray(argOne)) { | 826 if (FXJSE_Value_IsArray(argOne)) { |
| 827 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 827 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 828 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 828 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 829 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 829 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
| 830 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); | 830 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); |
| 831 if (FXJSE_Value_IsNull(propertyValue)) { | 831 if (FXJSE_Value_IsNull(propertyValue)) { |
| 832 dValue = HValueToDouble(hThis, jsObjectValue); | 832 dValue = ValueToDouble(pThis, jsObjectValue); |
| 833 } else { | 833 } else { |
| 834 CFX_ByteString propertyStr; | 834 CFX_ByteString propertyStr; |
| 835 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 835 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 836 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 836 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 837 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 837 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 838 newPropertyValue); | 838 newPropertyValue); |
| 839 dValue = HValueToDouble(hThis, newPropertyValue); | 839 dValue = ValueToDouble(pThis, newPropertyValue); |
| 840 FXJSE_Value_Release(newPropertyValue); | 840 FXJSE_Value_Release(newPropertyValue); |
| 841 } | 841 } |
| 842 FXJSE_Value_Release(propertyValue); | 842 FXJSE_Value_Release(propertyValue); |
| 843 FXJSE_Value_Release(jsObjectValue); | 843 FXJSE_Value_Release(jsObjectValue); |
| 844 } else { | 844 } else { |
| 845 dValue = HValueToDouble(hThis, argOne); | 845 dValue = ValueToDouble(pThis, argOne); |
| 846 } | 846 } |
| 847 FX_DOUBLE dPrecision = 0.0; | 847 FX_DOUBLE dPrecision = 0.0; |
| 848 if (FXJSE_Value_IsArray(argTwo)) { | 848 if (FXJSE_Value_IsArray(argTwo)) { |
| 849 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 849 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 850 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 850 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 851 FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); | 851 FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); |
| 852 FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); | 852 FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); |
| 853 if (FXJSE_Value_IsNull(propertyValue)) { | 853 if (FXJSE_Value_IsNull(propertyValue)) { |
| 854 dPrecision = HValueToDouble(hThis, jsObjectValue); | 854 dPrecision = ValueToDouble(pThis, jsObjectValue); |
| 855 } else { | 855 } else { |
| 856 CFX_ByteString propertyStr; | 856 CFX_ByteString propertyStr; |
| 857 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 857 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 858 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 858 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 859 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 859 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 860 newPropertyValue); | 860 newPropertyValue); |
| 861 dPrecision = HValueToDouble(hThis, newPropertyValue); | 861 dPrecision = ValueToDouble(pThis, newPropertyValue); |
| 862 FXJSE_Value_Release(newPropertyValue); | 862 FXJSE_Value_Release(newPropertyValue); |
| 863 } | 863 } |
| 864 FXJSE_Value_Release(propertyValue); | 864 FXJSE_Value_Release(propertyValue); |
| 865 FXJSE_Value_Release(jsObjectValue); | 865 FXJSE_Value_Release(jsObjectValue); |
| 866 } else { | 866 } else { |
| 867 dPrecision = HValueToDouble(hThis, argTwo); | 867 dPrecision = ValueToDouble(pThis, argTwo); |
| 868 } | 868 } |
| 869 if (dPrecision < 0) { | 869 if (dPrecision < 0) { |
| 870 uPrecision = 0; | 870 uPrecision = 0; |
| 871 } else if (dPrecision > 12.0) { | 871 } else if (dPrecision > 12.0) { |
| 872 uPrecision = 12; | 872 uPrecision = 12; |
| 873 } else { | 873 } else { |
| 874 uPrecision = (uint8_t)dPrecision; | 874 uPrecision = (uint8_t)dPrecision; |
| 875 } | 875 } |
| 876 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); | 876 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); |
| 877 CFX_WideString wsValue = decimalValue; | 877 CFX_WideString wsValue = decimalValue; |
| 878 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 878 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 879 wsValue.UTF8Encode().AsStringC()); | 879 wsValue.UTF8Encode().AsStringC()); |
| 880 } | 880 } |
| 881 FXJSE_Value_Release(argOne); | 881 FXJSE_Value_Release(argOne); |
| 882 FXJSE_Value_Release(argTwo); | 882 FXJSE_Value_Release(argTwo); |
| 883 } else { | 883 } else { |
| 884 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 884 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 885 L"Round"); | 885 L"Round"); |
| 886 } | 886 } |
| 887 } | 887 } |
| 888 void CXFA_FM2JSContext::Sum(FXJSE_HOBJECT hThis, | 888 void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis, |
| 889 const CFX_ByteStringC& szFuncName, | 889 const CFX_ByteStringC& szFuncName, |
| 890 CFXJSE_Arguments& args) { | 890 CFXJSE_Arguments& args) { |
| 891 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 891 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 892 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 892 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 893 int32_t argc = args.GetLength(); | 893 int32_t argc = args.GetLength(); |
| 894 uint32_t uCount = 0; | 894 uint32_t uCount = 0; |
| 895 FX_DOUBLE dSum = 0.0; | 895 FX_DOUBLE dSum = 0.0; |
| 896 if (argc) { | 896 if (argc) { |
| 897 FXJSE_HVALUE argValue = 0; | 897 CFXJSE_Value* argValue = nullptr; |
| 898 for (int32_t i = 0; i < argc; i++) { | 898 for (int32_t i = 0; i < argc; i++) { |
| 899 argValue = args.GetValue(i); | 899 argValue = args.GetValue(i); |
| 900 if (FXJSE_Value_IsNull(argValue)) { | 900 if (FXJSE_Value_IsNull(argValue)) { |
| 901 FXJSE_Value_Release(argValue); | 901 FXJSE_Value_Release(argValue); |
| 902 continue; | 902 continue; |
| 903 } else if (FXJSE_Value_IsArray(argValue)) { | 903 } else if (FXJSE_Value_IsArray(argValue)) { |
| 904 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 904 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 905 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); | 905 FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); |
| 906 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 906 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 907 FXJSE_Value_Release(lengthValue); | 907 FXJSE_Value_Release(lengthValue); |
| 908 if (iLength > 2) { | 908 if (iLength > 2) { |
| 909 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 909 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 910 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); | 910 FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); |
| 911 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 911 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 912 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 912 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 913 if (FXJSE_Value_IsNull(propertyValue)) { | 913 if (FXJSE_Value_IsNull(propertyValue)) { |
| 914 for (int32_t j = 2; j < iLength; j++) { | 914 for (int32_t j = 2; j < iLength; j++) { |
| 915 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); | 915 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); |
| 916 GetObjectDefaultValue(jsObjectValue, newPropertyValue); | 916 GetObjectDefaultValue(jsObjectValue, newPropertyValue); |
| 917 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 917 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 918 dSum += HValueToDouble(hThis, jsObjectValue); | 918 dSum += ValueToDouble(pThis, jsObjectValue); |
| 919 uCount++; | 919 uCount++; |
| 920 } | 920 } |
| 921 } | 921 } |
| 922 } else { | 922 } else { |
| 923 CFX_ByteString propertyStr; | 923 CFX_ByteString propertyStr; |
| 924 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 924 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 925 for (int32_t j = 2; j < iLength; j++) { | 925 for (int32_t j = 2; j < iLength; j++) { |
| 926 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); | 926 FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); |
| 927 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 927 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 928 newPropertyValue); | 928 newPropertyValue); |
| 929 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 929 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 930 dSum += HValueToDouble(hThis, newPropertyValue); | 930 dSum += ValueToDouble(pThis, newPropertyValue); |
| 931 uCount++; | 931 uCount++; |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 } | 934 } |
| 935 FXJSE_Value_Release(newPropertyValue); | 935 FXJSE_Value_Release(newPropertyValue); |
| 936 FXJSE_Value_Release(jsObjectValue); | 936 FXJSE_Value_Release(jsObjectValue); |
| 937 FXJSE_Value_Release(propertyValue); | 937 FXJSE_Value_Release(propertyValue); |
| 938 } else { | 938 } else { |
| 939 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 939 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 940 } | 940 } |
| 941 } else if (FXJSE_Value_IsObject(argValue)) { | 941 } else if (FXJSE_Value_IsObject(argValue)) { |
| 942 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 942 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 943 GetObjectDefaultValue(argValue, newPropertyValue); | 943 GetObjectDefaultValue(argValue, newPropertyValue); |
| 944 if (!FXJSE_Value_IsNull(newPropertyValue)) { | 944 if (!FXJSE_Value_IsNull(newPropertyValue)) { |
| 945 dSum += HValueToDouble(hThis, argValue); | 945 dSum += ValueToDouble(pThis, argValue); |
| 946 uCount++; | 946 uCount++; |
| 947 } | 947 } |
| 948 FXJSE_Value_Release(newPropertyValue); | 948 FXJSE_Value_Release(newPropertyValue); |
| 949 } else { | 949 } else { |
| 950 dSum += HValueToDouble(hThis, argValue); | 950 dSum += ValueToDouble(pThis, argValue); |
| 951 uCount++; | 951 uCount++; |
| 952 } | 952 } |
| 953 FXJSE_Value_Release(argValue); | 953 FXJSE_Value_Release(argValue); |
| 954 } | 954 } |
| 955 argValue = 0; | 955 argValue = nullptr; |
| 956 } | 956 } |
| 957 if (uCount < 1) { | 957 if (uCount < 1) { |
| 958 FXJSE_Value_SetNull(args.GetReturnValue()); | 958 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 959 } else { | 959 } else { |
| 960 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); | 960 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); |
| 961 } | 961 } |
| 962 } | 962 } |
| 963 void CXFA_FM2JSContext::Date(FXJSE_HOBJECT hThis, | 963 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis, |
| 964 const CFX_ByteStringC& szFuncName, | 964 const CFX_ByteStringC& szFuncName, |
| 965 CFXJSE_Arguments& args) { | 965 CFXJSE_Arguments& args) { |
| 966 if (args.GetLength() == 0) { | 966 if (args.GetLength() == 0) { |
| 967 struct tm* pTmStruct = 0; | 967 struct tm* pTmStruct = 0; |
| 968 time_t currentTime; | 968 time_t currentTime; |
| 969 time(¤tTime); | 969 time(¤tTime); |
| 970 pTmStruct = gmtime(¤tTime); | 970 pTmStruct = gmtime(¤tTime); |
| 971 CFX_ByteString bufferYear; | 971 CFX_ByteString bufferYear; |
| 972 CFX_ByteString bufferMon; | 972 CFX_ByteString bufferMon; |
| 973 CFX_ByteString bufferDay; | 973 CFX_ByteString bufferDay; |
| 974 bufferYear.Format("%d", pTmStruct->tm_year + 1900); | 974 bufferYear.Format("%d", pTmStruct->tm_year + 1900); |
| 975 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); | 975 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); |
| 976 bufferDay.Format("%02d", pTmStruct->tm_mday); | 976 bufferDay.Format("%02d", pTmStruct->tm_mday); |
| 977 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; | 977 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; |
| 978 int32_t dDays = DateString2Num(bufferCurrent.AsStringC()); | 978 int32_t dDays = DateString2Num(bufferCurrent.AsStringC()); |
| 979 FXJSE_Value_SetInteger(args.GetReturnValue(), dDays); | 979 FXJSE_Value_SetInteger(args.GetReturnValue(), dDays); |
| 980 } else { | 980 } else { |
| 981 CXFA_FM2JSContext* pContext = | 981 CXFA_FM2JSContext* pContext = |
| 982 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 982 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 983 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 983 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 984 L"Date"); | 984 L"Date"); |
| 985 } | 985 } |
| 986 } | 986 } |
| 987 void CXFA_FM2JSContext::Date2Num(FXJSE_HOBJECT hThis, | 987 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis, |
| 988 const CFX_ByteStringC& szFuncName, | 988 const CFX_ByteStringC& szFuncName, |
| 989 CFXJSE_Arguments& args) { | 989 CFXJSE_Arguments& args) { |
| 990 int32_t argc = args.GetLength(); | 990 int32_t argc = args.GetLength(); |
| 991 if ((argc > 0) && (argc < 4)) { | 991 if ((argc > 0) && (argc < 4)) { |
| 992 FX_BOOL bFlags = FALSE; | 992 FX_BOOL bFlags = FALSE; |
| 993 CFX_ByteString dateString; | 993 CFX_ByteString dateString; |
| 994 CFX_ByteString formatString; | 994 CFX_ByteString formatString; |
| 995 CFX_ByteString localString; | 995 CFX_ByteString localString; |
| 996 FXJSE_HVALUE dateValue = GetSimpleHValue(hThis, args, 0); | 996 CFXJSE_Value* dateValue = GetSimpleValue(pThis, args, 0); |
| 997 FXJSE_HVALUE formatValue = 0; | 997 CFXJSE_Value* formatValue = nullptr; |
| 998 FXJSE_HVALUE localValue = 0; | 998 CFXJSE_Value* localValue = nullptr; |
| 999 if (HValueIsNull(hThis, dateValue)) { | 999 if (ValueIsNull(pThis, dateValue)) { |
| 1000 bFlags = TRUE; | 1000 bFlags = TRUE; |
| 1001 } else { | 1001 } else { |
| 1002 HValueToUTF8String(dateValue, dateString); | 1002 ValueToUTF8String(dateValue, dateString); |
| 1003 } | 1003 } |
| 1004 if (argc > 1) { | 1004 if (argc > 1) { |
| 1005 formatValue = GetSimpleHValue(hThis, args, 1); | 1005 formatValue = GetSimpleValue(pThis, args, 1); |
| 1006 if (HValueIsNull(hThis, formatValue)) { | 1006 if (ValueIsNull(pThis, formatValue)) { |
| 1007 bFlags = TRUE; | 1007 bFlags = TRUE; |
| 1008 } else { | 1008 } else { |
| 1009 HValueToUTF8String(formatValue, formatString); | 1009 ValueToUTF8String(formatValue, formatString); |
| 1010 } | 1010 } |
| 1011 } | 1011 } |
| 1012 if (argc == 3) { | 1012 if (argc == 3) { |
| 1013 localValue = GetSimpleHValue(hThis, args, 2); | 1013 localValue = GetSimpleValue(pThis, args, 2); |
| 1014 if (HValueIsNull(hThis, localValue)) { | 1014 if (ValueIsNull(pThis, localValue)) { |
| 1015 bFlags = TRUE; | 1015 bFlags = TRUE; |
| 1016 } else { | 1016 } else { |
| 1017 HValueToUTF8String(localValue, localString); | 1017 ValueToUTF8String(localValue, localString); |
| 1018 } | 1018 } |
| 1019 } | 1019 } |
| 1020 if (!bFlags) { | 1020 if (!bFlags) { |
| 1021 CFX_ByteString szIsoDateString; | 1021 CFX_ByteString szIsoDateString; |
| 1022 FX_BOOL bRet = | 1022 FX_BOOL bRet = |
| 1023 Local2IsoDate(hThis, dateString.AsStringC(), formatString.AsStringC(), | 1023 Local2IsoDate(pThis, dateString.AsStringC(), formatString.AsStringC(), |
| 1024 localString.AsStringC(), szIsoDateString); | 1024 localString.AsStringC(), szIsoDateString); |
| 1025 if (bRet) { | 1025 if (bRet) { |
| 1026 FXJSE_Value_SetInteger(args.GetReturnValue(), | 1026 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 1027 DateString2Num(szIsoDateString.AsStringC())); | 1027 DateString2Num(szIsoDateString.AsStringC())); |
| 1028 } else { | 1028 } else { |
| 1029 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 1029 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 1030 } | 1030 } |
| 1031 } else { | 1031 } else { |
| 1032 FXJSE_Value_SetNull(args.GetReturnValue()); | 1032 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1033 } | 1033 } |
| 1034 FXJSE_Value_Release(dateValue); | 1034 FXJSE_Value_Release(dateValue); |
| 1035 if (argc > 1) { | 1035 if (argc > 1) { |
| 1036 FXJSE_Value_Release(formatValue); | 1036 FXJSE_Value_Release(formatValue); |
| 1037 if (argc == 3) { | 1037 if (argc == 3) { |
| 1038 FXJSE_Value_Release(localValue); | 1038 FXJSE_Value_Release(localValue); |
| 1039 } | 1039 } |
| 1040 } | 1040 } |
| 1041 } else { | 1041 } else { |
| 1042 CXFA_FM2JSContext* pContext = | 1042 CXFA_FM2JSContext* pContext = |
| 1043 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1043 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1044 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1044 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1045 L"Date2Num"); | 1045 L"Date2Num"); |
| 1046 } | 1046 } |
| 1047 } | 1047 } |
| 1048 void CXFA_FM2JSContext::DateFmt(FXJSE_HOBJECT hThis, | 1048 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis, |
| 1049 const CFX_ByteStringC& szFuncName, | 1049 const CFX_ByteStringC& szFuncName, |
| 1050 CFXJSE_Arguments& args) { | 1050 CFXJSE_Arguments& args) { |
| 1051 int32_t argc = args.GetLength(); | 1051 int32_t argc = args.GetLength(); |
| 1052 if (argc < 3) { | 1052 if (argc < 3) { |
| 1053 FX_BOOL bFlags = FALSE; | 1053 FX_BOOL bFlags = FALSE; |
| 1054 int32_t iStyle = 0; | 1054 int32_t iStyle = 0; |
| 1055 CFX_ByteString szLocal; | 1055 CFX_ByteString szLocal; |
| 1056 FXJSE_HVALUE argStyle = 0; | 1056 CFXJSE_Value* argStyle = nullptr; |
| 1057 FXJSE_HVALUE argLocal = 0; | 1057 CFXJSE_Value* argLocal = nullptr; |
| 1058 if (argc > 0) { | 1058 if (argc > 0) { |
| 1059 argStyle = GetSimpleHValue(hThis, args, 0); | 1059 argStyle = GetSimpleValue(pThis, args, 0); |
| 1060 if (FXJSE_Value_IsNull(argStyle)) { | 1060 if (FXJSE_Value_IsNull(argStyle)) { |
| 1061 bFlags = TRUE; | 1061 bFlags = TRUE; |
| 1062 } | 1062 } |
| 1063 iStyle = (int32_t)HValueToFloat(hThis, argStyle); | 1063 iStyle = (int32_t)ValueToFloat(pThis, argStyle); |
| 1064 if (iStyle > 4 || iStyle < 0) { | 1064 if (iStyle > 4 || iStyle < 0) { |
| 1065 iStyle = 0; | 1065 iStyle = 0; |
| 1066 } | 1066 } |
| 1067 } | 1067 } |
| 1068 if (argc == 2) { | 1068 if (argc == 2) { |
| 1069 argLocal = GetSimpleHValue(hThis, args, 1); | 1069 argLocal = GetSimpleValue(pThis, args, 1); |
| 1070 if (FXJSE_Value_IsNull(argLocal)) { | 1070 if (FXJSE_Value_IsNull(argLocal)) { |
| 1071 bFlags = TRUE; | 1071 bFlags = TRUE; |
| 1072 } else { | 1072 } else { |
| 1073 HValueToUTF8String(argLocal, szLocal); | 1073 ValueToUTF8String(argLocal, szLocal); |
| 1074 } | 1074 } |
| 1075 } | 1075 } |
| 1076 if (!bFlags) { | 1076 if (!bFlags) { |
| 1077 CFX_ByteString formatStr; | 1077 CFX_ByteString formatStr; |
| 1078 GetStandardDateFormat(hThis, iStyle, szLocal.AsStringC(), formatStr); | 1078 GetStandardDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); |
| 1079 if (formatStr.IsEmpty()) { | 1079 if (formatStr.IsEmpty()) { |
| 1080 formatStr = ""; | 1080 formatStr = ""; |
| 1081 } | 1081 } |
| 1082 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1082 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1083 } else { | 1083 } else { |
| 1084 FXJSE_Value_SetNull(args.GetReturnValue()); | 1084 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1085 } | 1085 } |
| 1086 if (argc > 0) { | 1086 if (argc > 0) { |
| 1087 FXJSE_Value_Release(argStyle); | 1087 FXJSE_Value_Release(argStyle); |
| 1088 if (argc == 2) { | 1088 if (argc == 2) { |
| 1089 FXJSE_Value_Release(argLocal); | 1089 FXJSE_Value_Release(argLocal); |
| 1090 } | 1090 } |
| 1091 } | 1091 } |
| 1092 } else { | 1092 } else { |
| 1093 CXFA_FM2JSContext* pContext = | 1093 CXFA_FM2JSContext* pContext = |
| 1094 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1094 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1095 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1095 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1096 L"Date2Num"); | 1096 L"Date2Num"); |
| 1097 } | 1097 } |
| 1098 } | 1098 } |
| 1099 void CXFA_FM2JSContext::IsoDate2Num(FXJSE_HOBJECT hThis, | 1099 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, |
| 1100 const CFX_ByteStringC& szFuncName, | 1100 const CFX_ByteStringC& szFuncName, |
| 1101 CFXJSE_Arguments& args) { | 1101 CFXJSE_Arguments& args) { |
| 1102 if (args.GetLength() == 1) { | 1102 if (args.GetLength() == 1) { |
| 1103 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 1103 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 1104 if (FXJSE_Value_IsNull(argOne)) { | 1104 if (FXJSE_Value_IsNull(argOne)) { |
| 1105 FXJSE_Value_SetNull(args.GetReturnValue()); | 1105 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1106 } else { | 1106 } else { |
| 1107 CFX_ByteString szArgString; | 1107 CFX_ByteString szArgString; |
| 1108 HValueToUTF8String(argOne, szArgString); | 1108 ValueToUTF8String(argOne, szArgString); |
| 1109 int32_t dDays = DateString2Num(szArgString.AsStringC()); | 1109 int32_t dDays = DateString2Num(szArgString.AsStringC()); |
| 1110 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)dDays); | 1110 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)dDays); |
| 1111 } | 1111 } |
| 1112 FXJSE_Value_Release(argOne); | 1112 FXJSE_Value_Release(argOne); |
| 1113 } else { | 1113 } else { |
| 1114 CXFA_FM2JSContext* pContext = | 1114 CXFA_FM2JSContext* pContext = |
| 1115 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1115 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1116 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1116 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1117 L"IsoDate2Num"); | 1117 L"IsoDate2Num"); |
| 1118 } | 1118 } |
| 1119 } | 1119 } |
| 1120 void CXFA_FM2JSContext::IsoTime2Num(FXJSE_HOBJECT hThis, | 1120 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, |
| 1121 const CFX_ByteStringC& szFuncName, | 1121 const CFX_ByteStringC& szFuncName, |
| 1122 CFXJSE_Arguments& args) { | 1122 CFXJSE_Arguments& args) { |
| 1123 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1123 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1124 if (args.GetLength() == 1) { | 1124 if (args.GetLength() == 1) { |
| 1125 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 1125 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 1126 if (HValueIsNull(hThis, argOne)) { | 1126 if (ValueIsNull(pThis, argOne)) { |
| 1127 FXJSE_Value_SetNull(args.GetReturnValue()); | 1127 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1128 } else { | 1128 } else { |
| 1129 CXFA_Document* pDoc = pContext->GetDocument(); | 1129 CXFA_Document* pDoc = pContext->GetDocument(); |
| 1130 ASSERT(pDoc); | 1130 ASSERT(pDoc); |
| 1131 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 1131 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 1132 CFX_ByteString szArgString; | 1132 CFX_ByteString szArgString; |
| 1133 HValueToUTF8String(argOne, szArgString); | 1133 ValueToUTF8String(argOne, szArgString); |
| 1134 szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1); | 1134 szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1); |
| 1135 if (szArgString.IsEmpty()) { | 1135 if (szArgString.IsEmpty()) { |
| 1136 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 1136 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 1137 FXJSE_Value_Release(argOne); | 1137 FXJSE_Value_Release(argOne); |
| 1138 return; | 1138 return; |
| 1139 } | 1139 } |
| 1140 CXFA_LocaleValue timeValue( | 1140 CXFA_LocaleValue timeValue( |
| 1141 XFA_VT_TIME, CFX_WideString::FromUTF8(szArgString.AsStringC()), | 1141 XFA_VT_TIME, CFX_WideString::FromUTF8(szArgString.AsStringC()), |
| 1142 (CXFA_LocaleMgr*)pMgr); | 1142 (CXFA_LocaleMgr*)pMgr); |
| 1143 if (timeValue.IsValid()) { | 1143 if (timeValue.IsValid()) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1166 } else { | 1166 } else { |
| 1167 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 1167 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 1168 } | 1168 } |
| 1169 } | 1169 } |
| 1170 FXJSE_Value_Release(argOne); | 1170 FXJSE_Value_Release(argOne); |
| 1171 } else { | 1171 } else { |
| 1172 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1172 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1173 L"IsoTime2Num"); | 1173 L"IsoTime2Num"); |
| 1174 } | 1174 } |
| 1175 } | 1175 } |
| 1176 void CXFA_FM2JSContext::LocalDateFmt(FXJSE_HOBJECT hThis, | 1176 void CXFA_FM2JSContext::LocalDateFmt(CFXJSE_Value* pThis, |
| 1177 const CFX_ByteStringC& szFuncName, | 1177 const CFX_ByteStringC& szFuncName, |
| 1178 CFXJSE_Arguments& args) { | 1178 CFXJSE_Arguments& args) { |
| 1179 int32_t argc = args.GetLength(); | 1179 int32_t argc = args.GetLength(); |
| 1180 if (argc < 3) { | 1180 if (argc < 3) { |
| 1181 FX_BOOL bFlags = FALSE; | 1181 FX_BOOL bFlags = FALSE; |
| 1182 int32_t iStyle = 0; | 1182 int32_t iStyle = 0; |
| 1183 CFX_ByteString szLocal; | 1183 CFX_ByteString szLocal; |
| 1184 FXJSE_HVALUE argStyle = 0; | 1184 CFXJSE_Value* argStyle = nullptr; |
| 1185 FXJSE_HVALUE argLocal = 0; | 1185 CFXJSE_Value* argLocal = nullptr; |
| 1186 if (argc > 0) { | 1186 if (argc > 0) { |
| 1187 argStyle = GetSimpleHValue(hThis, args, 0); | 1187 argStyle = GetSimpleValue(pThis, args, 0); |
| 1188 if (FXJSE_Value_IsNull(argStyle)) { | 1188 if (FXJSE_Value_IsNull(argStyle)) { |
| 1189 bFlags = TRUE; | 1189 bFlags = TRUE; |
| 1190 } | 1190 } |
| 1191 iStyle = (int32_t)HValueToFloat(hThis, argStyle); | 1191 iStyle = (int32_t)ValueToFloat(pThis, argStyle); |
| 1192 if (iStyle > 4 || iStyle < 0) { | 1192 if (iStyle > 4 || iStyle < 0) { |
| 1193 iStyle = 0; | 1193 iStyle = 0; |
| 1194 } | 1194 } |
| 1195 } | 1195 } |
| 1196 if (argc == 2) { | 1196 if (argc == 2) { |
| 1197 argLocal = GetSimpleHValue(hThis, args, 1); | 1197 argLocal = GetSimpleValue(pThis, args, 1); |
| 1198 if (FXJSE_Value_IsNull(argLocal)) { | 1198 if (FXJSE_Value_IsNull(argLocal)) { |
| 1199 bFlags = TRUE; | 1199 bFlags = TRUE; |
| 1200 } else { | 1200 } else { |
| 1201 HValueToUTF8String(argLocal, szLocal); | 1201 ValueToUTF8String(argLocal, szLocal); |
| 1202 } | 1202 } |
| 1203 } | 1203 } |
| 1204 if (!bFlags) { | 1204 if (!bFlags) { |
| 1205 CFX_ByteString formatStr; | 1205 CFX_ByteString formatStr; |
| 1206 GetLocalDateFormat(hThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); | 1206 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); |
| 1207 if (formatStr.IsEmpty()) { | 1207 if (formatStr.IsEmpty()) { |
| 1208 formatStr = ""; | 1208 formatStr = ""; |
| 1209 } | 1209 } |
| 1210 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1210 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1211 } else { | 1211 } else { |
| 1212 FXJSE_Value_SetNull(args.GetReturnValue()); | 1212 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1213 } | 1213 } |
| 1214 if (argc > 0) { | 1214 if (argc > 0) { |
| 1215 FXJSE_Value_Release(argStyle); | 1215 FXJSE_Value_Release(argStyle); |
| 1216 if (argc == 2) { | 1216 if (argc == 2) { |
| 1217 FXJSE_Value_Release(argLocal); | 1217 FXJSE_Value_Release(argLocal); |
| 1218 } | 1218 } |
| 1219 } | 1219 } |
| 1220 } else { | 1220 } else { |
| 1221 CXFA_FM2JSContext* pContext = | 1221 CXFA_FM2JSContext* pContext = |
| 1222 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1222 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1223 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1223 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1224 L"LocalDateFmt"); | 1224 L"LocalDateFmt"); |
| 1225 } | 1225 } |
| 1226 } | 1226 } |
| 1227 void CXFA_FM2JSContext::LocalTimeFmt(FXJSE_HOBJECT hThis, | 1227 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, |
| 1228 const CFX_ByteStringC& szFuncName, | 1228 const CFX_ByteStringC& szFuncName, |
| 1229 CFXJSE_Arguments& args) { | 1229 CFXJSE_Arguments& args) { |
| 1230 int32_t argc = args.GetLength(); | 1230 int32_t argc = args.GetLength(); |
| 1231 if (argc < 3) { | 1231 if (argc < 3) { |
| 1232 FX_BOOL bFlags = FALSE; | 1232 FX_BOOL bFlags = FALSE; |
| 1233 int32_t iStyle = 0; | 1233 int32_t iStyle = 0; |
| 1234 CFX_ByteString szLocal; | 1234 CFX_ByteString szLocal; |
| 1235 FXJSE_HVALUE argStyle = 0; | 1235 CFXJSE_Value* argStyle = nullptr; |
| 1236 FXJSE_HVALUE argLocal = 0; | 1236 CFXJSE_Value* argLocal = nullptr; |
| 1237 if (argc > 0) { | 1237 if (argc > 0) { |
| 1238 argStyle = GetSimpleHValue(hThis, args, 0); | 1238 argStyle = GetSimpleValue(pThis, args, 0); |
| 1239 if (FXJSE_Value_IsNull(argStyle)) { | 1239 if (FXJSE_Value_IsNull(argStyle)) { |
| 1240 bFlags = TRUE; | 1240 bFlags = TRUE; |
| 1241 } | 1241 } |
| 1242 iStyle = (int32_t)HValueToFloat(hThis, argStyle); | 1242 iStyle = (int32_t)ValueToFloat(pThis, argStyle); |
| 1243 if (iStyle > 4 || iStyle < 0) { | 1243 if (iStyle > 4 || iStyle < 0) { |
| 1244 iStyle = 0; | 1244 iStyle = 0; |
| 1245 } | 1245 } |
| 1246 } | 1246 } |
| 1247 if (argc == 2) { | 1247 if (argc == 2) { |
| 1248 argLocal = GetSimpleHValue(hThis, args, 1); | 1248 argLocal = GetSimpleValue(pThis, args, 1); |
| 1249 if (FXJSE_Value_IsNull(argLocal)) { | 1249 if (FXJSE_Value_IsNull(argLocal)) { |
| 1250 bFlags = TRUE; | 1250 bFlags = TRUE; |
| 1251 } else { | 1251 } else { |
| 1252 HValueToUTF8String(argLocal, szLocal); | 1252 ValueToUTF8String(argLocal, szLocal); |
| 1253 } | 1253 } |
| 1254 } | 1254 } |
| 1255 if (!bFlags) { | 1255 if (!bFlags) { |
| 1256 CFX_ByteString formatStr; | 1256 CFX_ByteString formatStr; |
| 1257 GetLocalTimeFormat(hThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); | 1257 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); |
| 1258 if (formatStr.IsEmpty()) { | 1258 if (formatStr.IsEmpty()) { |
| 1259 formatStr = ""; | 1259 formatStr = ""; |
| 1260 } | 1260 } |
| 1261 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1261 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1262 } else { | 1262 } else { |
| 1263 FXJSE_Value_SetNull(args.GetReturnValue()); | 1263 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1264 } | 1264 } |
| 1265 if (argc > 0) { | 1265 if (argc > 0) { |
| 1266 FXJSE_Value_Release(argStyle); | 1266 FXJSE_Value_Release(argStyle); |
| 1267 if (argc == 2) { | 1267 if (argc == 2) { |
| 1268 FXJSE_Value_Release(argLocal); | 1268 FXJSE_Value_Release(argLocal); |
| 1269 } | 1269 } |
| 1270 } | 1270 } |
| 1271 } else { | 1271 } else { |
| 1272 CXFA_FM2JSContext* pContext = | 1272 CXFA_FM2JSContext* pContext = |
| 1273 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1273 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1274 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1274 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1275 L"LocalTimeFmt"); | 1275 L"LocalTimeFmt"); |
| 1276 } | 1276 } |
| 1277 } | 1277 } |
| 1278 void CXFA_FM2JSContext::Num2Date(FXJSE_HOBJECT hThis, | 1278 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, |
| 1279 const CFX_ByteStringC& szFuncName, | 1279 const CFX_ByteStringC& szFuncName, |
| 1280 CFXJSE_Arguments& args) { | 1280 CFXJSE_Arguments& args) { |
| 1281 int32_t argc = args.GetLength(); | 1281 int32_t argc = args.GetLength(); |
| 1282 if ((argc > 0) && (argc < 4)) { | 1282 if ((argc > 0) && (argc < 4)) { |
| 1283 FX_BOOL bFlags = FALSE; | 1283 FX_BOOL bFlags = FALSE; |
| 1284 int32_t dDate = 0; | 1284 int32_t dDate = 0; |
| 1285 CFX_ByteString formatString; | 1285 CFX_ByteString formatString; |
| 1286 CFX_ByteString localString; | 1286 CFX_ByteString localString; |
| 1287 FXJSE_HVALUE dateValue = GetSimpleHValue(hThis, args, 0); | 1287 CFXJSE_Value* dateValue = GetSimpleValue(pThis, args, 0); |
| 1288 FXJSE_HVALUE formatValue = 0; | 1288 CFXJSE_Value* formatValue = nullptr; |
| 1289 FXJSE_HVALUE localValue = 0; | 1289 CFXJSE_Value* localValue = nullptr; |
| 1290 if (HValueIsNull(hThis, dateValue)) { | 1290 if (ValueIsNull(pThis, dateValue)) { |
| 1291 bFlags = TRUE; | 1291 bFlags = TRUE; |
| 1292 } else { | 1292 } else { |
| 1293 dDate = (int32_t)HValueToFloat(hThis, dateValue); | 1293 dDate = (int32_t)ValueToFloat(pThis, dateValue); |
| 1294 bFlags = dDate < 1; | 1294 bFlags = dDate < 1; |
| 1295 } | 1295 } |
| 1296 if (argc > 1) { | 1296 if (argc > 1) { |
| 1297 formatValue = GetSimpleHValue(hThis, args, 1); | 1297 formatValue = GetSimpleValue(pThis, args, 1); |
| 1298 if (HValueIsNull(hThis, formatValue)) { | 1298 if (ValueIsNull(pThis, formatValue)) { |
| 1299 bFlags = TRUE; | 1299 bFlags = TRUE; |
| 1300 } else { | 1300 } else { |
| 1301 HValueToUTF8String(formatValue, formatString); | 1301 ValueToUTF8String(formatValue, formatString); |
| 1302 } | 1302 } |
| 1303 } | 1303 } |
| 1304 if (argc == 3) { | 1304 if (argc == 3) { |
| 1305 localValue = GetSimpleHValue(hThis, args, 2); | 1305 localValue = GetSimpleValue(pThis, args, 2); |
| 1306 if (HValueIsNull(hThis, localValue)) { | 1306 if (ValueIsNull(pThis, localValue)) { |
| 1307 bFlags = TRUE; | 1307 bFlags = TRUE; |
| 1308 } else { | 1308 } else { |
| 1309 HValueToUTF8String(localValue, localString); | 1309 ValueToUTF8String(localValue, localString); |
| 1310 } | 1310 } |
| 1311 } | 1311 } |
| 1312 if (!bFlags) { | 1312 if (!bFlags) { |
| 1313 int32_t iYear = 1900; | 1313 int32_t iYear = 1900; |
| 1314 int32_t iMonth = 1; | 1314 int32_t iMonth = 1; |
| 1315 int32_t iDay = 1; | 1315 int32_t iDay = 1; |
| 1316 int32_t i = 0; | 1316 int32_t i = 0; |
| 1317 while (dDate > 0) { | 1317 while (dDate > 0) { |
| 1318 if (iMonth == 2) { | 1318 if (iMonth == 2) { |
| 1319 if ((!((iYear + i) % 4) && ((iYear + i) % 100)) || | 1319 if ((!((iYear + i) % 4) && ((iYear + i) % 100)) || |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 } else { | 1398 } else { |
| 1399 iDay += static_cast<int32_t>(dDate) - 1; | 1399 iDay += static_cast<int32_t>(dDate) - 1; |
| 1400 dDate = 0; | 1400 dDate = 0; |
| 1401 } | 1401 } |
| 1402 } | 1402 } |
| 1403 } | 1403 } |
| 1404 } | 1404 } |
| 1405 CFX_ByteString szIsoDateString; | 1405 CFX_ByteString szIsoDateString; |
| 1406 szIsoDateString.Format("%d%02d%02d", iYear + i, iMonth, iDay); | 1406 szIsoDateString.Format("%d%02d%02d", iYear + i, iMonth, iDay); |
| 1407 CFX_ByteString szLocalDateString; | 1407 CFX_ByteString szLocalDateString; |
| 1408 IsoDate2Local(hThis, szIsoDateString.AsStringC(), | 1408 IsoDate2Local(pThis, szIsoDateString.AsStringC(), |
| 1409 formatString.AsStringC(), localString.AsStringC(), | 1409 formatString.AsStringC(), localString.AsStringC(), |
| 1410 szLocalDateString); | 1410 szLocalDateString); |
| 1411 if (szLocalDateString.IsEmpty()) { | 1411 if (szLocalDateString.IsEmpty()) { |
| 1412 szLocalDateString = ""; | 1412 szLocalDateString = ""; |
| 1413 } | 1413 } |
| 1414 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1414 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 1415 szLocalDateString.AsStringC()); | 1415 szLocalDateString.AsStringC()); |
| 1416 } else { | 1416 } else { |
| 1417 FXJSE_Value_SetNull(args.GetReturnValue()); | 1417 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1418 } | 1418 } |
| 1419 FXJSE_Value_Release(dateValue); | 1419 FXJSE_Value_Release(dateValue); |
| 1420 if (argc > 1) { | 1420 if (argc > 1) { |
| 1421 FXJSE_Value_Release(formatValue); | 1421 FXJSE_Value_Release(formatValue); |
| 1422 if (argc == 3) { | 1422 if (argc == 3) { |
| 1423 FXJSE_Value_Release(localValue); | 1423 FXJSE_Value_Release(localValue); |
| 1424 } | 1424 } |
| 1425 } | 1425 } |
| 1426 } else { | 1426 } else { |
| 1427 CXFA_FM2JSContext* pContext = | 1427 CXFA_FM2JSContext* pContext = |
| 1428 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1428 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1429 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1429 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1430 L"Num2Date"); | 1430 L"Num2Date"); |
| 1431 } | 1431 } |
| 1432 } | 1432 } |
| 1433 void CXFA_FM2JSContext::Num2GMTime(FXJSE_HOBJECT hThis, | 1433 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, |
| 1434 const CFX_ByteStringC& szFuncName, | 1434 const CFX_ByteStringC& szFuncName, |
| 1435 CFXJSE_Arguments& args) { | 1435 CFXJSE_Arguments& args) { |
| 1436 int32_t argc = args.GetLength(); | 1436 int32_t argc = args.GetLength(); |
| 1437 if ((argc > 0) && (argc < 4)) { | 1437 if ((argc > 0) && (argc < 4)) { |
| 1438 FX_BOOL bFlags = FALSE; | 1438 FX_BOOL bFlags = FALSE; |
| 1439 int32_t iTime = 0; | 1439 int32_t iTime = 0; |
| 1440 CFX_ByteString formatString; | 1440 CFX_ByteString formatString; |
| 1441 CFX_ByteString localString; | 1441 CFX_ByteString localString; |
| 1442 FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); | 1442 CFXJSE_Value* timeValue = GetSimpleValue(pThis, args, 0); |
| 1443 FXJSE_HVALUE formatValue = 0; | 1443 CFXJSE_Value* formatValue = nullptr; |
| 1444 FXJSE_HVALUE localValue = 0; | 1444 CFXJSE_Value* localValue = nullptr; |
| 1445 if (FXJSE_Value_IsNull(timeValue)) { | 1445 if (FXJSE_Value_IsNull(timeValue)) { |
| 1446 bFlags = TRUE; | 1446 bFlags = TRUE; |
| 1447 } else { | 1447 } else { |
| 1448 iTime = (int32_t)HValueToFloat(hThis, timeValue); | 1448 iTime = (int32_t)ValueToFloat(pThis, timeValue); |
| 1449 if (FXSYS_abs(iTime) < 1.0) { | 1449 if (FXSYS_abs(iTime) < 1.0) { |
| 1450 bFlags = TRUE; | 1450 bFlags = TRUE; |
| 1451 } | 1451 } |
| 1452 } | 1452 } |
| 1453 if (argc > 1) { | 1453 if (argc > 1) { |
| 1454 formatValue = GetSimpleHValue(hThis, args, 1); | 1454 formatValue = GetSimpleValue(pThis, args, 1); |
| 1455 if (FXJSE_Value_IsNull(formatValue)) { | 1455 if (FXJSE_Value_IsNull(formatValue)) { |
| 1456 bFlags = TRUE; | 1456 bFlags = TRUE; |
| 1457 } else { | 1457 } else { |
| 1458 HValueToUTF8String(formatValue, formatString); | 1458 ValueToUTF8String(formatValue, formatString); |
| 1459 } | 1459 } |
| 1460 } | 1460 } |
| 1461 if (argc == 3) { | 1461 if (argc == 3) { |
| 1462 localValue = GetSimpleHValue(hThis, args, 2); | 1462 localValue = GetSimpleValue(pThis, args, 2); |
| 1463 if (FXJSE_Value_IsNull(localValue)) { | 1463 if (FXJSE_Value_IsNull(localValue)) { |
| 1464 bFlags = TRUE; | 1464 bFlags = TRUE; |
| 1465 } else { | 1465 } else { |
| 1466 HValueToUTF8String(localValue, localString); | 1466 ValueToUTF8String(localValue, localString); |
| 1467 } | 1467 } |
| 1468 } | 1468 } |
| 1469 if (!bFlags) { | 1469 if (!bFlags) { |
| 1470 CFX_ByteString szGMTTimeString; | 1470 CFX_ByteString szGMTTimeString; |
| 1471 Num2AllTime(hThis, iTime, formatString.AsStringC(), | 1471 Num2AllTime(pThis, iTime, formatString.AsStringC(), |
| 1472 localString.AsStringC(), TRUE, szGMTTimeString); | 1472 localString.AsStringC(), TRUE, szGMTTimeString); |
| 1473 if (szGMTTimeString.IsEmpty()) { | 1473 if (szGMTTimeString.IsEmpty()) { |
| 1474 szGMTTimeString = ""; | 1474 szGMTTimeString = ""; |
| 1475 } | 1475 } |
| 1476 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1476 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 1477 szGMTTimeString.AsStringC()); | 1477 szGMTTimeString.AsStringC()); |
| 1478 } else { | 1478 } else { |
| 1479 FXJSE_Value_SetNull(args.GetReturnValue()); | 1479 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1480 } | 1480 } |
| 1481 FXJSE_Value_Release(timeValue); | 1481 FXJSE_Value_Release(timeValue); |
| 1482 if (argc > 1) { | 1482 if (argc > 1) { |
| 1483 FXJSE_Value_Release(formatValue); | 1483 FXJSE_Value_Release(formatValue); |
| 1484 if (argc == 3) { | 1484 if (argc == 3) { |
| 1485 FXJSE_Value_Release(localValue); | 1485 FXJSE_Value_Release(localValue); |
| 1486 } | 1486 } |
| 1487 } | 1487 } |
| 1488 } else { | 1488 } else { |
| 1489 CXFA_FM2JSContext* pContext = | 1489 CXFA_FM2JSContext* pContext = |
| 1490 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1490 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1491 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1491 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1492 L"Num2GMTime"); | 1492 L"Num2GMTime"); |
| 1493 } | 1493 } |
| 1494 } | 1494 } |
| 1495 void CXFA_FM2JSContext::Num2Time(FXJSE_HOBJECT hThis, | 1495 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, |
| 1496 const CFX_ByteStringC& szFuncName, | 1496 const CFX_ByteStringC& szFuncName, |
| 1497 CFXJSE_Arguments& args) { | 1497 CFXJSE_Arguments& args) { |
| 1498 int32_t argc = args.GetLength(); | 1498 int32_t argc = args.GetLength(); |
| 1499 if ((argc > 0) && (argc < 4)) { | 1499 if ((argc > 0) && (argc < 4)) { |
| 1500 FX_BOOL bFlags = FALSE; | 1500 FX_BOOL bFlags = FALSE; |
| 1501 FX_FLOAT fTime = 0.0f; | 1501 FX_FLOAT fTime = 0.0f; |
| 1502 CFX_ByteString formatString; | 1502 CFX_ByteString formatString; |
| 1503 CFX_ByteString localString; | 1503 CFX_ByteString localString; |
| 1504 FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); | 1504 CFXJSE_Value* timeValue = GetSimpleValue(pThis, args, 0); |
| 1505 FXJSE_HVALUE formatValue = 0; | 1505 CFXJSE_Value* formatValue = nullptr; |
| 1506 FXJSE_HVALUE localValue = 0; | 1506 CFXJSE_Value* localValue = nullptr; |
| 1507 if (FXJSE_Value_IsNull(timeValue)) { | 1507 if (FXJSE_Value_IsNull(timeValue)) { |
| 1508 bFlags = TRUE; | 1508 bFlags = TRUE; |
| 1509 } else { | 1509 } else { |
| 1510 fTime = HValueToFloat(hThis, timeValue); | 1510 fTime = ValueToFloat(pThis, timeValue); |
| 1511 if (FXSYS_fabs(fTime) < 1.0) { | 1511 if (FXSYS_fabs(fTime) < 1.0) { |
| 1512 bFlags = TRUE; | 1512 bFlags = TRUE; |
| 1513 } | 1513 } |
| 1514 } | 1514 } |
| 1515 if (argc > 1) { | 1515 if (argc > 1) { |
| 1516 formatValue = GetSimpleHValue(hThis, args, 1); | 1516 formatValue = GetSimpleValue(pThis, args, 1); |
| 1517 if (FXJSE_Value_IsNull(formatValue)) { | 1517 if (FXJSE_Value_IsNull(formatValue)) { |
| 1518 bFlags = TRUE; | 1518 bFlags = TRUE; |
| 1519 } else { | 1519 } else { |
| 1520 HValueToUTF8String(formatValue, formatString); | 1520 ValueToUTF8String(formatValue, formatString); |
| 1521 } | 1521 } |
| 1522 } | 1522 } |
| 1523 if (argc == 3) { | 1523 if (argc == 3) { |
| 1524 localValue = GetSimpleHValue(hThis, args, 2); | 1524 localValue = GetSimpleValue(pThis, args, 2); |
| 1525 if (FXJSE_Value_IsNull(localValue)) { | 1525 if (FXJSE_Value_IsNull(localValue)) { |
| 1526 bFlags = TRUE; | 1526 bFlags = TRUE; |
| 1527 } else { | 1527 } else { |
| 1528 HValueToUTF8String(localValue, localString); | 1528 ValueToUTF8String(localValue, localString); |
| 1529 } | 1529 } |
| 1530 } | 1530 } |
| 1531 if (!bFlags) { | 1531 if (!bFlags) { |
| 1532 CFX_ByteString szLocalTimeString; | 1532 CFX_ByteString szLocalTimeString; |
| 1533 Num2AllTime(hThis, (int32_t)fTime, formatString.AsStringC(), | 1533 Num2AllTime(pThis, (int32_t)fTime, formatString.AsStringC(), |
| 1534 localString.AsStringC(), FALSE, szLocalTimeString); | 1534 localString.AsStringC(), FALSE, szLocalTimeString); |
| 1535 if (szLocalTimeString.IsEmpty()) { | 1535 if (szLocalTimeString.IsEmpty()) { |
| 1536 szLocalTimeString = ""; | 1536 szLocalTimeString = ""; |
| 1537 } | 1537 } |
| 1538 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1538 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 1539 szLocalTimeString.AsStringC()); | 1539 szLocalTimeString.AsStringC()); |
| 1540 } else { | 1540 } else { |
| 1541 FXJSE_Value_SetNull(args.GetReturnValue()); | 1541 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1542 } | 1542 } |
| 1543 FXJSE_Value_Release(timeValue); | 1543 FXJSE_Value_Release(timeValue); |
| 1544 if (argc > 1) { | 1544 if (argc > 1) { |
| 1545 FXJSE_Value_Release(formatValue); | 1545 FXJSE_Value_Release(formatValue); |
| 1546 if (argc == 3) { | 1546 if (argc == 3) { |
| 1547 FXJSE_Value_Release(localValue); | 1547 FXJSE_Value_Release(localValue); |
| 1548 } | 1548 } |
| 1549 } | 1549 } |
| 1550 } else { | 1550 } else { |
| 1551 CXFA_FM2JSContext* pContext = | 1551 CXFA_FM2JSContext* pContext = |
| 1552 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1552 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1553 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1553 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1554 L"Num2Time"); | 1554 L"Num2Time"); |
| 1555 } | 1555 } |
| 1556 } | 1556 } |
| 1557 void CXFA_FM2JSContext::Time(FXJSE_HOBJECT hThis, | 1557 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, |
| 1558 const CFX_ByteStringC& szFuncName, | 1558 const CFX_ByteStringC& szFuncName, |
| 1559 CFXJSE_Arguments& args) { | 1559 CFXJSE_Arguments& args) { |
| 1560 if (args.GetLength() == 0) { | 1560 if (args.GetLength() == 0) { |
| 1561 time_t now; | 1561 time_t now; |
| 1562 time(&now); | 1562 time(&now); |
| 1563 struct tm* pGmt = gmtime(&now); | 1563 struct tm* pGmt = gmtime(&now); |
| 1564 int32_t iGMHour = pGmt->tm_hour; | 1564 int32_t iGMHour = pGmt->tm_hour; |
| 1565 int32_t iGMMin = pGmt->tm_min; | 1565 int32_t iGMMin = pGmt->tm_min; |
| 1566 int32_t iGMSec = pGmt->tm_sec; | 1566 int32_t iGMSec = pGmt->tm_sec; |
| 1567 FXJSE_Value_SetInteger(args.GetReturnValue(), | 1567 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 1568 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); | 1568 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); |
| 1569 } else { | 1569 } else { |
| 1570 CXFA_FM2JSContext* pContext = | 1570 CXFA_FM2JSContext* pContext = |
| 1571 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1571 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1572 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1572 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1573 L"Time"); | 1573 L"Time"); |
| 1574 } | 1574 } |
| 1575 } | 1575 } |
| 1576 void CXFA_FM2JSContext::Time2Num(FXJSE_HOBJECT hThis, | 1576 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, |
| 1577 const CFX_ByteStringC& szFuncName, | 1577 const CFX_ByteStringC& szFuncName, |
| 1578 CFXJSE_Arguments& args) { | 1578 CFXJSE_Arguments& args) { |
| 1579 int32_t argc = args.GetLength(); | 1579 int32_t argc = args.GetLength(); |
| 1580 if ((argc > 0) && (argc < 4)) { | 1580 if ((argc > 0) && (argc < 4)) { |
| 1581 FX_BOOL bFlags = FALSE; | 1581 FX_BOOL bFlags = FALSE; |
| 1582 CFX_ByteString timeString; | 1582 CFX_ByteString timeString; |
| 1583 CFX_ByteString formatString; | 1583 CFX_ByteString formatString; |
| 1584 CFX_ByteString localString; | 1584 CFX_ByteString localString; |
| 1585 FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); | 1585 CFXJSE_Value* timeValue = GetSimpleValue(pThis, args, 0); |
| 1586 FXJSE_HVALUE formatValue = 0; | 1586 CFXJSE_Value* formatValue = nullptr; |
| 1587 FXJSE_HVALUE localValue = 0; | 1587 CFXJSE_Value* localValue = nullptr; |
| 1588 if (HValueIsNull(hThis, timeValue)) { | 1588 if (ValueIsNull(pThis, timeValue)) { |
| 1589 bFlags = TRUE; | 1589 bFlags = TRUE; |
| 1590 } else { | 1590 } else { |
| 1591 HValueToUTF8String(timeValue, timeString); | 1591 ValueToUTF8String(timeValue, timeString); |
| 1592 } | 1592 } |
| 1593 if (argc > 1) { | 1593 if (argc > 1) { |
| 1594 formatValue = GetSimpleHValue(hThis, args, 1); | 1594 formatValue = GetSimpleValue(pThis, args, 1); |
| 1595 if (HValueIsNull(hThis, formatValue)) { | 1595 if (ValueIsNull(pThis, formatValue)) { |
| 1596 bFlags = TRUE; | 1596 bFlags = TRUE; |
| 1597 } else { | 1597 } else { |
| 1598 HValueToUTF8String(formatValue, formatString); | 1598 ValueToUTF8String(formatValue, formatString); |
| 1599 } | 1599 } |
| 1600 } | 1600 } |
| 1601 if (argc == 3) { | 1601 if (argc == 3) { |
| 1602 localValue = GetSimpleHValue(hThis, args, 2); | 1602 localValue = GetSimpleValue(pThis, args, 2); |
| 1603 if (HValueIsNull(hThis, localValue)) { | 1603 if (ValueIsNull(pThis, localValue)) { |
| 1604 bFlags = TRUE; | 1604 bFlags = TRUE; |
| 1605 } else { | 1605 } else { |
| 1606 HValueToUTF8String(localValue, localString); | 1606 ValueToUTF8String(localValue, localString); |
| 1607 } | 1607 } |
| 1608 } | 1608 } |
| 1609 if (!bFlags) { | 1609 if (!bFlags) { |
| 1610 CXFA_FM2JSContext* pContext = | 1610 CXFA_FM2JSContext* pContext = |
| 1611 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1611 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1612 CXFA_Document* pDoc = pContext->GetDocument(); | 1612 CXFA_Document* pDoc = pContext->GetDocument(); |
| 1613 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 1613 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 1614 IFX_Locale* pLocale = NULL; | 1614 IFX_Locale* pLocale = NULL; |
| 1615 if (localString.IsEmpty()) { | 1615 if (localString.IsEmpty()) { |
| 1616 CXFA_Node* pThisNode = | 1616 CXFA_Node* pThisNode = |
| 1617 ToNode(pDoc->GetScriptContext()->GetThisObject()); | 1617 ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 1618 ASSERT(pThisNode); | 1618 ASSERT(pThisNode); |
| 1619 CXFA_WidgetData widgetData(pThisNode); | 1619 CXFA_WidgetData widgetData(pThisNode); |
| 1620 pLocale = widgetData.GetLocal(); | 1620 pLocale = widgetData.GetLocal(); |
| 1621 } else { | 1621 } else { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 } | 1665 } |
| 1666 FXJSE_Value_Release(timeValue); | 1666 FXJSE_Value_Release(timeValue); |
| 1667 if (argc > 1) { | 1667 if (argc > 1) { |
| 1668 FXJSE_Value_Release(formatValue); | 1668 FXJSE_Value_Release(formatValue); |
| 1669 if (argc == 3) { | 1669 if (argc == 3) { |
| 1670 FXJSE_Value_Release(localValue); | 1670 FXJSE_Value_Release(localValue); |
| 1671 } | 1671 } |
| 1672 } | 1672 } |
| 1673 } else { | 1673 } else { |
| 1674 CXFA_FM2JSContext* pContext = | 1674 CXFA_FM2JSContext* pContext = |
| 1675 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1675 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1676 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1676 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1677 L"Time2Num"); | 1677 L"Time2Num"); |
| 1678 } | 1678 } |
| 1679 } | 1679 } |
| 1680 void CXFA_FM2JSContext::TimeFmt(FXJSE_HOBJECT hThis, | 1680 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, |
| 1681 const CFX_ByteStringC& szFuncName, | 1681 const CFX_ByteStringC& szFuncName, |
| 1682 CFXJSE_Arguments& args) { | 1682 CFXJSE_Arguments& args) { |
| 1683 int32_t argc = args.GetLength(); | 1683 int32_t argc = args.GetLength(); |
| 1684 if (argc < 3) { | 1684 if (argc < 3) { |
| 1685 FX_BOOL bFlags = FALSE; | 1685 FX_BOOL bFlags = FALSE; |
| 1686 int32_t iStyle = 0; | 1686 int32_t iStyle = 0; |
| 1687 CFX_ByteString szLocal; | 1687 CFX_ByteString szLocal; |
| 1688 FXJSE_HVALUE argStyle = 0; | 1688 CFXJSE_Value* argStyle = nullptr; |
| 1689 FXJSE_HVALUE argLocal = 0; | 1689 CFXJSE_Value* argLocal = nullptr; |
| 1690 if (argc > 0) { | 1690 if (argc > 0) { |
| 1691 argStyle = GetSimpleHValue(hThis, args, 0); | 1691 argStyle = GetSimpleValue(pThis, args, 0); |
| 1692 if (FXJSE_Value_IsNull(argStyle)) { | 1692 if (FXJSE_Value_IsNull(argStyle)) { |
| 1693 bFlags = TRUE; | 1693 bFlags = TRUE; |
| 1694 } | 1694 } |
| 1695 iStyle = (int32_t)HValueToFloat(hThis, argStyle); | 1695 iStyle = (int32_t)ValueToFloat(pThis, argStyle); |
| 1696 if (iStyle > 4 || iStyle < 0) { | 1696 if (iStyle > 4 || iStyle < 0) { |
| 1697 iStyle = 0; | 1697 iStyle = 0; |
| 1698 } | 1698 } |
| 1699 } | 1699 } |
| 1700 if (argc == 2) { | 1700 if (argc == 2) { |
| 1701 argLocal = GetSimpleHValue(hThis, args, 1); | 1701 argLocal = GetSimpleValue(pThis, args, 1); |
| 1702 if (FXJSE_Value_IsNull(argLocal)) { | 1702 if (FXJSE_Value_IsNull(argLocal)) { |
| 1703 bFlags = TRUE; | 1703 bFlags = TRUE; |
| 1704 } else { | 1704 } else { |
| 1705 HValueToUTF8String(argLocal, szLocal); | 1705 ValueToUTF8String(argLocal, szLocal); |
| 1706 } | 1706 } |
| 1707 } | 1707 } |
| 1708 if (!bFlags) { | 1708 if (!bFlags) { |
| 1709 CFX_ByteString formatStr; | 1709 CFX_ByteString formatStr; |
| 1710 GetStandardTimeFormat(hThis, iStyle, szLocal.AsStringC(), formatStr); | 1710 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); |
| 1711 if (formatStr.IsEmpty()) { | 1711 if (formatStr.IsEmpty()) { |
| 1712 formatStr = ""; | 1712 formatStr = ""; |
| 1713 } | 1713 } |
| 1714 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1714 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1715 } else { | 1715 } else { |
| 1716 FXJSE_Value_SetNull(args.GetReturnValue()); | 1716 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1717 } | 1717 } |
| 1718 if (argc > 0) { | 1718 if (argc > 0) { |
| 1719 FXJSE_Value_Release(argStyle); | 1719 FXJSE_Value_Release(argStyle); |
| 1720 if (argc == 2) { | 1720 if (argc == 2) { |
| 1721 FXJSE_Value_Release(argLocal); | 1721 FXJSE_Value_Release(argLocal); |
| 1722 } | 1722 } |
| 1723 } | 1723 } |
| 1724 } else { | 1724 } else { |
| 1725 CXFA_FM2JSContext* pContext = | 1725 CXFA_FM2JSContext* pContext = |
| 1726 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 1726 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 1727 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1727 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1728 L"TimeFmt"); | 1728 L"TimeFmt"); |
| 1729 } | 1729 } |
| 1730 } | 1730 } |
| 1731 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, | 1731 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, |
| 1732 int32_t iLength, | 1732 int32_t iLength, |
| 1733 int32_t& iStyle, | 1733 int32_t& iStyle, |
| 1734 int32_t& iYear, | 1734 int32_t& iYear, |
| 1735 int32_t& iMonth, | 1735 int32_t& iMonth, |
| 1736 int32_t& iDay) { | 1736 int32_t& iDay) { |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2040 return iRet; | 2040 return iRet; |
| 2041 } | 2041 } |
| 2042 iRet = IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute, | 2042 iRet = IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute, |
| 2043 iSecond, iMillionSecond, iZoneHour, iZoneMinute); | 2043 iSecond, iMillionSecond, iZoneHour, iZoneMinute); |
| 2044 if (!iRet) { | 2044 if (!iRet) { |
| 2045 return iRet; | 2045 return iRet; |
| 2046 } | 2046 } |
| 2047 iRet = TRUE; | 2047 iRet = TRUE; |
| 2048 return iRet; | 2048 return iRet; |
| 2049 } | 2049 } |
| 2050 FX_BOOL CXFA_FM2JSContext::Local2IsoDate(FXJSE_HOBJECT hThis, | 2050 FX_BOOL CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis, |
| 2051 const CFX_ByteStringC& szDate, | 2051 const CFX_ByteStringC& szDate, |
| 2052 const CFX_ByteStringC& szFormat, | 2052 const CFX_ByteStringC& szFormat, |
| 2053 const CFX_ByteStringC& szLocale, | 2053 const CFX_ByteStringC& szLocale, |
| 2054 CFX_ByteString& strIsoDate) { | 2054 CFX_ByteString& strIsoDate) { |
| 2055 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2055 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2056 CXFA_Document* pDoc = pContext->GetDocument(); | 2056 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2057 if (!pDoc) { | 2057 if (!pDoc) { |
| 2058 return FALSE; | 2058 return FALSE; |
| 2059 } | 2059 } |
| 2060 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2060 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2061 IFX_Locale* pLocale = NULL; | 2061 IFX_Locale* pLocale = NULL; |
| 2062 if (szLocale.IsEmpty()) { | 2062 if (szLocale.IsEmpty()) { |
| 2063 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2063 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2064 ASSERT(pThisNode); | 2064 ASSERT(pThisNode); |
| 2065 CXFA_WidgetData widgetData(pThisNode); | 2065 CXFA_WidgetData widgetData(pThisNode); |
| 2066 pLocale = widgetData.GetLocal(); | 2066 pLocale = widgetData.GetLocal(); |
| 2067 } else { | 2067 } else { |
| 2068 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); | 2068 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); |
| 2069 } | 2069 } |
| 2070 if (!pLocale) { | 2070 if (!pLocale) { |
| 2071 return FALSE; | 2071 return FALSE; |
| 2072 } | 2072 } |
| 2073 CFX_WideString wsFormat; | 2073 CFX_WideString wsFormat; |
| 2074 if (szFormat.IsEmpty()) { | 2074 if (szFormat.IsEmpty()) { |
| 2075 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2075 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2076 } else { | 2076 } else { |
| 2077 wsFormat = CFX_WideString::FromUTF8(szFormat); | 2077 wsFormat = CFX_WideString::FromUTF8(szFormat); |
| 2078 } | 2078 } |
| 2079 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), | 2079 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), |
| 2080 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | 2080 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
| 2081 CFX_Unitime dt = widgetValue.GetDate(); | 2081 CFX_Unitime dt = widgetValue.GetDate(); |
| 2082 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); | 2082 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); |
| 2083 return TRUE; | 2083 return TRUE; |
| 2084 } | 2084 } |
| 2085 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis, | 2085 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis, |
| 2086 const CFX_ByteStringC& szTime, | 2086 const CFX_ByteStringC& szTime, |
| 2087 const CFX_ByteStringC& szFormat, | 2087 const CFX_ByteStringC& szFormat, |
| 2088 const CFX_ByteStringC& szLocale, | 2088 const CFX_ByteStringC& szLocale, |
| 2089 CFX_ByteString& strIsoTime) { | 2089 CFX_ByteString& strIsoTime) { |
| 2090 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2090 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2091 CXFA_Document* pDoc = pContext->GetDocument(); | 2091 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2092 if (!pDoc) { | 2092 if (!pDoc) { |
| 2093 return FALSE; | 2093 return FALSE; |
| 2094 } | 2094 } |
| 2095 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2095 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2096 IFX_Locale* pLocale = NULL; | 2096 IFX_Locale* pLocale = NULL; |
| 2097 if (szLocale.IsEmpty()) { | 2097 if (szLocale.IsEmpty()) { |
| 2098 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2098 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2099 ASSERT(pThisNode); | 2099 ASSERT(pThisNode); |
| 2100 CXFA_WidgetData widgetData(pThisNode); | 2100 CXFA_WidgetData widgetData(pThisNode); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2113 } | 2113 } |
| 2114 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2114 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2115 wsFormat += FX_WSTRC(L"}"); | 2115 wsFormat += FX_WSTRC(L"}"); |
| 2116 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), | 2116 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
| 2117 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | 2117 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
| 2118 CFX_Unitime utime = widgetValue.GetTime(); | 2118 CFX_Unitime utime = widgetValue.GetTime(); |
| 2119 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), | 2119 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), |
| 2120 utime.GetSecond(), utime.GetMillisecond()); | 2120 utime.GetSecond(), utime.GetMillisecond()); |
| 2121 return TRUE; | 2121 return TRUE; |
| 2122 } | 2122 } |
| 2123 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis, | 2123 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis, |
| 2124 const CFX_ByteStringC& szDate, | 2124 const CFX_ByteStringC& szDate, |
| 2125 const CFX_ByteStringC& szFormat, | 2125 const CFX_ByteStringC& szFormat, |
| 2126 const CFX_ByteStringC& szLocale, | 2126 const CFX_ByteStringC& szLocale, |
| 2127 CFX_ByteString& strLocalDate) { | 2127 CFX_ByteString& strLocalDate) { |
| 2128 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2128 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2129 CXFA_Document* pDoc = pContext->GetDocument(); | 2129 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2130 if (!pDoc) { | 2130 if (!pDoc) { |
| 2131 return FALSE; | 2131 return FALSE; |
| 2132 } | 2132 } |
| 2133 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2133 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2134 IFX_Locale* pLocale = NULL; | 2134 IFX_Locale* pLocale = NULL; |
| 2135 if (szLocale.IsEmpty()) { | 2135 if (szLocale.IsEmpty()) { |
| 2136 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2136 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2137 ASSERT(pThisNode); | 2137 ASSERT(pThisNode); |
| 2138 CXFA_WidgetData widgetData(pThisNode); | 2138 CXFA_WidgetData widgetData(pThisNode); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2150 wsFormat = CFX_WideString::FromUTF8(szFormat); | 2150 wsFormat = CFX_WideString::FromUTF8(szFormat); |
| 2151 } | 2151 } |
| 2152 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), | 2152 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), |
| 2153 (CXFA_LocaleMgr*)pMgr); | 2153 (CXFA_LocaleMgr*)pMgr); |
| 2154 CFX_WideString wsRet; | 2154 CFX_WideString wsRet; |
| 2155 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2155 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2156 XFA_VALUEPICTURE_Display); | 2156 XFA_VALUEPICTURE_Display); |
| 2157 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); | 2157 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); |
| 2158 return TRUE; | 2158 return TRUE; |
| 2159 } | 2159 } |
| 2160 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis, | 2160 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis, |
| 2161 const CFX_ByteStringC& szTime, | 2161 const CFX_ByteStringC& szTime, |
| 2162 const CFX_ByteStringC& szFormat, | 2162 const CFX_ByteStringC& szFormat, |
| 2163 const CFX_ByteStringC& szLocale, | 2163 const CFX_ByteStringC& szLocale, |
| 2164 CFX_ByteString& strLocalTime) { | 2164 CFX_ByteString& strLocalTime) { |
| 2165 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2165 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2166 CXFA_Document* pDoc = pContext->GetDocument(); | 2166 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2167 if (!pDoc) { | 2167 if (!pDoc) { |
| 2168 return FALSE; | 2168 return FALSE; |
| 2169 } | 2169 } |
| 2170 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2170 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2171 IFX_Locale* pLocale = NULL; | 2171 IFX_Locale* pLocale = NULL; |
| 2172 if (szLocale.IsEmpty()) { | 2172 if (szLocale.IsEmpty()) { |
| 2173 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2173 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2174 ASSERT(pThisNode); | 2174 ASSERT(pThisNode); |
| 2175 CXFA_WidgetData widgetData(pThisNode); | 2175 CXFA_WidgetData widgetData(pThisNode); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2189 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2189 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2190 wsFormat += FX_WSTRC(L"}"); | 2190 wsFormat += FX_WSTRC(L"}"); |
| 2191 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), | 2191 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
| 2192 (CXFA_LocaleMgr*)pMgr); | 2192 (CXFA_LocaleMgr*)pMgr); |
| 2193 CFX_WideString wsRet; | 2193 CFX_WideString wsRet; |
| 2194 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2194 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2195 XFA_VALUEPICTURE_Display); | 2195 XFA_VALUEPICTURE_Display); |
| 2196 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); | 2196 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); |
| 2197 return TRUE; | 2197 return TRUE; |
| 2198 } | 2198 } |
| 2199 FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis, | 2199 FX_BOOL CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis, |
| 2200 const CFX_ByteStringC& szTime, | 2200 const CFX_ByteStringC& szTime, |
| 2201 const CFX_ByteStringC& szFormat, | 2201 const CFX_ByteStringC& szFormat, |
| 2202 const CFX_ByteStringC& szLocale, | 2202 const CFX_ByteStringC& szLocale, |
| 2203 CFX_ByteString& strGMTTime) { | 2203 CFX_ByteString& strGMTTime) { |
| 2204 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2204 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2205 CXFA_Document* pDoc = pContext->GetDocument(); | 2205 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2206 if (!pDoc) { | 2206 if (!pDoc) { |
| 2207 return FALSE; | 2207 return FALSE; |
| 2208 } | 2208 } |
| 2209 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2209 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2210 IFX_Locale* pLocale = NULL; | 2210 IFX_Locale* pLocale = NULL; |
| 2211 if (szLocale.IsEmpty()) { | 2211 if (szLocale.IsEmpty()) { |
| 2212 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2212 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2213 ASSERT(pThisNode); | 2213 ASSERT(pThisNode); |
| 2214 CXFA_WidgetData widgetData(pThisNode); | 2214 CXFA_WidgetData widgetData(pThisNode); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2301 while (iDay - i > 0) { | 2301 while (iDay - i > 0) { |
| 2302 dDays += 1; | 2302 dDays += 1; |
| 2303 ++i; | 2303 ++i; |
| 2304 } | 2304 } |
| 2305 } else { | 2305 } else { |
| 2306 dDays = 0; | 2306 dDays = 0; |
| 2307 } | 2307 } |
| 2308 return (int32_t)dDays; | 2308 return (int32_t)dDays; |
| 2309 } | 2309 } |
| 2310 | 2310 |
| 2311 void CXFA_FM2JSContext::GetLocalDateFormat(FXJSE_HOBJECT hThis, | 2311 void CXFA_FM2JSContext::GetLocalDateFormat(CFXJSE_Value* pThis, |
| 2312 int32_t iStyle, | 2312 int32_t iStyle, |
| 2313 const CFX_ByteStringC& szLocalStr, | 2313 const CFX_ByteStringC& szLocalStr, |
| 2314 CFX_ByteString& strFormat, | 2314 CFX_ByteString& strFormat, |
| 2315 FX_BOOL bStandard) { | 2315 FX_BOOL bStandard) { |
| 2316 FX_LOCALEDATETIMESUBCATEGORY strStyle; | 2316 FX_LOCALEDATETIMESUBCATEGORY strStyle; |
| 2317 switch (iStyle) { | 2317 switch (iStyle) { |
| 2318 case 0: | 2318 case 0: |
| 2319 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2319 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2320 break; | 2320 break; |
| 2321 case 1: | 2321 case 1: |
| 2322 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; | 2322 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; |
| 2323 break; | 2323 break; |
| 2324 case 2: | 2324 case 2: |
| 2325 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2325 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2326 break; | 2326 break; |
| 2327 case 3: | 2327 case 3: |
| 2328 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; | 2328 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; |
| 2329 break; | 2329 break; |
| 2330 case 4: | 2330 case 4: |
| 2331 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; | 2331 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; |
| 2332 break; | 2332 break; |
| 2333 default: | 2333 default: |
| 2334 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2334 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2335 break; | 2335 break; |
| 2336 } | 2336 } |
| 2337 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2337 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2338 CXFA_Document* pDoc = pContext->GetDocument(); | 2338 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2339 if (!pDoc) { | 2339 if (!pDoc) { |
| 2340 return; | 2340 return; |
| 2341 } | 2341 } |
| 2342 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2342 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2343 IFX_Locale* pLocale = NULL; | 2343 IFX_Locale* pLocale = NULL; |
| 2344 if (szLocalStr.IsEmpty()) { | 2344 if (szLocalStr.IsEmpty()) { |
| 2345 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2345 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2346 ASSERT(pThisNode); | 2346 ASSERT(pThisNode); |
| 2347 CXFA_WidgetData widgetData(pThisNode); | 2347 CXFA_WidgetData widgetData(pThisNode); |
| 2348 pLocale = widgetData.GetLocal(); | 2348 pLocale = widgetData.GetLocal(); |
| 2349 } else { | 2349 } else { |
| 2350 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); | 2350 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); |
| 2351 } | 2351 } |
| 2352 if (!pLocale) { | 2352 if (!pLocale) { |
| 2353 return; | 2353 return; |
| 2354 } | 2354 } |
| 2355 CFX_WideString strRet; | 2355 CFX_WideString strRet; |
| 2356 pLocale->GetDatePattern(strStyle, strRet); | 2356 pLocale->GetDatePattern(strStyle, strRet); |
| 2357 if (!bStandard) { | 2357 if (!bStandard) { |
| 2358 CFX_WideString wsSymbols; | 2358 CFX_WideString wsSymbols; |
| 2359 pLocale->GetDateTimeSymbols(wsSymbols); | 2359 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2360 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); | 2360 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); |
| 2361 } | 2361 } |
| 2362 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); | 2362 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); |
| 2363 } | 2363 } |
| 2364 void CXFA_FM2JSContext::GetLocalTimeFormat(FXJSE_HOBJECT hThis, | 2364 void CXFA_FM2JSContext::GetLocalTimeFormat(CFXJSE_Value* pThis, |
| 2365 int32_t iStyle, | 2365 int32_t iStyle, |
| 2366 const CFX_ByteStringC& szLocalStr, | 2366 const CFX_ByteStringC& szLocalStr, |
| 2367 CFX_ByteString& strFormat, | 2367 CFX_ByteString& strFormat, |
| 2368 FX_BOOL bStandard) { | 2368 FX_BOOL bStandard) { |
| 2369 FX_LOCALEDATETIMESUBCATEGORY strStyle; | 2369 FX_LOCALEDATETIMESUBCATEGORY strStyle; |
| 2370 switch (iStyle) { | 2370 switch (iStyle) { |
| 2371 case 0: | 2371 case 0: |
| 2372 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2372 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2373 break; | 2373 break; |
| 2374 case 1: | 2374 case 1: |
| 2375 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; | 2375 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; |
| 2376 break; | 2376 break; |
| 2377 case 2: | 2377 case 2: |
| 2378 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2378 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2379 break; | 2379 break; |
| 2380 case 3: | 2380 case 3: |
| 2381 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; | 2381 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; |
| 2382 break; | 2382 break; |
| 2383 case 4: | 2383 case 4: |
| 2384 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; | 2384 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; |
| 2385 break; | 2385 break; |
| 2386 default: | 2386 default: |
| 2387 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2387 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2388 break; | 2388 break; |
| 2389 } | 2389 } |
| 2390 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2390 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2391 CXFA_Document* pDoc = pContext->GetDocument(); | 2391 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2392 if (!pDoc) { | 2392 if (!pDoc) { |
| 2393 return; | 2393 return; |
| 2394 } | 2394 } |
| 2395 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2395 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2396 IFX_Locale* pLocale = NULL; | 2396 IFX_Locale* pLocale = NULL; |
| 2397 if (szLocalStr.IsEmpty()) { | 2397 if (szLocalStr.IsEmpty()) { |
| 2398 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2398 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2399 ASSERT(pThisNode); | 2399 ASSERT(pThisNode); |
| 2400 CXFA_WidgetData widgetData(pThisNode); | 2400 CXFA_WidgetData widgetData(pThisNode); |
| 2401 pLocale = widgetData.GetLocal(); | 2401 pLocale = widgetData.GetLocal(); |
| 2402 } else { | 2402 } else { |
| 2403 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); | 2403 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); |
| 2404 } | 2404 } |
| 2405 if (!pLocale) { | 2405 if (!pLocale) { |
| 2406 return; | 2406 return; |
| 2407 } | 2407 } |
| 2408 CFX_WideString strRet; | 2408 CFX_WideString strRet; |
| 2409 pLocale->GetTimePattern(strStyle, strRet); | 2409 pLocale->GetTimePattern(strStyle, strRet); |
| 2410 if (!bStandard) { | 2410 if (!bStandard) { |
| 2411 CFX_WideString wsSymbols; | 2411 CFX_WideString wsSymbols; |
| 2412 pLocale->GetDateTimeSymbols(wsSymbols); | 2412 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2413 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); | 2413 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); |
| 2414 } | 2414 } |
| 2415 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); | 2415 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); |
| 2416 } | 2416 } |
| 2417 void CXFA_FM2JSContext::GetStandardDateFormat(FXJSE_HOBJECT hThis, | 2417 void CXFA_FM2JSContext::GetStandardDateFormat(CFXJSE_Value* pThis, |
| 2418 int32_t iStyle, | 2418 int32_t iStyle, |
| 2419 const CFX_ByteStringC& szLocalStr, | 2419 const CFX_ByteStringC& szLocalStr, |
| 2420 CFX_ByteString& strFormat) { | 2420 CFX_ByteString& strFormat) { |
| 2421 GetLocalDateFormat(hThis, iStyle, szLocalStr, strFormat, TRUE); | 2421 GetLocalDateFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); |
| 2422 } | 2422 } |
| 2423 void CXFA_FM2JSContext::GetStandardTimeFormat(FXJSE_HOBJECT hThis, | 2423 void CXFA_FM2JSContext::GetStandardTimeFormat(CFXJSE_Value* pThis, |
| 2424 int32_t iStyle, | 2424 int32_t iStyle, |
| 2425 const CFX_ByteStringC& szLocalStr, | 2425 const CFX_ByteStringC& szLocalStr, |
| 2426 CFX_ByteString& strFormat) { | 2426 CFX_ByteString& strFormat) { |
| 2427 GetLocalTimeFormat(hThis, iStyle, szLocalStr, strFormat, TRUE); | 2427 GetLocalTimeFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); |
| 2428 } | 2428 } |
| 2429 void CXFA_FM2JSContext::Num2AllTime(FXJSE_HOBJECT hThis, | 2429 void CXFA_FM2JSContext::Num2AllTime(CFXJSE_Value* pThis, |
| 2430 int32_t iTime, | 2430 int32_t iTime, |
| 2431 const CFX_ByteStringC& szFormat, | 2431 const CFX_ByteStringC& szFormat, |
| 2432 const CFX_ByteStringC& szLocale, | 2432 const CFX_ByteStringC& szLocale, |
| 2433 FX_BOOL bGM, | 2433 FX_BOOL bGM, |
| 2434 CFX_ByteString& strTime) { | 2434 CFX_ByteString& strTime) { |
| 2435 int32_t iHour = 0; | 2435 int32_t iHour = 0; |
| 2436 int32_t iMin = 0; | 2436 int32_t iMin = 0; |
| 2437 int32_t iSec = 0; | 2437 int32_t iSec = 0; |
| 2438 int32_t iZoneHour = 0; | 2438 int32_t iZoneHour = 0; |
| 2439 int32_t iZoneMin = 0; | 2439 int32_t iZoneMin = 0; |
| 2440 int32_t iZoneSec = 0; | 2440 int32_t iZoneSec = 0; |
| 2441 iHour = static_cast<int>(iTime) / 3600000; | 2441 iHour = static_cast<int>(iTime) / 3600000; |
| 2442 iMin = (static_cast<int>(iTime) - iHour * 3600000) / 60000; | 2442 iMin = (static_cast<int>(iTime) - iHour * 3600000) / 60000; |
| 2443 iSec = (static_cast<int>(iTime) - iHour * 3600000 - iMin * 60000) / 1000; | 2443 iSec = (static_cast<int>(iTime) - iHour * 3600000 - iMin * 60000) / 1000; |
| 2444 if (!bGM) { | 2444 if (!bGM) { |
| 2445 GetLocalTimeZone(iZoneHour, iZoneMin, iZoneSec); | 2445 GetLocalTimeZone(iZoneHour, iZoneMin, iZoneSec); |
| 2446 iHour += iZoneHour; | 2446 iHour += iZoneHour; |
| 2447 iMin += iZoneMin; | 2447 iMin += iZoneMin; |
| 2448 iSec += iZoneSec; | 2448 iSec += iZoneSec; |
| 2449 } | 2449 } |
| 2450 int32_t iRet = 0; | 2450 int32_t iRet = 0; |
| 2451 CFX_ByteString strIsoTime; | 2451 CFX_ByteString strIsoTime; |
| 2452 strIsoTime.Format("%02d:%02d:%02d", iHour, iMin, iSec); | 2452 strIsoTime.Format("%02d:%02d:%02d", iHour, iMin, iSec); |
| 2453 if (bGM) { | 2453 if (bGM) { |
| 2454 iRet = | 2454 iRet = |
| 2455 GetGMTTime(hThis, strIsoTime.AsStringC(), szFormat, szLocale, strTime); | 2455 GetGMTTime(pThis, strIsoTime.AsStringC(), szFormat, szLocale, strTime); |
| 2456 } else { | 2456 } else { |
| 2457 iRet = IsoTime2Local(hThis, strIsoTime.AsStringC(), szFormat, szLocale, | 2457 iRet = IsoTime2Local(pThis, strIsoTime.AsStringC(), szFormat, szLocale, |
| 2458 strTime); | 2458 strTime); |
| 2459 } | 2459 } |
| 2460 if (!iRet) { | 2460 if (!iRet) { |
| 2461 strTime = ""; | 2461 strTime = ""; |
| 2462 } | 2462 } |
| 2463 } | 2463 } |
| 2464 | 2464 |
| 2465 void CXFA_FM2JSContext::GetLocalTimeZone(int32_t& iHour, | 2465 void CXFA_FM2JSContext::GetLocalTimeZone(int32_t& iHour, |
| 2466 int32_t& iMin, | 2466 int32_t& iMin, |
| 2467 int32_t& iSec) { | 2467 int32_t& iSec) { |
| 2468 time_t now; | 2468 time_t now; |
| 2469 time(&now); | 2469 time(&now); |
| 2470 struct tm* pGmt = gmtime(&now); | 2470 struct tm* pGmt = gmtime(&now); |
| 2471 int32_t iGMHour = pGmt->tm_hour; | 2471 int32_t iGMHour = pGmt->tm_hour; |
| 2472 int32_t iGMMin = pGmt->tm_min; | 2472 int32_t iGMMin = pGmt->tm_min; |
| 2473 int32_t iGMSec = pGmt->tm_sec; | 2473 int32_t iGMSec = pGmt->tm_sec; |
| 2474 struct tm* pLocal = localtime(&now); | 2474 struct tm* pLocal = localtime(&now); |
| 2475 int32_t iLocalHour = pLocal->tm_hour; | 2475 int32_t iLocalHour = pLocal->tm_hour; |
| 2476 int32_t iLocalMin = pLocal->tm_min; | 2476 int32_t iLocalMin = pLocal->tm_min; |
| 2477 int32_t iLocalSec = pLocal->tm_sec; | 2477 int32_t iLocalSec = pLocal->tm_sec; |
| 2478 iHour = iLocalHour - iGMHour; | 2478 iHour = iLocalHour - iGMHour; |
| 2479 iMin = iLocalMin - iGMMin; | 2479 iMin = iLocalMin - iGMMin; |
| 2480 iSec = iLocalSec - iGMSec; | 2480 iSec = iLocalSec - iGMSec; |
| 2481 } | 2481 } |
| 2482 void CXFA_FM2JSContext::Apr(FXJSE_HOBJECT hThis, | 2482 void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis, |
| 2483 const CFX_ByteStringC& szFuncName, | 2483 const CFX_ByteStringC& szFuncName, |
| 2484 CFXJSE_Arguments& args) { | 2484 CFXJSE_Arguments& args) { |
| 2485 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2485 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2486 if (args.GetLength() == 3) { | 2486 if (args.GetLength() == 3) { |
| 2487 FX_BOOL bFlags = FALSE; | 2487 FX_BOOL bFlags = FALSE; |
| 2488 FX_DOUBLE nPrincipal = 0; | 2488 FX_DOUBLE nPrincipal = 0; |
| 2489 FX_DOUBLE nPayment = 0; | 2489 FX_DOUBLE nPayment = 0; |
| 2490 FX_DOUBLE nPeriods = 0; | 2490 FX_DOUBLE nPeriods = 0; |
| 2491 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2491 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2492 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2492 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2493 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2493 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2494 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2494 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2495 HValueIsNull(hThis, argThree)); | 2495 ValueIsNull(pThis, argThree)); |
| 2496 if (bFlags) { | 2496 if (bFlags) { |
| 2497 FXJSE_Value_SetNull(args.GetReturnValue()); | 2497 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2498 } else { | 2498 } else { |
| 2499 nPrincipal = HValueToDouble(hThis, argOne); | 2499 nPrincipal = ValueToDouble(pThis, argOne); |
| 2500 nPayment = HValueToDouble(hThis, argTwo); | 2500 nPayment = ValueToDouble(pThis, argTwo); |
| 2501 nPeriods = HValueToDouble(hThis, argThree); | 2501 nPeriods = ValueToDouble(pThis, argThree); |
| 2502 bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0)); | 2502 bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0)); |
| 2503 if (bFlags) { | 2503 if (bFlags) { |
| 2504 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2504 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2505 } else { | 2505 } else { |
| 2506 FX_DOUBLE r = | 2506 FX_DOUBLE r = |
| 2507 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); | 2507 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); |
| 2508 FX_DOUBLE nTemp = 1; | 2508 FX_DOUBLE nTemp = 1; |
| 2509 for (int32_t i = 0; i < nPeriods; ++i) { | 2509 for (int32_t i = 0; i < nPeriods; ++i) { |
| 2510 nTemp *= (1 + r); | 2510 nTemp *= (1 + r); |
| 2511 } | 2511 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2537 } | 2537 } |
| 2538 } | 2538 } |
| 2539 FXJSE_Value_Release(argOne); | 2539 FXJSE_Value_Release(argOne); |
| 2540 FXJSE_Value_Release(argTwo); | 2540 FXJSE_Value_Release(argTwo); |
| 2541 FXJSE_Value_Release(argThree); | 2541 FXJSE_Value_Release(argThree); |
| 2542 } else { | 2542 } else { |
| 2543 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2543 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2544 L"Apr"); | 2544 L"Apr"); |
| 2545 } | 2545 } |
| 2546 } | 2546 } |
| 2547 void CXFA_FM2JSContext::CTerm(FXJSE_HOBJECT hThis, | 2547 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, |
| 2548 const CFX_ByteStringC& szFuncName, | 2548 const CFX_ByteStringC& szFuncName, |
| 2549 CFXJSE_Arguments& args) { | 2549 CFXJSE_Arguments& args) { |
| 2550 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2550 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2551 if (args.GetLength() == 3) { | 2551 if (args.GetLength() == 3) { |
| 2552 FX_BOOL bFlags = FALSE; | 2552 FX_BOOL bFlags = FALSE; |
| 2553 FX_FLOAT nRate = 0; | 2553 FX_FLOAT nRate = 0; |
| 2554 FX_FLOAT nFutureValue = 0; | 2554 FX_FLOAT nFutureValue = 0; |
| 2555 FX_FLOAT nInitAmount = 0; | 2555 FX_FLOAT nInitAmount = 0; |
| 2556 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2556 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2557 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2557 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2558 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2558 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2559 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2559 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2560 HValueIsNull(hThis, argThree)); | 2560 ValueIsNull(pThis, argThree)); |
| 2561 if (bFlags) { | 2561 if (bFlags) { |
| 2562 FXJSE_Value_SetNull(args.GetReturnValue()); | 2562 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2563 } else { | 2563 } else { |
| 2564 nRate = HValueToFloat(hThis, argOne); | 2564 nRate = ValueToFloat(pThis, argOne); |
| 2565 nFutureValue = HValueToFloat(hThis, argTwo); | 2565 nFutureValue = ValueToFloat(pThis, argTwo); |
| 2566 nInitAmount = HValueToFloat(hThis, argThree); | 2566 nInitAmount = ValueToFloat(pThis, argThree); |
| 2567 bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)); | 2567 bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)); |
| 2568 if (bFlags) { | 2568 if (bFlags) { |
| 2569 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2569 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2570 } else { | 2570 } else { |
| 2571 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2571 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2572 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / | 2572 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / |
| 2573 FXSYS_log((FX_FLOAT)(1 + nRate))); | 2573 FXSYS_log((FX_FLOAT)(1 + nRate))); |
| 2574 } | 2574 } |
| 2575 } | 2575 } |
| 2576 FXJSE_Value_Release(argOne); | 2576 FXJSE_Value_Release(argOne); |
| 2577 FXJSE_Value_Release(argTwo); | 2577 FXJSE_Value_Release(argTwo); |
| 2578 FXJSE_Value_Release(argThree); | 2578 FXJSE_Value_Release(argThree); |
| 2579 } else { | 2579 } else { |
| 2580 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2580 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2581 L"CTerm"); | 2581 L"CTerm"); |
| 2582 } | 2582 } |
| 2583 } | 2583 } |
| 2584 void CXFA_FM2JSContext::FV(FXJSE_HOBJECT hThis, | 2584 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, |
| 2585 const CFX_ByteStringC& szFuncName, | 2585 const CFX_ByteStringC& szFuncName, |
| 2586 CFXJSE_Arguments& args) { | 2586 CFXJSE_Arguments& args) { |
| 2587 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2587 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2588 if (args.GetLength() == 3) { | 2588 if (args.GetLength() == 3) { |
| 2589 FX_BOOL bFlags = FALSE; | 2589 FX_BOOL bFlags = FALSE; |
| 2590 FX_DOUBLE nAmount = 0; | 2590 FX_DOUBLE nAmount = 0; |
| 2591 FX_DOUBLE nRate = 0; | 2591 FX_DOUBLE nRate = 0; |
| 2592 FX_DOUBLE nPeriod = 0; | 2592 FX_DOUBLE nPeriod = 0; |
| 2593 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2593 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2594 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2594 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2595 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2595 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2596 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2596 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2597 HValueIsNull(hThis, argThree)); | 2597 ValueIsNull(pThis, argThree)); |
| 2598 if (bFlags) { | 2598 if (bFlags) { |
| 2599 FXJSE_Value_SetNull(args.GetReturnValue()); | 2599 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2600 } else { | 2600 } else { |
| 2601 nAmount = HValueToDouble(hThis, argOne); | 2601 nAmount = ValueToDouble(pThis, argOne); |
| 2602 nRate = HValueToDouble(hThis, argTwo); | 2602 nRate = ValueToDouble(pThis, argTwo); |
| 2603 nPeriod = HValueToDouble(hThis, argThree); | 2603 nPeriod = ValueToDouble(pThis, argThree); |
| 2604 bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)); | 2604 bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)); |
| 2605 if (bFlags) { | 2605 if (bFlags) { |
| 2606 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2606 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2607 } else { | 2607 } else { |
| 2608 FX_DOUBLE dResult = 0; | 2608 FX_DOUBLE dResult = 0; |
| 2609 if (!nRate) { | 2609 if (!nRate) { |
| 2610 dResult = nAmount * nPeriod; | 2610 dResult = nAmount * nPeriod; |
| 2611 } else { | 2611 } else { |
| 2612 FX_DOUBLE nTemp = 1; | 2612 FX_DOUBLE nTemp = 1; |
| 2613 for (int i = 0; i < nPeriod; ++i) { | 2613 for (int i = 0; i < nPeriod; ++i) { |
| 2614 nTemp *= 1 + nRate; | 2614 nTemp *= 1 + nRate; |
| 2615 } | 2615 } |
| 2616 dResult = nAmount * (nTemp - 1) / nRate; | 2616 dResult = nAmount * (nTemp - 1) / nRate; |
| 2617 } | 2617 } |
| 2618 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); | 2618 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); |
| 2619 } | 2619 } |
| 2620 } | 2620 } |
| 2621 FXJSE_Value_Release(argOne); | 2621 FXJSE_Value_Release(argOne); |
| 2622 FXJSE_Value_Release(argTwo); | 2622 FXJSE_Value_Release(argTwo); |
| 2623 FXJSE_Value_Release(argThree); | 2623 FXJSE_Value_Release(argThree); |
| 2624 } else { | 2624 } else { |
| 2625 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2625 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2626 L"FV"); | 2626 L"FV"); |
| 2627 } | 2627 } |
| 2628 } | 2628 } |
| 2629 void CXFA_FM2JSContext::IPmt(FXJSE_HOBJECT hThis, | 2629 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, |
| 2630 const CFX_ByteStringC& szFuncName, | 2630 const CFX_ByteStringC& szFuncName, |
| 2631 CFXJSE_Arguments& args) { | 2631 CFXJSE_Arguments& args) { |
| 2632 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2632 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2633 if (args.GetLength() == 5) { | 2633 if (args.GetLength() == 5) { |
| 2634 FX_BOOL bFlags = FALSE; | 2634 FX_BOOL bFlags = FALSE; |
| 2635 FX_FLOAT nPrincpalAmount = 0; | 2635 FX_FLOAT nPrincpalAmount = 0; |
| 2636 FX_FLOAT nRate = 0; | 2636 FX_FLOAT nRate = 0; |
| 2637 FX_FLOAT nPayment = 0; | 2637 FX_FLOAT nPayment = 0; |
| 2638 FX_FLOAT nFirstMonth = 0; | 2638 FX_FLOAT nFirstMonth = 0; |
| 2639 FX_FLOAT nNumberOfMonths = 0; | 2639 FX_FLOAT nNumberOfMonths = 0; |
| 2640 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2640 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2641 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2641 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2642 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2642 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2643 FXJSE_HVALUE argFour = GetSimpleHValue(hThis, args, 3); | 2643 CFXJSE_Value* argFour = GetSimpleValue(pThis, args, 3); |
| 2644 FXJSE_HVALUE argFive = GetSimpleHValue(hThis, args, 4); | 2644 CFXJSE_Value* argFive = GetSimpleValue(pThis, args, 4); |
| 2645 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2645 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2646 HValueIsNull(hThis, argThree) || HValueIsNull(hThis, argFour) || | 2646 ValueIsNull(pThis, argThree) || ValueIsNull(pThis, argFour) || |
| 2647 HValueIsNull(hThis, argFive)); | 2647 ValueIsNull(pThis, argFive)); |
| 2648 if (bFlags) { | 2648 if (bFlags) { |
| 2649 FXJSE_Value_SetNull(args.GetReturnValue()); | 2649 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2650 } else { | 2650 } else { |
| 2651 nPrincpalAmount = HValueToFloat(hThis, argOne); | 2651 nPrincpalAmount = ValueToFloat(pThis, argOne); |
| 2652 nRate = HValueToFloat(hThis, argTwo); | 2652 nRate = ValueToFloat(pThis, argTwo); |
| 2653 nPayment = HValueToFloat(hThis, argThree); | 2653 nPayment = ValueToFloat(pThis, argThree); |
| 2654 nFirstMonth = HValueToFloat(hThis, argFour); | 2654 nFirstMonth = ValueToFloat(pThis, argFour); |
| 2655 nNumberOfMonths = HValueToFloat(hThis, argFive); | 2655 nNumberOfMonths = ValueToFloat(pThis, argFive); |
| 2656 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || | 2656 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || |
| 2657 (nFirstMonth < 0) || (nNumberOfMonths < 0)); | 2657 (nFirstMonth < 0) || (nNumberOfMonths < 0)); |
| 2658 if (bFlags) { | 2658 if (bFlags) { |
| 2659 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2659 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2660 } else { | 2660 } else { |
| 2661 FX_FLOAT fResult = 0; | 2661 FX_FLOAT fResult = 0; |
| 2662 FX_FLOAT nRateOfMonth = nRate / 12; | 2662 FX_FLOAT nRateOfMonth = nRate / 12; |
| 2663 int32_t iNums = | 2663 int32_t iNums = |
| 2664 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - | 2664 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - |
| 2665 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - | 2665 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2691 FXJSE_Value_Release(argOne); | 2691 FXJSE_Value_Release(argOne); |
| 2692 FXJSE_Value_Release(argTwo); | 2692 FXJSE_Value_Release(argTwo); |
| 2693 FXJSE_Value_Release(argThree); | 2693 FXJSE_Value_Release(argThree); |
| 2694 FXJSE_Value_Release(argFour); | 2694 FXJSE_Value_Release(argFour); |
| 2695 FXJSE_Value_Release(argFive); | 2695 FXJSE_Value_Release(argFive); |
| 2696 } else { | 2696 } else { |
| 2697 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2697 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2698 L"IPmt"); | 2698 L"IPmt"); |
| 2699 } | 2699 } |
| 2700 } | 2700 } |
| 2701 void CXFA_FM2JSContext::NPV(FXJSE_HOBJECT hThis, | 2701 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, |
| 2702 const CFX_ByteStringC& szFuncName, | 2702 const CFX_ByteStringC& szFuncName, |
| 2703 CFXJSE_Arguments& args) { | 2703 CFXJSE_Arguments& args) { |
| 2704 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2704 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2705 int32_t argc = args.GetLength(); | 2705 int32_t argc = args.GetLength(); |
| 2706 if (argc > 2) { | 2706 if (argc > 2) { |
| 2707 FX_BOOL bFlags = FALSE; | 2707 FX_BOOL bFlags = FALSE; |
| 2708 FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argc); | 2708 CFXJSE_Value** argValues = FX_Alloc(CFXJSE_Value*, argc); |
| 2709 for (int32_t i = 0; i < argc; i++) { | 2709 for (int32_t i = 0; i < argc; i++) { |
| 2710 argValues[i] = GetSimpleHValue(hThis, args, i); | 2710 argValues[i] = GetSimpleValue(pThis, args, i); |
| 2711 if (HValueIsNull(hThis, argValues[i])) { | 2711 if (ValueIsNull(pThis, argValues[i])) { |
| 2712 bFlags = TRUE; | 2712 bFlags = TRUE; |
| 2713 } | 2713 } |
| 2714 } | 2714 } |
| 2715 if (!bFlags) { | 2715 if (!bFlags) { |
| 2716 FX_DOUBLE nRate = 0; | 2716 FX_DOUBLE nRate = 0; |
| 2717 nRate = HValueToDouble(hThis, argValues[0]); | 2717 nRate = ValueToDouble(pThis, argValues[0]); |
| 2718 if (nRate <= 0) { | 2718 if (nRate <= 0) { |
| 2719 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2719 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2720 } else { | 2720 } else { |
| 2721 FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1); | 2721 FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1); |
| 2722 for (int32_t i = 1; i < argc; i++) { | 2722 for (int32_t i = 1; i < argc; i++) { |
| 2723 pData[i - 1] = HValueToDouble(hThis, argValues[i]); | 2723 pData[i - 1] = ValueToDouble(pThis, argValues[i]); |
| 2724 } | 2724 } |
| 2725 FX_DOUBLE nSum = 0; | 2725 FX_DOUBLE nSum = 0; |
| 2726 int32_t iIndex = 0; | 2726 int32_t iIndex = 0; |
| 2727 for (int32_t i = 0; i < argc - 1; i++) { | 2727 for (int32_t i = 0; i < argc - 1; i++) { |
| 2728 FX_DOUBLE nTemp = 1; | 2728 FX_DOUBLE nTemp = 1; |
| 2729 for (int32_t j = 0; j <= i; j++) { | 2729 for (int32_t j = 0; j <= i; j++) { |
| 2730 nTemp *= 1 + nRate; | 2730 nTemp *= 1 + nRate; |
| 2731 } | 2731 } |
| 2732 FX_DOUBLE nNum = *(pData + iIndex++); | 2732 FX_DOUBLE nNum = *(pData + iIndex++); |
| 2733 nSum += nNum / nTemp; | 2733 nSum += nNum / nTemp; |
| 2734 } | 2734 } |
| 2735 FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); | 2735 FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); |
| 2736 FX_Free(pData); | 2736 FX_Free(pData); |
| 2737 pData = 0; | 2737 pData = 0; |
| 2738 } | 2738 } |
| 2739 } else { | 2739 } else { |
| 2740 FXJSE_Value_SetNull(args.GetReturnValue()); | 2740 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2741 } | 2741 } |
| 2742 for (int32_t i = 0; i < argc; i++) { | 2742 for (int32_t i = 0; i < argc; i++) { |
| 2743 FXJSE_Value_Release(argValues[i]); | 2743 FXJSE_Value_Release(argValues[i]); |
| 2744 } | 2744 } |
| 2745 FX_Free(argValues); | 2745 FX_Free(argValues); |
| 2746 } else { | 2746 } else { |
| 2747 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2747 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2748 L"NPV"); | 2748 L"NPV"); |
| 2749 } | 2749 } |
| 2750 } | 2750 } |
| 2751 void CXFA_FM2JSContext::Pmt(FXJSE_HOBJECT hThis, | 2751 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, |
| 2752 const CFX_ByteStringC& szFuncName, | 2752 const CFX_ByteStringC& szFuncName, |
| 2753 CFXJSE_Arguments& args) { | 2753 CFXJSE_Arguments& args) { |
| 2754 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2754 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2755 if (args.GetLength() == 3) { | 2755 if (args.GetLength() == 3) { |
| 2756 FX_BOOL bFlags = FALSE; | 2756 FX_BOOL bFlags = FALSE; |
| 2757 FX_FLOAT nPrincipal = 0; | 2757 FX_FLOAT nPrincipal = 0; |
| 2758 FX_FLOAT nRate = 0; | 2758 FX_FLOAT nRate = 0; |
| 2759 FX_FLOAT nPeriods = 0; | 2759 FX_FLOAT nPeriods = 0; |
| 2760 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2760 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2761 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2761 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2762 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2762 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2763 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2763 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2764 HValueIsNull(hThis, argThree)); | 2764 ValueIsNull(pThis, argThree)); |
| 2765 if (bFlags) { | 2765 if (bFlags) { |
| 2766 FXJSE_Value_SetNull(args.GetReturnValue()); | 2766 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2767 } else { | 2767 } else { |
| 2768 nPrincipal = HValueToFloat(hThis, argOne); | 2768 nPrincipal = ValueToFloat(pThis, argOne); |
| 2769 nRate = HValueToFloat(hThis, argTwo); | 2769 nRate = ValueToFloat(pThis, argTwo); |
| 2770 nPeriods = HValueToFloat(hThis, argThree); | 2770 nPeriods = ValueToFloat(pThis, argThree); |
| 2771 bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)); | 2771 bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)); |
| 2772 if (bFlags) { | 2772 if (bFlags) { |
| 2773 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2773 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2774 } else { | 2774 } else { |
| 2775 FX_FLOAT nSum = 0; | 2775 FX_FLOAT nSum = 0; |
| 2776 FX_FLOAT nTmp = 1 + nRate; | 2776 FX_FLOAT nTmp = 1 + nRate; |
| 2777 nSum = nTmp; | 2777 nSum = nTmp; |
| 2778 for (int32_t i = 0; i < nPeriods - 1; ++i) { | 2778 for (int32_t i = 0; i < nPeriods - 1; ++i) { |
| 2779 nSum *= nTmp; | 2779 nSum *= nTmp; |
| 2780 } | 2780 } |
| 2781 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2781 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2782 (nPrincipal * nRate * nSum) / (nSum - 1)); | 2782 (nPrincipal * nRate * nSum) / (nSum - 1)); |
| 2783 } | 2783 } |
| 2784 } | 2784 } |
| 2785 FXJSE_Value_Release(argOne); | 2785 FXJSE_Value_Release(argOne); |
| 2786 FXJSE_Value_Release(argTwo); | 2786 FXJSE_Value_Release(argTwo); |
| 2787 FXJSE_Value_Release(argThree); | 2787 FXJSE_Value_Release(argThree); |
| 2788 } else { | 2788 } else { |
| 2789 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2789 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2790 L"Pmt"); | 2790 L"Pmt"); |
| 2791 } | 2791 } |
| 2792 } | 2792 } |
| 2793 void CXFA_FM2JSContext::PPmt(FXJSE_HOBJECT hThis, | 2793 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, |
| 2794 const CFX_ByteStringC& szFuncName, | 2794 const CFX_ByteStringC& szFuncName, |
| 2795 CFXJSE_Arguments& args) { | 2795 CFXJSE_Arguments& args) { |
| 2796 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2796 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2797 if (args.GetLength() == 5) { | 2797 if (args.GetLength() == 5) { |
| 2798 FX_BOOL bFlags = FALSE; | 2798 FX_BOOL bFlags = FALSE; |
| 2799 FX_FLOAT nPrincpalAmount = 0; | 2799 FX_FLOAT nPrincpalAmount = 0; |
| 2800 FX_FLOAT nRate = 0; | 2800 FX_FLOAT nRate = 0; |
| 2801 FX_FLOAT nPayment = 0; | 2801 FX_FLOAT nPayment = 0; |
| 2802 FX_FLOAT nFirstMonth = 0; | 2802 FX_FLOAT nFirstMonth = 0; |
| 2803 FX_FLOAT nNumberOfMonths = 0; | 2803 FX_FLOAT nNumberOfMonths = 0; |
| 2804 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2804 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2805 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2805 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2806 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2806 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2807 FXJSE_HVALUE argFour = GetSimpleHValue(hThis, args, 3); | 2807 CFXJSE_Value* argFour = GetSimpleValue(pThis, args, 3); |
| 2808 FXJSE_HVALUE argFive = GetSimpleHValue(hThis, args, 4); | 2808 CFXJSE_Value* argFive = GetSimpleValue(pThis, args, 4); |
| 2809 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2809 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2810 HValueIsNull(hThis, argThree) || HValueIsNull(hThis, argFour) || | 2810 ValueIsNull(pThis, argThree) || ValueIsNull(pThis, argFour) || |
| 2811 HValueIsNull(hThis, argFive)); | 2811 ValueIsNull(pThis, argFive)); |
| 2812 if (bFlags) { | 2812 if (bFlags) { |
| 2813 FXJSE_Value_SetNull(args.GetReturnValue()); | 2813 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2814 } else { | 2814 } else { |
| 2815 nPrincpalAmount = HValueToFloat(hThis, argOne); | 2815 nPrincpalAmount = ValueToFloat(pThis, argOne); |
| 2816 nRate = HValueToFloat(hThis, argTwo); | 2816 nRate = ValueToFloat(pThis, argTwo); |
| 2817 nPayment = HValueToFloat(hThis, argThree); | 2817 nPayment = ValueToFloat(pThis, argThree); |
| 2818 nFirstMonth = HValueToFloat(hThis, argFour); | 2818 nFirstMonth = ValueToFloat(pThis, argFour); |
| 2819 nNumberOfMonths = HValueToFloat(hThis, argFive); | 2819 nNumberOfMonths = ValueToFloat(pThis, argFive); |
| 2820 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || | 2820 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || |
| 2821 (nFirstMonth < 0) || (nNumberOfMonths < 0)); | 2821 (nFirstMonth < 0) || (nNumberOfMonths < 0)); |
| 2822 if (bFlags) { | 2822 if (bFlags) { |
| 2823 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2823 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2824 } else { | 2824 } else { |
| 2825 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); | 2825 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); |
| 2826 FX_FLOAT nSum = 0; | 2826 FX_FLOAT nSum = 0; |
| 2827 FX_FLOAT nRateOfMonth = nRate / 12; | 2827 FX_FLOAT nRateOfMonth = nRate / 12; |
| 2828 int32_t iNums = | 2828 int32_t iNums = |
| 2829 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - | 2829 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2856 FXJSE_Value_Release(argOne); | 2856 FXJSE_Value_Release(argOne); |
| 2857 FXJSE_Value_Release(argTwo); | 2857 FXJSE_Value_Release(argTwo); |
| 2858 FXJSE_Value_Release(argThree); | 2858 FXJSE_Value_Release(argThree); |
| 2859 FXJSE_Value_Release(argFour); | 2859 FXJSE_Value_Release(argFour); |
| 2860 FXJSE_Value_Release(argFive); | 2860 FXJSE_Value_Release(argFive); |
| 2861 } else { | 2861 } else { |
| 2862 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2862 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2863 L"PPmt"); | 2863 L"PPmt"); |
| 2864 } | 2864 } |
| 2865 } | 2865 } |
| 2866 void CXFA_FM2JSContext::PV(FXJSE_HOBJECT hThis, | 2866 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, |
| 2867 const CFX_ByteStringC& szFuncName, | 2867 const CFX_ByteStringC& szFuncName, |
| 2868 CFXJSE_Arguments& args) { | 2868 CFXJSE_Arguments& args) { |
| 2869 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2869 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2870 if (args.GetLength() == 3) { | 2870 if (args.GetLength() == 3) { |
| 2871 FX_BOOL bFlags = FALSE; | 2871 FX_BOOL bFlags = FALSE; |
| 2872 FX_DOUBLE nAmount = 0; | 2872 FX_DOUBLE nAmount = 0; |
| 2873 FX_DOUBLE nRate = 0; | 2873 FX_DOUBLE nRate = 0; |
| 2874 FX_DOUBLE nPeriod = 0; | 2874 FX_DOUBLE nPeriod = 0; |
| 2875 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2875 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2876 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2876 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2877 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2877 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2878 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2878 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2879 HValueIsNull(hThis, argThree)); | 2879 ValueIsNull(pThis, argThree)); |
| 2880 if (bFlags) { | 2880 if (bFlags) { |
| 2881 FXJSE_Value_SetNull(args.GetReturnValue()); | 2881 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2882 } else { | 2882 } else { |
| 2883 nAmount = HValueToDouble(hThis, argOne); | 2883 nAmount = ValueToDouble(pThis, argOne); |
| 2884 nRate = HValueToDouble(hThis, argTwo); | 2884 nRate = ValueToDouble(pThis, argTwo); |
| 2885 nPeriod = HValueToDouble(hThis, argThree); | 2885 nPeriod = ValueToDouble(pThis, argThree); |
| 2886 bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)); | 2886 bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)); |
| 2887 if (bFlags) { | 2887 if (bFlags) { |
| 2888 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2888 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2889 } else { | 2889 } else { |
| 2890 FX_DOUBLE nTemp = 1; | 2890 FX_DOUBLE nTemp = 1; |
| 2891 for (int32_t i = 0; i < nPeriod; ++i) { | 2891 for (int32_t i = 0; i < nPeriod; ++i) { |
| 2892 nTemp *= 1 + nRate; | 2892 nTemp *= 1 + nRate; |
| 2893 } | 2893 } |
| 2894 nTemp = 1 / nTemp; | 2894 nTemp = 1 / nTemp; |
| 2895 FXJSE_Value_SetDouble(args.GetReturnValue(), | 2895 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 2896 nAmount * ((1 - nTemp) / nRate)); | 2896 nAmount * ((1 - nTemp) / nRate)); |
| 2897 } | 2897 } |
| 2898 } | 2898 } |
| 2899 FXJSE_Value_Release(argOne); | 2899 FXJSE_Value_Release(argOne); |
| 2900 FXJSE_Value_Release(argTwo); | 2900 FXJSE_Value_Release(argTwo); |
| 2901 FXJSE_Value_Release(argThree); | 2901 FXJSE_Value_Release(argThree); |
| 2902 } else { | 2902 } else { |
| 2903 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2903 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2904 L"PV"); | 2904 L"PV"); |
| 2905 } | 2905 } |
| 2906 } | 2906 } |
| 2907 void CXFA_FM2JSContext::Rate(FXJSE_HOBJECT hThis, | 2907 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, |
| 2908 const CFX_ByteStringC& szFuncName, | 2908 const CFX_ByteStringC& szFuncName, |
| 2909 CFXJSE_Arguments& args) { | 2909 CFXJSE_Arguments& args) { |
| 2910 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2910 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2911 if (args.GetLength() == 3) { | 2911 if (args.GetLength() == 3) { |
| 2912 FX_BOOL bFlags = FALSE; | 2912 FX_BOOL bFlags = FALSE; |
| 2913 FX_FLOAT nFuture = 0; | 2913 FX_FLOAT nFuture = 0; |
| 2914 FX_FLOAT nPresent = 0; | 2914 FX_FLOAT nPresent = 0; |
| 2915 FX_FLOAT nTotalNumber = 0; | 2915 FX_FLOAT nTotalNumber = 0; |
| 2916 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2916 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2917 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2917 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2918 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2918 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2919 bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || | 2919 bFlags = (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo) || |
| 2920 HValueIsNull(hThis, argThree)); | 2920 ValueIsNull(pThis, argThree)); |
| 2921 if (bFlags) { | 2921 if (bFlags) { |
| 2922 FXJSE_Value_SetNull(args.GetReturnValue()); | 2922 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2923 } else { | 2923 } else { |
| 2924 nFuture = HValueToFloat(hThis, argOne); | 2924 nFuture = ValueToFloat(pThis, argOne); |
| 2925 nPresent = HValueToFloat(hThis, argTwo); | 2925 nPresent = ValueToFloat(pThis, argTwo); |
| 2926 nTotalNumber = HValueToFloat(hThis, argThree); | 2926 nTotalNumber = ValueToFloat(pThis, argThree); |
| 2927 bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)); | 2927 bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)); |
| 2928 if (bFlags) { | 2928 if (bFlags) { |
| 2929 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2929 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2930 } else { | 2930 } else { |
| 2931 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2931 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2932 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), | 2932 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), |
| 2933 (FX_FLOAT)(1 / nTotalNumber)) - | 2933 (FX_FLOAT)(1 / nTotalNumber)) - |
| 2934 1)); | 2934 1)); |
| 2935 } | 2935 } |
| 2936 } | 2936 } |
| 2937 FXJSE_Value_Release(argOne); | 2937 FXJSE_Value_Release(argOne); |
| 2938 FXJSE_Value_Release(argTwo); | 2938 FXJSE_Value_Release(argTwo); |
| 2939 FXJSE_Value_Release(argThree); | 2939 FXJSE_Value_Release(argThree); |
| 2940 } else { | 2940 } else { |
| 2941 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2941 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2942 L"Rate"); | 2942 L"Rate"); |
| 2943 } | 2943 } |
| 2944 } | 2944 } |
| 2945 void CXFA_FM2JSContext::Term(FXJSE_HOBJECT hThis, | 2945 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, |
| 2946 const CFX_ByteStringC& szFuncName, | 2946 const CFX_ByteStringC& szFuncName, |
| 2947 CFXJSE_Arguments& args) { | 2947 CFXJSE_Arguments& args) { |
| 2948 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2948 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2949 if (args.GetLength() == 3) { | 2949 if (args.GetLength() == 3) { |
| 2950 FX_BOOL bFlags = FALSE; | 2950 FX_BOOL bFlags = FALSE; |
| 2951 FX_FLOAT nMount = 0; | 2951 FX_FLOAT nMount = 0; |
| 2952 FX_FLOAT nRate = 0; | 2952 FX_FLOAT nRate = 0; |
| 2953 FX_FLOAT nFuture = 0; | 2953 FX_FLOAT nFuture = 0; |
| 2954 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 2954 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 2955 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 2955 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 2956 FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); | 2956 CFXJSE_Value* argThree = GetSimpleValue(pThis, args, 2); |
| 2957 bFlags = (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo) || | 2957 bFlags = (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo) || |
| 2958 FXJSE_Value_IsNull(argThree)); | 2958 FXJSE_Value_IsNull(argThree)); |
| 2959 if (bFlags) { | 2959 if (bFlags) { |
| 2960 FXJSE_Value_SetNull(args.GetReturnValue()); | 2960 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2961 } else { | 2961 } else { |
| 2962 nMount = HValueToFloat(hThis, argOne); | 2962 nMount = ValueToFloat(pThis, argOne); |
| 2963 nRate = HValueToFloat(hThis, argTwo); | 2963 nRate = ValueToFloat(pThis, argTwo); |
| 2964 nFuture = HValueToFloat(hThis, argThree); | 2964 nFuture = ValueToFloat(pThis, argThree); |
| 2965 bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)); | 2965 bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)); |
| 2966 if (bFlags) { | 2966 if (bFlags) { |
| 2967 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2967 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2968 } else { | 2968 } else { |
| 2969 FXJSE_Value_SetFloat( | 2969 FXJSE_Value_SetFloat( |
| 2970 args.GetReturnValue(), | 2970 args.GetReturnValue(), |
| 2971 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / | 2971 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / |
| 2972 FXSYS_log((FX_FLOAT)(1 + nRate)))); | 2972 FXSYS_log((FX_FLOAT)(1 + nRate)))); |
| 2973 } | 2973 } |
| 2974 } | 2974 } |
| 2975 FXJSE_Value_Release(argOne); | 2975 FXJSE_Value_Release(argOne); |
| 2976 FXJSE_Value_Release(argTwo); | 2976 FXJSE_Value_Release(argTwo); |
| 2977 FXJSE_Value_Release(argThree); | 2977 FXJSE_Value_Release(argThree); |
| 2978 } else { | 2978 } else { |
| 2979 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2979 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2980 L"Term"); | 2980 L"Term"); |
| 2981 } | 2981 } |
| 2982 } | 2982 } |
| 2983 void CXFA_FM2JSContext::Choose(FXJSE_HOBJECT hThis, | 2983 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, |
| 2984 const CFX_ByteStringC& szFuncName, | 2984 const CFX_ByteStringC& szFuncName, |
| 2985 CFXJSE_Arguments& args) { | 2985 CFXJSE_Arguments& args) { |
| 2986 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 2986 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 2987 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 2987 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 2988 int32_t argc = args.GetLength(); | 2988 int32_t argc = args.GetLength(); |
| 2989 if (argc > 1) { | 2989 if (argc > 1) { |
| 2990 FXJSE_HVALUE argOne = args.GetValue(0); | 2990 CFXJSE_Value* argOne = args.GetValue(0); |
| 2991 FX_BOOL argOneIsNull = FALSE; | 2991 FX_BOOL argOneIsNull = FALSE; |
| 2992 int32_t iIndex = 0; | 2992 int32_t iIndex = 0; |
| 2993 argOneIsNull = HValueIsNull(hThis, argOne); | 2993 argOneIsNull = ValueIsNull(pThis, argOne); |
| 2994 if (!argOneIsNull) { | 2994 if (!argOneIsNull) { |
| 2995 iIndex = (int32_t)HValueToFloat(hThis, argOne); | 2995 iIndex = (int32_t)ValueToFloat(pThis, argOne); |
| 2996 } | 2996 } |
| 2997 FXJSE_Value_Release(argOne); | 2997 FXJSE_Value_Release(argOne); |
| 2998 if (argOneIsNull) { | 2998 if (argOneIsNull) { |
| 2999 FXJSE_Value_SetNull(args.GetReturnValue()); | 2999 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3000 } else if (iIndex < 1) { | 3000 } else if (iIndex < 1) { |
| 3001 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 3001 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 3002 } else { | 3002 } else { |
| 3003 FX_BOOL bFound = FALSE; | 3003 FX_BOOL bFound = FALSE; |
| 3004 FX_BOOL bStopCounterFlags = FALSE; | 3004 FX_BOOL bStopCounterFlags = FALSE; |
| 3005 int32_t iArgIndex = 1; | 3005 int32_t iArgIndex = 1; |
| 3006 int32_t iValueIndex = 0; | 3006 int32_t iValueIndex = 0; |
| 3007 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { | 3007 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { |
| 3008 FXJSE_HVALUE argIndexValue = args.GetValue(iArgIndex); | 3008 CFXJSE_Value* argIndexValue = args.GetValue(iArgIndex); |
| 3009 if (FXJSE_Value_IsArray(argIndexValue)) { | 3009 if (FXJSE_Value_IsArray(argIndexValue)) { |
| 3010 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 3010 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 3011 FXJSE_Value_GetObjectProp(argIndexValue, "length", lengthValue); | 3011 FXJSE_Value_GetObjectProp(argIndexValue, "length", lengthValue); |
| 3012 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 3012 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 3013 FXJSE_Value_Release(lengthValue); | 3013 FXJSE_Value_Release(lengthValue); |
| 3014 if (iLength > 3) { | 3014 if (iLength > 3) { |
| 3015 bStopCounterFlags = TRUE; | 3015 bStopCounterFlags = TRUE; |
| 3016 } | 3016 } |
| 3017 iValueIndex += (iLength - 2); | 3017 iValueIndex += (iLength - 2); |
| 3018 if (iValueIndex >= iIndex) { | 3018 if (iValueIndex >= iIndex) { |
| 3019 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 3019 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 3020 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 3020 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 3021 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 3021 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 3022 FXJSE_Value_GetObjectPropByIdx(argIndexValue, 1, propertyValue); | 3022 FXJSE_Value_GetObjectPropByIdx(argIndexValue, 1, propertyValue); |
| 3023 FXJSE_Value_GetObjectPropByIdx( | 3023 FXJSE_Value_GetObjectPropByIdx( |
| 3024 argIndexValue, ((iLength - 1) - (iValueIndex - iIndex)), | 3024 argIndexValue, ((iLength - 1) - (iValueIndex - iIndex)), |
| 3025 jsobjectValue); | 3025 jsobjectValue); |
| 3026 if (FXJSE_Value_IsNull(propertyValue)) { | 3026 if (FXJSE_Value_IsNull(propertyValue)) { |
| 3027 GetObjectDefaultValue(jsobjectValue, newProperty); | 3027 GetObjectDefaultValue(jsobjectValue, newProperty); |
| 3028 } else { | 3028 } else { |
| 3029 CFX_ByteString propStr; | 3029 CFX_ByteString propStr; |
| 3030 FXJSE_Value_ToUTF8String(propertyValue, propStr); | 3030 FXJSE_Value_ToUTF8String(propertyValue, propStr); |
| 3031 FXJSE_Value_GetObjectProp(jsobjectValue, propStr.AsStringC(), | 3031 FXJSE_Value_GetObjectProp(jsobjectValue, propStr.AsStringC(), |
| 3032 newProperty); | 3032 newProperty); |
| 3033 } | 3033 } |
| 3034 CFX_ByteString bsChoosed; | 3034 CFX_ByteString bsChoosed; |
| 3035 HValueToUTF8String(newProperty, bsChoosed); | 3035 ValueToUTF8String(newProperty, bsChoosed); |
| 3036 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 3036 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 3037 bsChoosed.AsStringC()); | 3037 bsChoosed.AsStringC()); |
| 3038 FXJSE_Value_Release(newProperty); | 3038 FXJSE_Value_Release(newProperty); |
| 3039 FXJSE_Value_Release(jsobjectValue); | 3039 FXJSE_Value_Release(jsobjectValue); |
| 3040 FXJSE_Value_Release(propertyValue); | 3040 FXJSE_Value_Release(propertyValue); |
| 3041 bFound = TRUE; | 3041 bFound = TRUE; |
| 3042 } | 3042 } |
| 3043 } else { | 3043 } else { |
| 3044 iValueIndex++; | 3044 iValueIndex++; |
| 3045 if (iValueIndex == iIndex) { | 3045 if (iValueIndex == iIndex) { |
| 3046 CFX_ByteString bsChoosed; | 3046 CFX_ByteString bsChoosed; |
| 3047 HValueToUTF8String(argIndexValue, bsChoosed); | 3047 ValueToUTF8String(argIndexValue, bsChoosed); |
| 3048 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 3048 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 3049 bsChoosed.AsStringC()); | 3049 bsChoosed.AsStringC()); |
| 3050 bFound = TRUE; | 3050 bFound = TRUE; |
| 3051 } | 3051 } |
| 3052 } | 3052 } |
| 3053 FXJSE_Value_Release(argIndexValue); | 3053 FXJSE_Value_Release(argIndexValue); |
| 3054 iArgIndex++; | 3054 iArgIndex++; |
| 3055 } | 3055 } |
| 3056 if (!bFound) { | 3056 if (!bFound) { |
| 3057 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 3057 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 3058 } | 3058 } |
| 3059 } | 3059 } |
| 3060 } else { | 3060 } else { |
| 3061 CXFA_FM2JSContext* pContext = | 3061 CXFA_FM2JSContext* pContext = |
| 3062 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3062 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3063 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3063 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3064 L"Choose"); | 3064 L"Choose"); |
| 3065 } | 3065 } |
| 3066 } | 3066 } |
| 3067 void CXFA_FM2JSContext::Exists(FXJSE_HOBJECT hThis, | 3067 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, |
| 3068 const CFX_ByteStringC& szFuncName, | 3068 const CFX_ByteStringC& szFuncName, |
| 3069 CFXJSE_Arguments& args) { | 3069 CFXJSE_Arguments& args) { |
| 3070 if (args.GetLength() == 1) { | 3070 if (args.GetLength() == 1) { |
| 3071 FXJSE_HVALUE argOne = args.GetValue(0); | 3071 CFXJSE_Value* argOne = args.GetValue(0); |
| 3072 FXJSE_Value_SetInteger(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); | 3072 FXJSE_Value_SetInteger(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); |
| 3073 FXJSE_Value_Release(argOne); | 3073 FXJSE_Value_Release(argOne); |
| 3074 } else { | 3074 } else { |
| 3075 CXFA_FM2JSContext* pContext = | 3075 CXFA_FM2JSContext* pContext = |
| 3076 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3076 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3077 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3077 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3078 L"Exists"); | 3078 L"Exists"); |
| 3079 } | 3079 } |
| 3080 } | 3080 } |
| 3081 void CXFA_FM2JSContext::HasValue(FXJSE_HOBJECT hThis, | 3081 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, |
| 3082 const CFX_ByteStringC& szFuncName, | 3082 const CFX_ByteStringC& szFuncName, |
| 3083 CFXJSE_Arguments& args) { | 3083 CFXJSE_Arguments& args) { |
| 3084 if (args.GetLength() == 1) { | 3084 if (args.GetLength() == 1) { |
| 3085 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3085 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3086 if (FXJSE_Value_IsUTF8String(argOne)) { | 3086 if (FXJSE_Value_IsUTF8String(argOne)) { |
| 3087 CFX_ByteString valueStr; | 3087 CFX_ByteString valueStr; |
| 3088 FXJSE_Value_ToUTF8String(argOne, valueStr); | 3088 FXJSE_Value_ToUTF8String(argOne, valueStr); |
| 3089 valueStr.TrimLeft(); | 3089 valueStr.TrimLeft(); |
| 3090 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); | 3090 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); |
| 3091 } else if (FXJSE_Value_IsNumber(argOne) || FXJSE_Value_IsBoolean(argOne)) { | 3091 } else if (FXJSE_Value_IsNumber(argOne) || FXJSE_Value_IsBoolean(argOne)) { |
| 3092 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); | 3092 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); |
| 3093 } else { | 3093 } else { |
| 3094 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); | 3094 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); |
| 3095 } | 3095 } |
| 3096 FXJSE_Value_Release(argOne); | 3096 FXJSE_Value_Release(argOne); |
| 3097 } else { | 3097 } else { |
| 3098 CXFA_FM2JSContext* pContext = | 3098 CXFA_FM2JSContext* pContext = |
| 3099 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3099 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3100 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3100 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3101 L"HasValue"); | 3101 L"HasValue"); |
| 3102 } | 3102 } |
| 3103 } | 3103 } |
| 3104 void CXFA_FM2JSContext::Oneof(FXJSE_HOBJECT hThis, | 3104 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, |
| 3105 const CFX_ByteStringC& szFuncName, | 3105 const CFX_ByteStringC& szFuncName, |
| 3106 CFXJSE_Arguments& args) { | 3106 CFXJSE_Arguments& args) { |
| 3107 int32_t argc = args.GetLength(); | 3107 int32_t argc = args.GetLength(); |
| 3108 if (argc > 1) { | 3108 if (argc > 1) { |
| 3109 FX_BOOL bFlags = FALSE; | 3109 FX_BOOL bFlags = FALSE; |
| 3110 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3110 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3111 FXJSE_HVALUE* parametersValue = 0; | 3111 CFXJSE_Value** parametersValue = nullptr; |
| 3112 int32_t iCount = 0; | 3112 int32_t iCount = 0; |
| 3113 unfoldArgs(hThis, args, parametersValue, iCount, 1); | 3113 unfoldArgs(pThis, args, parametersValue, iCount, 1); |
| 3114 for (int32_t i = 0; i < iCount; i++) { | 3114 for (int32_t i = 0; i < iCount; i++) { |
| 3115 if (simpleValueCompare(hThis, argOne, parametersValue[i])) { | 3115 if (simpleValueCompare(pThis, argOne, parametersValue[i])) { |
| 3116 bFlags = TRUE; | 3116 bFlags = TRUE; |
| 3117 break; | 3117 break; |
| 3118 } | 3118 } |
| 3119 } | 3119 } |
| 3120 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); | 3120 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); |
| 3121 FXJSE_Value_Release(argOne); | 3121 FXJSE_Value_Release(argOne); |
| 3122 for (int32_t i = 0; i < iCount; i++) { | 3122 for (int32_t i = 0; i < iCount; i++) { |
| 3123 FXJSE_Value_Release(parametersValue[i]); | 3123 FXJSE_Value_Release(parametersValue[i]); |
| 3124 } | 3124 } |
| 3125 FX_Free(parametersValue); | 3125 FX_Free(parametersValue); |
| 3126 parametersValue = 0; | 3126 parametersValue = 0; |
| 3127 } else { | 3127 } else { |
| 3128 CXFA_FM2JSContext* pContext = | 3128 CXFA_FM2JSContext* pContext = |
| 3129 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3129 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3130 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3130 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3131 L"Oneof"); | 3131 L"Oneof"); |
| 3132 } | 3132 } |
| 3133 } | 3133 } |
| 3134 void CXFA_FM2JSContext::Within(FXJSE_HOBJECT hThis, | 3134 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, |
| 3135 const CFX_ByteStringC& szFuncName, | 3135 const CFX_ByteStringC& szFuncName, |
| 3136 CFXJSE_Arguments& args) { | 3136 CFXJSE_Arguments& args) { |
| 3137 int32_t argc = args.GetLength(); | 3137 int32_t argc = args.GetLength(); |
| 3138 if (argc == 3) { | 3138 if (argc == 3) { |
| 3139 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3139 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3140 if (FXJSE_Value_IsNull(argOne)) { | 3140 if (FXJSE_Value_IsNull(argOne)) { |
| 3141 FXJSE_Value_SetUndefined(args.GetReturnValue()); | 3141 FXJSE_Value_SetUndefined(args.GetReturnValue()); |
| 3142 } else { | 3142 } else { |
| 3143 FXJSE_HVALUE argLow = GetSimpleHValue(hThis, args, 1); | 3143 CFXJSE_Value* argLow = GetSimpleValue(pThis, args, 1); |
| 3144 FXJSE_HVALUE argHeight = GetSimpleHValue(hThis, args, 2); | 3144 CFXJSE_Value* argHeight = GetSimpleValue(pThis, args, 2); |
| 3145 if (FXJSE_Value_IsNumber(argOne)) { | 3145 if (FXJSE_Value_IsNumber(argOne)) { |
| 3146 FX_FLOAT oneNumber = HValueToFloat(hThis, argOne); | 3146 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne); |
| 3147 FX_FLOAT lowNumber = HValueToFloat(hThis, argLow); | 3147 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow); |
| 3148 FX_FLOAT heightNumber = HValueToFloat(hThis, argHeight); | 3148 FX_FLOAT heightNumber = ValueToFloat(pThis, argHeight); |
| 3149 FXJSE_Value_SetInteger( | 3149 FXJSE_Value_SetInteger( |
| 3150 args.GetReturnValue(), | 3150 args.GetReturnValue(), |
| 3151 ((oneNumber >= lowNumber) && (oneNumber <= heightNumber))); | 3151 ((oneNumber >= lowNumber) && (oneNumber <= heightNumber))); |
| 3152 } else { | 3152 } else { |
| 3153 CFX_ByteString oneString; | 3153 CFX_ByteString oneString; |
| 3154 CFX_ByteString lowString; | 3154 CFX_ByteString lowString; |
| 3155 CFX_ByteString heightString; | 3155 CFX_ByteString heightString; |
| 3156 HValueToUTF8String(argOne, oneString); | 3156 ValueToUTF8String(argOne, oneString); |
| 3157 HValueToUTF8String(argLow, lowString); | 3157 ValueToUTF8String(argLow, lowString); |
| 3158 HValueToUTF8String(argHeight, heightString); | 3158 ValueToUTF8String(argHeight, heightString); |
| 3159 FXJSE_Value_SetInteger( | 3159 FXJSE_Value_SetInteger( |
| 3160 args.GetReturnValue(), | 3160 args.GetReturnValue(), |
| 3161 ((oneString.Compare(lowString.AsStringC()) >= 0) && | 3161 ((oneString.Compare(lowString.AsStringC()) >= 0) && |
| 3162 (oneString.Compare(heightString.AsStringC()) <= 0))); | 3162 (oneString.Compare(heightString.AsStringC()) <= 0))); |
| 3163 } | 3163 } |
| 3164 FXJSE_Value_Release(argLow); | 3164 FXJSE_Value_Release(argLow); |
| 3165 FXJSE_Value_Release(argHeight); | 3165 FXJSE_Value_Release(argHeight); |
| 3166 } | 3166 } |
| 3167 FXJSE_Value_Release(argOne); | 3167 FXJSE_Value_Release(argOne); |
| 3168 } else { | 3168 } else { |
| 3169 CXFA_FM2JSContext* pContext = | 3169 CXFA_FM2JSContext* pContext = |
| 3170 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3170 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3171 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3171 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3172 L"Within"); | 3172 L"Within"); |
| 3173 } | 3173 } |
| 3174 } | 3174 } |
| 3175 void CXFA_FM2JSContext::If(FXJSE_HOBJECT hThis, | 3175 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, |
| 3176 const CFX_ByteStringC& szFuncName, | 3176 const CFX_ByteStringC& szFuncName, |
| 3177 CFXJSE_Arguments& args) { | 3177 CFXJSE_Arguments& args) { |
| 3178 if (args.GetLength() == 3) { | 3178 if (args.GetLength() == 3) { |
| 3179 FXJSE_HVALUE argCondition = GetSimpleHValue(hThis, args, 0); | 3179 CFXJSE_Value* argCondition = GetSimpleValue(pThis, args, 0); |
| 3180 FXJSE_HVALUE argFirstValue = GetSimpleHValue(hThis, args, 1); | 3180 CFXJSE_Value* argFirstValue = GetSimpleValue(pThis, args, 1); |
| 3181 FXJSE_HVALUE argSecondValue = GetSimpleHValue(hThis, args, 2); | 3181 CFXJSE_Value* argSecondValue = GetSimpleValue(pThis, args, 2); |
| 3182 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition); | 3182 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition); |
| 3183 FXJSE_Value_Set(args.GetReturnValue(), | 3183 FXJSE_Value_Set(args.GetReturnValue(), |
| 3184 bCondition ? argFirstValue : argSecondValue); | 3184 bCondition ? argFirstValue : argSecondValue); |
| 3185 FXJSE_Value_Release(argSecondValue); | 3185 FXJSE_Value_Release(argSecondValue); |
| 3186 FXJSE_Value_Release(argFirstValue); | 3186 FXJSE_Value_Release(argFirstValue); |
| 3187 FXJSE_Value_Release(argCondition); | 3187 FXJSE_Value_Release(argCondition); |
| 3188 } else { | 3188 } else { |
| 3189 CXFA_FM2JSContext* pContext = | 3189 CXFA_FM2JSContext* pContext = |
| 3190 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3190 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3191 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3191 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3192 L"If"); | 3192 L"If"); |
| 3193 } | 3193 } |
| 3194 } | 3194 } |
| 3195 void CXFA_FM2JSContext::Eval(FXJSE_HOBJECT hThis, | 3195 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, |
| 3196 const CFX_ByteStringC& szFuncName, | 3196 const CFX_ByteStringC& szFuncName, |
| 3197 CFXJSE_Arguments& args) { | 3197 CFXJSE_Arguments& args) { |
| 3198 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3198 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3199 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3199 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3200 if (args.GetLength() == 1) { | 3200 if (args.GetLength() == 1) { |
| 3201 FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); | 3201 CFXJSE_Value* scriptValue = GetSimpleValue(pThis, args, 0); |
| 3202 CFX_ByteString utf8ScriptString; | 3202 CFX_ByteString utf8ScriptString; |
| 3203 HValueToUTF8String(scriptValue, utf8ScriptString); | 3203 ValueToUTF8String(scriptValue, utf8ScriptString); |
| 3204 if (utf8ScriptString.IsEmpty()) { | 3204 if (utf8ScriptString.IsEmpty()) { |
| 3205 FXJSE_Value_SetNull(args.GetReturnValue()); | 3205 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3206 } else { | 3206 } else { |
| 3207 CFX_WideTextBuf wsJavaScriptBuf; | 3207 CFX_WideTextBuf wsJavaScriptBuf; |
| 3208 CFX_WideString javaScript; | 3208 CFX_WideString javaScript; |
| 3209 CFX_WideString wsError; | 3209 CFX_WideString wsError; |
| 3210 XFA_FM2JS_Translate( | 3210 XFA_FM2JS_Translate( |
| 3211 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), | 3211 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), |
| 3212 wsJavaScriptBuf, wsError); | 3212 wsJavaScriptBuf, wsError); |
| 3213 CFXJSE_Context* pContext = FXJSE_Context_Create(pIsolate); | 3213 CFXJSE_Context* pContext = FXJSE_Context_Create(pIsolate); |
| 3214 FXJSE_HVALUE returnValue = FXJSE_Value_Create(pIsolate); | 3214 CFXJSE_Value* returnValue = FXJSE_Value_Create(pIsolate); |
| 3215 javaScript = wsJavaScriptBuf.AsStringC(); | 3215 javaScript = wsJavaScriptBuf.AsStringC(); |
| 3216 FXJSE_ExecuteScript( | 3216 FXJSE_ExecuteScript( |
| 3217 pContext, | 3217 pContext, |
| 3218 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), | 3218 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), |
| 3219 returnValue); | 3219 returnValue); |
| 3220 FXJSE_Value_Set(args.GetReturnValue(), returnValue); | 3220 FXJSE_Value_Set(args.GetReturnValue(), returnValue); |
| 3221 FXJSE_Value_Release(returnValue); | 3221 FXJSE_Value_Release(returnValue); |
| 3222 FXJSE_Context_Release(pContext); | 3222 FXJSE_Context_Release(pContext); |
| 3223 } | 3223 } |
| 3224 FXJSE_Value_Release(scriptValue); | 3224 FXJSE_Value_Release(scriptValue); |
| 3225 } else { | 3225 } else { |
| 3226 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3226 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3227 L"Eval"); | 3227 L"Eval"); |
| 3228 } | 3228 } |
| 3229 } | 3229 } |
| 3230 void CXFA_FM2JSContext::Ref(FXJSE_HOBJECT hThis, | 3230 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, |
| 3231 const CFX_ByteStringC& szFuncName, | 3231 const CFX_ByteStringC& szFuncName, |
| 3232 CFXJSE_Arguments& args) { | 3232 CFXJSE_Arguments& args) { |
| 3233 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3233 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3234 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3234 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3235 if (args.GetLength() == 1) { | 3235 if (args.GetLength() == 1) { |
| 3236 FXJSE_HVALUE argOne = args.GetValue(0); | 3236 CFXJSE_Value* argOne = args.GetValue(0); |
| 3237 if (FXJSE_Value_IsNull(argOne)) { | 3237 if (FXJSE_Value_IsNull(argOne)) { |
| 3238 FXJSE_HVALUE rgValues[3]; | 3238 CFXJSE_Value* rgValues[3]; |
| 3239 for (int32_t i = 0; i < 3; i++) { | 3239 for (int32_t i = 0; i < 3; i++) { |
| 3240 rgValues[i] = FXJSE_Value_Create(pIsolate); | 3240 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 3241 } | 3241 } |
| 3242 FXJSE_Value_SetInteger(rgValues[0], 4); | 3242 FXJSE_Value_SetInteger(rgValues[0], 4); |
| 3243 FXJSE_Value_SetNull(rgValues[1]); | 3243 FXJSE_Value_SetNull(rgValues[1]); |
| 3244 FXJSE_Value_SetNull(rgValues[2]); | 3244 FXJSE_Value_SetNull(rgValues[2]); |
| 3245 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 3245 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 3246 for (int32_t i = 0; i < 3; i++) { | 3246 for (int32_t i = 0; i < 3; i++) { |
| 3247 FXJSE_Value_Release(rgValues[i]); | 3247 FXJSE_Value_Release(rgValues[i]); |
| 3248 } | 3248 } |
| 3249 } else if (FXJSE_Value_IsArray(argOne)) { | 3249 } else if (FXJSE_Value_IsArray(argOne)) { |
| 3250 #ifndef NDEBUG | 3250 #ifndef NDEBUG |
| 3251 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 3251 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 3252 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 3252 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
| 3253 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); | 3253 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); |
| 3254 FXJSE_Value_Release(lengthValue); | 3254 FXJSE_Value_Release(lengthValue); |
| 3255 #endif | 3255 #endif |
| 3256 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 3256 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 3257 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 3257 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 3258 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 3258 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
| 3259 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); | 3259 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); |
| 3260 if (FXJSE_Value_IsNull(jsObjectValue)) { | 3260 if (FXJSE_Value_IsNull(jsObjectValue)) { |
| 3261 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3261 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 3262 } else if (FXJSE_Value_IsNull(propertyValue) && | 3262 } else if (FXJSE_Value_IsNull(propertyValue) && |
| 3263 (!FXJSE_Value_IsNull(jsObjectValue))) { | 3263 (!FXJSE_Value_IsNull(jsObjectValue))) { |
| 3264 FXJSE_HVALUE rgValues[3]; | 3264 CFXJSE_Value* rgValues[3]; |
| 3265 for (int32_t i = 0; i < 3; i++) { | 3265 for (int32_t i = 0; i < 3; i++) { |
| 3266 rgValues[i] = FXJSE_Value_Create(pIsolate); | 3266 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 3267 } | 3267 } |
| 3268 FXJSE_Value_SetInteger(rgValues[0], 3); | 3268 FXJSE_Value_SetInteger(rgValues[0], 3); |
| 3269 FXJSE_Value_SetNull(rgValues[1]); | 3269 FXJSE_Value_SetNull(rgValues[1]); |
| 3270 FXJSE_Value_Set(rgValues[2], jsObjectValue); | 3270 FXJSE_Value_Set(rgValues[2], jsObjectValue); |
| 3271 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 3271 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 3272 for (int32_t i = 0; i < 3; i++) { | 3272 for (int32_t i = 0; i < 3; i++) { |
| 3273 FXJSE_Value_Release(rgValues[i]); | 3273 FXJSE_Value_Release(rgValues[i]); |
| 3274 } | 3274 } |
| 3275 } else { | 3275 } else { |
| 3276 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3276 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 3277 } | 3277 } |
| 3278 FXJSE_Value_Release(jsObjectValue); | 3278 FXJSE_Value_Release(jsObjectValue); |
| 3279 FXJSE_Value_Release(propertyValue); | 3279 FXJSE_Value_Release(propertyValue); |
| 3280 } else if (FXJSE_Value_IsObject(argOne)) { | 3280 } else if (FXJSE_Value_IsObject(argOne)) { |
| 3281 FXJSE_HVALUE rgValues[3]; | 3281 CFXJSE_Value* rgValues[3]; |
| 3282 for (int32_t i = 0; i < 3; i++) { | 3282 for (int32_t i = 0; i < 3; i++) { |
| 3283 rgValues[i] = FXJSE_Value_Create(pIsolate); | 3283 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 3284 } | 3284 } |
| 3285 FXJSE_Value_SetInteger(rgValues[0], 3); | 3285 FXJSE_Value_SetInteger(rgValues[0], 3); |
| 3286 FXJSE_Value_SetNull(rgValues[1]); | 3286 FXJSE_Value_SetNull(rgValues[1]); |
| 3287 FXJSE_Value_Set(rgValues[2], argOne); | 3287 FXJSE_Value_Set(rgValues[2], argOne); |
| 3288 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 3288 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 3289 for (int32_t i = 0; i < 3; i++) { | 3289 for (int32_t i = 0; i < 3; i++) { |
| 3290 FXJSE_Value_Release(rgValues[i]); | 3290 FXJSE_Value_Release(rgValues[i]); |
| 3291 } | 3291 } |
| 3292 } else if (FXJSE_Value_IsBoolean(argOne) || | 3292 } else if (FXJSE_Value_IsBoolean(argOne) || |
| 3293 FXJSE_Value_IsUTF8String(argOne) || | 3293 FXJSE_Value_IsUTF8String(argOne) || |
| 3294 FXJSE_Value_IsNumber(argOne)) { | 3294 FXJSE_Value_IsNumber(argOne)) { |
| 3295 FXJSE_Value_Set(args.GetReturnValue(), argOne); | 3295 FXJSE_Value_Set(args.GetReturnValue(), argOne); |
| 3296 } else { | 3296 } else { |
| 3297 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3297 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 3298 } | 3298 } |
| 3299 FXJSE_Value_Release(argOne); | 3299 FXJSE_Value_Release(argOne); |
| 3300 } else { | 3300 } else { |
| 3301 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3301 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3302 L"Ref"); | 3302 L"Ref"); |
| 3303 } | 3303 } |
| 3304 } | 3304 } |
| 3305 void CXFA_FM2JSContext::UnitType(FXJSE_HOBJECT hThis, | 3305 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, |
| 3306 const CFX_ByteStringC& szFuncName, | 3306 const CFX_ByteStringC& szFuncName, |
| 3307 CFXJSE_Arguments& args) { | 3307 CFXJSE_Arguments& args) { |
| 3308 if (args.GetLength() == 1) { | 3308 if (args.GetLength() == 1) { |
| 3309 FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0); | 3309 CFXJSE_Value* unitspanValue = GetSimpleValue(pThis, args, 0); |
| 3310 if (FXJSE_Value_IsNull(unitspanValue)) { | 3310 if (FXJSE_Value_IsNull(unitspanValue)) { |
| 3311 FXJSE_Value_SetNull(args.GetReturnValue()); | 3311 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3312 FXJSE_Value_Release(unitspanValue); | 3312 FXJSE_Value_Release(unitspanValue); |
| 3313 return; | 3313 return; |
| 3314 } | 3314 } |
| 3315 CFX_ByteString unitspanString; | 3315 CFX_ByteString unitspanString; |
| 3316 HValueToUTF8String(unitspanValue, unitspanString); | 3316 ValueToUTF8String(unitspanValue, unitspanString); |
| 3317 if (unitspanString.IsEmpty()) { | 3317 if (unitspanString.IsEmpty()) { |
| 3318 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); | 3318 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); |
| 3319 } else { | 3319 } else { |
| 3320 enum XFA_FM2JS_VALUETYPE_ParserStatus { | 3320 enum XFA_FM2JS_VALUETYPE_ParserStatus { |
| 3321 VALUETYPE_START, | 3321 VALUETYPE_START, |
| 3322 VALUETYPE_HAVEINVALIDCHAR, | 3322 VALUETYPE_HAVEINVALIDCHAR, |
| 3323 VALUETYPE_HAVEDIGIT, | 3323 VALUETYPE_HAVEDIGIT, |
| 3324 VALUETYPE_HAVEDIGITWHITE, | 3324 VALUETYPE_HAVEDIGITWHITE, |
| 3325 VALUETYPE_ISCM, | 3325 VALUETYPE_ISCM, |
| 3326 VALUETYPE_ISMM, | 3326 VALUETYPE_ISMM, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3407 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); | 3407 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); |
| 3408 break; | 3408 break; |
| 3409 default: | 3409 default: |
| 3410 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); | 3410 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); |
| 3411 break; | 3411 break; |
| 3412 } | 3412 } |
| 3413 } | 3413 } |
| 3414 FXJSE_Value_Release(unitspanValue); | 3414 FXJSE_Value_Release(unitspanValue); |
| 3415 } else { | 3415 } else { |
| 3416 CXFA_FM2JSContext* pContext = | 3416 CXFA_FM2JSContext* pContext = |
| 3417 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3417 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3418 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3418 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3419 L"UnitType"); | 3419 L"UnitType"); |
| 3420 } | 3420 } |
| 3421 } | 3421 } |
| 3422 void CXFA_FM2JSContext::UnitValue(FXJSE_HOBJECT hThis, | 3422 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, |
| 3423 const CFX_ByteStringC& szFuncName, | 3423 const CFX_ByteStringC& szFuncName, |
| 3424 CFXJSE_Arguments& args) { | 3424 CFXJSE_Arguments& args) { |
| 3425 int32_t argc = args.GetLength(); | 3425 int32_t argc = args.GetLength(); |
| 3426 if ((argc == 1) || (argc == 2)) { | 3426 if ((argc == 1) || (argc == 2)) { |
| 3427 FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0); | 3427 CFXJSE_Value* unitspanValue = GetSimpleValue(pThis, args, 0); |
| 3428 FXJSE_HVALUE unitValue = 0; | 3428 CFXJSE_Value* unitValue = nullptr; |
| 3429 CFX_ByteString unitspanString; | 3429 CFX_ByteString unitspanString; |
| 3430 FX_DOUBLE dFirstNumber = 0; | 3430 FX_DOUBLE dFirstNumber = 0; |
| 3431 CFX_ByteString strFirstUnit; | 3431 CFX_ByteString strFirstUnit; |
| 3432 CFX_ByteString strUnit; | 3432 CFX_ByteString strUnit; |
| 3433 if (FXJSE_Value_IsNull(unitspanValue)) { | 3433 if (FXJSE_Value_IsNull(unitspanValue)) { |
| 3434 FXJSE_Value_SetNull(args.GetReturnValue()); | 3434 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3435 } else { | 3435 } else { |
| 3436 HValueToUTF8String(unitspanValue, unitspanString); | 3436 ValueToUTF8String(unitspanValue, unitspanString); |
| 3437 const FX_CHAR* pData = unitspanString.c_str(); | 3437 const FX_CHAR* pData = unitspanString.c_str(); |
| 3438 if (pData) { | 3438 if (pData) { |
| 3439 int32_t u = 0; | 3439 int32_t u = 0; |
| 3440 while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || | 3440 while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || |
| 3441 *(pData + u) == 0x0B || *(pData + u) == 0x0C || | 3441 *(pData + u) == 0x0B || *(pData + u) == 0x0C || |
| 3442 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3442 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { |
| 3443 ++u; | 3443 ++u; |
| 3444 } | 3444 } |
| 3445 while (u < unitspanString.GetLength()) { | 3445 while (u < unitspanString.GetLength()) { |
| 3446 if ((*(pData + u) > '9' || *(pData + u) < '0') && | 3446 if ((*(pData + u) > '9' || *(pData + u) < '0') && |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3459 int32_t uLen = unitspanString.GetLength(); | 3459 int32_t uLen = unitspanString.GetLength(); |
| 3460 while (u < uLen) { | 3460 while (u < uLen) { |
| 3461 if (*(pData + u) == ' ') { | 3461 if (*(pData + u) == ' ') { |
| 3462 break; | 3462 break; |
| 3463 } | 3463 } |
| 3464 strFirstUnit += (*(pData + u)); | 3464 strFirstUnit += (*(pData + u)); |
| 3465 ++u; | 3465 ++u; |
| 3466 } | 3466 } |
| 3467 strFirstUnit.MakeLower(); | 3467 strFirstUnit.MakeLower(); |
| 3468 if (argc == 2) { | 3468 if (argc == 2) { |
| 3469 unitValue = GetSimpleHValue(hThis, args, 1); | 3469 unitValue = GetSimpleValue(pThis, args, 1); |
| 3470 CFX_ByteString unitTempString; | 3470 CFX_ByteString unitTempString; |
| 3471 HValueToUTF8String(unitValue, unitTempString); | 3471 ValueToUTF8String(unitValue, unitTempString); |
| 3472 const FX_CHAR* pData = unitTempString.c_str(); | 3472 const FX_CHAR* pData = unitTempString.c_str(); |
| 3473 int32_t u = 0; | 3473 int32_t u = 0; |
| 3474 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || | 3474 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || |
| 3475 *(pData + u) == 0x0B || *(pData + u) == 0x0C || | 3475 *(pData + u) == 0x0B || *(pData + u) == 0x0C || |
| 3476 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3476 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { |
| 3477 ++u; | 3477 ++u; |
| 3478 } | 3478 } |
| 3479 while (u < unitTempString.GetLength()) { | 3479 while (u < unitTempString.GetLength()) { |
| 3480 if ((*(pData + u) > '9' || *(pData + u) < '0') && | 3480 if ((*(pData + u) > '9' || *(pData + u) < '0') && |
| 3481 *(pData + u) != '.') { | 3481 *(pData + u) != '.') { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3566 } else { | 3566 } else { |
| 3567 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 3567 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 3568 } | 3568 } |
| 3569 } | 3569 } |
| 3570 FXJSE_Value_Release(unitspanValue); | 3570 FXJSE_Value_Release(unitspanValue); |
| 3571 if (argc == 2) { | 3571 if (argc == 2) { |
| 3572 FXJSE_Value_Release(unitValue); | 3572 FXJSE_Value_Release(unitValue); |
| 3573 } | 3573 } |
| 3574 } else { | 3574 } else { |
| 3575 CXFA_FM2JSContext* pContext = | 3575 CXFA_FM2JSContext* pContext = |
| 3576 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3576 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3577 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3577 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3578 L"UnitValue"); | 3578 L"UnitValue"); |
| 3579 } | 3579 } |
| 3580 } | 3580 } |
| 3581 void CXFA_FM2JSContext::At(FXJSE_HOBJECT hThis, | 3581 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, |
| 3582 const CFX_ByteStringC& szFuncName, | 3582 const CFX_ByteStringC& szFuncName, |
| 3583 CFXJSE_Arguments& args) { | 3583 CFXJSE_Arguments& args) { |
| 3584 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3584 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3585 if (args.GetLength() == 2) { | 3585 if (args.GetLength() == 2) { |
| 3586 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3586 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3587 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 3587 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 3588 if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { | 3588 if (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo)) { |
| 3589 FXJSE_Value_SetNull(args.GetReturnValue()); | 3589 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3590 } else { | 3590 } else { |
| 3591 CFX_ByteString stringTwo; | 3591 CFX_ByteString stringTwo; |
| 3592 HValueToUTF8String(argTwo, stringTwo); | 3592 ValueToUTF8String(argTwo, stringTwo); |
| 3593 if (stringTwo.IsEmpty()) { | 3593 if (stringTwo.IsEmpty()) { |
| 3594 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 3594 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
| 3595 } else { | 3595 } else { |
| 3596 CFX_ByteString stringOne; | 3596 CFX_ByteString stringOne; |
| 3597 HValueToUTF8String(argOne, stringOne); | 3597 ValueToUTF8String(argOne, stringOne); |
| 3598 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); | 3598 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); |
| 3599 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); | 3599 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); |
| 3600 } | 3600 } |
| 3601 } | 3601 } |
| 3602 FXJSE_Value_Release(argOne); | 3602 FXJSE_Value_Release(argOne); |
| 3603 FXJSE_Value_Release(argTwo); | 3603 FXJSE_Value_Release(argTwo); |
| 3604 } else { | 3604 } else { |
| 3605 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3605 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3606 L"At"); | 3606 L"At"); |
| 3607 } | 3607 } |
| 3608 } | 3608 } |
| 3609 void CXFA_FM2JSContext::Concat(FXJSE_HOBJECT hThis, | 3609 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, |
| 3610 const CFX_ByteStringC& szFuncName, | 3610 const CFX_ByteStringC& szFuncName, |
| 3611 CFXJSE_Arguments& args) { | 3611 CFXJSE_Arguments& args) { |
| 3612 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3612 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3613 int32_t argc = args.GetLength(); | 3613 int32_t argc = args.GetLength(); |
| 3614 if (argc >= 1) { | 3614 if (argc >= 1) { |
| 3615 CFX_ByteString resultString; | 3615 CFX_ByteString resultString; |
| 3616 FX_BOOL bAllNull = TRUE; | 3616 FX_BOOL bAllNull = TRUE; |
| 3617 FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argc); | 3617 CFXJSE_Value** argValues = FX_Alloc(CFXJSE_Value*, argc); |
| 3618 for (int32_t i = 0; i < argc; i++) { | 3618 for (int32_t i = 0; i < argc; i++) { |
| 3619 argValues[i] = GetSimpleHValue(hThis, args, i); | 3619 argValues[i] = GetSimpleValue(pThis, args, i); |
| 3620 if (!HValueIsNull(hThis, argValues[i])) { | 3620 if (!ValueIsNull(pThis, argValues[i])) { |
| 3621 CFX_ByteString valueStr; | 3621 CFX_ByteString valueStr; |
| 3622 HValueToUTF8String(argValues[i], valueStr); | 3622 ValueToUTF8String(argValues[i], valueStr); |
| 3623 resultString += valueStr; | 3623 resultString += valueStr; |
| 3624 bAllNull = FALSE; | 3624 bAllNull = FALSE; |
| 3625 } | 3625 } |
| 3626 } | 3626 } |
| 3627 for (int32_t i = 0; i < argc; i++) { | 3627 for (int32_t i = 0; i < argc; i++) { |
| 3628 FXJSE_Value_Release(argValues[i]); | 3628 FXJSE_Value_Release(argValues[i]); |
| 3629 } | 3629 } |
| 3630 FX_Free(argValues); | 3630 FX_Free(argValues); |
| 3631 if (bAllNull) { | 3631 if (bAllNull) { |
| 3632 FXJSE_Value_SetNull(args.GetReturnValue()); | 3632 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3633 } else { | 3633 } else { |
| 3634 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 3634 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 3635 resultString.AsStringC()); | 3635 resultString.AsStringC()); |
| 3636 } | 3636 } |
| 3637 } else { | 3637 } else { |
| 3638 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3638 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3639 L"Concat"); | 3639 L"Concat"); |
| 3640 } | 3640 } |
| 3641 } | 3641 } |
| 3642 void CXFA_FM2JSContext::Decode(FXJSE_HOBJECT hThis, | 3642 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, |
| 3643 const CFX_ByteStringC& szFuncName, | 3643 const CFX_ByteStringC& szFuncName, |
| 3644 CFXJSE_Arguments& args) { | 3644 CFXJSE_Arguments& args) { |
| 3645 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3645 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3646 int32_t argc = args.GetLength(); | 3646 int32_t argc = args.GetLength(); |
| 3647 if (argc == 1) { | 3647 if (argc == 1) { |
| 3648 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3648 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3649 if (HValueIsNull(hThis, argOne)) { | 3649 if (ValueIsNull(pThis, argOne)) { |
| 3650 FXJSE_Value_SetNull(args.GetReturnValue()); | 3650 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3651 } else { | 3651 } else { |
| 3652 CFX_ByteString toDecodeString; | 3652 CFX_ByteString toDecodeString; |
| 3653 HValueToUTF8String(argOne, toDecodeString); | 3653 ValueToUTF8String(argOne, toDecodeString); |
| 3654 CFX_ByteTextBuf resultBuf; | 3654 CFX_ByteTextBuf resultBuf; |
| 3655 DecodeURL(toDecodeString.AsStringC(), resultBuf); | 3655 DecodeURL(toDecodeString.AsStringC(), resultBuf); |
| 3656 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3656 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3657 } | 3657 } |
| 3658 FXJSE_Value_Release(argOne); | 3658 FXJSE_Value_Release(argOne); |
| 3659 } else if (argc == 2) { | 3659 } else if (argc == 2) { |
| 3660 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3660 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3661 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 3661 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 3662 if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { | 3662 if (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo)) { |
| 3663 FXJSE_Value_SetNull(args.GetReturnValue()); | 3663 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3664 } else { | 3664 } else { |
| 3665 CFX_ByteString toDecodeString; | 3665 CFX_ByteString toDecodeString; |
| 3666 HValueToUTF8String(argOne, toDecodeString); | 3666 ValueToUTF8String(argOne, toDecodeString); |
| 3667 CFX_ByteString identifyString; | 3667 CFX_ByteString identifyString; |
| 3668 HValueToUTF8String(argTwo, identifyString); | 3668 ValueToUTF8String(argTwo, identifyString); |
| 3669 CFX_ByteTextBuf resultBuf; | 3669 CFX_ByteTextBuf resultBuf; |
| 3670 if (identifyString.EqualNoCase("html")) { | 3670 if (identifyString.EqualNoCase("html")) { |
| 3671 DecodeHTML(toDecodeString.AsStringC(), resultBuf); | 3671 DecodeHTML(toDecodeString.AsStringC(), resultBuf); |
| 3672 } else if (identifyString.EqualNoCase("xml")) { | 3672 } else if (identifyString.EqualNoCase("xml")) { |
| 3673 DecodeXML(toDecodeString.AsStringC(), resultBuf); | 3673 DecodeXML(toDecodeString.AsStringC(), resultBuf); |
| 3674 } else { | 3674 } else { |
| 3675 DecodeURL(toDecodeString.AsStringC(), resultBuf); | 3675 DecodeURL(toDecodeString.AsStringC(), resultBuf); |
| 3676 } | 3676 } |
| 3677 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3677 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3678 } | 3678 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3902 iStrIndex = 0; | 3902 iStrIndex = 0; |
| 3903 strString[iStrIndex] = 0; | 3903 strString[iStrIndex] = 0; |
| 3904 ++i; | 3904 ++i; |
| 3905 iCode = 0; | 3905 iCode = 0; |
| 3906 } | 3906 } |
| 3907 wsXMLBuf.AppendChar(0); | 3907 wsXMLBuf.AppendChar(0); |
| 3908 szResultString.Clear(); | 3908 szResultString.Clear(); |
| 3909 szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()) | 3909 szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()) |
| 3910 .AsStringC(); | 3910 .AsStringC(); |
| 3911 } | 3911 } |
| 3912 void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis, | 3912 void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis, |
| 3913 const CFX_ByteStringC& szFuncName, | 3913 const CFX_ByteStringC& szFuncName, |
| 3914 CFXJSE_Arguments& args) { | 3914 CFXJSE_Arguments& args) { |
| 3915 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 3915 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 3916 int32_t argc = args.GetLength(); | 3916 int32_t argc = args.GetLength(); |
| 3917 if (argc == 1) { | 3917 if (argc == 1) { |
| 3918 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3918 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3919 if (HValueIsNull(hThis, argOne)) { | 3919 if (ValueIsNull(pThis, argOne)) { |
| 3920 FXJSE_Value_SetNull(args.GetReturnValue()); | 3920 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3921 } else { | 3921 } else { |
| 3922 CFX_ByteString toEncodeString; | 3922 CFX_ByteString toEncodeString; |
| 3923 HValueToUTF8String(argOne, toEncodeString); | 3923 ValueToUTF8String(argOne, toEncodeString); |
| 3924 CFX_ByteTextBuf resultBuf; | 3924 CFX_ByteTextBuf resultBuf; |
| 3925 EncodeURL(toEncodeString.AsStringC(), resultBuf); | 3925 EncodeURL(toEncodeString.AsStringC(), resultBuf); |
| 3926 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3926 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3927 } | 3927 } |
| 3928 FXJSE_Value_Release(argOne); | 3928 FXJSE_Value_Release(argOne); |
| 3929 } else if (argc == 2) { | 3929 } else if (argc == 2) { |
| 3930 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 3930 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 3931 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 3931 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 3932 if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { | 3932 if (ValueIsNull(pThis, argOne) || ValueIsNull(pThis, argTwo)) { |
| 3933 FXJSE_Value_SetNull(args.GetReturnValue()); | 3933 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3934 } else { | 3934 } else { |
| 3935 CFX_ByteString toEncodeString; | 3935 CFX_ByteString toEncodeString; |
| 3936 HValueToUTF8String(argOne, toEncodeString); | 3936 ValueToUTF8String(argOne, toEncodeString); |
| 3937 CFX_ByteString identifyString; | 3937 CFX_ByteString identifyString; |
| 3938 HValueToUTF8String(argTwo, identifyString); | 3938 ValueToUTF8String(argTwo, identifyString); |
| 3939 CFX_ByteTextBuf resultBuf; | 3939 CFX_ByteTextBuf resultBuf; |
| 3940 if (identifyString.EqualNoCase("html")) { | 3940 if (identifyString.EqualNoCase("html")) { |
| 3941 EncodeHTML(toEncodeString.AsStringC(), resultBuf); | 3941 EncodeHTML(toEncodeString.AsStringC(), resultBuf); |
| 3942 } else if (identifyString.EqualNoCase("xml")) { | 3942 } else if (identifyString.EqualNoCase("xml")) { |
| 3943 EncodeXML(toEncodeString.AsStringC(), resultBuf); | 3943 EncodeXML(toEncodeString.AsStringC(), resultBuf); |
| 3944 } else { | 3944 } else { |
| 3945 EncodeURL(toEncodeString.AsStringC(), resultBuf); | 3945 EncodeURL(toEncodeString.AsStringC(), resultBuf); |
| 3946 } | 3946 } |
| 3947 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3947 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3948 } | 3948 } |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4312 break; | 4312 break; |
| 4313 } | 4313 } |
| 4314 } | 4314 } |
| 4315 iIndex++; | 4315 iIndex++; |
| 4316 } | 4316 } |
| 4317 if (patternType == XFA_VT_NULL) { | 4317 if (patternType == XFA_VT_NULL) { |
| 4318 patternType = XFA_VT_TEXT | XFA_VT_FLOAT; | 4318 patternType = XFA_VT_TEXT | XFA_VT_FLOAT; |
| 4319 } | 4319 } |
| 4320 return FALSE; | 4320 return FALSE; |
| 4321 } | 4321 } |
| 4322 void CXFA_FM2JSContext::Format(FXJSE_HOBJECT hThis, | 4322 void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis, |
| 4323 const CFX_ByteStringC& szFuncName, | 4323 const CFX_ByteStringC& szFuncName, |
| 4324 CFXJSE_Arguments& args) { | 4324 CFXJSE_Arguments& args) { |
| 4325 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4325 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4326 int32_t argc = args.GetLength(); | 4326 int32_t argc = args.GetLength(); |
| 4327 if (argc >= 2) { | 4327 if (argc >= 2) { |
| 4328 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4328 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4329 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4329 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4330 CFX_ByteString szPattern; | 4330 CFX_ByteString szPattern; |
| 4331 HValueToUTF8String(argOne, szPattern); | 4331 ValueToUTF8String(argOne, szPattern); |
| 4332 CFX_ByteString szValue; | 4332 CFX_ByteString szValue; |
| 4333 HValueToUTF8String(argTwo, szValue); | 4333 ValueToUTF8String(argTwo, szValue); |
| 4334 CXFA_Document* pDoc = pContext->GetDocument(); | 4334 CXFA_Document* pDoc = pContext->GetDocument(); |
| 4335 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4335 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 4336 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4336 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 4337 ASSERT(pThisNode); | 4337 ASSERT(pThisNode); |
| 4338 CXFA_WidgetData widgetData(pThisNode); | 4338 CXFA_WidgetData widgetData(pThisNode); |
| 4339 IFX_Locale* pLocale = widgetData.GetLocal(); | 4339 IFX_Locale* pLocale = widgetData.GetLocal(); |
| 4340 uint32_t patternType; | 4340 uint32_t patternType; |
| 4341 FX_BOOL bCompelte = | 4341 FX_BOOL bCompelte = |
| 4342 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); | 4342 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); |
| 4343 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern.AsStringC()); | 4343 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern.AsStringC()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4399 } else { | 4399 } else { |
| 4400 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4400 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 4401 } | 4401 } |
| 4402 FXJSE_Value_Release(argOne); | 4402 FXJSE_Value_Release(argOne); |
| 4403 FXJSE_Value_Release(argTwo); | 4403 FXJSE_Value_Release(argTwo); |
| 4404 } else { | 4404 } else { |
| 4405 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4405 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4406 L"Format"); | 4406 L"Format"); |
| 4407 } | 4407 } |
| 4408 } | 4408 } |
| 4409 void CXFA_FM2JSContext::Left(FXJSE_HOBJECT hThis, | 4409 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, |
| 4410 const CFX_ByteStringC& szFuncName, | 4410 const CFX_ByteStringC& szFuncName, |
| 4411 CFXJSE_Arguments& args) { | 4411 CFXJSE_Arguments& args) { |
| 4412 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4412 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4413 if (args.GetLength() == 2) { | 4413 if (args.GetLength() == 2) { |
| 4414 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4414 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4415 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4415 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4416 FX_BOOL argIsNull = FALSE; | 4416 FX_BOOL argIsNull = FALSE; |
| 4417 if ((HValueIsNull(hThis, argOne)) || (HValueIsNull(hThis, argTwo))) { | 4417 if ((ValueIsNull(pThis, argOne)) || (ValueIsNull(pThis, argTwo))) { |
| 4418 argIsNull = TRUE; | 4418 argIsNull = TRUE; |
| 4419 } | 4419 } |
| 4420 if (argIsNull) { | 4420 if (argIsNull) { |
| 4421 FXJSE_Value_SetNull(args.GetReturnValue()); | 4421 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4422 } else { | 4422 } else { |
| 4423 CFX_ByteString sourceString; | 4423 CFX_ByteString sourceString; |
| 4424 HValueToUTF8String(argOne, sourceString); | 4424 ValueToUTF8String(argOne, sourceString); |
| 4425 int32_t count = HValueToInteger(hThis, argTwo); | 4425 int32_t count = ValueToInteger(pThis, argTwo); |
| 4426 if (count < 0) { | 4426 if (count < 0) { |
| 4427 count = 0; | 4427 count = 0; |
| 4428 } | 4428 } |
| 4429 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4429 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4430 sourceString.Left(count).AsStringC()); | 4430 sourceString.Left(count).AsStringC()); |
| 4431 } | 4431 } |
| 4432 FXJSE_Value_Release(argOne); | 4432 FXJSE_Value_Release(argOne); |
| 4433 FXJSE_Value_Release(argTwo); | 4433 FXJSE_Value_Release(argTwo); |
| 4434 } else { | 4434 } else { |
| 4435 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4435 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4436 L"Left"); | 4436 L"Left"); |
| 4437 } | 4437 } |
| 4438 } | 4438 } |
| 4439 void CXFA_FM2JSContext::Len(FXJSE_HOBJECT hThis, | 4439 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, |
| 4440 const CFX_ByteStringC& szFuncName, | 4440 const CFX_ByteStringC& szFuncName, |
| 4441 CFXJSE_Arguments& args) { | 4441 CFXJSE_Arguments& args) { |
| 4442 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4442 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4443 if (args.GetLength() == 1) { | 4443 if (args.GetLength() == 1) { |
| 4444 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4444 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4445 if (HValueIsNull(hThis, argOne)) { | 4445 if (ValueIsNull(pThis, argOne)) { |
| 4446 FXJSE_Value_SetNull(args.GetReturnValue()); | 4446 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4447 } else { | 4447 } else { |
| 4448 CFX_ByteString sourceString; | 4448 CFX_ByteString sourceString; |
| 4449 HValueToUTF8String(argOne, sourceString); | 4449 ValueToUTF8String(argOne, sourceString); |
| 4450 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); | 4450 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); |
| 4451 } | 4451 } |
| 4452 FXJSE_Value_Release(argOne); | 4452 FXJSE_Value_Release(argOne); |
| 4453 } else { | 4453 } else { |
| 4454 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4454 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4455 L"Len"); | 4455 L"Len"); |
| 4456 } | 4456 } |
| 4457 } | 4457 } |
| 4458 void CXFA_FM2JSContext::Lower(FXJSE_HOBJECT hThis, | 4458 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, |
| 4459 const CFX_ByteStringC& szFuncName, | 4459 const CFX_ByteStringC& szFuncName, |
| 4460 CFXJSE_Arguments& args) { | 4460 CFXJSE_Arguments& args) { |
| 4461 int32_t argc = args.GetLength(); | 4461 int32_t argc = args.GetLength(); |
| 4462 if ((argc > 0) && (argc < 3)) { | 4462 if ((argc > 0) && (argc < 3)) { |
| 4463 CFX_ByteString argString; | 4463 CFX_ByteString argString; |
| 4464 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4464 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4465 FXJSE_HVALUE localeValue = 0; | 4465 CFXJSE_Value* localeValue = nullptr; |
| 4466 if (HValueIsNull(hThis, argOne)) { | 4466 if (ValueIsNull(pThis, argOne)) { |
| 4467 FXJSE_Value_SetNull(args.GetReturnValue()); | 4467 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4468 } else { | 4468 } else { |
| 4469 if (argc == 2) { | 4469 if (argc == 2) { |
| 4470 localeValue = GetSimpleHValue(hThis, args, 1); | 4470 localeValue = GetSimpleValue(pThis, args, 1); |
| 4471 } | 4471 } |
| 4472 HValueToUTF8String(argOne, argString); | 4472 ValueToUTF8String(argOne, argString); |
| 4473 CFX_WideTextBuf lowStringBuf; | 4473 CFX_WideTextBuf lowStringBuf; |
| 4474 CFX_WideString wsArgString = | 4474 CFX_WideString wsArgString = |
| 4475 CFX_WideString::FromUTF8(argString.AsStringC()); | 4475 CFX_WideString::FromUTF8(argString.AsStringC()); |
| 4476 const FX_WCHAR* pData = wsArgString.c_str(); | 4476 const FX_WCHAR* pData = wsArgString.c_str(); |
| 4477 int32_t iLen = argString.GetLength(); | 4477 int32_t iLen = argString.GetLength(); |
| 4478 int32_t i = 0; | 4478 int32_t i = 0; |
| 4479 int32_t ch = 0; | 4479 int32_t ch = 0; |
| 4480 while (i < iLen) { | 4480 while (i < iLen) { |
| 4481 ch = *(pData + i); | 4481 ch = *(pData + i); |
| 4482 if (ch >= 0x41 && ch <= 0x5A) { | 4482 if (ch >= 0x41 && ch <= 0x5A) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4494 args.GetReturnValue(), | 4494 args.GetReturnValue(), |
| 4495 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) | 4495 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) |
| 4496 .AsStringC()); | 4496 .AsStringC()); |
| 4497 if (argc == 2) { | 4497 if (argc == 2) { |
| 4498 FXJSE_Value_Release(localeValue); | 4498 FXJSE_Value_Release(localeValue); |
| 4499 } | 4499 } |
| 4500 } | 4500 } |
| 4501 FXJSE_Value_Release(argOne); | 4501 FXJSE_Value_Release(argOne); |
| 4502 } else { | 4502 } else { |
| 4503 CXFA_FM2JSContext* pContext = | 4503 CXFA_FM2JSContext* pContext = |
| 4504 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4504 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4505 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4505 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4506 L"Lower"); | 4506 L"Lower"); |
| 4507 } | 4507 } |
| 4508 } | 4508 } |
| 4509 void CXFA_FM2JSContext::Ltrim(FXJSE_HOBJECT hThis, | 4509 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, |
| 4510 const CFX_ByteStringC& szFuncName, | 4510 const CFX_ByteStringC& szFuncName, |
| 4511 CFXJSE_Arguments& args) { | 4511 CFXJSE_Arguments& args) { |
| 4512 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4512 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4513 if (args.GetLength() == 1) { | 4513 if (args.GetLength() == 1) { |
| 4514 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4514 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4515 if (HValueIsNull(hThis, argOne)) { | 4515 if (ValueIsNull(pThis, argOne)) { |
| 4516 FXJSE_Value_SetNull(args.GetReturnValue()); | 4516 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4517 } else { | 4517 } else { |
| 4518 CFX_ByteString sourceString; | 4518 CFX_ByteString sourceString; |
| 4519 HValueToUTF8String(argOne, sourceString); | 4519 ValueToUTF8String(argOne, sourceString); |
| 4520 sourceString.TrimLeft(); | 4520 sourceString.TrimLeft(); |
| 4521 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4521 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4522 sourceString.AsStringC()); | 4522 sourceString.AsStringC()); |
| 4523 } | 4523 } |
| 4524 FXJSE_Value_Release(argOne); | 4524 FXJSE_Value_Release(argOne); |
| 4525 } else { | 4525 } else { |
| 4526 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4526 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4527 L"Ltrim"); | 4527 L"Ltrim"); |
| 4528 } | 4528 } |
| 4529 } | 4529 } |
| 4530 void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis, | 4530 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, |
| 4531 const CFX_ByteStringC& szFuncName, | 4531 const CFX_ByteStringC& szFuncName, |
| 4532 CFXJSE_Arguments& args) { | 4532 CFXJSE_Arguments& args) { |
| 4533 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4533 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4534 if (args.GetLength() == 2) { | 4534 if (args.GetLength() == 2) { |
| 4535 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4535 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4536 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4536 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4537 if (HValueIsNull(hThis, argTwo)) { | 4537 if (ValueIsNull(pThis, argTwo)) { |
| 4538 FXJSE_Value_SetNull(args.GetReturnValue()); | 4538 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4539 } else { | 4539 } else { |
| 4540 CFX_ByteString szPattern; | 4540 CFX_ByteString szPattern; |
| 4541 HValueToUTF8String(argOne, szPattern); | 4541 ValueToUTF8String(argOne, szPattern); |
| 4542 CFX_ByteString szValue; | 4542 CFX_ByteString szValue; |
| 4543 HValueToUTF8String(argTwo, szValue); | 4543 ValueToUTF8String(argTwo, szValue); |
| 4544 CXFA_Document* pDoc = pContext->GetDocument(); | 4544 CXFA_Document* pDoc = pContext->GetDocument(); |
| 4545 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4545 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 4546 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4546 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 4547 ASSERT(pThisNode); | 4547 ASSERT(pThisNode); |
| 4548 CXFA_WidgetData widgetData(pThisNode); | 4548 CXFA_WidgetData widgetData(pThisNode); |
| 4549 IFX_Locale* pLocale = widgetData.GetLocal(); | 4549 IFX_Locale* pLocale = widgetData.GetLocal(); |
| 4550 uint32_t patternType; | 4550 uint32_t patternType; |
| 4551 FX_BOOL bCompletePattern = | 4551 FX_BOOL bCompletePattern = |
| 4552 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); | 4552 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); |
| 4553 CFX_WideString wsPattern = | 4553 CFX_WideString wsPattern = |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4662 } | 4662 } |
| 4663 } | 4663 } |
| 4664 } | 4664 } |
| 4665 FXJSE_Value_Release(argOne); | 4665 FXJSE_Value_Release(argOne); |
| 4666 FXJSE_Value_Release(argTwo); | 4666 FXJSE_Value_Release(argTwo); |
| 4667 } else { | 4667 } else { |
| 4668 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4668 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4669 L"Parse"); | 4669 L"Parse"); |
| 4670 } | 4670 } |
| 4671 } | 4671 } |
| 4672 void CXFA_FM2JSContext::Replace(FXJSE_HOBJECT hThis, | 4672 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, |
| 4673 const CFX_ByteStringC& szFuncName, | 4673 const CFX_ByteStringC& szFuncName, |
| 4674 CFXJSE_Arguments& args) { | 4674 CFXJSE_Arguments& args) { |
| 4675 int32_t argc = args.GetLength(); | 4675 int32_t argc = args.GetLength(); |
| 4676 if ((argc == 2) || (argc == 3)) { | 4676 if ((argc == 2) || (argc == 3)) { |
| 4677 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4677 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4678 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4678 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4679 FXJSE_HVALUE argThree = 0; | 4679 CFXJSE_Value* argThree = nullptr; |
| 4680 CFX_ByteString oneString; | 4680 CFX_ByteString oneString; |
| 4681 CFX_ByteString twoString; | 4681 CFX_ByteString twoString; |
| 4682 CFX_ByteString threeString; | 4682 CFX_ByteString threeString; |
| 4683 if (!HValueIsNull(hThis, argOne) && !HValueIsNull(hThis, argTwo)) { | 4683 if (!ValueIsNull(pThis, argOne) && !ValueIsNull(pThis, argTwo)) { |
| 4684 HValueToUTF8String(argOne, oneString); | 4684 ValueToUTF8String(argOne, oneString); |
| 4685 HValueToUTF8String(argTwo, twoString); | 4685 ValueToUTF8String(argTwo, twoString); |
| 4686 } | 4686 } |
| 4687 if (argc == 3) { | 4687 if (argc == 3) { |
| 4688 argThree = GetSimpleHValue(hThis, args, 2); | 4688 argThree = GetSimpleValue(pThis, args, 2); |
| 4689 HValueToUTF8String(argThree, threeString); | 4689 ValueToUTF8String(argThree, threeString); |
| 4690 } | 4690 } |
| 4691 int32_t iSrcLen = oneString.GetLength(); | 4691 int32_t iSrcLen = oneString.GetLength(); |
| 4692 int32_t iFindLen = twoString.GetLength(); | 4692 int32_t iFindLen = twoString.GetLength(); |
| 4693 CFX_ByteTextBuf resultString; | 4693 CFX_ByteTextBuf resultString; |
| 4694 int32_t iFindIndex = 0; | 4694 int32_t iFindIndex = 0; |
| 4695 uint8_t ch = 0; | 4695 uint8_t ch = 0; |
| 4696 for (int32_t u = 0; u < iSrcLen; ++u) { | 4696 for (int32_t u = 0; u < iSrcLen; ++u) { |
| 4697 ch = oneString.GetAt(u); | 4697 ch = oneString.GetAt(u); |
| 4698 if (ch == twoString.GetAt(iFindIndex)) { | 4698 if (ch == twoString.GetAt(iFindIndex)) { |
| 4699 int32_t iTemp = u + 1; | 4699 int32_t iTemp = u + 1; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4722 } | 4722 } |
| 4723 resultString.AppendChar(0); | 4723 resultString.AppendChar(0); |
| 4724 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 4724 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
| 4725 FXJSE_Value_Release(argOne); | 4725 FXJSE_Value_Release(argOne); |
| 4726 FXJSE_Value_Release(argTwo); | 4726 FXJSE_Value_Release(argTwo); |
| 4727 if (argc == 3) { | 4727 if (argc == 3) { |
| 4728 FXJSE_Value_Release(argThree); | 4728 FXJSE_Value_Release(argThree); |
| 4729 } | 4729 } |
| 4730 } else { | 4730 } else { |
| 4731 CXFA_FM2JSContext* pContext = | 4731 CXFA_FM2JSContext* pContext = |
| 4732 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4732 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4733 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4733 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4734 L"Replace"); | 4734 L"Replace"); |
| 4735 } | 4735 } |
| 4736 } | 4736 } |
| 4737 void CXFA_FM2JSContext::Right(FXJSE_HOBJECT hThis, | 4737 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, |
| 4738 const CFX_ByteStringC& szFuncName, | 4738 const CFX_ByteStringC& szFuncName, |
| 4739 CFXJSE_Arguments& args) { | 4739 CFXJSE_Arguments& args) { |
| 4740 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4740 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4741 if (args.GetLength() == 2) { | 4741 if (args.GetLength() == 2) { |
| 4742 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4742 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4743 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4743 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 4744 FX_BOOL argIsNull = FALSE; | 4744 FX_BOOL argIsNull = FALSE; |
| 4745 if ((HValueIsNull(hThis, argOne)) || (HValueIsNull(hThis, argTwo))) { | 4745 if ((ValueIsNull(pThis, argOne)) || (ValueIsNull(pThis, argTwo))) { |
| 4746 argIsNull = TRUE; | 4746 argIsNull = TRUE; |
| 4747 } | 4747 } |
| 4748 if (argIsNull) { | 4748 if (argIsNull) { |
| 4749 FXJSE_Value_SetNull(args.GetReturnValue()); | 4749 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4750 } else { | 4750 } else { |
| 4751 CFX_ByteString sourceString; | 4751 CFX_ByteString sourceString; |
| 4752 HValueToUTF8String(argOne, sourceString); | 4752 ValueToUTF8String(argOne, sourceString); |
| 4753 int32_t count = HValueToInteger(hThis, argTwo); | 4753 int32_t count = ValueToInteger(pThis, argTwo); |
| 4754 if (count < 0) { | 4754 if (count < 0) { |
| 4755 count = 0; | 4755 count = 0; |
| 4756 } | 4756 } |
| 4757 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4757 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4758 sourceString.Right(count).AsStringC()); | 4758 sourceString.Right(count).AsStringC()); |
| 4759 } | 4759 } |
| 4760 FXJSE_Value_Release(argOne); | 4760 FXJSE_Value_Release(argOne); |
| 4761 FXJSE_Value_Release(argTwo); | 4761 FXJSE_Value_Release(argTwo); |
| 4762 } else { | 4762 } else { |
| 4763 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4763 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4764 L"Right"); | 4764 L"Right"); |
| 4765 } | 4765 } |
| 4766 } | 4766 } |
| 4767 void CXFA_FM2JSContext::Rtrim(FXJSE_HOBJECT hThis, | 4767 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, |
| 4768 const CFX_ByteStringC& szFuncName, | 4768 const CFX_ByteStringC& szFuncName, |
| 4769 CFXJSE_Arguments& args) { | 4769 CFXJSE_Arguments& args) { |
| 4770 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4770 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4771 if (args.GetLength() == 1) { | 4771 if (args.GetLength() == 1) { |
| 4772 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4772 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4773 if (HValueIsNull(hThis, argOne)) { | 4773 if (ValueIsNull(pThis, argOne)) { |
| 4774 FXJSE_Value_SetNull(args.GetReturnValue()); | 4774 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4775 } else { | 4775 } else { |
| 4776 CFX_ByteString sourceString; | 4776 CFX_ByteString sourceString; |
| 4777 HValueToUTF8String(argOne, sourceString); | 4777 ValueToUTF8String(argOne, sourceString); |
| 4778 sourceString.TrimRight(); | 4778 sourceString.TrimRight(); |
| 4779 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4779 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4780 sourceString.AsStringC()); | 4780 sourceString.AsStringC()); |
| 4781 } | 4781 } |
| 4782 FXJSE_Value_Release(argOne); | 4782 FXJSE_Value_Release(argOne); |
| 4783 } else { | 4783 } else { |
| 4784 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4784 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4785 L"Rtrim"); | 4785 L"Rtrim"); |
| 4786 } | 4786 } |
| 4787 } | 4787 } |
| 4788 void CXFA_FM2JSContext::Space(FXJSE_HOBJECT hThis, | 4788 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, |
| 4789 const CFX_ByteStringC& szFuncName, | 4789 const CFX_ByteStringC& szFuncName, |
| 4790 CFXJSE_Arguments& args) { | 4790 CFXJSE_Arguments& args) { |
| 4791 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4791 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4792 if (args.GetLength() == 1) { | 4792 if (args.GetLength() == 1) { |
| 4793 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4793 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 4794 if (FXJSE_Value_IsNull(argOne)) { | 4794 if (FXJSE_Value_IsNull(argOne)) { |
| 4795 FXJSE_Value_SetNull(args.GetReturnValue()); | 4795 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4796 } else { | 4796 } else { |
| 4797 int32_t count = 0; | 4797 int32_t count = 0; |
| 4798 count = HValueToInteger(hThis, argOne); | 4798 count = ValueToInteger(pThis, argOne); |
| 4799 count = (count < 0) ? 0 : count; | 4799 count = (count < 0) ? 0 : count; |
| 4800 CFX_ByteTextBuf spaceString; | 4800 CFX_ByteTextBuf spaceString; |
| 4801 int32_t index = 0; | 4801 int32_t index = 0; |
| 4802 while (index < count) { | 4802 while (index < count) { |
| 4803 spaceString.AppendByte(' '); | 4803 spaceString.AppendByte(' '); |
| 4804 index++; | 4804 index++; |
| 4805 } | 4805 } |
| 4806 spaceString.AppendByte(0); | 4806 spaceString.AppendByte(0); |
| 4807 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); | 4807 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); |
| 4808 } | 4808 } |
| 4809 FXJSE_Value_Release(argOne); | 4809 FXJSE_Value_Release(argOne); |
| 4810 } else { | 4810 } else { |
| 4811 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4811 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4812 L"Space"); | 4812 L"Space"); |
| 4813 } | 4813 } |
| 4814 } | 4814 } |
| 4815 void CXFA_FM2JSContext::Str(FXJSE_HOBJECT hThis, | 4815 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, |
| 4816 const CFX_ByteStringC& szFuncName, | 4816 const CFX_ByteStringC& szFuncName, |
| 4817 CFXJSE_Arguments& args) { | 4817 CFXJSE_Arguments& args) { |
| 4818 int32_t argc = args.GetLength(); | 4818 int32_t argc = args.GetLength(); |
| 4819 if ((argc > 0) && (argc < 4)) { | 4819 if ((argc > 0) && (argc < 4)) { |
| 4820 FX_BOOL bFlags = FALSE; | 4820 FX_BOOL bFlags = FALSE; |
| 4821 FX_FLOAT fNumber = 0.0f; | 4821 FX_FLOAT fNumber = 0.0f; |
| 4822 int32_t iWidth = 10; | 4822 int32_t iWidth = 10; |
| 4823 int32_t iPrecision = 0; | 4823 int32_t iPrecision = 0; |
| 4824 FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0); | 4824 CFXJSE_Value* numberValue = GetSimpleValue(pThis, args, 0); |
| 4825 FXJSE_HVALUE widthValue = 0; | 4825 CFXJSE_Value* widthValue = nullptr; |
| 4826 FXJSE_HVALUE precisionValue = 0; | 4826 CFXJSE_Value* precisionValue = nullptr; |
| 4827 if (FXJSE_Value_IsNull(numberValue)) { | 4827 if (FXJSE_Value_IsNull(numberValue)) { |
| 4828 bFlags = TRUE; | 4828 bFlags = TRUE; |
| 4829 } else { | 4829 } else { |
| 4830 fNumber = HValueToFloat(hThis, numberValue); | 4830 fNumber = ValueToFloat(pThis, numberValue); |
| 4831 } | 4831 } |
| 4832 if (argc > 1) { | 4832 if (argc > 1) { |
| 4833 widthValue = GetSimpleHValue(hThis, args, 1); | 4833 widthValue = GetSimpleValue(pThis, args, 1); |
| 4834 iWidth = (int32_t)HValueToFloat(hThis, widthValue); | 4834 iWidth = (int32_t)ValueToFloat(pThis, widthValue); |
| 4835 } | 4835 } |
| 4836 if (argc == 3) { | 4836 if (argc == 3) { |
| 4837 precisionValue = GetSimpleHValue(hThis, args, 2); | 4837 precisionValue = GetSimpleValue(pThis, args, 2); |
| 4838 iPrecision = (int32_t)HValueToFloat(hThis, precisionValue); | 4838 iPrecision = (int32_t)ValueToFloat(pThis, precisionValue); |
| 4839 if (iPrecision < 0) { | 4839 if (iPrecision < 0) { |
| 4840 iPrecision = 0; | 4840 iPrecision = 0; |
| 4841 } | 4841 } |
| 4842 } | 4842 } |
| 4843 if (!bFlags) { | 4843 if (!bFlags) { |
| 4844 CFX_ByteString numberString; | 4844 CFX_ByteString numberString; |
| 4845 CFX_ByteString formatStr = "%"; | 4845 CFX_ByteString formatStr = "%"; |
| 4846 if (iPrecision) { | 4846 if (iPrecision) { |
| 4847 formatStr += "."; | 4847 formatStr += "."; |
| 4848 formatStr += CFX_ByteString::FormatInteger(iPrecision); | 4848 formatStr += CFX_ByteString::FormatInteger(iPrecision); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4926 } | 4926 } |
| 4927 FXJSE_Value_Release(numberValue); | 4927 FXJSE_Value_Release(numberValue); |
| 4928 if (argc > 1) { | 4928 if (argc > 1) { |
| 4929 FXJSE_Value_Release(widthValue); | 4929 FXJSE_Value_Release(widthValue); |
| 4930 if (argc == 3) { | 4930 if (argc == 3) { |
| 4931 FXJSE_Value_Release(precisionValue); | 4931 FXJSE_Value_Release(precisionValue); |
| 4932 } | 4932 } |
| 4933 } | 4933 } |
| 4934 } else { | 4934 } else { |
| 4935 CXFA_FM2JSContext* pContext = | 4935 CXFA_FM2JSContext* pContext = |
| 4936 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4936 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4937 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4937 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4938 L"Str"); | 4938 L"Str"); |
| 4939 } | 4939 } |
| 4940 } | 4940 } |
| 4941 void CXFA_FM2JSContext::Stuff(FXJSE_HOBJECT hThis, | 4941 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, |
| 4942 const CFX_ByteStringC& szFuncName, | 4942 const CFX_ByteStringC& szFuncName, |
| 4943 CFXJSE_Arguments& args) { | 4943 CFXJSE_Arguments& args) { |
| 4944 int32_t argc = args.GetLength(); | 4944 int32_t argc = args.GetLength(); |
| 4945 if ((argc == 3) || (argc == 4)) { | 4945 if ((argc == 3) || (argc == 4)) { |
| 4946 CFX_ByteString sourceString; | 4946 CFX_ByteString sourceString; |
| 4947 CFX_ByteString insertString; | 4947 CFX_ByteString insertString; |
| 4948 int32_t iLength = 0; | 4948 int32_t iLength = 0; |
| 4949 int32_t iStart = 0; | 4949 int32_t iStart = 0; |
| 4950 int32_t iDelete = 0; | 4950 int32_t iDelete = 0; |
| 4951 FXJSE_HVALUE sourceValue = GetSimpleHValue(hThis, args, 0); | 4951 CFXJSE_Value* sourceValue = GetSimpleValue(pThis, args, 0); |
| 4952 FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); | 4952 CFXJSE_Value* startValue = GetSimpleValue(pThis, args, 1); |
| 4953 FXJSE_HVALUE deleteValue = GetSimpleHValue(hThis, args, 2); | 4953 CFXJSE_Value* deleteValue = GetSimpleValue(pThis, args, 2); |
| 4954 FXJSE_HVALUE insertValue = 0; | 4954 CFXJSE_Value* insertValue = nullptr; |
| 4955 if (!FXJSE_Value_IsNull(sourceValue) && !FXJSE_Value_IsNull(startValue) && | 4955 if (!FXJSE_Value_IsNull(sourceValue) && !FXJSE_Value_IsNull(startValue) && |
| 4956 !FXJSE_Value_IsNull(deleteValue)) { | 4956 !FXJSE_Value_IsNull(deleteValue)) { |
| 4957 HValueToUTF8String(sourceValue, sourceString); | 4957 ValueToUTF8String(sourceValue, sourceString); |
| 4958 iLength = sourceString.GetLength(); | 4958 iLength = sourceString.GetLength(); |
| 4959 iStart = (int32_t)HValueToFloat(hThis, startValue); | 4959 iStart = (int32_t)ValueToFloat(pThis, startValue); |
| 4960 if (iStart < 1) { | 4960 if (iStart < 1) { |
| 4961 iStart = 1; | 4961 iStart = 1; |
| 4962 } | 4962 } |
| 4963 if (iStart > iLength) { | 4963 if (iStart > iLength) { |
| 4964 iStart = iLength; | 4964 iStart = iLength; |
| 4965 } | 4965 } |
| 4966 iDelete = (int32_t)HValueToFloat(hThis, deleteValue); | 4966 iDelete = (int32_t)ValueToFloat(pThis, deleteValue); |
| 4967 if (iDelete <= 0) { | 4967 if (iDelete <= 0) { |
| 4968 iDelete = 0; | 4968 iDelete = 0; |
| 4969 } | 4969 } |
| 4970 } | 4970 } |
| 4971 if (argc == 4) { | 4971 if (argc == 4) { |
| 4972 insertValue = GetSimpleHValue(hThis, args, 3); | 4972 insertValue = GetSimpleValue(pThis, args, 3); |
| 4973 HValueToUTF8String(insertValue, insertString); | 4973 ValueToUTF8String(insertValue, insertString); |
| 4974 } | 4974 } |
| 4975 iStart -= 1; | 4975 iStart -= 1; |
| 4976 CFX_ByteTextBuf resultString; | 4976 CFX_ByteTextBuf resultString; |
| 4977 int32_t i = 0; | 4977 int32_t i = 0; |
| 4978 while (i < iStart) { | 4978 while (i < iStart) { |
| 4979 resultString.AppendChar(sourceString.GetAt(i)); | 4979 resultString.AppendChar(sourceString.GetAt(i)); |
| 4980 ++i; | 4980 ++i; |
| 4981 } | 4981 } |
| 4982 resultString << insertString.AsStringC(); | 4982 resultString << insertString.AsStringC(); |
| 4983 i = iStart + iDelete; | 4983 i = iStart + iDelete; |
| 4984 while (i < iLength) { | 4984 while (i < iLength) { |
| 4985 resultString.AppendChar(sourceString.GetAt(i)); | 4985 resultString.AppendChar(sourceString.GetAt(i)); |
| 4986 ++i; | 4986 ++i; |
| 4987 } | 4987 } |
| 4988 resultString.AppendChar(0); | 4988 resultString.AppendChar(0); |
| 4989 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 4989 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
| 4990 FXJSE_Value_Release(sourceValue); | 4990 FXJSE_Value_Release(sourceValue); |
| 4991 FXJSE_Value_Release(startValue); | 4991 FXJSE_Value_Release(startValue); |
| 4992 FXJSE_Value_Release(deleteValue); | 4992 FXJSE_Value_Release(deleteValue); |
| 4993 if (argc == 4) { | 4993 if (argc == 4) { |
| 4994 FXJSE_Value_Release(insertValue); | 4994 FXJSE_Value_Release(insertValue); |
| 4995 } | 4995 } |
| 4996 } else { | 4996 } else { |
| 4997 CXFA_FM2JSContext* pContext = | 4997 CXFA_FM2JSContext* pContext = |
| 4998 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 4998 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 4999 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4999 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5000 L"Stuff"); | 5000 L"Stuff"); |
| 5001 } | 5001 } |
| 5002 } | 5002 } |
| 5003 void CXFA_FM2JSContext::Substr(FXJSE_HOBJECT hThis, | 5003 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, |
| 5004 const CFX_ByteStringC& szFuncName, | 5004 const CFX_ByteStringC& szFuncName, |
| 5005 CFXJSE_Arguments& args) { | 5005 CFXJSE_Arguments& args) { |
| 5006 int32_t argc = args.GetLength(); | 5006 int32_t argc = args.GetLength(); |
| 5007 if (argc == 3) { | 5007 if (argc == 3) { |
| 5008 FXJSE_HVALUE stringValue = GetSimpleHValue(hThis, args, 0); | 5008 CFXJSE_Value* stringValue = GetSimpleValue(pThis, args, 0); |
| 5009 FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); | 5009 CFXJSE_Value* startValue = GetSimpleValue(pThis, args, 1); |
| 5010 FXJSE_HVALUE endValue = GetSimpleHValue(hThis, args, 2); | 5010 CFXJSE_Value* endValue = GetSimpleValue(pThis, args, 2); |
| 5011 if (HValueIsNull(hThis, stringValue) || (HValueIsNull(hThis, startValue)) || | 5011 if (ValueIsNull(pThis, stringValue) || (ValueIsNull(pThis, startValue)) || |
| 5012 (HValueIsNull(hThis, endValue))) { | 5012 (ValueIsNull(pThis, endValue))) { |
| 5013 FXJSE_Value_SetNull(args.GetReturnValue()); | 5013 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5014 } else { | 5014 } else { |
| 5015 CFX_ByteString szSourceStr; | 5015 CFX_ByteString szSourceStr; |
| 5016 int32_t iStart = 0; | 5016 int32_t iStart = 0; |
| 5017 int32_t iCount = 0; | 5017 int32_t iCount = 0; |
| 5018 HValueToUTF8String(stringValue, szSourceStr); | 5018 ValueToUTF8String(stringValue, szSourceStr); |
| 5019 int32_t iLength = szSourceStr.GetLength(); | 5019 int32_t iLength = szSourceStr.GetLength(); |
| 5020 if (iLength == 0) { | 5020 if (iLength == 0) { |
| 5021 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5021 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 5022 } else { | 5022 } else { |
| 5023 iStart = (int32_t)HValueToFloat(hThis, startValue); | 5023 iStart = (int32_t)ValueToFloat(pThis, startValue); |
| 5024 iCount = (int32_t)HValueToFloat(hThis, endValue); | 5024 iCount = (int32_t)ValueToFloat(pThis, endValue); |
| 5025 if (iStart < 1) { | 5025 if (iStart < 1) { |
| 5026 iStart = 1; | 5026 iStart = 1; |
| 5027 } | 5027 } |
| 5028 if (iStart > iLength) { | 5028 if (iStart > iLength) { |
| 5029 iStart = iLength; | 5029 iStart = iLength; |
| 5030 } | 5030 } |
| 5031 if (iCount <= 0) { | 5031 if (iCount <= 0) { |
| 5032 iCount = 0; | 5032 iCount = 0; |
| 5033 } | 5033 } |
| 5034 iStart -= 1; | 5034 iStart -= 1; |
| 5035 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5035 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 5036 szSourceStr.Mid(iStart, iCount).AsStringC()); | 5036 szSourceStr.Mid(iStart, iCount).AsStringC()); |
| 5037 } | 5037 } |
| 5038 } | 5038 } |
| 5039 FXJSE_Value_Release(stringValue); | 5039 FXJSE_Value_Release(stringValue); |
| 5040 FXJSE_Value_Release(startValue); | 5040 FXJSE_Value_Release(startValue); |
| 5041 FXJSE_Value_Release(endValue); | 5041 FXJSE_Value_Release(endValue); |
| 5042 } else { | 5042 } else { |
| 5043 CXFA_FM2JSContext* pContext = | 5043 CXFA_FM2JSContext* pContext = |
| 5044 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5044 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5045 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5045 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5046 L"Substr"); | 5046 L"Substr"); |
| 5047 } | 5047 } |
| 5048 } | 5048 } |
| 5049 void CXFA_FM2JSContext::Uuid(FXJSE_HOBJECT hThis, | 5049 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, |
| 5050 const CFX_ByteStringC& szFuncName, | 5050 const CFX_ByteStringC& szFuncName, |
| 5051 CFXJSE_Arguments& args) { | 5051 CFXJSE_Arguments& args) { |
| 5052 int32_t argc = args.GetLength(); | 5052 int32_t argc = args.GetLength(); |
| 5053 if ((argc == 0) || (argc == 1)) { | 5053 if ((argc == 0) || (argc == 1)) { |
| 5054 int32_t iNum = 0; | 5054 int32_t iNum = 0; |
| 5055 FXJSE_HVALUE argOne = 0; | 5055 CFXJSE_Value* argOne = nullptr; |
| 5056 if (argc == 1) { | 5056 if (argc == 1) { |
| 5057 argOne = GetSimpleHValue(hThis, args, 0); | 5057 argOne = GetSimpleValue(pThis, args, 0); |
| 5058 iNum = (int32_t)HValueToFloat(hThis, argOne); | 5058 iNum = (int32_t)ValueToFloat(pThis, argOne); |
| 5059 } | 5059 } |
| 5060 FX_GUID guid; | 5060 FX_GUID guid; |
| 5061 FX_GUID_CreateV4(&guid); | 5061 FX_GUID_CreateV4(&guid); |
| 5062 CFX_ByteString bsUId; | 5062 CFX_ByteString bsUId; |
| 5063 FX_GUID_ToString(&guid, bsUId, iNum); | 5063 FX_GUID_ToString(&guid, bsUId, iNum); |
| 5064 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); | 5064 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); |
| 5065 if (argc == 1) { | 5065 if (argc == 1) { |
| 5066 FXJSE_Value_Release(argOne); | 5066 FXJSE_Value_Release(argOne); |
| 5067 } | 5067 } |
| 5068 } else { | 5068 } else { |
| 5069 CXFA_FM2JSContext* pContext = | 5069 CXFA_FM2JSContext* pContext = |
| 5070 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5070 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5071 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5071 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5072 L"Uuid"); | 5072 L"Uuid"); |
| 5073 } | 5073 } |
| 5074 } | 5074 } |
| 5075 void CXFA_FM2JSContext::Upper(FXJSE_HOBJECT hThis, | 5075 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, |
| 5076 const CFX_ByteStringC& szFuncName, | 5076 const CFX_ByteStringC& szFuncName, |
| 5077 CFXJSE_Arguments& args) { | 5077 CFXJSE_Arguments& args) { |
| 5078 int32_t argc = args.GetLength(); | 5078 int32_t argc = args.GetLength(); |
| 5079 if ((argc > 0) && (argc < 3)) { | 5079 if ((argc > 0) && (argc < 3)) { |
| 5080 CFX_ByteString argString; | 5080 CFX_ByteString argString; |
| 5081 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5081 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5082 FXJSE_HVALUE localeValue = 0; | 5082 CFXJSE_Value* localeValue = nullptr; |
| 5083 if (HValueIsNull(hThis, argOne)) { | 5083 if (ValueIsNull(pThis, argOne)) { |
| 5084 FXJSE_Value_SetNull(args.GetReturnValue()); | 5084 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5085 } else { | 5085 } else { |
| 5086 if (argc == 2) { | 5086 if (argc == 2) { |
| 5087 localeValue = GetSimpleHValue(hThis, args, 1); | 5087 localeValue = GetSimpleValue(pThis, args, 1); |
| 5088 } | 5088 } |
| 5089 HValueToUTF8String(argOne, argString); | 5089 ValueToUTF8String(argOne, argString); |
| 5090 CFX_WideTextBuf upperStringBuf; | 5090 CFX_WideTextBuf upperStringBuf; |
| 5091 CFX_WideString wsArgString = | 5091 CFX_WideString wsArgString = |
| 5092 CFX_WideString::FromUTF8(argString.AsStringC()); | 5092 CFX_WideString::FromUTF8(argString.AsStringC()); |
| 5093 const FX_WCHAR* pData = wsArgString.c_str(); | 5093 const FX_WCHAR* pData = wsArgString.c_str(); |
| 5094 int32_t iLen = wsArgString.GetLength(); | 5094 int32_t iLen = wsArgString.GetLength(); |
| 5095 int32_t i = 0; | 5095 int32_t i = 0; |
| 5096 int32_t ch = 0; | 5096 int32_t ch = 0; |
| 5097 while (i < iLen) { | 5097 while (i < iLen) { |
| 5098 ch = *(pData + i); | 5098 ch = *(pData + i); |
| 5099 if (ch >= 0x61 && ch <= 0x7A) { | 5099 if (ch >= 0x61 && ch <= 0x7A) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5111 args.GetReturnValue(), | 5111 args.GetReturnValue(), |
| 5112 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) | 5112 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) |
| 5113 .AsStringC()); | 5113 .AsStringC()); |
| 5114 if (argc == 2) { | 5114 if (argc == 2) { |
| 5115 FXJSE_Value_Release(localeValue); | 5115 FXJSE_Value_Release(localeValue); |
| 5116 } | 5116 } |
| 5117 } | 5117 } |
| 5118 FXJSE_Value_Release(argOne); | 5118 FXJSE_Value_Release(argOne); |
| 5119 } else { | 5119 } else { |
| 5120 CXFA_FM2JSContext* pContext = | 5120 CXFA_FM2JSContext* pContext = |
| 5121 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5121 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5122 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5122 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5123 L"Upper"); | 5123 L"Upper"); |
| 5124 } | 5124 } |
| 5125 } | 5125 } |
| 5126 void CXFA_FM2JSContext::WordNum(FXJSE_HOBJECT hThis, | 5126 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, |
| 5127 const CFX_ByteStringC& szFuncName, | 5127 const CFX_ByteStringC& szFuncName, |
| 5128 CFXJSE_Arguments& args) { | 5128 CFXJSE_Arguments& args) { |
| 5129 int32_t argc = args.GetLength(); | 5129 int32_t argc = args.GetLength(); |
| 5130 if ((argc > 0) && (argc < 4)) { | 5130 if ((argc > 0) && (argc < 4)) { |
| 5131 FX_BOOL bFlags = FALSE; | 5131 FX_BOOL bFlags = FALSE; |
| 5132 FX_FLOAT fNumber = 0.0f; | 5132 FX_FLOAT fNumber = 0.0f; |
| 5133 int32_t iIdentifier = 0; | 5133 int32_t iIdentifier = 0; |
| 5134 CFX_ByteString localeString; | 5134 CFX_ByteString localeString; |
| 5135 FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0); | 5135 CFXJSE_Value* numberValue = GetSimpleValue(pThis, args, 0); |
| 5136 FXJSE_HVALUE identifierValue = 0; | 5136 CFXJSE_Value* identifierValue = nullptr; |
| 5137 FXJSE_HVALUE localeValue = 0; | 5137 CFXJSE_Value* localeValue = nullptr; |
| 5138 if (FXJSE_Value_IsNull(numberValue)) { | 5138 if (FXJSE_Value_IsNull(numberValue)) { |
| 5139 bFlags = TRUE; | 5139 bFlags = TRUE; |
| 5140 } else { | 5140 } else { |
| 5141 fNumber = HValueToFloat(hThis, numberValue); | 5141 fNumber = ValueToFloat(pThis, numberValue); |
| 5142 } | 5142 } |
| 5143 if (argc > 1) { | 5143 if (argc > 1) { |
| 5144 identifierValue = GetSimpleHValue(hThis, args, 1); | 5144 identifierValue = GetSimpleValue(pThis, args, 1); |
| 5145 if (FXJSE_Value_IsNull(identifierValue)) { | 5145 if (FXJSE_Value_IsNull(identifierValue)) { |
| 5146 bFlags = TRUE; | 5146 bFlags = TRUE; |
| 5147 } else { | 5147 } else { |
| 5148 iIdentifier = (int32_t)HValueToFloat(hThis, identifierValue); | 5148 iIdentifier = (int32_t)ValueToFloat(pThis, identifierValue); |
| 5149 } | 5149 } |
| 5150 } | 5150 } |
| 5151 if (argc == 3) { | 5151 if (argc == 3) { |
| 5152 localeValue = GetSimpleHValue(hThis, args, 2); | 5152 localeValue = GetSimpleValue(pThis, args, 2); |
| 5153 if (FXJSE_Value_IsNull(localeValue)) { | 5153 if (FXJSE_Value_IsNull(localeValue)) { |
| 5154 bFlags = TRUE; | 5154 bFlags = TRUE; |
| 5155 } else { | 5155 } else { |
| 5156 HValueToUTF8String(localeValue, localeString); | 5156 ValueToUTF8String(localeValue, localeString); |
| 5157 } | 5157 } |
| 5158 } | 5158 } |
| 5159 if (!bFlags) { | 5159 if (!bFlags) { |
| 5160 if ((fNumber < 0) || (fNumber > 922337203685477550)) { | 5160 if ((fNumber < 0) || (fNumber > 922337203685477550)) { |
| 5161 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "*"); | 5161 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "*"); |
| 5162 } else { | 5162 } else { |
| 5163 CFX_ByteTextBuf resultBuf; | 5163 CFX_ByteTextBuf resultBuf; |
| 5164 CFX_ByteString numberString; | 5164 CFX_ByteString numberString; |
| 5165 numberString.Format("%.2f", fNumber); | 5165 numberString.Format("%.2f", fNumber); |
| 5166 WordUS(numberString.AsStringC(), iIdentifier, resultBuf); | 5166 WordUS(numberString.AsStringC(), iIdentifier, resultBuf); |
| 5167 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 5167 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 5168 } | 5168 } |
| 5169 } else { | 5169 } else { |
| 5170 FXJSE_Value_SetNull(args.GetReturnValue()); | 5170 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5171 } | 5171 } |
| 5172 FXJSE_Value_Release(numberValue); | 5172 FXJSE_Value_Release(numberValue); |
| 5173 if (argc > 1) { | 5173 if (argc > 1) { |
| 5174 FXJSE_Value_Release(identifierValue); | 5174 FXJSE_Value_Release(identifierValue); |
| 5175 if (argc == 3) { | 5175 if (argc == 3) { |
| 5176 FXJSE_Value_Release(localeValue); | 5176 FXJSE_Value_Release(localeValue); |
| 5177 } | 5177 } |
| 5178 } | 5178 } |
| 5179 } else { | 5179 } else { |
| 5180 CXFA_FM2JSContext* pContext = | 5180 CXFA_FM2JSContext* pContext = |
| 5181 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5181 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5182 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5182 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5183 L"WordNum"); | 5183 L"WordNum"); |
| 5184 } | 5184 } |
| 5185 } | 5185 } |
| 5186 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, | 5186 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, |
| 5187 CFX_ByteTextBuf& strBuf) { | 5187 CFX_ByteTextBuf& strBuf) { |
| 5188 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", | 5188 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", |
| 5189 "five", "six", "seven", "eight", "nine"}; | 5189 "five", "six", "seven", "eight", "nine"}; |
| 5190 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", | 5190 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", |
| 5191 "Five", "Six", "Seven", "Eight", "Nine"}; | 5191 "Five", "Six", "Seven", "Eight", "Nine"}; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5371 strBuf << " Trillion "; | 5371 strBuf << " Trillion "; |
| 5372 } | 5372 } |
| 5373 } | 5373 } |
| 5374 strBuf << " Cents"; | 5374 strBuf << " Cents"; |
| 5375 } | 5375 } |
| 5376 } break; | 5376 } break; |
| 5377 default: | 5377 default: |
| 5378 break; | 5378 break; |
| 5379 } | 5379 } |
| 5380 } | 5380 } |
| 5381 void CXFA_FM2JSContext::Get(FXJSE_HOBJECT hThis, | 5381 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, |
| 5382 const CFX_ByteStringC& szFuncName, | 5382 const CFX_ByteStringC& szFuncName, |
| 5383 CFXJSE_Arguments& args) { | 5383 CFXJSE_Arguments& args) { |
| 5384 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5384 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5385 int32_t argc = args.GetLength(); | 5385 int32_t argc = args.GetLength(); |
| 5386 if (argc == 1) { | 5386 if (argc == 1) { |
| 5387 CXFA_Document* pDoc = pContext->GetDocument(); | 5387 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5388 if (!pDoc) { | 5388 if (!pDoc) { |
| 5389 return; | 5389 return; |
| 5390 } | 5390 } |
| 5391 IXFA_AppProvider* pAppProvider = | 5391 IXFA_AppProvider* pAppProvider = |
| 5392 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5392 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5393 if (!pAppProvider) { | 5393 if (!pAppProvider) { |
| 5394 return; | 5394 return; |
| 5395 } | 5395 } |
| 5396 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5396 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5397 CFX_ByteString urlString; | 5397 CFX_ByteString urlString; |
| 5398 HValueToUTF8String(argOne, urlString); | 5398 ValueToUTF8String(argOne, urlString); |
| 5399 IFX_FileRead* pFile = pAppProvider->DownloadURL( | 5399 IFX_FileRead* pFile = pAppProvider->DownloadURL( |
| 5400 CFX_WideString::FromUTF8(urlString.AsStringC())); | 5400 CFX_WideString::FromUTF8(urlString.AsStringC())); |
| 5401 if (pFile) { | 5401 if (pFile) { |
| 5402 int32_t size = pFile->GetSize(); | 5402 int32_t size = pFile->GetSize(); |
| 5403 uint8_t* pData = FX_Alloc(uint8_t, size); | 5403 uint8_t* pData = FX_Alloc(uint8_t, size); |
| 5404 pFile->ReadBlock(pData, size); | 5404 pFile->ReadBlock(pData, size); |
| 5405 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5405 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 5406 CFX_ByteStringC(pData, size)); | 5406 CFX_ByteStringC(pData, size)); |
| 5407 FX_Free(pData); | 5407 FX_Free(pData); |
| 5408 pFile->Release(); | 5408 pFile->Release(); |
| 5409 } | 5409 } |
| 5410 FXJSE_Value_Release(argOne); | 5410 FXJSE_Value_Release(argOne); |
| 5411 } else { | 5411 } else { |
| 5412 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5412 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5413 L"Get"); | 5413 L"Get"); |
| 5414 } | 5414 } |
| 5415 } | 5415 } |
| 5416 void CXFA_FM2JSContext::Post(FXJSE_HOBJECT hThis, | 5416 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, |
| 5417 const CFX_ByteStringC& szFuncName, | 5417 const CFX_ByteStringC& szFuncName, |
| 5418 CFXJSE_Arguments& args) { | 5418 CFXJSE_Arguments& args) { |
| 5419 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5419 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5420 int32_t argc = args.GetLength(); | 5420 int32_t argc = args.GetLength(); |
| 5421 if ((argc >= 2) && (argc <= 5)) { | 5421 if ((argc >= 2) && (argc <= 5)) { |
| 5422 CXFA_Document* pDoc = pContext->GetDocument(); | 5422 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5423 if (!pDoc) { | 5423 if (!pDoc) { |
| 5424 return; | 5424 return; |
| 5425 } | 5425 } |
| 5426 IXFA_AppProvider* pAppProvider = | 5426 IXFA_AppProvider* pAppProvider = |
| 5427 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5427 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5428 if (!pAppProvider) { | 5428 if (!pAppProvider) { |
| 5429 return; | 5429 return; |
| 5430 } | 5430 } |
| 5431 CFX_ByteString bsURL; | 5431 CFX_ByteString bsURL; |
| 5432 CFX_ByteString bsData; | 5432 CFX_ByteString bsData; |
| 5433 CFX_ByteString bsContentType; | 5433 CFX_ByteString bsContentType; |
| 5434 CFX_ByteString bsEncode; | 5434 CFX_ByteString bsEncode; |
| 5435 CFX_ByteString bsHeader; | 5435 CFX_ByteString bsHeader; |
| 5436 FXJSE_HVALUE argThree = nullptr; | 5436 CFXJSE_Value* argThree = nullptr; |
| 5437 FXJSE_HVALUE argFour = nullptr; | 5437 CFXJSE_Value* argFour = nullptr; |
| 5438 FXJSE_HVALUE argFive = nullptr; | 5438 CFXJSE_Value* argFive = nullptr; |
| 5439 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5439 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5440 HValueToUTF8String(argOne, bsURL); | 5440 ValueToUTF8String(argOne, bsURL); |
| 5441 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 5441 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 5442 HValueToUTF8String(argTwo, bsData); | 5442 ValueToUTF8String(argTwo, bsData); |
| 5443 if (argc > 2) { | 5443 if (argc > 2) { |
| 5444 argThree = GetSimpleHValue(hThis, args, 2); | 5444 argThree = GetSimpleValue(pThis, args, 2); |
| 5445 HValueToUTF8String(argThree, bsContentType); | 5445 ValueToUTF8String(argThree, bsContentType); |
| 5446 } | 5446 } |
| 5447 if (argc > 3) { | 5447 if (argc > 3) { |
| 5448 argFour = GetSimpleHValue(hThis, args, 3); | 5448 argFour = GetSimpleValue(pThis, args, 3); |
| 5449 HValueToUTF8String(argFour, bsEncode); | 5449 ValueToUTF8String(argFour, bsEncode); |
| 5450 } | 5450 } |
| 5451 if (argc > 4) { | 5451 if (argc > 4) { |
| 5452 argFive = GetSimpleHValue(hThis, args, 4); | 5452 argFive = GetSimpleValue(pThis, args, 4); |
| 5453 HValueToUTF8String(argFive, bsHeader); | 5453 ValueToUTF8String(argFive, bsHeader); |
| 5454 } | 5454 } |
| 5455 CFX_WideString decodedResponse; | 5455 CFX_WideString decodedResponse; |
| 5456 FX_BOOL bFlags = pAppProvider->PostRequestURL( | 5456 FX_BOOL bFlags = pAppProvider->PostRequestURL( |
| 5457 CFX_WideString::FromUTF8(bsURL.AsStringC()), | 5457 CFX_WideString::FromUTF8(bsURL.AsStringC()), |
| 5458 CFX_WideString::FromUTF8(bsData.AsStringC()), | 5458 CFX_WideString::FromUTF8(bsData.AsStringC()), |
| 5459 CFX_WideString::FromUTF8(bsContentType.AsStringC()), | 5459 CFX_WideString::FromUTF8(bsContentType.AsStringC()), |
| 5460 CFX_WideString::FromUTF8(bsEncode.AsStringC()), | 5460 CFX_WideString::FromUTF8(bsEncode.AsStringC()), |
| 5461 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse); | 5461 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse); |
| 5462 FXJSE_Value_Release(argOne); | 5462 FXJSE_Value_Release(argOne); |
| 5463 FXJSE_Value_Release(argTwo); | 5463 FXJSE_Value_Release(argTwo); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5476 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) | 5476 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) |
| 5477 .AsStringC()); | 5477 .AsStringC()); |
| 5478 } else { | 5478 } else { |
| 5479 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5479 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
| 5480 } | 5480 } |
| 5481 } else { | 5481 } else { |
| 5482 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5482 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5483 L"Post"); | 5483 L"Post"); |
| 5484 } | 5484 } |
| 5485 } | 5485 } |
| 5486 void CXFA_FM2JSContext::Put(FXJSE_HOBJECT hThis, | 5486 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, |
| 5487 const CFX_ByteStringC& szFuncName, | 5487 const CFX_ByteStringC& szFuncName, |
| 5488 CFXJSE_Arguments& args) { | 5488 CFXJSE_Arguments& args) { |
| 5489 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5489 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5490 int32_t argc = args.GetLength(); | 5490 int32_t argc = args.GetLength(); |
| 5491 if ((argc == 2) || (argc == 3)) { | 5491 if ((argc == 2) || (argc == 3)) { |
| 5492 CXFA_Document* pDoc = pContext->GetDocument(); | 5492 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5493 if (!pDoc) { | 5493 if (!pDoc) { |
| 5494 return; | 5494 return; |
| 5495 } | 5495 } |
| 5496 IXFA_AppProvider* pAppProvider = | 5496 IXFA_AppProvider* pAppProvider = |
| 5497 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5497 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5498 if (!pAppProvider) { | 5498 if (!pAppProvider) { |
| 5499 return; | 5499 return; |
| 5500 } | 5500 } |
| 5501 CFX_ByteString bsURL; | 5501 CFX_ByteString bsURL; |
| 5502 CFX_ByteString bsData; | 5502 CFX_ByteString bsData; |
| 5503 CFX_ByteString bsEncode; | 5503 CFX_ByteString bsEncode; |
| 5504 FXJSE_HVALUE argThree = nullptr; | 5504 CFXJSE_Value* argThree = nullptr; |
| 5505 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5505 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5506 HValueToUTF8String(argOne, bsURL); | 5506 ValueToUTF8String(argOne, bsURL); |
| 5507 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 5507 CFXJSE_Value* argTwo = GetSimpleValue(pThis, args, 1); |
| 5508 HValueToUTF8String(argTwo, bsData); | 5508 ValueToUTF8String(argTwo, bsData); |
| 5509 if (argc > 2) { | 5509 if (argc > 2) { |
| 5510 argThree = GetSimpleHValue(hThis, args, 2); | 5510 argThree = GetSimpleValue(pThis, args, 2); |
| 5511 HValueToUTF8String(argThree, bsEncode); | 5511 ValueToUTF8String(argThree, bsEncode); |
| 5512 } | 5512 } |
| 5513 FX_BOOL bFlags = pAppProvider->PutRequestURL( | 5513 FX_BOOL bFlags = pAppProvider->PutRequestURL( |
| 5514 CFX_WideString::FromUTF8(bsURL.AsStringC()), | 5514 CFX_WideString::FromUTF8(bsURL.AsStringC()), |
| 5515 CFX_WideString::FromUTF8(bsData.AsStringC()), | 5515 CFX_WideString::FromUTF8(bsData.AsStringC()), |
| 5516 CFX_WideString::FromUTF8(bsEncode.AsStringC())); | 5516 CFX_WideString::FromUTF8(bsEncode.AsStringC())); |
| 5517 FXJSE_Value_Release(argOne); | 5517 FXJSE_Value_Release(argOne); |
| 5518 FXJSE_Value_Release(argTwo); | 5518 FXJSE_Value_Release(argTwo); |
| 5519 if (argc > 2) { | 5519 if (argc > 2) { |
| 5520 FXJSE_Value_Release(argThree); | 5520 FXJSE_Value_Release(argThree); |
| 5521 } | 5521 } |
| 5522 if (bFlags) { | 5522 if (bFlags) { |
| 5523 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5523 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 5524 } else { | 5524 } else { |
| 5525 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5525 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
| 5526 } | 5526 } |
| 5527 } else { | 5527 } else { |
| 5528 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5528 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5529 L"Put"); | 5529 L"Put"); |
| 5530 } | 5530 } |
| 5531 } | 5531 } |
| 5532 void CXFA_FM2JSContext::assign_value_operator(FXJSE_HOBJECT hThis, | 5532 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, |
| 5533 const CFX_ByteStringC& szFuncName, | 5533 const CFX_ByteStringC& szFuncName, |
| 5534 CFXJSE_Arguments& args) { | 5534 CFXJSE_Arguments& args) { |
| 5535 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5535 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5536 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5536 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5537 if (args.GetLength() == 2) { | 5537 if (args.GetLength() == 2) { |
| 5538 FXJSE_HVALUE lValue = args.GetValue(0); | 5538 CFXJSE_Value* lValue = args.GetValue(0); |
| 5539 FXJSE_HVALUE rValue = GetSimpleHValue(hThis, args, 1); | 5539 CFXJSE_Value* rValue = GetSimpleValue(pThis, args, 1); |
| 5540 FX_BOOL bSetStatus = TRUE; | 5540 FX_BOOL bSetStatus = TRUE; |
| 5541 if (FXJSE_Value_IsArray(lValue)) { | 5541 if (FXJSE_Value_IsArray(lValue)) { |
| 5542 FXJSE_HVALUE leftLengthValue = FXJSE_Value_Create(pIsolate); | 5542 CFXJSE_Value* leftLengthValue = FXJSE_Value_Create(pIsolate); |
| 5543 FXJSE_Value_GetObjectProp(lValue, "length", leftLengthValue); | 5543 FXJSE_Value_GetObjectProp(lValue, "length", leftLengthValue); |
| 5544 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue); | 5544 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue); |
| 5545 FXJSE_Value_Release(leftLengthValue); | 5545 FXJSE_Value_Release(leftLengthValue); |
| 5546 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 5546 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 5547 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 5547 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 5548 FXJSE_Value_GetObjectPropByIdx(lValue, 1, propertyValue); | 5548 FXJSE_Value_GetObjectPropByIdx(lValue, 1, propertyValue); |
| 5549 if (FXJSE_Value_IsNull(propertyValue)) { | 5549 if (FXJSE_Value_IsNull(propertyValue)) { |
| 5550 for (int32_t i = 2; i < iLeftLength; i++) { | 5550 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5551 FXJSE_Value_GetObjectPropByIdx(lValue, i, jsObjectValue); | 5551 FXJSE_Value_GetObjectPropByIdx(lValue, i, jsObjectValue); |
| 5552 bSetStatus = SetObjectDefaultValue(jsObjectValue, rValue); | 5552 bSetStatus = SetObjectDefaultValue(jsObjectValue, rValue); |
| 5553 if (!bSetStatus) { | 5553 if (!bSetStatus) { |
| 5554 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); | 5554 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5555 break; | 5555 break; |
| 5556 } | 5556 } |
| 5557 } | 5557 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5572 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); | 5572 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5573 } | 5573 } |
| 5574 } | 5574 } |
| 5575 FXJSE_Value_Set(args.GetReturnValue(), rValue); | 5575 FXJSE_Value_Set(args.GetReturnValue(), rValue); |
| 5576 FXJSE_Value_Release(lValue); | 5576 FXJSE_Value_Release(lValue); |
| 5577 FXJSE_Value_Release(rValue); | 5577 FXJSE_Value_Release(rValue); |
| 5578 } else { | 5578 } else { |
| 5579 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5579 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5580 } | 5580 } |
| 5581 } | 5581 } |
| 5582 void CXFA_FM2JSContext::logical_or_operator(FXJSE_HOBJECT hThis, | 5582 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, |
| 5583 const CFX_ByteStringC& szFuncName, | 5583 const CFX_ByteStringC& szFuncName, |
| 5584 CFXJSE_Arguments& args) { | 5584 CFXJSE_Arguments& args) { |
| 5585 if (args.GetLength() == 2) { | 5585 if (args.GetLength() == 2) { |
| 5586 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5586 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5587 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5587 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5588 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5588 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5589 FXJSE_Value_SetNull(args.GetReturnValue()); | 5589 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5590 } else { | 5590 } else { |
| 5591 FX_FLOAT first = HValueToFloat(hThis, argFirst); | 5591 FX_FLOAT first = ValueToFloat(pThis, argFirst); |
| 5592 FX_FLOAT second = HValueToFloat(hThis, argSecond); | 5592 FX_FLOAT second = ValueToFloat(pThis, argSecond); |
| 5593 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); | 5593 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); |
| 5594 } | 5594 } |
| 5595 FXJSE_Value_Release(argFirst); | 5595 FXJSE_Value_Release(argFirst); |
| 5596 FXJSE_Value_Release(argSecond); | 5596 FXJSE_Value_Release(argSecond); |
| 5597 } else { | 5597 } else { |
| 5598 CXFA_FM2JSContext* pContext = | 5598 CXFA_FM2JSContext* pContext = |
| 5599 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5599 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5600 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5600 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5601 } | 5601 } |
| 5602 } | 5602 } |
| 5603 void CXFA_FM2JSContext::logical_and_operator(FXJSE_HOBJECT hThis, | 5603 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, |
| 5604 const CFX_ByteStringC& szFuncName, | 5604 const CFX_ByteStringC& szFuncName, |
| 5605 CFXJSE_Arguments& args) { | 5605 CFXJSE_Arguments& args) { |
| 5606 if (args.GetLength() == 2) { | 5606 if (args.GetLength() == 2) { |
| 5607 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5607 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5608 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5608 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5609 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5609 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5610 FXJSE_Value_SetNull(args.GetReturnValue()); | 5610 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5611 } else { | 5611 } else { |
| 5612 FX_FLOAT first = HValueToFloat(hThis, argFirst); | 5612 FX_FLOAT first = ValueToFloat(pThis, argFirst); |
| 5613 FX_FLOAT second = HValueToFloat(hThis, argSecond); | 5613 FX_FLOAT second = ValueToFloat(pThis, argSecond); |
| 5614 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); | 5614 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); |
| 5615 } | 5615 } |
| 5616 FXJSE_Value_Release(argFirst); | 5616 FXJSE_Value_Release(argFirst); |
| 5617 FXJSE_Value_Release(argSecond); | 5617 FXJSE_Value_Release(argSecond); |
| 5618 } else { | 5618 } else { |
| 5619 CXFA_FM2JSContext* pContext = | 5619 CXFA_FM2JSContext* pContext = |
| 5620 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5620 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5621 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5621 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5622 } | 5622 } |
| 5623 } | 5623 } |
| 5624 void CXFA_FM2JSContext::equality_operator(FXJSE_HOBJECT hThis, | 5624 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, |
| 5625 const CFX_ByteStringC& szFuncName, | 5625 const CFX_ByteStringC& szFuncName, |
| 5626 CFXJSE_Arguments& args) { | 5626 CFXJSE_Arguments& args) { |
| 5627 if (args.GetLength() == 2) { | 5627 if (args.GetLength() == 2) { |
| 5628 if (fm_ref_equal(hThis, args)) { | 5628 if (fm_ref_equal(pThis, args)) { |
| 5629 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 5629 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
| 5630 } else { | 5630 } else { |
| 5631 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5631 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5632 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5632 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5633 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5633 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5634 FXJSE_Value_SetInteger( | 5634 FXJSE_Value_SetInteger( |
| 5635 args.GetReturnValue(), | 5635 args.GetReturnValue(), |
| 5636 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) | 5636 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) |
| 5637 ? 1 | 5637 ? 1 |
| 5638 : 0); | 5638 : 0); |
| 5639 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5639 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5640 FXJSE_Value_IsUTF8String(argSecond)) { | 5640 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5641 CFX_ByteString firstOutput; | 5641 CFX_ByteString firstOutput; |
| 5642 CFX_ByteString secondOutput; | 5642 CFX_ByteString secondOutput; |
| 5643 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5643 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5644 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5644 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5645 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5645 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5646 firstOutput == secondOutput); | 5646 firstOutput == secondOutput); |
| 5647 } else { | 5647 } else { |
| 5648 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5648 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5649 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5649 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5650 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5650 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5651 (first == second) ? 1 : 0); | 5651 (first == second) ? 1 : 0); |
| 5652 } | 5652 } |
| 5653 FXJSE_Value_Release(argFirst); | 5653 FXJSE_Value_Release(argFirst); |
| 5654 FXJSE_Value_Release(argSecond); | 5654 FXJSE_Value_Release(argSecond); |
| 5655 } | 5655 } |
| 5656 } else { | 5656 } else { |
| 5657 CXFA_FM2JSContext* pContext = | 5657 CXFA_FM2JSContext* pContext = |
| 5658 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5658 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5659 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5659 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5660 } | 5660 } |
| 5661 } | 5661 } |
| 5662 void CXFA_FM2JSContext::notequality_operator(FXJSE_HOBJECT hThis, | 5662 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, |
| 5663 const CFX_ByteStringC& szFuncName, | 5663 const CFX_ByteStringC& szFuncName, |
| 5664 CFXJSE_Arguments& args) { | 5664 CFXJSE_Arguments& args) { |
| 5665 if (args.GetLength() == 2) { | 5665 if (args.GetLength() == 2) { |
| 5666 if (fm_ref_equal(hThis, args)) { | 5666 if (fm_ref_equal(pThis, args)) { |
| 5667 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5667 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5668 } else { | 5668 } else { |
| 5669 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5669 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5670 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5670 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5671 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5671 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5672 FXJSE_Value_SetInteger( | 5672 FXJSE_Value_SetInteger( |
| 5673 args.GetReturnValue(), | 5673 args.GetReturnValue(), |
| 5674 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) | 5674 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) |
| 5675 ? 0 | 5675 ? 0 |
| 5676 : 1); | 5676 : 1); |
| 5677 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5677 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5678 FXJSE_Value_IsUTF8String(argSecond)) { | 5678 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5679 CFX_ByteString firstOutput; | 5679 CFX_ByteString firstOutput; |
| 5680 CFX_ByteString secondOutput; | 5680 CFX_ByteString secondOutput; |
| 5681 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5681 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5682 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5682 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5683 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5683 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5684 firstOutput != secondOutput); | 5684 firstOutput != secondOutput); |
| 5685 } else { | 5685 } else { |
| 5686 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5686 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5687 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5687 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5688 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); | 5688 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); |
| 5689 } | 5689 } |
| 5690 FXJSE_Value_Release(argFirst); | 5690 FXJSE_Value_Release(argFirst); |
| 5691 FXJSE_Value_Release(argSecond); | 5691 FXJSE_Value_Release(argSecond); |
| 5692 } | 5692 } |
| 5693 } else { | 5693 } else { |
| 5694 CXFA_FM2JSContext* pContext = | 5694 CXFA_FM2JSContext* pContext = |
| 5695 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5695 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5696 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5696 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5697 } | 5697 } |
| 5698 } | 5698 } |
| 5699 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(FXJSE_HOBJECT hThis, | 5699 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, |
| 5700 CFXJSE_Arguments& args) { | 5700 CFXJSE_Arguments& args) { |
| 5701 FX_BOOL bRet = FALSE; | 5701 FX_BOOL bRet = FALSE; |
| 5702 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5702 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5703 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5703 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5704 FXJSE_HVALUE argFirst = args.GetValue(0); | 5704 CFXJSE_Value* argFirst = args.GetValue(0); |
| 5705 FXJSE_HVALUE argSecond = args.GetValue(0); | 5705 CFXJSE_Value* argSecond = args.GetValue(0); |
| 5706 if (FXJSE_Value_IsArray(argFirst) && FXJSE_Value_IsArray(argSecond)) { | 5706 if (FXJSE_Value_IsArray(argFirst) && FXJSE_Value_IsArray(argSecond)) { |
| 5707 FXJSE_HVALUE firstFlagValue = FXJSE_Value_Create(pIsolate); | 5707 CFXJSE_Value* firstFlagValue = FXJSE_Value_Create(pIsolate); |
| 5708 FXJSE_HVALUE secondFlagValue = FXJSE_Value_Create(pIsolate); | 5708 CFXJSE_Value* secondFlagValue = FXJSE_Value_Create(pIsolate); |
| 5709 FXJSE_Value_GetObjectPropByIdx(argFirst, 0, firstFlagValue); | 5709 FXJSE_Value_GetObjectPropByIdx(argFirst, 0, firstFlagValue); |
| 5710 FXJSE_Value_GetObjectPropByIdx(argSecond, 0, secondFlagValue); | 5710 FXJSE_Value_GetObjectPropByIdx(argSecond, 0, secondFlagValue); |
| 5711 if ((FXJSE_Value_ToInteger(firstFlagValue) == 3) && | 5711 if ((FXJSE_Value_ToInteger(firstFlagValue) == 3) && |
| 5712 (FXJSE_Value_ToInteger(secondFlagValue) == 3)) { | 5712 (FXJSE_Value_ToInteger(secondFlagValue) == 3)) { |
| 5713 FXJSE_HVALUE firstJSObject = FXJSE_Value_Create(pIsolate); | 5713 CFXJSE_Value* firstJSObject = FXJSE_Value_Create(pIsolate); |
| 5714 FXJSE_HVALUE secondJSObject = FXJSE_Value_Create(pIsolate); | 5714 CFXJSE_Value* secondJSObject = FXJSE_Value_Create(pIsolate); |
| 5715 FXJSE_Value_GetObjectPropByIdx(argFirst, 2, firstJSObject); | 5715 FXJSE_Value_GetObjectPropByIdx(argFirst, 2, firstJSObject); |
| 5716 FXJSE_Value_GetObjectPropByIdx(argSecond, 2, secondJSObject); | 5716 FXJSE_Value_GetObjectPropByIdx(argSecond, 2, secondJSObject); |
| 5717 if (!FXJSE_Value_IsNull(firstJSObject) && | 5717 if (!FXJSE_Value_IsNull(firstJSObject) && |
| 5718 !FXJSE_Value_IsNull(secondJSObject)) { | 5718 !FXJSE_Value_IsNull(secondJSObject)) { |
| 5719 bRet = (FXJSE_Value_ToObject(firstJSObject) == | 5719 bRet = (FXJSE_Value_ToObject(firstJSObject) == |
| 5720 FXJSE_Value_ToObject(secondJSObject)); | 5720 FXJSE_Value_ToObject(secondJSObject)); |
| 5721 } | 5721 } |
| 5722 FXJSE_Value_Release(firstJSObject); | 5722 FXJSE_Value_Release(firstJSObject); |
| 5723 FXJSE_Value_Release(secondJSObject); | 5723 FXJSE_Value_Release(secondJSObject); |
| 5724 } | 5724 } |
| 5725 FXJSE_Value_Release(firstFlagValue); | 5725 FXJSE_Value_Release(firstFlagValue); |
| 5726 FXJSE_Value_Release(secondFlagValue); | 5726 FXJSE_Value_Release(secondFlagValue); |
| 5727 } | 5727 } |
| 5728 FXJSE_Value_Release(argFirst); | 5728 FXJSE_Value_Release(argFirst); |
| 5729 FXJSE_Value_Release(argSecond); | 5729 FXJSE_Value_Release(argSecond); |
| 5730 return bRet; | 5730 return bRet; |
| 5731 } | 5731 } |
| 5732 void CXFA_FM2JSContext::less_operator(FXJSE_HOBJECT hThis, | 5732 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, |
| 5733 const CFX_ByteStringC& szFuncName, | 5733 const CFX_ByteStringC& szFuncName, |
| 5734 CFXJSE_Arguments& args) { | 5734 CFXJSE_Arguments& args) { |
| 5735 if (args.GetLength() == 2) { | 5735 if (args.GetLength() == 2) { |
| 5736 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5736 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5737 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5737 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5738 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5738 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5739 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5739 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5740 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5740 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5741 FXJSE_Value_IsUTF8String(argSecond)) { | 5741 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5742 CFX_ByteString firstOutput; | 5742 CFX_ByteString firstOutput; |
| 5743 CFX_ByteString secondOutput; | 5743 CFX_ByteString secondOutput; |
| 5744 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5744 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5745 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5745 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5746 FXJSE_Value_SetInteger( | 5746 FXJSE_Value_SetInteger( |
| 5747 args.GetReturnValue(), | 5747 args.GetReturnValue(), |
| 5748 firstOutput.Compare(secondOutput.AsStringC()) == -1); | 5748 firstOutput.Compare(secondOutput.AsStringC()) == -1); |
| 5749 } else { | 5749 } else { |
| 5750 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5750 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5751 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5751 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5752 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); | 5752 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); |
| 5753 } | 5753 } |
| 5754 FXJSE_Value_Release(argFirst); | 5754 FXJSE_Value_Release(argFirst); |
| 5755 FXJSE_Value_Release(argSecond); | 5755 FXJSE_Value_Release(argSecond); |
| 5756 } else { | 5756 } else { |
| 5757 CXFA_FM2JSContext* pContext = | 5757 CXFA_FM2JSContext* pContext = |
| 5758 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5758 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5759 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5759 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5760 } | 5760 } |
| 5761 } | 5761 } |
| 5762 void CXFA_FM2JSContext::lessequal_operator(FXJSE_HOBJECT hThis, | 5762 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, |
| 5763 const CFX_ByteStringC& szFuncName, | 5763 const CFX_ByteStringC& szFuncName, |
| 5764 CFXJSE_Arguments& args) { | 5764 CFXJSE_Arguments& args) { |
| 5765 if (args.GetLength() == 2) { | 5765 if (args.GetLength() == 2) { |
| 5766 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5766 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5767 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5767 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5768 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5768 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5769 FXJSE_Value_SetInteger( | 5769 FXJSE_Value_SetInteger( |
| 5770 args.GetReturnValue(), | 5770 args.GetReturnValue(), |
| 5771 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 | 5771 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 |
| 5772 : 0); | 5772 : 0); |
| 5773 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5773 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5774 FXJSE_Value_IsUTF8String(argSecond)) { | 5774 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5775 CFX_ByteString firstOutput; | 5775 CFX_ByteString firstOutput; |
| 5776 CFX_ByteString secondOutput; | 5776 CFX_ByteString secondOutput; |
| 5777 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5777 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5778 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5778 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5779 FXJSE_Value_SetInteger( | 5779 FXJSE_Value_SetInteger( |
| 5780 args.GetReturnValue(), | 5780 args.GetReturnValue(), |
| 5781 firstOutput.Compare(secondOutput.AsStringC()) != 1); | 5781 firstOutput.Compare(secondOutput.AsStringC()) != 1); |
| 5782 } else { | 5782 } else { |
| 5783 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5783 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5784 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5784 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5785 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); | 5785 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); |
| 5786 } | 5786 } |
| 5787 FXJSE_Value_Release(argFirst); | 5787 FXJSE_Value_Release(argFirst); |
| 5788 FXJSE_Value_Release(argSecond); | 5788 FXJSE_Value_Release(argSecond); |
| 5789 } else { | 5789 } else { |
| 5790 CXFA_FM2JSContext* pContext = | 5790 CXFA_FM2JSContext* pContext = |
| 5791 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5791 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5792 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5792 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5793 } | 5793 } |
| 5794 } | 5794 } |
| 5795 void CXFA_FM2JSContext::greater_operator(FXJSE_HOBJECT hThis, | 5795 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, |
| 5796 const CFX_ByteStringC& szFuncName, | 5796 const CFX_ByteStringC& szFuncName, |
| 5797 CFXJSE_Arguments& args) { | 5797 CFXJSE_Arguments& args) { |
| 5798 if (args.GetLength() == 2) { | 5798 if (args.GetLength() == 2) { |
| 5799 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5799 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5800 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5800 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5801 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5801 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5802 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5802 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5803 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5803 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5804 FXJSE_Value_IsUTF8String(argSecond)) { | 5804 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5805 CFX_ByteString firstOutput; | 5805 CFX_ByteString firstOutput; |
| 5806 CFX_ByteString secondOutput; | 5806 CFX_ByteString secondOutput; |
| 5807 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5807 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5808 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5808 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5809 FXJSE_Value_SetInteger( | 5809 FXJSE_Value_SetInteger( |
| 5810 args.GetReturnValue(), | 5810 args.GetReturnValue(), |
| 5811 firstOutput.Compare(secondOutput.AsStringC()) == 1); | 5811 firstOutput.Compare(secondOutput.AsStringC()) == 1); |
| 5812 } else { | 5812 } else { |
| 5813 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5813 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5814 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5814 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5815 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); | 5815 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); |
| 5816 } | 5816 } |
| 5817 FXJSE_Value_Release(argFirst); | 5817 FXJSE_Value_Release(argFirst); |
| 5818 FXJSE_Value_Release(argSecond); | 5818 FXJSE_Value_Release(argSecond); |
| 5819 } else { | 5819 } else { |
| 5820 CXFA_FM2JSContext* pContext = | 5820 CXFA_FM2JSContext* pContext = |
| 5821 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5821 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5822 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5822 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5823 } | 5823 } |
| 5824 } | 5824 } |
| 5825 void CXFA_FM2JSContext::greaterequal_operator(FXJSE_HOBJECT hThis, | 5825 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, |
| 5826 const CFX_ByteStringC& szFuncName, | 5826 const CFX_ByteStringC& szFuncName, |
| 5827 CFXJSE_Arguments& args) { | 5827 CFXJSE_Arguments& args) { |
| 5828 if (args.GetLength() == 2) { | 5828 if (args.GetLength() == 2) { |
| 5829 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5829 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5830 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5830 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5831 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { | 5831 if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { |
| 5832 FXJSE_Value_SetInteger( | 5832 FXJSE_Value_SetInteger( |
| 5833 args.GetReturnValue(), | 5833 args.GetReturnValue(), |
| 5834 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 | 5834 (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 |
| 5835 : 0); | 5835 : 0); |
| 5836 } else if (FXJSE_Value_IsUTF8String(argFirst) && | 5836 } else if (FXJSE_Value_IsUTF8String(argFirst) && |
| 5837 FXJSE_Value_IsUTF8String(argSecond)) { | 5837 FXJSE_Value_IsUTF8String(argSecond)) { |
| 5838 CFX_ByteString firstOutput; | 5838 CFX_ByteString firstOutput; |
| 5839 CFX_ByteString secondOutput; | 5839 CFX_ByteString secondOutput; |
| 5840 FXJSE_Value_ToUTF8String(argFirst, firstOutput); | 5840 FXJSE_Value_ToUTF8String(argFirst, firstOutput); |
| 5841 FXJSE_Value_ToUTF8String(argSecond, secondOutput); | 5841 FXJSE_Value_ToUTF8String(argSecond, secondOutput); |
| 5842 FXJSE_Value_SetInteger( | 5842 FXJSE_Value_SetInteger( |
| 5843 args.GetReturnValue(), | 5843 args.GetReturnValue(), |
| 5844 firstOutput.Compare(secondOutput.AsStringC()) != -1); | 5844 firstOutput.Compare(secondOutput.AsStringC()) != -1); |
| 5845 } else { | 5845 } else { |
| 5846 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5846 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5847 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5847 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5848 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); | 5848 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); |
| 5849 } | 5849 } |
| 5850 FXJSE_Value_Release(argFirst); | 5850 FXJSE_Value_Release(argFirst); |
| 5851 FXJSE_Value_Release(argSecond); | 5851 FXJSE_Value_Release(argSecond); |
| 5852 } else { | 5852 } else { |
| 5853 CXFA_FM2JSContext* pContext = | 5853 CXFA_FM2JSContext* pContext = |
| 5854 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5854 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5855 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5855 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5856 } | 5856 } |
| 5857 } | 5857 } |
| 5858 void CXFA_FM2JSContext::plus_operator(FXJSE_HOBJECT hThis, | 5858 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, |
| 5859 const CFX_ByteStringC& szFuncName, | 5859 const CFX_ByteStringC& szFuncName, |
| 5860 CFXJSE_Arguments& args) { | 5860 CFXJSE_Arguments& args) { |
| 5861 if (args.GetLength() == 2) { | 5861 if (args.GetLength() == 2) { |
| 5862 FXJSE_HVALUE argFirst = args.GetValue(0); | 5862 CFXJSE_Value* argFirst = args.GetValue(0); |
| 5863 FXJSE_HVALUE argSecond = args.GetValue(1); | 5863 CFXJSE_Value* argSecond = args.GetValue(1); |
| 5864 if (HValueIsNull(hThis, argFirst) && HValueIsNull(hThis, argSecond)) { | 5864 if (ValueIsNull(pThis, argFirst) && ValueIsNull(pThis, argSecond)) { |
| 5865 FXJSE_Value_SetNull(args.GetReturnValue()); | 5865 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5866 } else { | 5866 } else { |
| 5867 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5867 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5868 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5868 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5869 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); | 5869 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); |
| 5870 } | 5870 } |
| 5871 FXJSE_Value_Release(argFirst); | 5871 FXJSE_Value_Release(argFirst); |
| 5872 FXJSE_Value_Release(argSecond); | 5872 FXJSE_Value_Release(argSecond); |
| 5873 } else { | 5873 } else { |
| 5874 CXFA_FM2JSContext* pContext = | 5874 CXFA_FM2JSContext* pContext = |
| 5875 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5875 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5876 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5876 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5877 } | 5877 } |
| 5878 } | 5878 } |
| 5879 void CXFA_FM2JSContext::minus_operator(FXJSE_HOBJECT hThis, | 5879 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, |
| 5880 const CFX_ByteStringC& szFuncName, | 5880 const CFX_ByteStringC& szFuncName, |
| 5881 CFXJSE_Arguments& args) { | 5881 CFXJSE_Arguments& args) { |
| 5882 if (args.GetLength() == 2) { | 5882 if (args.GetLength() == 2) { |
| 5883 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5883 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5884 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5884 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5885 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5885 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5886 FXJSE_Value_SetNull(args.GetReturnValue()); | 5886 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5887 } else { | 5887 } else { |
| 5888 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5888 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5889 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5889 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5890 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); | 5890 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); |
| 5891 } | 5891 } |
| 5892 FXJSE_Value_Release(argFirst); | 5892 FXJSE_Value_Release(argFirst); |
| 5893 FXJSE_Value_Release(argSecond); | 5893 FXJSE_Value_Release(argSecond); |
| 5894 } else { | 5894 } else { |
| 5895 CXFA_FM2JSContext* pContext = | 5895 CXFA_FM2JSContext* pContext = |
| 5896 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5896 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5897 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5897 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5898 } | 5898 } |
| 5899 } | 5899 } |
| 5900 void CXFA_FM2JSContext::multiple_operator(FXJSE_HOBJECT hThis, | 5900 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, |
| 5901 const CFX_ByteStringC& szFuncName, | 5901 const CFX_ByteStringC& szFuncName, |
| 5902 CFXJSE_Arguments& args) { | 5902 CFXJSE_Arguments& args) { |
| 5903 if (args.GetLength() == 2) { | 5903 if (args.GetLength() == 2) { |
| 5904 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5904 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5905 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5905 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5906 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5906 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5907 FXJSE_Value_SetNull(args.GetReturnValue()); | 5907 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5908 } else { | 5908 } else { |
| 5909 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5909 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5910 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5910 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5911 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); | 5911 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); |
| 5912 } | 5912 } |
| 5913 FXJSE_Value_Release(argFirst); | 5913 FXJSE_Value_Release(argFirst); |
| 5914 FXJSE_Value_Release(argSecond); | 5914 FXJSE_Value_Release(argSecond); |
| 5915 } else { | 5915 } else { |
| 5916 CXFA_FM2JSContext* pContext = | 5916 CXFA_FM2JSContext* pContext = |
| 5917 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5917 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5918 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5918 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5919 } | 5919 } |
| 5920 } | 5920 } |
| 5921 void CXFA_FM2JSContext::divide_operator(FXJSE_HOBJECT hThis, | 5921 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, |
| 5922 const CFX_ByteStringC& szFuncName, | 5922 const CFX_ByteStringC& szFuncName, |
| 5923 CFXJSE_Arguments& args) { | 5923 CFXJSE_Arguments& args) { |
| 5924 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5924 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5925 if (args.GetLength() == 2) { | 5925 if (args.GetLength() == 2) { |
| 5926 FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); | 5926 CFXJSE_Value* argFirst = GetSimpleValue(pThis, args, 0); |
| 5927 FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); | 5927 CFXJSE_Value* argSecond = GetSimpleValue(pThis, args, 1); |
| 5928 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { | 5928 if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { |
| 5929 FXJSE_Value_SetNull(args.GetReturnValue()); | 5929 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5930 } else { | 5930 } else { |
| 5931 FX_DOUBLE first = HValueToDouble(hThis, argFirst); | 5931 FX_DOUBLE first = ValueToDouble(pThis, argFirst); |
| 5932 FX_DOUBLE second = HValueToDouble(hThis, argSecond); | 5932 FX_DOUBLE second = ValueToDouble(pThis, argSecond); |
| 5933 if (second == 0.0) { | 5933 if (second == 0.0) { |
| 5934 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); | 5934 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); |
| 5935 } else { | 5935 } else { |
| 5936 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); | 5936 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); |
| 5937 } | 5937 } |
| 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 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5942 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5943 } | 5943 } |
| 5944 } | 5944 } |
| 5945 void CXFA_FM2JSContext::positive_operator(FXJSE_HOBJECT hThis, | 5945 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, |
| 5946 const CFX_ByteStringC& szFuncName, | 5946 const CFX_ByteStringC& szFuncName, |
| 5947 CFXJSE_Arguments& args) { | 5947 CFXJSE_Arguments& args) { |
| 5948 int32_t iLength = args.GetLength(); | 5948 int32_t iLength = args.GetLength(); |
| 5949 if (iLength == 1) { | 5949 if (iLength == 1) { |
| 5950 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5950 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5951 if (FXJSE_Value_IsNull(argOne)) { | 5951 if (FXJSE_Value_IsNull(argOne)) { |
| 5952 FXJSE_Value_SetNull(args.GetReturnValue()); | 5952 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5953 } else { | 5953 } else { |
| 5954 FXJSE_Value_SetDouble(args.GetReturnValue(), | 5954 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 5955 0.0 + HValueToDouble(hThis, argOne)); | 5955 0.0 + ValueToDouble(pThis, argOne)); |
| 5956 } | 5956 } |
| 5957 FXJSE_Value_Release(argOne); | 5957 FXJSE_Value_Release(argOne); |
| 5958 } else { | 5958 } else { |
| 5959 CXFA_FM2JSContext* pContext = | 5959 CXFA_FM2JSContext* pContext = |
| 5960 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5960 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5961 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5961 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5962 } | 5962 } |
| 5963 } | 5963 } |
| 5964 void CXFA_FM2JSContext::negative_operator(FXJSE_HOBJECT hThis, | 5964 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, |
| 5965 const CFX_ByteStringC& szFuncName, | 5965 const CFX_ByteStringC& szFuncName, |
| 5966 CFXJSE_Arguments& args) { | 5966 CFXJSE_Arguments& args) { |
| 5967 int32_t iLength = args.GetLength(); | 5967 int32_t iLength = args.GetLength(); |
| 5968 if (iLength == 1) { | 5968 if (iLength == 1) { |
| 5969 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5969 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5970 if (FXJSE_Value_IsNull(argOne)) { | 5970 if (FXJSE_Value_IsNull(argOne)) { |
| 5971 FXJSE_Value_SetNull(args.GetReturnValue()); | 5971 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5972 } else { | 5972 } else { |
| 5973 FXJSE_Value_SetDouble(args.GetReturnValue(), | 5973 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 5974 0.0 - HValueToDouble(hThis, argOne)); | 5974 0.0 - ValueToDouble(pThis, argOne)); |
| 5975 } | 5975 } |
| 5976 FXJSE_Value_Release(argOne); | 5976 FXJSE_Value_Release(argOne); |
| 5977 } else { | 5977 } else { |
| 5978 CXFA_FM2JSContext* pContext = | 5978 CXFA_FM2JSContext* pContext = |
| 5979 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5979 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5980 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5980 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5981 } | 5981 } |
| 5982 } | 5982 } |
| 5983 void CXFA_FM2JSContext::logical_not_operator(FXJSE_HOBJECT hThis, | 5983 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, |
| 5984 const CFX_ByteStringC& szFuncName, | 5984 const CFX_ByteStringC& szFuncName, |
| 5985 CFXJSE_Arguments& args) { | 5985 CFXJSE_Arguments& args) { |
| 5986 int32_t iLength = args.GetLength(); | 5986 int32_t iLength = args.GetLength(); |
| 5987 if (iLength == 1) { | 5987 if (iLength == 1) { |
| 5988 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 5988 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 5989 if (FXJSE_Value_IsNull(argOne)) { | 5989 if (FXJSE_Value_IsNull(argOne)) { |
| 5990 FXJSE_Value_SetNull(args.GetReturnValue()); | 5990 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5991 } else { | 5991 } else { |
| 5992 FX_DOUBLE first = HValueToDouble(hThis, argOne); | 5992 FX_DOUBLE first = ValueToDouble(pThis, argOne); |
| 5993 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); | 5993 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); |
| 5994 } | 5994 } |
| 5995 FXJSE_Value_Release(argOne); | 5995 FXJSE_Value_Release(argOne); |
| 5996 } else { | 5996 } else { |
| 5997 CXFA_FM2JSContext* pContext = | 5997 CXFA_FM2JSContext* pContext = |
| 5998 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 5998 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 5999 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5999 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6000 } | 6000 } |
| 6001 } | 6001 } |
| 6002 void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis, | 6002 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, |
| 6003 const CFX_ByteStringC& szFuncName, | 6003 const CFX_ByteStringC& szFuncName, |
| 6004 CFXJSE_Arguments& args) { | 6004 CFXJSE_Arguments& args) { |
| 6005 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6005 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6006 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6006 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6007 int32_t argc = args.GetLength(); | 6007 int32_t argc = args.GetLength(); |
| 6008 if ((argc == 4) || (argc == 5)) { | 6008 if ((argc == 4) || (argc == 5)) { |
| 6009 FX_BOOL bIsStar = TRUE; | 6009 FX_BOOL bIsStar = TRUE; |
| 6010 FXJSE_HVALUE argAccessor = args.GetValue(0); | 6010 CFXJSE_Value* argAccessor = args.GetValue(0); |
| 6011 CFX_ByteString bsAccessorName = args.GetUTF8String(1); | 6011 CFX_ByteString bsAccessorName = args.GetUTF8String(1); |
| 6012 CFX_ByteString szName = args.GetUTF8String(2); | 6012 CFX_ByteString szName = args.GetUTF8String(2); |
| 6013 int32_t iIndexFlags = args.GetInt32(3); | 6013 int32_t iIndexFlags = args.GetInt32(3); |
| 6014 int32_t iIndexValue = 0; | 6014 int32_t iIndexValue = 0; |
| 6015 FXJSE_HVALUE argIndex = NULL; | 6015 CFXJSE_Value* argIndex = NULL; |
| 6016 if (argc == 5) { | 6016 if (argc == 5) { |
| 6017 bIsStar = FALSE; | 6017 bIsStar = FALSE; |
| 6018 argIndex = args.GetValue(4); | 6018 argIndex = args.GetValue(4); |
| 6019 iIndexValue = HValueToInteger(hThis, argIndex); | 6019 iIndexValue = ValueToInteger(pThis, argIndex); |
| 6020 } | 6020 } |
| 6021 CFX_ByteString szSomExp; | 6021 CFX_ByteString szSomExp; |
| 6022 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, | 6022 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, |
| 6023 szSomExp); | 6023 szSomExp); |
| 6024 if (FXJSE_Value_IsArray(argAccessor)) { | 6024 if (FXJSE_Value_IsArray(argAccessor)) { |
| 6025 FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(pIsolate); | 6025 CFXJSE_Value* pLengthValue = FXJSE_Value_Create(pIsolate); |
| 6026 FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue); | 6026 FXJSE_Value_GetObjectProp(argAccessor, "length", pLengthValue); |
| 6027 int32_t iLength = FXJSE_Value_ToInteger(hLengthValue); | 6027 int32_t iLength = FXJSE_Value_ToInteger(pLengthValue); |
| 6028 FXJSE_Value_Release(hLengthValue); | 6028 FXJSE_Value_Release(pLengthValue); |
| 6029 int32_t iCounter = 0; | 6029 int32_t iCounter = 0; |
| 6030 FXJSE_HVALUE** hResolveValues = FX_Alloc(FXJSE_HVALUE*, iLength - 2); | 6030 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); |
| 6031 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); | 6031 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); |
| 6032 for (int32_t i = 0; i < (iLength - 2); i++) { | 6032 for (int32_t i = 0; i < (iLength - 2); i++) { |
| 6033 iSizes[i] = 0; | 6033 iSizes[i] = 0; |
| 6034 } | 6034 } |
| 6035 FXJSE_HVALUE hJSObjValue = FXJSE_Value_Create(pIsolate); | 6035 CFXJSE_Value* hJSObjValue = FXJSE_Value_Create(pIsolate); |
| 6036 FX_BOOL bAttribute = FALSE; | 6036 FX_BOOL bAttribute = FALSE; |
| 6037 for (int32_t i = 2; i < iLength; i++) { | 6037 for (int32_t i = 2; i < iLength; i++) { |
| 6038 FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue); | 6038 FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue); |
| 6039 XFA_RESOLVENODE_RS resoveNodeRS; | 6039 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6040 int32_t iRet = ResolveObjects(hThis, hJSObjValue, szSomExp.AsStringC(), | 6040 int32_t iRet = ResolveObjects(pThis, hJSObjValue, szSomExp.AsStringC(), |
| 6041 resoveNodeRS, TRUE, szName.IsEmpty()); | 6041 resoveNodeRS, TRUE, szName.IsEmpty()); |
| 6042 if (iRet > 0) { | 6042 if (iRet > 0) { |
| 6043 ParseResolveResult(hThis, resoveNodeRS, hJSObjValue, | 6043 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue, |
| 6044 hResolveValues[i - 2], iSizes[i - 2], bAttribute); | 6044 hResolveValues[i - 2], iSizes[i - 2], bAttribute); |
| 6045 iCounter += iSizes[i - 2]; | 6045 iCounter += iSizes[i - 2]; |
| 6046 } | 6046 } |
| 6047 } | 6047 } |
| 6048 FXJSE_Value_Release(hJSObjValue); | 6048 FXJSE_Value_Release(hJSObjValue); |
| 6049 if (iCounter > 0) { | 6049 if (iCounter > 0) { |
| 6050 FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iCounter + 2); | 6050 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2); |
| 6051 for (int32_t i = 0; i < (iCounter + 2); i++) { | 6051 for (int32_t i = 0; i < (iCounter + 2); i++) { |
| 6052 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6052 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6053 } | 6053 } |
| 6054 FXJSE_Value_SetInteger(rgValues[0], 1); | 6054 FXJSE_Value_SetInteger(rgValues[0], 1); |
| 6055 if (bAttribute) { | 6055 if (bAttribute) { |
| 6056 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); | 6056 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); |
| 6057 } else { | 6057 } else { |
| 6058 FXJSE_Value_SetNull(rgValues[1]); | 6058 FXJSE_Value_SetNull(rgValues[1]); |
| 6059 } | 6059 } |
| 6060 int32_t iIndex = 2; | 6060 int32_t iIndex = 2; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6086 FX_Free(hResolveValues[i]); | 6086 FX_Free(hResolveValues[i]); |
| 6087 } | 6087 } |
| 6088 } | 6088 } |
| 6089 FX_Free(hResolveValues); | 6089 FX_Free(hResolveValues); |
| 6090 FX_Free(iSizes); | 6090 FX_Free(iSizes); |
| 6091 } else { | 6091 } else { |
| 6092 XFA_RESOLVENODE_RS resoveNodeRS; | 6092 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6093 int32_t iRet = 0; | 6093 int32_t iRet = 0; |
| 6094 if (FXJSE_Value_IsObject(argAccessor) || | 6094 if (FXJSE_Value_IsObject(argAccessor) || |
| 6095 (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { | 6095 (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { |
| 6096 iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(), | 6096 iRet = ResolveObjects(pThis, argAccessor, szSomExp.AsStringC(), |
| 6097 resoveNodeRS, TRUE, szName.IsEmpty()); | 6097 resoveNodeRS, TRUE, szName.IsEmpty()); |
| 6098 } else if (!FXJSE_Value_IsObject(argAccessor) && | 6098 } else if (!FXJSE_Value_IsObject(argAccessor) && |
| 6099 !bsAccessorName.IsEmpty()) { | 6099 !bsAccessorName.IsEmpty()) { |
| 6100 FX_BOOL bGetObject = | 6100 FX_BOOL bGetObject = |
| 6101 GetObjectByName(hThis, argAccessor, bsAccessorName.AsStringC()); | 6101 GetObjectByName(pThis, argAccessor, bsAccessorName.AsStringC()); |
| 6102 if (bGetObject) { | 6102 if (bGetObject) { |
| 6103 iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(), | 6103 iRet = ResolveObjects(pThis, argAccessor, szSomExp.AsStringC(), |
| 6104 resoveNodeRS, TRUE, szName.IsEmpty()); | 6104 resoveNodeRS, TRUE, szName.IsEmpty()); |
| 6105 } | 6105 } |
| 6106 } | 6106 } |
| 6107 if (iRet > 0) { | 6107 if (iRet > 0) { |
| 6108 FXJSE_HVALUE* hResolveValues; | 6108 CFXJSE_Value** hResolveValues; |
| 6109 int32_t iSize = 0; | 6109 int32_t iSize = 0; |
| 6110 FX_BOOL bAttribute = FALSE; | 6110 FX_BOOL bAttribute = FALSE; |
| 6111 ParseResolveResult(hThis, resoveNodeRS, argAccessor, hResolveValues, | 6111 ParseResolveResult(pThis, resoveNodeRS, argAccessor, hResolveValues, |
| 6112 iSize, bAttribute); | 6112 iSize, bAttribute); |
| 6113 FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iSize + 2); | 6113 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2); |
| 6114 for (int32_t i = 0; i < (iSize + 2); i++) { | 6114 for (int32_t i = 0; i < (iSize + 2); i++) { |
| 6115 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6115 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6116 } | 6116 } |
| 6117 FXJSE_Value_SetInteger(rgValues[0], 1); | 6117 FXJSE_Value_SetInteger(rgValues[0], 1); |
| 6118 if (bAttribute) { | 6118 if (bAttribute) { |
| 6119 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); | 6119 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); |
| 6120 } else { | 6120 } else { |
| 6121 FXJSE_Value_SetNull(rgValues[1]); | 6121 FXJSE_Value_SetNull(rgValues[1]); |
| 6122 } | 6122 } |
| 6123 for (int32_t i = 0; i < iSize; i++) { | 6123 for (int32_t i = 0; i < iSize; i++) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6143 } | 6143 } |
| 6144 } | 6144 } |
| 6145 if (argc == 5) { | 6145 if (argc == 5) { |
| 6146 FXJSE_Value_Release(argIndex); | 6146 FXJSE_Value_Release(argIndex); |
| 6147 } | 6147 } |
| 6148 FXJSE_Value_Release(argAccessor); | 6148 FXJSE_Value_Release(argAccessor); |
| 6149 } else { | 6149 } else { |
| 6150 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6150 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6151 } | 6151 } |
| 6152 } | 6152 } |
| 6153 void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis, | 6153 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, |
| 6154 const CFX_ByteStringC& szFuncName, | 6154 const CFX_ByteStringC& szFuncName, |
| 6155 CFXJSE_Arguments& args) { | 6155 CFXJSE_Arguments& args) { |
| 6156 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6156 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6157 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6157 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6158 int32_t argc = args.GetLength(); | 6158 int32_t argc = args.GetLength(); |
| 6159 if ((argc == 4) || (argc == 5)) { | 6159 if ((argc == 4) || (argc == 5)) { |
| 6160 FX_BOOL bIsStar = TRUE; | 6160 FX_BOOL bIsStar = TRUE; |
| 6161 FXJSE_HVALUE argAccessor = args.GetValue(0); | 6161 CFXJSE_Value* argAccessor = args.GetValue(0); |
| 6162 CFX_ByteString bsAccessorName = args.GetUTF8String(1); | 6162 CFX_ByteString bsAccessorName = args.GetUTF8String(1); |
| 6163 CFX_ByteString szName = args.GetUTF8String(2); | 6163 CFX_ByteString szName = args.GetUTF8String(2); |
| 6164 int32_t iIndexFlags = args.GetInt32(3); | 6164 int32_t iIndexFlags = args.GetInt32(3); |
| 6165 int32_t iIndexValue = 0; | 6165 int32_t iIndexValue = 0; |
| 6166 FXJSE_HVALUE argIndex = NULL; | 6166 CFXJSE_Value* argIndex = NULL; |
| 6167 if (argc == 5) { | 6167 if (argc == 5) { |
| 6168 bIsStar = FALSE; | 6168 bIsStar = FALSE; |
| 6169 argIndex = args.GetValue(4); | 6169 argIndex = args.GetValue(4); |
| 6170 iIndexValue = HValueToInteger(hThis, argIndex); | 6170 iIndexValue = ValueToInteger(pThis, argIndex); |
| 6171 } | 6171 } |
| 6172 CFX_ByteString szSomExp; | 6172 CFX_ByteString szSomExp; |
| 6173 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, | 6173 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, |
| 6174 szSomExp); | 6174 szSomExp); |
| 6175 if (FXJSE_Value_IsArray(argAccessor)) { | 6175 if (FXJSE_Value_IsArray(argAccessor)) { |
| 6176 FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(pIsolate); | 6176 CFXJSE_Value* pLengthValue = FXJSE_Value_Create(pIsolate); |
| 6177 FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue); | 6177 FXJSE_Value_GetObjectProp(argAccessor, "length", pLengthValue); |
| 6178 int32_t iLength = FXJSE_Value_ToInteger(hLengthValue); | 6178 int32_t iLength = FXJSE_Value_ToInteger(pLengthValue); |
| 6179 int32_t iCounter = 0; | 6179 int32_t iCounter = 0; |
| 6180 FXJSE_HVALUE** hResolveValues = FX_Alloc(FXJSE_HVALUE*, iLength - 2); | 6180 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); |
| 6181 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); | 6181 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); |
| 6182 FXJSE_HVALUE hJSObjValue = FXJSE_Value_Create(pIsolate); | 6182 CFXJSE_Value* hJSObjValue = FXJSE_Value_Create(pIsolate); |
| 6183 FX_BOOL bAttribute = FALSE; | 6183 FX_BOOL bAttribute = FALSE; |
| 6184 for (int32_t i = 2; i < iLength; i++) { | 6184 for (int32_t i = 2; i < iLength; i++) { |
| 6185 FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue); | 6185 FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue); |
| 6186 XFA_RESOLVENODE_RS resoveNodeRS; | 6186 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6187 int32_t iRet = ResolveObjects(hThis, hJSObjValue, szSomExp.AsStringC(), | 6187 int32_t iRet = ResolveObjects(pThis, hJSObjValue, szSomExp.AsStringC(), |
| 6188 resoveNodeRS, FALSE); | 6188 resoveNodeRS, FALSE); |
| 6189 if (iRet > 0) { | 6189 if (iRet > 0) { |
| 6190 ParseResolveResult(hThis, resoveNodeRS, hJSObjValue, | 6190 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue, |
| 6191 hResolveValues[i - 2], iSizes[i - 2], bAttribute); | 6191 hResolveValues[i - 2], iSizes[i - 2], bAttribute); |
| 6192 iCounter += iSizes[i - 2]; | 6192 iCounter += iSizes[i - 2]; |
| 6193 } | 6193 } |
| 6194 } | 6194 } |
| 6195 FXJSE_Value_Release(hJSObjValue); | 6195 FXJSE_Value_Release(hJSObjValue); |
| 6196 if (iCounter > 0) { | 6196 if (iCounter > 0) { |
| 6197 FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iCounter + 2); | 6197 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2); |
| 6198 for (int32_t i = 0; i < (iCounter + 2); i++) { | 6198 for (int32_t i = 0; i < (iCounter + 2); i++) { |
| 6199 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6199 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6200 } | 6200 } |
| 6201 FXJSE_Value_SetInteger(rgValues[0], 1); | 6201 FXJSE_Value_SetInteger(rgValues[0], 1); |
| 6202 if (bAttribute) { | 6202 if (bAttribute) { |
| 6203 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); | 6203 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); |
| 6204 } else { | 6204 } else { |
| 6205 FXJSE_Value_SetNull(rgValues[1]); | 6205 FXJSE_Value_SetNull(rgValues[1]); |
| 6206 } | 6206 } |
| 6207 int32_t iIndex = 2; | 6207 int32_t iIndex = 2; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6226 wsSomExpression.c_str()); | 6226 wsSomExpression.c_str()); |
| 6227 } | 6227 } |
| 6228 for (int32_t i = 0; i < iLength - 2; i++) { | 6228 for (int32_t i = 0; i < iLength - 2; i++) { |
| 6229 for (int32_t j = 0; j < iSizes[i]; j++) { | 6229 for (int32_t j = 0; j < iSizes[i]; j++) { |
| 6230 FXJSE_Value_Release(hResolveValues[i][j]); | 6230 FXJSE_Value_Release(hResolveValues[i][j]); |
| 6231 } | 6231 } |
| 6232 FX_Free(hResolveValues[i]); | 6232 FX_Free(hResolveValues[i]); |
| 6233 } | 6233 } |
| 6234 FX_Free(hResolveValues); | 6234 FX_Free(hResolveValues); |
| 6235 FX_Free(iSizes); | 6235 FX_Free(iSizes); |
| 6236 FXJSE_Value_Release(hLengthValue); | 6236 FXJSE_Value_Release(pLengthValue); |
| 6237 } else { | 6237 } else { |
| 6238 XFA_RESOLVENODE_RS resoveNodeRS; | 6238 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6239 int32_t iRet = 0; | 6239 int32_t iRet = 0; |
| 6240 if (FXJSE_Value_IsObject(argAccessor) || | 6240 if (FXJSE_Value_IsObject(argAccessor) || |
| 6241 (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { | 6241 (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { |
| 6242 iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(), | 6242 iRet = ResolveObjects(pThis, argAccessor, szSomExp.AsStringC(), |
| 6243 resoveNodeRS, FALSE); | 6243 resoveNodeRS, FALSE); |
| 6244 } else if (!FXJSE_Value_IsObject(argAccessor) && | 6244 } else if (!FXJSE_Value_IsObject(argAccessor) && |
| 6245 !bsAccessorName.IsEmpty()) { | 6245 !bsAccessorName.IsEmpty()) { |
| 6246 FX_BOOL bGetObject = | 6246 FX_BOOL bGetObject = |
| 6247 GetObjectByName(hThis, argAccessor, bsAccessorName.AsStringC()); | 6247 GetObjectByName(pThis, argAccessor, bsAccessorName.AsStringC()); |
| 6248 if (bGetObject) { | 6248 if (bGetObject) { |
| 6249 iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(), | 6249 iRet = ResolveObjects(pThis, argAccessor, szSomExp.AsStringC(), |
| 6250 resoveNodeRS, FALSE); | 6250 resoveNodeRS, FALSE); |
| 6251 } | 6251 } |
| 6252 } | 6252 } |
| 6253 if (iRet > 0) { | 6253 if (iRet > 0) { |
| 6254 FXJSE_HVALUE* hResolveValues; | 6254 CFXJSE_Value** hResolveValues; |
| 6255 int32_t iSize = 0; | 6255 int32_t iSize = 0; |
| 6256 FX_BOOL bAttribute = FALSE; | 6256 FX_BOOL bAttribute = FALSE; |
| 6257 ParseResolveResult(hThis, resoveNodeRS, argAccessor, hResolveValues, | 6257 ParseResolveResult(pThis, resoveNodeRS, argAccessor, hResolveValues, |
| 6258 iSize, bAttribute); | 6258 iSize, bAttribute); |
| 6259 FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iSize + 2); | 6259 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2); |
| 6260 for (int32_t i = 0; i < (iSize + 2); i++) { | 6260 for (int32_t i = 0; i < (iSize + 2); i++) { |
| 6261 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6261 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6262 } | 6262 } |
| 6263 FXJSE_Value_SetInteger(rgValues[0], 1); | 6263 FXJSE_Value_SetInteger(rgValues[0], 1); |
| 6264 if (bAttribute) { | 6264 if (bAttribute) { |
| 6265 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); | 6265 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); |
| 6266 } else { | 6266 } else { |
| 6267 FXJSE_Value_SetNull(rgValues[1]); | 6267 FXJSE_Value_SetNull(rgValues[1]); |
| 6268 } | 6268 } |
| 6269 for (int32_t i = 0; i < iSize; i++) { | 6269 for (int32_t i = 0; i < iSize; i++) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6289 } | 6289 } |
| 6290 } | 6290 } |
| 6291 if (argc == 5) { | 6291 if (argc == 5) { |
| 6292 FXJSE_Value_Release(argIndex); | 6292 FXJSE_Value_Release(argIndex); |
| 6293 } | 6293 } |
| 6294 FXJSE_Value_Release(argAccessor); | 6294 FXJSE_Value_Release(argAccessor); |
| 6295 } else { | 6295 } else { |
| 6296 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6296 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6297 } | 6297 } |
| 6298 } | 6298 } |
| 6299 void CXFA_FM2JSContext::eval_translation(FXJSE_HOBJECT hThis, | 6299 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, |
| 6300 const CFX_ByteStringC& szFuncName, | 6300 const CFX_ByteStringC& szFuncName, |
| 6301 CFXJSE_Arguments& args) { | 6301 CFXJSE_Arguments& args) { |
| 6302 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6302 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6303 int32_t argc = args.GetLength(); | 6303 int32_t argc = args.GetLength(); |
| 6304 if (argc == 1) { | 6304 if (argc == 1) { |
| 6305 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 6305 CFXJSE_Value* argOne = GetSimpleValue(pThis, args, 0); |
| 6306 CFX_ByteString argString; | 6306 CFX_ByteString argString; |
| 6307 HValueToUTF8String(argOne, argString); | 6307 ValueToUTF8String(argOne, argString); |
| 6308 if (argString.IsEmpty()) { | 6308 if (argString.IsEmpty()) { |
| 6309 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 6309 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 6310 } else { | 6310 } else { |
| 6311 CFX_WideString scriptString = | 6311 CFX_WideString scriptString = |
| 6312 CFX_WideString::FromUTF8(argString.AsStringC()); | 6312 CFX_WideString::FromUTF8(argString.AsStringC()); |
| 6313 CFX_WideTextBuf wsJavaScriptBuf; | 6313 CFX_WideTextBuf wsJavaScriptBuf; |
| 6314 CFX_WideString wsError; | 6314 CFX_WideString wsError; |
| 6315 XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError); | 6315 XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError); |
| 6316 if (wsError.IsEmpty()) { | 6316 if (wsError.IsEmpty()) { |
| 6317 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); | 6317 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); |
| 6318 FXJSE_Value_SetUTF8String( | 6318 FXJSE_Value_SetUTF8String( |
| 6319 args.GetReturnValue(), | 6319 args.GetReturnValue(), |
| 6320 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) | 6320 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) |
| 6321 .AsStringC()); | 6321 .AsStringC()); |
| 6322 } else { | 6322 } else { |
| 6323 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6323 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6324 } | 6324 } |
| 6325 } | 6325 } |
| 6326 FXJSE_Value_Release(argOne); | 6326 FXJSE_Value_Release(argOne); |
| 6327 } else { | 6327 } else { |
| 6328 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 6328 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 6329 L"Eval"); | 6329 L"Eval"); |
| 6330 } | 6330 } |
| 6331 } | 6331 } |
| 6332 void CXFA_FM2JSContext::is_fm_object(FXJSE_HOBJECT hThis, | 6332 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, |
| 6333 const CFX_ByteStringC& szFuncName, | 6333 const CFX_ByteStringC& szFuncName, |
| 6334 CFXJSE_Arguments& args) { | 6334 CFXJSE_Arguments& args) { |
| 6335 int32_t iLength = args.GetLength(); | 6335 int32_t iLength = args.GetLength(); |
| 6336 if (iLength == 1) { | 6336 if (iLength == 1) { |
| 6337 FXJSE_HVALUE argOne = args.GetValue(0); | 6337 CFXJSE_Value* argOne = args.GetValue(0); |
| 6338 FXJSE_Value_SetBoolean(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); | 6338 FXJSE_Value_SetBoolean(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); |
| 6339 FXJSE_Value_Release(argOne); | 6339 FXJSE_Value_Release(argOne); |
| 6340 } else { | 6340 } else { |
| 6341 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); | 6341 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); |
| 6342 } | 6342 } |
| 6343 } | 6343 } |
| 6344 void CXFA_FM2JSContext::is_fm_array(FXJSE_HOBJECT hThis, | 6344 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, |
| 6345 const CFX_ByteStringC& szFuncName, | 6345 const CFX_ByteStringC& szFuncName, |
| 6346 CFXJSE_Arguments& args) { | 6346 CFXJSE_Arguments& args) { |
| 6347 int32_t iLength = args.GetLength(); | 6347 int32_t iLength = args.GetLength(); |
| 6348 if (iLength == 1) { | 6348 if (iLength == 1) { |
| 6349 FXJSE_HVALUE argOne = args.GetValue(0); | 6349 CFXJSE_Value* argOne = args.GetValue(0); |
| 6350 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne); | 6350 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne); |
| 6351 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); | 6351 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); |
| 6352 FXJSE_Value_Release(argOne); | 6352 FXJSE_Value_Release(argOne); |
| 6353 } else { | 6353 } else { |
| 6354 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); | 6354 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); |
| 6355 } | 6355 } |
| 6356 } | 6356 } |
| 6357 void CXFA_FM2JSContext::get_fm_value(FXJSE_HOBJECT hThis, | 6357 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, |
| 6358 const CFX_ByteStringC& szFuncName, | 6358 const CFX_ByteStringC& szFuncName, |
| 6359 CFXJSE_Arguments& args) { | 6359 CFXJSE_Arguments& args) { |
| 6360 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6360 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6361 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6361 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6362 int32_t iLength = args.GetLength(); | 6362 int32_t iLength = args.GetLength(); |
| 6363 if (iLength == 1) { | 6363 if (iLength == 1) { |
| 6364 FXJSE_HVALUE argOne = args.GetValue(0); | 6364 CFXJSE_Value* argOne = args.GetValue(0); |
| 6365 if (FXJSE_Value_IsArray(argOne)) { | 6365 if (FXJSE_Value_IsArray(argOne)) { |
| 6366 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6366 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6367 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 6367 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 6368 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); | 6368 FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); |
| 6369 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsobjectValue); | 6369 FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsobjectValue); |
| 6370 if (FXJSE_Value_IsNull(propertyValue)) { | 6370 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6371 GetObjectDefaultValue(jsobjectValue, args.GetReturnValue()); | 6371 GetObjectDefaultValue(jsobjectValue, args.GetReturnValue()); |
| 6372 } else { | 6372 } else { |
| 6373 CFX_ByteString propertyStr; | 6373 CFX_ByteString propertyStr; |
| 6374 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6374 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6375 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 6375 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 6376 args.GetReturnValue()); | 6376 args.GetReturnValue()); |
| 6377 } | 6377 } |
| 6378 FXJSE_Value_Release(propertyValue); | 6378 FXJSE_Value_Release(propertyValue); |
| 6379 FXJSE_Value_Release(jsobjectValue); | 6379 FXJSE_Value_Release(jsobjectValue); |
| 6380 } else if (FXJSE_Value_IsObject(argOne)) { | 6380 } else if (FXJSE_Value_IsObject(argOne)) { |
| 6381 GetObjectDefaultValue(argOne, args.GetReturnValue()); | 6381 GetObjectDefaultValue(argOne, args.GetReturnValue()); |
| 6382 } else { | 6382 } else { |
| 6383 FXJSE_Value_Set(args.GetReturnValue(), argOne); | 6383 FXJSE_Value_Set(args.GetReturnValue(), argOne); |
| 6384 } | 6384 } |
| 6385 FXJSE_Value_Release(argOne); | 6385 FXJSE_Value_Release(argOne); |
| 6386 } else { | 6386 } else { |
| 6387 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6387 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6388 } | 6388 } |
| 6389 } | 6389 } |
| 6390 void CXFA_FM2JSContext::get_fm_jsobj(FXJSE_HOBJECT hThis, | 6390 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, |
| 6391 const CFX_ByteStringC& szFuncName, | 6391 const CFX_ByteStringC& szFuncName, |
| 6392 CFXJSE_Arguments& args) { | 6392 CFXJSE_Arguments& args) { |
| 6393 CXFA_FM2JSContext* pContext = | 6393 CXFA_FM2JSContext* pContext = |
| 6394 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(hThis)); | 6394 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis)); |
| 6395 int32_t argc = args.GetLength(); | 6395 int32_t argc = args.GetLength(); |
| 6396 if (argc == 1) { | 6396 if (argc == 1) { |
| 6397 FXJSE_HVALUE argOne = args.GetValue(0); | 6397 CFXJSE_Value* argOne = args.GetValue(0); |
| 6398 if (FXJSE_Value_IsArray(argOne)) { | 6398 if (FXJSE_Value_IsArray(argOne)) { |
| 6399 #ifndef NDEBUG | 6399 #ifndef NDEBUG |
| 6400 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6400 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6401 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6401 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6402 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 6402 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
| 6403 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); | 6403 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); |
| 6404 FXJSE_Value_Release(lengthValue); | 6404 FXJSE_Value_Release(lengthValue); |
| 6405 #endif | 6405 #endif |
| 6406 FXJSE_Value_GetObjectPropByIdx(argOne, 2, args.GetReturnValue()); | 6406 FXJSE_Value_GetObjectPropByIdx(argOne, 2, args.GetReturnValue()); |
| 6407 } else { | 6407 } else { |
| 6408 FXJSE_Value_Set(args.GetReturnValue(), argOne); | 6408 FXJSE_Value_Set(args.GetReturnValue(), argOne); |
| 6409 } | 6409 } |
| 6410 FXJSE_Value_Release(argOne); | 6410 FXJSE_Value_Release(argOne); |
| 6411 } else { | 6411 } else { |
| 6412 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6412 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6413 } | 6413 } |
| 6414 } | 6414 } |
| 6415 void CXFA_FM2JSContext::fm_var_filter(FXJSE_HOBJECT hThis, | 6415 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, |
| 6416 const CFX_ByteStringC& szFuncName, | 6416 const CFX_ByteStringC& szFuncName, |
| 6417 CFXJSE_Arguments& args) { | 6417 CFXJSE_Arguments& args) { |
| 6418 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6418 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6419 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6419 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6420 int32_t argc = args.GetLength(); | 6420 int32_t argc = args.GetLength(); |
| 6421 if (argc == 1) { | 6421 if (argc == 1) { |
| 6422 FXJSE_HVALUE argOne = args.GetValue(0); | 6422 CFXJSE_Value* argOne = args.GetValue(0); |
| 6423 if (FXJSE_Value_IsArray(argOne)) { | 6423 if (FXJSE_Value_IsArray(argOne)) { |
| 6424 #ifndef NDEBUG | 6424 #ifndef NDEBUG |
| 6425 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6425 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6426 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); | 6426 FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); |
| 6427 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); | 6427 ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3); |
| 6428 FXJSE_Value_Release(lengthValue); | 6428 FXJSE_Value_Release(lengthValue); |
| 6429 #endif | 6429 #endif |
| 6430 FXJSE_HVALUE flagsValue = FXJSE_Value_Create(pIsolate); | 6430 CFXJSE_Value* flagsValue = FXJSE_Value_Create(pIsolate); |
| 6431 FXJSE_Value_GetObjectPropByIdx(argOne, 0, flagsValue); | 6431 FXJSE_Value_GetObjectPropByIdx(argOne, 0, flagsValue); |
| 6432 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue); | 6432 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue); |
| 6433 FXJSE_Value_Release(flagsValue); | 6433 FXJSE_Value_Release(flagsValue); |
| 6434 if (iFlags == 4) { | 6434 if (iFlags == 4) { |
| 6435 FXJSE_HVALUE rgValues[3]; | 6435 CFXJSE_Value* rgValues[3]; |
| 6436 for (int32_t i = 0; i < 3; i++) { | 6436 for (int32_t i = 0; i < 3; i++) { |
| 6437 rgValues[i] = FXJSE_Value_Create(pIsolate); | 6437 rgValues[i] = FXJSE_Value_Create(pIsolate); |
| 6438 } | 6438 } |
| 6439 FXJSE_Value_SetInteger(rgValues[0], 3); | 6439 FXJSE_Value_SetInteger(rgValues[0], 3); |
| 6440 FXJSE_Value_SetNull(rgValues[1]); | 6440 FXJSE_Value_SetNull(rgValues[1]); |
| 6441 FXJSE_Value_SetNull(rgValues[2]); | 6441 FXJSE_Value_SetNull(rgValues[2]); |
| 6442 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 6442 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 6443 for (int32_t i = 0; i < 3; i++) { | 6443 for (int32_t i = 0; i < 3; i++) { |
| 6444 FXJSE_Value_Release(rgValues[i]); | 6444 FXJSE_Value_Release(rgValues[i]); |
| 6445 } | 6445 } |
| 6446 } else if (iFlags == 3) { | 6446 } else if (iFlags == 3) { |
| 6447 FXJSE_HVALUE objectValue = FXJSE_Value_Create(pIsolate); | 6447 CFXJSE_Value* objectValue = FXJSE_Value_Create(pIsolate); |
| 6448 FXJSE_Value_GetObjectPropByIdx(argOne, 2, objectValue); | 6448 FXJSE_Value_GetObjectPropByIdx(argOne, 2, objectValue); |
| 6449 if (!FXJSE_Value_IsNull(objectValue)) { | 6449 if (!FXJSE_Value_IsNull(objectValue)) { |
| 6450 FXJSE_Value_Set(args.GetReturnValue(), argOne); | 6450 FXJSE_Value_Set(args.GetReturnValue(), argOne); |
| 6451 } else { | 6451 } else { |
| 6452 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6452 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6453 } | 6453 } |
| 6454 FXJSE_Value_Release(objectValue); | 6454 FXJSE_Value_Release(objectValue); |
| 6455 } else { | 6455 } else { |
| 6456 FXJSE_HVALUE simpleValue = GetSimpleHValue(hThis, args, 0); | 6456 CFXJSE_Value* simpleValue = GetSimpleValue(pThis, args, 0); |
| 6457 FXJSE_Value_Set(args.GetReturnValue(), simpleValue); | 6457 FXJSE_Value_Set(args.GetReturnValue(), simpleValue); |
| 6458 FXJSE_Value_Release(simpleValue); | 6458 FXJSE_Value_Release(simpleValue); |
| 6459 } | 6459 } |
| 6460 } else { | 6460 } else { |
| 6461 FXJSE_HVALUE simpleValue = GetSimpleHValue(hThis, args, 0); | 6461 CFXJSE_Value* simpleValue = GetSimpleValue(pThis, args, 0); |
| 6462 FXJSE_Value_Set(args.GetReturnValue(), simpleValue); | 6462 FXJSE_Value_Set(args.GetReturnValue(), simpleValue); |
| 6463 FXJSE_Value_Release(simpleValue); | 6463 FXJSE_Value_Release(simpleValue); |
| 6464 } | 6464 } |
| 6465 FXJSE_Value_Release(argOne); | 6465 FXJSE_Value_Release(argOne); |
| 6466 } else { | 6466 } else { |
| 6467 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6467 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6468 } | 6468 } |
| 6469 } | 6469 } |
| 6470 void CXFA_FM2JSContext::concat_fm_object(FXJSE_HOBJECT hThis, | 6470 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, |
| 6471 const CFX_ByteStringC& szFuncName, | 6471 const CFX_ByteStringC& szFuncName, |
| 6472 CFXJSE_Arguments& args) { | 6472 CFXJSE_Arguments& args) { |
| 6473 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6473 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6474 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6474 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6475 uint32_t iLength = 0; | 6475 uint32_t iLength = 0; |
| 6476 int32_t argCount = args.GetLength(); | 6476 int32_t argCount = args.GetLength(); |
| 6477 FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argCount); | 6477 CFXJSE_Value** argValues = FX_Alloc(CFXJSE_Value*, argCount); |
| 6478 for (int32_t i = 0; i < argCount; i++) { | 6478 for (int32_t i = 0; i < argCount; i++) { |
| 6479 argValues[i] = args.GetValue(i); | 6479 argValues[i] = args.GetValue(i); |
| 6480 if (FXJSE_Value_IsArray(argValues[i])) { | 6480 if (FXJSE_Value_IsArray(argValues[i])) { |
| 6481 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6481 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6482 FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); | 6482 FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); |
| 6483 int32_t length = FXJSE_Value_ToInteger(lengthValue); | 6483 int32_t length = FXJSE_Value_ToInteger(lengthValue); |
| 6484 iLength = iLength + ((length > 2) ? (length - 2) : 0); | 6484 iLength = iLength + ((length > 2) ? (length - 2) : 0); |
| 6485 FXJSE_Value_Release(lengthValue); | 6485 FXJSE_Value_Release(lengthValue); |
| 6486 } | 6486 } |
| 6487 iLength += 1; | 6487 iLength += 1; |
| 6488 } | 6488 } |
| 6489 FXJSE_HVALUE* returnValues = FX_Alloc(FXJSE_HVALUE, iLength); | 6489 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); |
| 6490 for (int32_t i = 0; i < (int32_t)iLength; i++) { | 6490 for (int32_t i = 0; i < (int32_t)iLength; i++) { |
| 6491 returnValues[i] = FXJSE_Value_Create(pIsolate); | 6491 returnValues[i] = FXJSE_Value_Create(pIsolate); |
| 6492 } | 6492 } |
| 6493 int32_t index = 0; | 6493 int32_t index = 0; |
| 6494 for (int32_t i = 0; i < argCount; i++) { | 6494 for (int32_t i = 0; i < argCount; i++) { |
| 6495 if (FXJSE_Value_IsArray(argValues[i])) { | 6495 if (FXJSE_Value_IsArray(argValues[i])) { |
| 6496 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6496 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6497 FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); | 6497 FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); |
| 6498 int32_t length = FXJSE_Value_ToInteger(lengthValue); | 6498 int32_t length = FXJSE_Value_ToInteger(lengthValue); |
| 6499 for (int32_t j = 2; j < length; j++) { | 6499 for (int32_t j = 2; j < length; j++) { |
| 6500 FXJSE_Value_GetObjectPropByIdx(argValues[i], j, returnValues[index]); | 6500 FXJSE_Value_GetObjectPropByIdx(argValues[i], j, returnValues[index]); |
| 6501 index++; | 6501 index++; |
| 6502 } | 6502 } |
| 6503 FXJSE_Value_Release(lengthValue); | 6503 FXJSE_Value_Release(lengthValue); |
| 6504 } | 6504 } |
| 6505 FXJSE_Value_Set(returnValues[index], argValues[i]); | 6505 FXJSE_Value_Set(returnValues[index], argValues[i]); |
| 6506 index++; | 6506 index++; |
| 6507 } | 6507 } |
| 6508 FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); | 6508 FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); |
| 6509 for (int32_t i = 0; i < argCount; i++) { | 6509 for (int32_t i = 0; i < argCount; i++) { |
| 6510 FXJSE_Value_Release(argValues[i]); | 6510 FXJSE_Value_Release(argValues[i]); |
| 6511 } | 6511 } |
| 6512 FX_Free(argValues); | 6512 FX_Free(argValues); |
| 6513 for (int32_t i = 0; i < (int32_t)iLength; i++) { | 6513 for (int32_t i = 0; i < (int32_t)iLength; i++) { |
| 6514 FXJSE_Value_Release(returnValues[i]); | 6514 FXJSE_Value_Release(returnValues[i]); |
| 6515 } | 6515 } |
| 6516 FX_Free(returnValues); | 6516 FX_Free(returnValues); |
| 6517 } | 6517 } |
| 6518 FXJSE_HVALUE CXFA_FM2JSContext::GetSimpleHValue(FXJSE_HOBJECT hThis, | 6518 CFXJSE_Value* CXFA_FM2JSContext::GetSimpleValue(CFXJSE_Value* pThis, |
| 6519 CFXJSE_Arguments& args, | 6519 CFXJSE_Arguments& args, |
| 6520 uint32_t index) { | 6520 uint32_t index) { |
| 6521 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6521 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6522 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6522 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6523 ASSERT(index < (uint32_t)args.GetLength()); | 6523 ASSERT(index < (uint32_t)args.GetLength()); |
| 6524 FXJSE_HVALUE argIndex = args.GetValue(index); | 6524 CFXJSE_Value* argIndex = args.GetValue(index); |
| 6525 if (FXJSE_Value_IsArray(argIndex)) { | 6525 if (FXJSE_Value_IsArray(argIndex)) { |
| 6526 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6526 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6527 FXJSE_Value_GetObjectProp(argIndex, "length", lengthValue); | 6527 FXJSE_Value_GetObjectProp(argIndex, "length", lengthValue); |
| 6528 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 6528 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 6529 FXJSE_Value_Release(lengthValue); | 6529 FXJSE_Value_Release(lengthValue); |
| 6530 FXJSE_HVALUE simpleValue = FXJSE_Value_Create(pIsolate); | 6530 CFXJSE_Value* simpleValue = FXJSE_Value_Create(pIsolate); |
| 6531 if (iLength > 2) { | 6531 if (iLength > 2) { |
| 6532 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6532 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6533 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 6533 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 6534 FXJSE_Value_GetObjectPropByIdx(argIndex, 1, propertyValue); | 6534 FXJSE_Value_GetObjectPropByIdx(argIndex, 1, propertyValue); |
| 6535 FXJSE_Value_GetObjectPropByIdx(argIndex, 2, jsobjectValue); | 6535 FXJSE_Value_GetObjectPropByIdx(argIndex, 2, jsobjectValue); |
| 6536 if (FXJSE_Value_IsNull(propertyValue)) { | 6536 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6537 GetObjectDefaultValue(jsobjectValue, simpleValue); | 6537 GetObjectDefaultValue(jsobjectValue, simpleValue); |
| 6538 } else { | 6538 } else { |
| 6539 CFX_ByteString propertyStr; | 6539 CFX_ByteString propertyStr; |
| 6540 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6540 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6541 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 6541 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 6542 simpleValue); | 6542 simpleValue); |
| 6543 } | 6543 } |
| 6544 FXJSE_Value_Release(propertyValue); | 6544 FXJSE_Value_Release(propertyValue); |
| 6545 FXJSE_Value_Release(jsobjectValue); | 6545 FXJSE_Value_Release(jsobjectValue); |
| 6546 } else { | 6546 } else { |
| 6547 FXJSE_Value_SetUndefined(simpleValue); | 6547 FXJSE_Value_SetUndefined(simpleValue); |
| 6548 } | 6548 } |
| 6549 FXJSE_Value_Release(argIndex); | 6549 FXJSE_Value_Release(argIndex); |
| 6550 return simpleValue; | 6550 return simpleValue; |
| 6551 } else if (FXJSE_Value_IsObject(argIndex)) { | 6551 } else if (FXJSE_Value_IsObject(argIndex)) { |
| 6552 FXJSE_HVALUE defaultValue = FXJSE_Value_Create(pIsolate); | 6552 CFXJSE_Value* defaultValue = FXJSE_Value_Create(pIsolate); |
| 6553 GetObjectDefaultValue(argIndex, defaultValue); | 6553 GetObjectDefaultValue(argIndex, defaultValue); |
| 6554 FXJSE_Value_Release(argIndex); | 6554 FXJSE_Value_Release(argIndex); |
| 6555 return defaultValue; | 6555 return defaultValue; |
| 6556 } else { | 6556 } else { |
| 6557 return argIndex; | 6557 return argIndex; |
| 6558 } | 6558 } |
| 6559 } | 6559 } |
| 6560 FX_BOOL CXFA_FM2JSContext::HValueIsNull(FXJSE_HOBJECT hThis, FXJSE_HVALUE arg) { | 6560 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { |
| 6561 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6561 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6562 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6562 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6563 FX_BOOL isNull = FALSE; | 6563 FX_BOOL isNull = FALSE; |
| 6564 if (FXJSE_Value_IsNull(arg)) { | 6564 if (FXJSE_Value_IsNull(arg)) { |
| 6565 isNull = TRUE; | 6565 isNull = TRUE; |
| 6566 } else if (FXJSE_Value_IsArray(arg)) { | 6566 } else if (FXJSE_Value_IsArray(arg)) { |
| 6567 int32_t iLength = hvalue_get_array_length(hThis, arg); | 6567 int32_t iLength = hvalue_get_array_length(pThis, arg); |
| 6568 if (iLength > 2) { | 6568 if (iLength > 2) { |
| 6569 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6569 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6570 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 6570 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 6571 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); | 6571 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); |
| 6572 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue); | 6572 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue); |
| 6573 if (FXJSE_Value_IsNull(propertyValue)) { | 6573 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6574 FXJSE_HVALUE defaultValue = FXJSE_Value_Create(pIsolate); | 6574 CFXJSE_Value* defaultValue = FXJSE_Value_Create(pIsolate); |
| 6575 GetObjectDefaultValue(jsObjectValue, defaultValue); | 6575 GetObjectDefaultValue(jsObjectValue, defaultValue); |
| 6576 if (FXJSE_Value_IsNull(defaultValue)) { | 6576 if (FXJSE_Value_IsNull(defaultValue)) { |
| 6577 isNull = TRUE; | 6577 isNull = TRUE; |
| 6578 } | 6578 } |
| 6579 FXJSE_Value_Release(defaultValue); | 6579 FXJSE_Value_Release(defaultValue); |
| 6580 } else { | 6580 } else { |
| 6581 CFX_ByteString propertyStr; | 6581 CFX_ByteString propertyStr; |
| 6582 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6582 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6583 FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(pIsolate); | 6583 CFXJSE_Value* newPropertyValue = FXJSE_Value_Create(pIsolate); |
| 6584 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), | 6584 FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(), |
| 6585 newPropertyValue); | 6585 newPropertyValue); |
| 6586 if (FXJSE_Value_IsNull(newPropertyValue)) { | 6586 if (FXJSE_Value_IsNull(newPropertyValue)) { |
| 6587 isNull = TRUE; | 6587 isNull = TRUE; |
| 6588 } | 6588 } |
| 6589 FXJSE_Value_Release(newPropertyValue); | 6589 FXJSE_Value_Release(newPropertyValue); |
| 6590 } | 6590 } |
| 6591 FXJSE_Value_Release(propertyValue); | 6591 FXJSE_Value_Release(propertyValue); |
| 6592 FXJSE_Value_Release(jsObjectValue); | 6592 FXJSE_Value_Release(jsObjectValue); |
| 6593 } else { | 6593 } else { |
| 6594 isNull = TRUE; | 6594 isNull = TRUE; |
| 6595 } | 6595 } |
| 6596 } else if (FXJSE_Value_IsObject(arg)) { | 6596 } else if (FXJSE_Value_IsObject(arg)) { |
| 6597 FXJSE_HVALUE defaultValue = FXJSE_Value_Create(pIsolate); | 6597 CFXJSE_Value* defaultValue = FXJSE_Value_Create(pIsolate); |
| 6598 GetObjectDefaultValue(arg, defaultValue); | 6598 GetObjectDefaultValue(arg, defaultValue); |
| 6599 if (FXJSE_Value_IsNull(defaultValue)) { | 6599 if (FXJSE_Value_IsNull(defaultValue)) { |
| 6600 isNull = TRUE; | 6600 isNull = TRUE; |
| 6601 } | 6601 } |
| 6602 FXJSE_Value_Release(defaultValue); | 6602 FXJSE_Value_Release(defaultValue); |
| 6603 } | 6603 } |
| 6604 return isNull; | 6604 return isNull; |
| 6605 } | 6605 } |
| 6606 int32_t CXFA_FM2JSContext::hvalue_get_array_length(FXJSE_HOBJECT hThis, | 6606 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, |
| 6607 FXJSE_HVALUE arg) { | 6607 CFXJSE_Value* arg) { |
| 6608 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6608 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6609 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6609 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6610 int32_t iLength = 0; | 6610 int32_t iLength = 0; |
| 6611 if (FXJSE_Value_IsArray(arg)) { | 6611 if (FXJSE_Value_IsArray(arg)) { |
| 6612 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6612 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6613 FXJSE_Value_GetObjectProp(arg, "length", lengthValue); | 6613 FXJSE_Value_GetObjectProp(arg, "length", lengthValue); |
| 6614 iLength = FXJSE_Value_ToInteger(lengthValue); | 6614 iLength = FXJSE_Value_ToInteger(lengthValue); |
| 6615 FXJSE_Value_Release(lengthValue); | 6615 FXJSE_Value_Release(lengthValue); |
| 6616 } | 6616 } |
| 6617 return iLength; | 6617 return iLength; |
| 6618 } | 6618 } |
| 6619 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(FXJSE_HOBJECT hThis, | 6619 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, |
| 6620 FXJSE_HVALUE firstValue, | 6620 CFXJSE_Value* firstValue, |
| 6621 FXJSE_HVALUE secondValue) { | 6621 CFXJSE_Value* secondValue) { |
| 6622 FX_BOOL bReturn = FALSE; | 6622 FX_BOOL bReturn = FALSE; |
| 6623 if (FXJSE_Value_IsUTF8String(firstValue)) { | 6623 if (FXJSE_Value_IsUTF8String(firstValue)) { |
| 6624 CFX_ByteString firstString, secondString; | 6624 CFX_ByteString firstString, secondString; |
| 6625 HValueToUTF8String(firstValue, firstString); | 6625 ValueToUTF8String(firstValue, firstString); |
| 6626 HValueToUTF8String(secondValue, secondString); | 6626 ValueToUTF8String(secondValue, secondString); |
| 6627 bReturn = firstString == secondString; | 6627 bReturn = firstString == secondString; |
| 6628 } else if (FXJSE_Value_IsNumber(firstValue)) { | 6628 } else if (FXJSE_Value_IsNumber(firstValue)) { |
| 6629 FX_FLOAT first = HValueToFloat(hThis, firstValue); | 6629 FX_FLOAT first = ValueToFloat(pThis, firstValue); |
| 6630 FX_FLOAT second = HValueToFloat(hThis, secondValue); | 6630 FX_FLOAT second = ValueToFloat(pThis, secondValue); |
| 6631 bReturn = (first == second); | 6631 bReturn = (first == second); |
| 6632 } else if (FXJSE_Value_IsBoolean(firstValue)) { | 6632 } else if (FXJSE_Value_IsBoolean(firstValue)) { |
| 6633 bReturn = (FXJSE_Value_ToBoolean(firstValue) == | 6633 bReturn = (FXJSE_Value_ToBoolean(firstValue) == |
| 6634 FXJSE_Value_ToBoolean(secondValue)); | 6634 FXJSE_Value_ToBoolean(secondValue)); |
| 6635 } else if (FXJSE_Value_IsNull(firstValue) && | 6635 } else if (FXJSE_Value_IsNull(firstValue) && |
| 6636 FXJSE_Value_IsNull(secondValue)) { | 6636 FXJSE_Value_IsNull(secondValue)) { |
| 6637 bReturn = TRUE; | 6637 bReturn = TRUE; |
| 6638 } | 6638 } |
| 6639 return bReturn; | 6639 return bReturn; |
| 6640 } | 6640 } |
| 6641 void CXFA_FM2JSContext::unfoldArgs(FXJSE_HOBJECT hThis, | 6641 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, |
| 6642 CFXJSE_Arguments& args, | 6642 CFXJSE_Arguments& args, |
| 6643 FXJSE_HVALUE*& resultValues, | 6643 CFXJSE_Value**& resultValues, |
| 6644 int32_t& iCount, | 6644 int32_t& iCount, |
| 6645 int32_t iStart) { | 6645 int32_t iStart) { |
| 6646 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6646 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6647 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6647 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6648 iCount = 0; | 6648 iCount = 0; |
| 6649 int32_t argc = args.GetLength(); | 6649 int32_t argc = args.GetLength(); |
| 6650 FXJSE_HVALUE* argsValue = FX_Alloc(FXJSE_HVALUE, argc); | 6650 CFXJSE_Value** argsValue = FX_Alloc(CFXJSE_Value*, argc); |
| 6651 for (int32_t i = iStart; i < argc; i++) { | 6651 for (int32_t i = iStart; i < argc; i++) { |
| 6652 argsValue[i] = args.GetValue(i); | 6652 argsValue[i] = args.GetValue(i); |
| 6653 if (FXJSE_Value_IsArray(argsValue[i])) { | 6653 if (FXJSE_Value_IsArray(argsValue[i])) { |
| 6654 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6654 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6655 FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); | 6655 FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); |
| 6656 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 6656 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 6657 FXJSE_Value_Release(lengthValue); | 6657 FXJSE_Value_Release(lengthValue); |
| 6658 iCount += ((iLength > 2) ? (iLength - 2) : 0); | 6658 iCount += ((iLength > 2) ? (iLength - 2) : 0); |
| 6659 } else { | 6659 } else { |
| 6660 iCount += 1; | 6660 iCount += 1; |
| 6661 } | 6661 } |
| 6662 } | 6662 } |
| 6663 resultValues = FX_Alloc(FXJSE_HVALUE, iCount); | 6663 resultValues = FX_Alloc(CFXJSE_Value*, iCount); |
| 6664 for (int32_t i = 0; i < iCount; i++) { | 6664 for (int32_t i = 0; i < iCount; i++) { |
| 6665 resultValues[i] = FXJSE_Value_Create(pIsolate); | 6665 resultValues[i] = FXJSE_Value_Create(pIsolate); |
| 6666 } | 6666 } |
| 6667 int32_t index = 0; | 6667 int32_t index = 0; |
| 6668 for (int32_t i = iStart; i < argc; i++) { | 6668 for (int32_t i = iStart; i < argc; i++) { |
| 6669 if (FXJSE_Value_IsArray(argsValue[i])) { | 6669 if (FXJSE_Value_IsArray(argsValue[i])) { |
| 6670 FXJSE_HVALUE lengthValue = FXJSE_Value_Create(pIsolate); | 6670 CFXJSE_Value* lengthValue = FXJSE_Value_Create(pIsolate); |
| 6671 FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); | 6671 FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); |
| 6672 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); | 6672 int32_t iLength = FXJSE_Value_ToInteger(lengthValue); |
| 6673 FXJSE_Value_Release(lengthValue); | 6673 FXJSE_Value_Release(lengthValue); |
| 6674 if (iLength > 2) { | 6674 if (iLength > 2) { |
| 6675 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6675 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6676 FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(pIsolate); | 6676 CFXJSE_Value* jsObjectValue = FXJSE_Value_Create(pIsolate); |
| 6677 FXJSE_Value_GetObjectPropByIdx(argsValue[i], 1, propertyValue); | 6677 FXJSE_Value_GetObjectPropByIdx(argsValue[i], 1, propertyValue); |
| 6678 if (FXJSE_Value_IsNull(propertyValue)) { | 6678 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6679 for (int32_t j = 2; j < iLength; j++) { | 6679 for (int32_t j = 2; j < iLength; j++) { |
| 6680 FXJSE_Value_GetObjectPropByIdx(argsValue[i], j, jsObjectValue); | 6680 FXJSE_Value_GetObjectPropByIdx(argsValue[i], j, jsObjectValue); |
| 6681 GetObjectDefaultValue(jsObjectValue, resultValues[index]); | 6681 GetObjectDefaultValue(jsObjectValue, resultValues[index]); |
| 6682 index++; | 6682 index++; |
| 6683 } | 6683 } |
| 6684 } else { | 6684 } else { |
| 6685 CFX_ByteString propertyString; | 6685 CFX_ByteString propertyString; |
| 6686 FXJSE_Value_ToUTF8String(propertyValue, propertyString); | 6686 FXJSE_Value_ToUTF8String(propertyValue, propertyString); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6700 } else { | 6700 } else { |
| 6701 FXJSE_Value_Set(resultValues[index], argsValue[i]); | 6701 FXJSE_Value_Set(resultValues[index], argsValue[i]); |
| 6702 index++; | 6702 index++; |
| 6703 } | 6703 } |
| 6704 } | 6704 } |
| 6705 for (int32_t i = iStart; i < argc; i++) { | 6705 for (int32_t i = iStart; i < argc; i++) { |
| 6706 FXJSE_Value_Release(argsValue[i]); | 6706 FXJSE_Value_Release(argsValue[i]); |
| 6707 } | 6707 } |
| 6708 FX_Free(argsValue); | 6708 FX_Free(argsValue); |
| 6709 } | 6709 } |
| 6710 void CXFA_FM2JSContext::GetObjectDefaultValue(FXJSE_HVALUE hObjectValue, | 6710 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
| 6711 FXJSE_HVALUE hDefaultValue) { | 6711 CFXJSE_Value* pDefaultValue) { |
| 6712 CXFA_Node* pNode = ToNode((CXFA_Object*)FXJSE_Value_ToObject(hObjectValue)); | 6712 CXFA_Node* pNode = ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue)); |
| 6713 if (pNode) { | 6713 if (pNode) { |
| 6714 pNode->Script_Som_DefaultValue(hDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); | 6714 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); |
| 6715 } else { | 6715 } else { |
| 6716 FXJSE_Value_SetNull(hDefaultValue); | 6716 FXJSE_Value_SetNull(pDefaultValue); |
| 6717 } | 6717 } |
| 6718 } | 6718 } |
| 6719 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(FXJSE_HVALUE hObjectValue, | 6719 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
| 6720 FXJSE_HVALUE hNewValue) { | 6720 CFXJSE_Value* hNewValue) { |
| 6721 CXFA_Node* pNode = ToNode((CXFA_Object*)FXJSE_Value_ToObject(hObjectValue)); | 6721 CXFA_Node* pNode = ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue)); |
| 6722 if (pNode) { | 6722 if (pNode) { |
| 6723 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); | 6723 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); |
| 6724 return TRUE; | 6724 return TRUE; |
| 6725 } | 6725 } |
| 6726 return FALSE; | 6726 return FALSE; |
| 6727 } | 6727 } |
| 6728 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, | 6728 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, |
| 6729 int32_t iIndexFlags, | 6729 int32_t iIndexFlags, |
| 6730 int32_t iIndexValue, | 6730 int32_t iIndexValue, |
| 6731 FX_BOOL bIsStar, | 6731 FX_BOOL bIsStar, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6748 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); | 6748 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); |
| 6749 szSomExp += "]"; | 6749 szSomExp += "]"; |
| 6750 } else { | 6750 } else { |
| 6751 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); | 6751 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); |
| 6752 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; | 6752 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; |
| 6753 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); | 6753 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); |
| 6754 szSomExp += "]"; | 6754 szSomExp += "]"; |
| 6755 } | 6755 } |
| 6756 } | 6756 } |
| 6757 FX_BOOL CXFA_FM2JSContext::GetObjectByName( | 6757 FX_BOOL CXFA_FM2JSContext::GetObjectByName( |
| 6758 FXJSE_HOBJECT hThis, | 6758 CFXJSE_Value* pThis, |
| 6759 FXJSE_HVALUE accessorValue, | 6759 CFXJSE_Value* accessorValue, |
| 6760 const CFX_ByteStringC& szAccessorName) { | 6760 const CFX_ByteStringC& szAccessorName) { |
| 6761 FX_BOOL bFlags = FALSE; | 6761 FX_BOOL bFlags = FALSE; |
| 6762 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6762 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6763 CXFA_Document* pDoc = pContext->GetDocument(); | 6763 CXFA_Document* pDoc = pContext->GetDocument(); |
| 6764 if (!pDoc) { | 6764 if (!pDoc) { |
| 6765 return bFlags; | 6765 return bFlags; |
| 6766 } | 6766 } |
| 6767 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6767 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6768 XFA_RESOLVENODE_RS resoveNodeRS; | 6768 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6769 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6769 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
| 6770 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6770 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6771 int32_t iRet = pScriptContext->ResolveObjects( | 6771 int32_t iRet = pScriptContext->ResolveObjects( |
| 6772 pScriptContext->GetThisObject(), | 6772 pScriptContext->GetThisObject(), |
| 6773 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, | 6773 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, |
| 6774 dwFlags); | 6774 dwFlags); |
| 6775 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6775 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 6776 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6776 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
| 6777 resoveNodeRS.nodes.GetAt(0))); | 6777 resoveNodeRS.nodes.GetAt(0))); |
| 6778 bFlags = TRUE; | 6778 bFlags = TRUE; |
| 6779 } | 6779 } |
| 6780 return bFlags; | 6780 return bFlags; |
| 6781 } | 6781 } |
| 6782 int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, | 6782 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, |
| 6783 FXJSE_HVALUE hRefValue, | 6783 CFXJSE_Value* pRefValue, |
| 6784 const CFX_ByteStringC& bsSomExp, | 6784 const CFX_ByteStringC& bsSomExp, |
| 6785 XFA_RESOLVENODE_RS& resoveNodeRS, | 6785 XFA_RESOLVENODE_RS& resoveNodeRS, |
| 6786 FX_BOOL bdotAccessor, | 6786 FX_BOOL bdotAccessor, |
| 6787 FX_BOOL bHasNoResolveName) { | 6787 FX_BOOL bHasNoResolveName) { |
| 6788 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); | 6788 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); |
| 6789 int32_t iRet = -1; | 6789 int32_t iRet = -1; |
| 6790 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6790 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6791 CXFA_Document* pDoc = pContext->GetDocument(); | 6791 CXFA_Document* pDoc = pContext->GetDocument(); |
| 6792 if (!pDoc) { | 6792 if (!pDoc) { |
| 6793 return iRet; | 6793 return iRet; |
| 6794 } | 6794 } |
| 6795 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6795 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6796 CXFA_Object* pNode = NULL; | 6796 CXFA_Object* pNode = NULL; |
| 6797 uint32_t dFlags = 0UL; | 6797 uint32_t dFlags = 0UL; |
| 6798 if (bdotAccessor) { | 6798 if (bdotAccessor) { |
| 6799 if (FXJSE_Value_IsNull(hRefValue)) { | 6799 if (FXJSE_Value_IsNull(pRefValue)) { |
| 6800 pNode = pScriptContext->GetThisObject(); | 6800 pNode = pScriptContext->GetThisObject(); |
| 6801 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6801 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6802 } else { | 6802 } else { |
| 6803 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue); | 6803 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue); |
| 6804 ASSERT(pNode); | 6804 ASSERT(pNode); |
| 6805 if (bHasNoResolveName) { | 6805 if (bHasNoResolveName) { |
| 6806 CFX_WideString wsName; | 6806 CFX_WideString wsName; |
| 6807 if (CXFA_Node* pXFANode = pNode->AsNode()) { | 6807 if (CXFA_Node* pXFANode = pNode->AsNode()) { |
| 6808 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); | 6808 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); |
| 6809 } | 6809 } |
| 6810 if (wsName.IsEmpty()) { | 6810 if (wsName.IsEmpty()) { |
| 6811 CFX_WideStringC className; | 6811 CFX_WideStringC className; |
| 6812 pNode->GetClassName(className); | 6812 pNode->GetClassName(className); |
| 6813 wsName = FX_WSTRC(L"#") + className; | 6813 wsName = FX_WSTRC(L"#") + className; |
| 6814 } | 6814 } |
| 6815 wsSomExpression = wsName + wsSomExpression; | 6815 wsSomExpression = wsName + wsSomExpression; |
| 6816 dFlags = XFA_RESOLVENODE_Siblings; | 6816 dFlags = XFA_RESOLVENODE_Siblings; |
| 6817 } else { | 6817 } else { |
| 6818 dFlags = (bsSomExp == "*") | 6818 dFlags = (bsSomExp == "*") |
| 6819 ? (XFA_RESOLVENODE_Children) | 6819 ? (XFA_RESOLVENODE_Children) |
| 6820 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | | 6820 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | |
| 6821 XFA_RESOLVENODE_Properties); | 6821 XFA_RESOLVENODE_Properties); |
| 6822 } | 6822 } |
| 6823 } | 6823 } |
| 6824 } else { | 6824 } else { |
| 6825 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue); | 6825 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue); |
| 6826 dFlags = XFA_RESOLVENODE_AnyChild; | 6826 dFlags = XFA_RESOLVENODE_AnyChild; |
| 6827 } | 6827 } |
| 6828 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), | 6828 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), |
| 6829 resoveNodeRS, dFlags); | 6829 resoveNodeRS, dFlags); |
| 6830 return iRet; | 6830 return iRet; |
| 6831 } | 6831 } |
| 6832 void CXFA_FM2JSContext::ParseResolveResult( | 6832 void CXFA_FM2JSContext::ParseResolveResult( |
| 6833 FXJSE_HOBJECT hThis, | 6833 CFXJSE_Value* pThis, |
| 6834 const XFA_RESOLVENODE_RS& resoveNodeRS, | 6834 const XFA_RESOLVENODE_RS& resoveNodeRS, |
| 6835 FXJSE_HVALUE hParentValue, | 6835 CFXJSE_Value* pParentValue, |
| 6836 FXJSE_HVALUE*& resultValues, | 6836 CFXJSE_Value**& resultValues, |
| 6837 int32_t& iSize, | 6837 int32_t& iSize, |
| 6838 FX_BOOL& bAttribute) { | 6838 FX_BOOL& bAttribute) { |
| 6839 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6839 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6840 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6840 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6841 iSize = 0; | 6841 iSize = 0; |
| 6842 resultValues = NULL; | 6842 resultValues = NULL; |
| 6843 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6843 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 6844 bAttribute = FALSE; | 6844 bAttribute = FALSE; |
| 6845 iSize = resoveNodeRS.nodes.GetSize(); | 6845 iSize = resoveNodeRS.nodes.GetSize(); |
| 6846 resultValues = FX_Alloc(FXJSE_HVALUE, iSize); | 6846 resultValues = FX_Alloc(CFXJSE_Value*, iSize); |
| 6847 for (int32_t i = 0; i < iSize; i++) { | 6847 for (int32_t i = 0; i < iSize; i++) { |
| 6848 resultValues[i] = FXJSE_Value_Create(pIsolate); | 6848 resultValues[i] = FXJSE_Value_Create(pIsolate); |
| 6849 FXJSE_Value_Set( | 6849 FXJSE_Value_Set( |
| 6850 resultValues[i], | 6850 resultValues[i], |
| 6851 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( | 6851 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( |
| 6852 resoveNodeRS.nodes.GetAt(i))); | 6852 resoveNodeRS.nodes.GetAt(i))); |
| 6853 } | 6853 } |
| 6854 } else { | 6854 } else { |
| 6855 CXFA_HVALUEArray objectProperties(pIsolate); | 6855 CXFA_ValueArray objectProperties(pIsolate); |
| 6856 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); | 6856 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); |
| 6857 bAttribute = (iRet == 0); | 6857 bAttribute = (iRet == 0); |
| 6858 if (bAttribute) { | 6858 if (bAttribute) { |
| 6859 if (FXJSE_Value_IsObject(hParentValue)) { | 6859 if (FXJSE_Value_IsObject(pParentValue)) { |
| 6860 iSize = 1; | 6860 iSize = 1; |
| 6861 resultValues = FX_Alloc(FXJSE_HVALUE, 1); | 6861 resultValues = FX_Alloc(CFXJSE_Value*, 1); |
| 6862 resultValues[0] = FXJSE_Value_Create(pIsolate); | 6862 resultValues[0] = FXJSE_Value_Create(pIsolate); |
| 6863 FXJSE_Value_Set(resultValues[0], hParentValue); | 6863 FXJSE_Value_Set(resultValues[0], pParentValue); |
| 6864 } | 6864 } |
| 6865 } else { | 6865 } else { |
| 6866 iSize = iRet; | 6866 iSize = iRet; |
| 6867 resultValues = FX_Alloc(FXJSE_HVALUE, iSize); | 6867 resultValues = FX_Alloc(CFXJSE_Value*, iSize); |
| 6868 for (int32_t i = 0; i < iSize; i++) { | 6868 for (int32_t i = 0; i < iSize; i++) { |
| 6869 resultValues[i] = FXJSE_Value_Create(pIsolate); | 6869 resultValues[i] = FXJSE_Value_Create(pIsolate); |
| 6870 FXJSE_Value_Set(resultValues[i], objectProperties[i]); | 6870 FXJSE_Value_Set(resultValues[i], objectProperties[i]); |
| 6871 } | 6871 } |
| 6872 } | 6872 } |
| 6873 } | 6873 } |
| 6874 } | 6874 } |
| 6875 int32_t CXFA_FM2JSContext::HValueToInteger(FXJSE_HOBJECT hThis, | 6875 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, |
| 6876 FXJSE_HVALUE hValue) { | 6876 CFXJSE_Value* pValue) { |
| 6877 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6877 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6878 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6878 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6879 int32_t iValue = 0; | 6879 int32_t iValue = 0; |
| 6880 if (FXJSE_Value_IsArray(hValue)) { | 6880 if (FXJSE_Value_IsArray(pValue)) { |
| 6881 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6881 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6882 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 6882 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 6883 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 6883 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 6884 FXJSE_Value_GetObjectPropByIdx(hValue, 1, propertyValue); | 6884 FXJSE_Value_GetObjectPropByIdx(pValue, 1, propertyValue); |
| 6885 FXJSE_Value_GetObjectPropByIdx(hValue, 2, jsobjectValue); | 6885 FXJSE_Value_GetObjectPropByIdx(pValue, 2, jsobjectValue); |
| 6886 if (FXJSE_Value_IsNull(propertyValue)) { | 6886 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6887 GetObjectDefaultValue(jsobjectValue, newProperty); | 6887 GetObjectDefaultValue(jsobjectValue, newProperty); |
| 6888 } else { | 6888 } else { |
| 6889 CFX_ByteString propertyStr; | 6889 CFX_ByteString propertyStr; |
| 6890 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6890 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6891 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 6891 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 6892 newProperty); | 6892 newProperty); |
| 6893 } | 6893 } |
| 6894 iValue = HValueToInteger(hThis, newProperty); | 6894 iValue = ValueToInteger(pThis, newProperty); |
| 6895 FXJSE_Value_Release(newProperty); | 6895 FXJSE_Value_Release(newProperty); |
| 6896 FXJSE_Value_Release(jsobjectValue); | 6896 FXJSE_Value_Release(jsobjectValue); |
| 6897 FXJSE_Value_Release(propertyValue); | 6897 FXJSE_Value_Release(propertyValue); |
| 6898 return iValue; | 6898 return iValue; |
| 6899 } else if (FXJSE_Value_IsObject(hValue)) { | 6899 } else if (FXJSE_Value_IsObject(pValue)) { |
| 6900 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 6900 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 6901 GetObjectDefaultValue(hValue, newProperty); | 6901 GetObjectDefaultValue(pValue, newProperty); |
| 6902 iValue = HValueToInteger(hThis, newProperty); | 6902 iValue = ValueToInteger(pThis, newProperty); |
| 6903 FXJSE_Value_Release(newProperty); | 6903 FXJSE_Value_Release(newProperty); |
| 6904 return iValue; | 6904 return iValue; |
| 6905 } else if (FXJSE_Value_IsUTF8String(hValue)) { | 6905 } else if (FXJSE_Value_IsUTF8String(pValue)) { |
| 6906 CFX_ByteString szValue; | 6906 CFX_ByteString szValue; |
| 6907 FXJSE_Value_ToUTF8String(hValue, szValue); | 6907 FXJSE_Value_ToUTF8String(pValue, szValue); |
| 6908 iValue = FXSYS_atoi(szValue.c_str()); | 6908 iValue = FXSYS_atoi(szValue.c_str()); |
| 6909 } else { | 6909 } else { |
| 6910 iValue = FXJSE_Value_ToInteger(hValue); | 6910 iValue = FXJSE_Value_ToInteger(pValue); |
| 6911 } | 6911 } |
| 6912 return iValue; | 6912 return iValue; |
| 6913 } | 6913 } |
| 6914 FX_DOUBLE CXFA_FM2JSContext::StringToDouble( | 6914 FX_DOUBLE CXFA_FM2JSContext::StringToDouble( |
| 6915 const CFX_ByteStringC& szStringVal) { | 6915 const CFX_ByteStringC& szStringVal) { |
| 6916 return XFA_ByteStringToDouble(szStringVal); | 6916 return XFA_ByteStringToDouble(szStringVal); |
| 6917 } | 6917 } |
| 6918 FX_FLOAT CXFA_FM2JSContext::HValueToFloat(FXJSE_HOBJECT hThis, | 6918 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, |
| 6919 FXJSE_HVALUE arg) { | 6919 CFXJSE_Value* arg) { |
| 6920 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6920 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6921 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6921 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6922 FX_FLOAT fRet = 0.0f; | 6922 FX_FLOAT fRet = 0.0f; |
| 6923 if (FXJSE_Value_IsArray(arg)) { | 6923 if (FXJSE_Value_IsArray(arg)) { |
| 6924 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6924 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6925 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 6925 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 6926 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 6926 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 6927 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); | 6927 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); |
| 6928 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); | 6928 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); |
| 6929 if (FXJSE_Value_IsNull(propertyValue)) { | 6929 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6930 GetObjectDefaultValue(jsobjectValue, newProperty); | 6930 GetObjectDefaultValue(jsobjectValue, newProperty); |
| 6931 } else { | 6931 } else { |
| 6932 CFX_ByteString propertyStr; | 6932 CFX_ByteString propertyStr; |
| 6933 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6933 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6934 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 6934 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 6935 newProperty); | 6935 newProperty); |
| 6936 } | 6936 } |
| 6937 fRet = HValueToFloat(hThis, newProperty); | 6937 fRet = ValueToFloat(pThis, newProperty); |
| 6938 FXJSE_Value_Release(newProperty); | 6938 FXJSE_Value_Release(newProperty); |
| 6939 FXJSE_Value_Release(jsobjectValue); | 6939 FXJSE_Value_Release(jsobjectValue); |
| 6940 FXJSE_Value_Release(propertyValue); | 6940 FXJSE_Value_Release(propertyValue); |
| 6941 } else if (FXJSE_Value_IsObject(arg)) { | 6941 } else if (FXJSE_Value_IsObject(arg)) { |
| 6942 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 6942 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 6943 GetObjectDefaultValue(arg, newProperty); | 6943 GetObjectDefaultValue(arg, newProperty); |
| 6944 fRet = HValueToFloat(hThis, newProperty); | 6944 fRet = ValueToFloat(pThis, newProperty); |
| 6945 FXJSE_Value_Release(newProperty); | 6945 FXJSE_Value_Release(newProperty); |
| 6946 } else if (FXJSE_Value_IsUTF8String(arg)) { | 6946 } else if (FXJSE_Value_IsUTF8String(arg)) { |
| 6947 CFX_ByteString bsOutput; | 6947 CFX_ByteString bsOutput; |
| 6948 FXJSE_Value_ToUTF8String(arg, bsOutput); | 6948 FXJSE_Value_ToUTF8String(arg, bsOutput); |
| 6949 fRet = (FX_FLOAT)StringToDouble(bsOutput.AsStringC()); | 6949 fRet = (FX_FLOAT)StringToDouble(bsOutput.AsStringC()); |
| 6950 } else if (FXJSE_Value_IsUndefined(arg)) { | 6950 } else if (FXJSE_Value_IsUndefined(arg)) { |
| 6951 fRet = 0; | 6951 fRet = 0; |
| 6952 } else { | 6952 } else { |
| 6953 fRet = FXJSE_Value_ToFloat(arg); | 6953 fRet = FXJSE_Value_ToFloat(arg); |
| 6954 } | 6954 } |
| 6955 return fRet; | 6955 return fRet; |
| 6956 } | 6956 } |
| 6957 FX_DOUBLE CXFA_FM2JSContext::HValueToDouble(FXJSE_HOBJECT hThis, | 6957 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, |
| 6958 FXJSE_HVALUE arg) { | 6958 CFXJSE_Value* arg) { |
| 6959 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis); | 6959 CXFA_FM2JSContext* pContext = (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis); |
| 6960 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6960 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6961 FX_DOUBLE dRet = 0; | 6961 FX_DOUBLE dRet = 0; |
| 6962 if (FXJSE_Value_IsArray(arg)) { | 6962 if (FXJSE_Value_IsArray(arg)) { |
| 6963 FXJSE_HVALUE propertyValue = FXJSE_Value_Create(pIsolate); | 6963 CFXJSE_Value* propertyValue = FXJSE_Value_Create(pIsolate); |
| 6964 FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(pIsolate); | 6964 CFXJSE_Value* jsobjectValue = FXJSE_Value_Create(pIsolate); |
| 6965 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 6965 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 6966 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); | 6966 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); |
| 6967 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); | 6967 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); |
| 6968 if (FXJSE_Value_IsNull(propertyValue)) { | 6968 if (FXJSE_Value_IsNull(propertyValue)) { |
| 6969 GetObjectDefaultValue(jsobjectValue, newProperty); | 6969 GetObjectDefaultValue(jsobjectValue, newProperty); |
| 6970 } else { | 6970 } else { |
| 6971 CFX_ByteString propertyStr; | 6971 CFX_ByteString propertyStr; |
| 6972 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); | 6972 FXJSE_Value_ToUTF8String(propertyValue, propertyStr); |
| 6973 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), | 6973 FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(), |
| 6974 newProperty); | 6974 newProperty); |
| 6975 } | 6975 } |
| 6976 dRet = HValueToDouble(hThis, newProperty); | 6976 dRet = ValueToDouble(pThis, newProperty); |
| 6977 FXJSE_Value_Release(newProperty); | 6977 FXJSE_Value_Release(newProperty); |
| 6978 FXJSE_Value_Release(jsobjectValue); | 6978 FXJSE_Value_Release(jsobjectValue); |
| 6979 FXJSE_Value_Release(propertyValue); | 6979 FXJSE_Value_Release(propertyValue); |
| 6980 } else if (FXJSE_Value_IsObject(arg)) { | 6980 } else if (FXJSE_Value_IsObject(arg)) { |
| 6981 FXJSE_HVALUE newProperty = FXJSE_Value_Create(pIsolate); | 6981 CFXJSE_Value* newProperty = FXJSE_Value_Create(pIsolate); |
| 6982 GetObjectDefaultValue(arg, newProperty); | 6982 GetObjectDefaultValue(arg, newProperty); |
| 6983 dRet = HValueToDouble(hThis, newProperty); | 6983 dRet = ValueToDouble(pThis, newProperty); |
| 6984 FXJSE_Value_Release(newProperty); | 6984 FXJSE_Value_Release(newProperty); |
| 6985 } else if (FXJSE_Value_IsUTF8String(arg)) { | 6985 } else if (FXJSE_Value_IsUTF8String(arg)) { |
| 6986 CFX_ByteString bsOutput; | 6986 CFX_ByteString bsOutput; |
| 6987 FXJSE_Value_ToUTF8String(arg, bsOutput); | 6987 FXJSE_Value_ToUTF8String(arg, bsOutput); |
| 6988 dRet = StringToDouble(bsOutput.AsStringC()); | 6988 dRet = StringToDouble(bsOutput.AsStringC()); |
| 6989 } else if (FXJSE_Value_IsUndefined(arg)) { | 6989 } else if (FXJSE_Value_IsUndefined(arg)) { |
| 6990 dRet = 0; | 6990 dRet = 0; |
| 6991 } else { | 6991 } else { |
| 6992 dRet = FXJSE_Value_ToDouble(arg); | 6992 dRet = FXJSE_Value_ToDouble(arg); |
| 6993 } | 6993 } |
| 6994 return dRet; | 6994 return dRet; |
| 6995 } | 6995 } |
| 6996 void CXFA_FM2JSContext::HValueToUTF8String(FXJSE_HVALUE arg, | 6996 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, |
| 6997 CFX_ByteString& szOutputString) { | 6997 CFX_ByteString& szOutputString) { |
| 6998 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { | 6998 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { |
| 6999 szOutputString = ""; | 6999 szOutputString = ""; |
| 7000 } else if (FXJSE_Value_IsBoolean(arg)) { | 7000 } else if (FXJSE_Value_IsBoolean(arg)) { |
| 7001 szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; | 7001 szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; |
| 7002 } else { | 7002 } else { |
| 7003 szOutputString = ""; | 7003 szOutputString = ""; |
| 7004 FXJSE_Value_ToUTF8String(arg, szOutputString); | 7004 FXJSE_Value_ToUTF8String(arg, szOutputString); |
| 7005 } | 7005 } |
| 7006 } | 7006 } |
| 7007 static FXJSE_FUNCTION formcalc_fm2js_functions[] = { | 7007 static FXJSE_FUNCTION formcalc_fm2js_functions[] = { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7094 {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, | 7094 {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, |
| 7095 {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, | 7095 {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, |
| 7096 {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, | 7096 {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, |
| 7097 {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, | 7097 {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, |
| 7098 {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, | 7098 {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, |
| 7099 }; | 7099 }; |
| 7100 CXFA_FM2JSContext::CXFA_FM2JSContext() | 7100 CXFA_FM2JSContext::CXFA_FM2JSContext() |
| 7101 : m_pFMClass(nullptr), m_pDocument(nullptr) { | 7101 : m_pFMClass(nullptr), m_pDocument(nullptr) { |
| 7102 FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); | 7102 FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); |
| 7103 } | 7103 } |
| 7104 |
| 7104 CXFA_FM2JSContext::~CXFA_FM2JSContext() { | 7105 CXFA_FM2JSContext::~CXFA_FM2JSContext() { |
| 7105 m_pDocument = NULL; | 7106 if (m_pValue) |
| 7106 if (m_hValue) { | 7107 FXJSE_Value_Release(m_pValue); |
| 7107 FXJSE_Value_Release(m_hValue); | |
| 7108 m_hValue = NULL; | |
| 7109 } | |
| 7110 m_pIsolate = NULL; | |
| 7111 } | 7108 } |
| 7109 |
| 7112 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, | 7110 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, |
| 7113 CFXJSE_Context* pScriptContext, | 7111 CFXJSE_Context* pScriptContext, |
| 7114 CXFA_Document* pDoc) { | 7112 CXFA_Document* pDoc) { |
| 7115 m_pDocument = pDoc; | 7113 m_pDocument = pDoc; |
| 7116 m_pIsolate = pScriptIsolate; | 7114 m_pIsolate = pScriptIsolate; |
| 7117 m_fmClass.name = "XFA_FM2JS_FormCalcClass"; | 7115 m_fmClass.name = "XFA_FM2JS_FormCalcClass"; |
| 7118 m_fmClass.constructor = NULL; | 7116 m_fmClass.constructor = NULL; |
| 7119 m_fmClass.properties = NULL; | 7117 m_fmClass.properties = NULL; |
| 7120 m_fmClass.methods = formcalc_fm2js_functions; | 7118 m_fmClass.methods = formcalc_fm2js_functions; |
| 7121 m_fmClass.propNum = 0; | 7119 m_fmClass.propNum = 0; |
| 7122 m_fmClass.methNum = | 7120 m_fmClass.methNum = |
| 7123 sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); | 7121 sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); |
| 7124 m_pFMClass = FXJSE_DefineClass(pScriptContext, &m_fmClass); | 7122 m_pFMClass = FXJSE_DefineClass(pScriptContext, &m_fmClass); |
| 7125 m_hValue = FXJSE_Value_Create(pScriptIsolate); | 7123 m_pValue = FXJSE_Value_Create(pScriptIsolate); |
| 7126 FXJSE_Value_SetNull(m_hValue); | 7124 FXJSE_Value_SetNull(m_pValue); |
| 7127 FXJSE_Value_SetObject(m_hValue, this, m_pFMClass); | 7125 FXJSE_Value_SetObject(m_pValue, this, m_pFMClass); |
| 7128 } | 7126 } |
| 7129 void CXFA_FM2JSContext::GlobalPropertyGetter(FXJSE_HVALUE hValue) { | 7127 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { |
| 7130 FXJSE_Value_Set(hValue, m_hValue); | 7128 FXJSE_Value_Set(pValue, m_pValue); |
| 7131 } | 7129 } |
| 7132 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { | 7130 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { |
| 7133 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 7131 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
| 7134 ASSERT(pAppProvider); | 7132 ASSERT(pAppProvider); |
| 7135 CFX_WideString wsFormat; | 7133 CFX_WideString wsFormat; |
| 7136 pAppProvider->LoadString(iStringID, wsFormat); | 7134 pAppProvider->LoadString(iStringID, wsFormat); |
| 7137 CFX_WideString wsMessage; | 7135 CFX_WideString wsMessage; |
| 7138 va_list arg_ptr; | 7136 va_list arg_ptr; |
| 7139 va_start(arg_ptr, iStringID); | 7137 va_start(arg_ptr, iStringID); |
| 7140 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7138 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 7141 va_end(arg_ptr); | 7139 va_end(arg_ptr); |
| 7142 FXJSE_ThrowMessage( | 7140 FXJSE_ThrowMessage( |
| 7143 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7141 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 7144 } | 7142 } |
| OLD | NEW |