Use stdint.h types throughout PDFium.
[pdfium.git] / fpdfsdk / src / javascript / PublicMethods.cpp
index 08d5cb7..4607fc6 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2014 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
+
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #include "../../include/javascript/JavaScript.h"
@@ -36,28 +36,28 @@ static v8::Isolate* GetIsolate(IFXJS_Context* cc)
 #define DOUBLE_CORRECT 0.000000000000001
 
 BEGIN_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Format,6)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Keystroke,6)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Format,2)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Keystroke,2)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_FormatEx,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_KeystrokeEx,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_Format,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_Keystroke,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_FormatEx,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_KeystrokeEx,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_Format,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_Keystroke,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_Format,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_Keystroke,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_KeystrokeEx,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple,3)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFMakeNumber,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple_Calculate,2)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate,4)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange,1)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx,2)
-       JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums,1)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Format)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Keystroke)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Format)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Keystroke)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_FormatEx)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_KeystrokeEx)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_Format)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_Keystroke)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_FormatEx)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_KeystrokeEx)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_Format)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFTime_Keystroke)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_Format)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_Keystroke)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFSpecial_KeystrokeEx)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFMakeNumber)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple_Calculate)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx)
+       JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums)
 END_JS_STATIC_GLOBAL_FUN()
 
 IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods)
@@ -68,42 +68,43 @@ struct stru_TbConvert
        FX_LPCSTR lpszCppMark;
 };
 
-static const stru_TbConvert fcTable[] = {"mmmm","%B",
-       "mmm", "%b",
-       "mm",  "%m",
+static const stru_TbConvert fcTable[] = {
+       { "mmmm","%B" },
+       { "mmm", "%b" },
+       { "mm",  "%m" },
        //"m"
-       "dddd","%A",
-       "ddd", "%a",
-       "dd",  "%d",
+       { "dddd","%A" },
+       { "ddd", "%a" },
+       { "dd",  "%d" },
        //"d",   "%w",
-       "yyyy","%Y",
-       "yy",  "%y",
-       "HH",  "%H",
+       { "yyyy","%Y" },
+       { "yy",  "%y" },
+       { "HH",  "%H" },
        //"H"
-       "hh",  "%I",
+       { "hh",  "%I" },
        //"h"
-       "MM",  "%M",
+       { "MM",  "%M" },
        //"M"
-       "ss",  "%S",
+       { "ss",  "%S" },
        //"s
-       "tt",  "%p"
+       { "tt",  "%p" },
        //"t"
 };
 
 static FX_LPCWSTR months[] =
 {
-       (FX_LPCWSTR)L"Jan", (FX_LPCWSTR)L"Feb", (FX_LPCWSTR)L"Mar", (FX_LPCWSTR)L"Apr", (FX_LPCWSTR)L"May", (FX_LPCWSTR)L"Jun", (FX_LPCWSTR)L"Jul", (FX_LPCWSTR)L"Aug", (FX_LPCWSTR)L"Sep", (FX_LPCWSTR)L"Oct", (FX_LPCWSTR)L"Nov", (FX_LPCWSTR)L"Dec"
+       L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
 };
 
-static FX_LPCWSTR fullmonths[] = 
-{ 
-       (FX_LPCWSTR)L"January", (FX_LPCWSTR)L"February", (FX_LPCWSTR)L"March", (FX_LPCWSTR)L"April", (FX_LPCWSTR)L"May", (FX_LPCWSTR)L"June", (FX_LPCWSTR)L"July", (FX_LPCWSTR)L"August", (FX_LPCWSTR)L"September", (FX_LPCWSTR)L"October", (FX_LPCWSTR)L"November", (FX_LPCWSTR)L"December" 
+static FX_LPCWSTR fullmonths[] =
+{
+       L"January", L"February", L"March", L"April", L"May", L"June", L"July", L"August", L"September", L"October", L"November", L"December"
 };
 
 FX_BOOL CJS_PublicMethods::IsNumber(FX_LPCWSTR string)
 {
        CFX_WideString sTrim = StrTrim(string);
-       FX_LPCWSTR pTrim = sTrim;
+       FX_LPCWSTR pTrim = sTrim.c_str();
        FX_LPCWSTR p = pTrim;
 
 
@@ -173,13 +174,13 @@ FX_BOOL CJS_PublicMethods::maskSatisfied(wchar_t c_Change,wchar_t c_Mask)
        switch (c_Mask)
        {
        case L'9':
-        return IsDigit(c_Change);              
+        return IsDigit(c_Change);
     case L'A':
-        return IsAlphabetic(c_Change);         
+        return IsAlphabetic(c_Change);
     case L'O':
-        return IsAlphaNumeric(c_Change);               
+        return IsAlphaNumeric(c_Change);
     case L'X':
-        return TRUE;           
+        return TRUE;
        default:
         return (c_Change == c_Mask);
        }
@@ -192,19 +193,19 @@ FX_BOOL CJS_PublicMethods::isReservedMaskChar(wchar_t ch)
 
 double CJS_PublicMethods::AF_Simple(FX_LPCWSTR sFuction, double dValue1, double dValue2)
 {
-       if (FXSYS_wcsicmp(sFuction,(FX_LPCWSTR)L"AVG") == 0 || FXSYS_wcsicmp(sFuction,(FX_LPCWSTR)L"SUM") == 0)
+       if (FXSYS_wcsicmp(sFuction,L"AVG") == 0 || FXSYS_wcsicmp(sFuction,L"SUM") == 0)
        {
                return dValue1 + dValue2;
        }
-       else if (FXSYS_wcsicmp(sFuction, (FX_LPCWSTR)L"PRD") == 0)
+       else if (FXSYS_wcsicmp(sFuction, L"PRD") == 0)
        {
                return dValue1 * dValue2;
        }
-       else if (FXSYS_wcsicmp(sFuction,(FX_LPCWSTR)L"MIN") == 0)
+       else if (FXSYS_wcsicmp(sFuction,L"MIN") == 0)
        {
                return FX_MIN(dValue1, dValue2);
        }
-       else if (FXSYS_wcsicmp(sFuction,(FX_LPCWSTR)L"MAX") == 0)
+       else if (FXSYS_wcsicmp(sFuction,L"MAX") == 0)
        {
                return FX_MAX(dValue1, dValue2);
        }
@@ -222,43 +223,31 @@ CFX_WideString CJS_PublicMethods::StrLTrim(FX_LPCWSTR pStr)
 CFX_WideString CJS_PublicMethods::StrRTrim(FX_LPCWSTR pStr)
 {
        FX_LPCWSTR p = pStr;
-
        while (*p) p++;
-       p--;
-       if (p >= pStr)
-       {               
-               while (*p && *p == L' ') p--;
-               p++;
-               return CFX_WideString(pStr,p-pStr);
-       }
-       return L"";
+       while (p > pStr && *(p - 1) == L' ') p--;
+
+       return CFX_WideString(pStr, p - pStr);
 }
 
 CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr)
 {
-       return StrRTrim(StrLTrim(pStr));
+       return StrRTrim(StrLTrim(pStr).c_str());
 }
 
 CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr)
 {
        while (*pStr && *pStr == ' ') pStr++;
 
-    return pStr;
+        return pStr;
 }
 
 CFX_ByteString CJS_PublicMethods::StrRTrim(FX_LPCSTR pStr)
 {
        FX_LPCSTR p = pStr;
-
        while (*p) p++;
-       p--;
-       if (p >= pStr)
-       {               
-               while (*p && *p == ' ') p--;
-               p++;
-               return CFX_ByteString(pStr,p-pStr);
-       }
-       return "";
+       while (p > pStr && *(p - 1) == L' ') p--;
+
+       return CFX_ByteString(pStr,p-pStr);
 }
 
 CFX_ByteString CJS_PublicMethods::StrTrim(FX_LPCSTR pStr)
@@ -311,7 +300,7 @@ double CJS_PublicMethods::ParseNumber(FX_LPCWSTR swSource, FX_BOOL& bAllDigits,
        CFX_WideString swDigits;
 
        while (p <= pEnd)
-       {       
+       {
                c = *p;
 
                if (IsDigit(c))
@@ -319,7 +308,7 @@ double CJS_PublicMethods::ParseNumber(FX_LPCWSTR swSource, FX_BOOL& bAllDigits,
                        swDigits += c;
                        bDigitExist = TRUE;
                }
-               else 
+               else
                {
                        switch (c)
                        {
@@ -441,7 +430,7 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu
                val.ConvertToArray(StrArray);
                return StrArray;
        }
-       CFX_WideString wsStr = val.operator CFX_WideString();
+       CFX_WideString wsStr = val.ToCFXWideString();
        CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr);
        const char * p = (const char *)t;
 
@@ -454,7 +443,7 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu
                const char * pTemp = strchr(p, ch);
                if (pTemp == NULL)
                {
-                       StrArray.SetElement(nIndex, CJS_Value(isolate,(FX_LPCSTR)StrTrim(p)));
+                       StrArray.SetElement(nIndex, CJS_Value(isolate, StrTrim(p).c_str()));
                        break;
                }
                else
@@ -463,13 +452,13 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu
                        strncpy(pSub, p, pTemp - p);
                        *(pSub + (pTemp - p)) = '\0';
 
-                       StrArray.SetElement(nIndex, CJS_Value(isolate,(FX_LPCSTR)StrTrim(pSub)));
+                       StrArray.SetElement(nIndex, CJS_Value(isolate, StrTrim(pSub).c_str()));
                        delete []pSub;
-                       
+
                        nIndex ++;
                        p = ++pTemp;
                }
-               
+
        }
        return StrArray;
 }
@@ -488,7 +477,7 @@ int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& string,int nStar
                {
                        nRet = nRet * 10 + (c - '0');
                        nSkip = i - nStart + 1;
-                       if (nSkip >= nMaxStep) 
+                       if (nSkip >= nMaxStep)
                                break;
                }
                else
@@ -542,7 +531,7 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL&
                if (IsDigit((wchar_t)c))
                {
                        number[nIndex++] = ParseStringInteger(value, i, nSkip, 4);
-                       i += nSkip;                     
+                       i += nSkip;
                }
                else
                {
@@ -601,8 +590,8 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL&
        }
 
        CFX_WideString swTemp;
-       swTemp.Format((FX_LPCWSTR)L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec);
-       return JS_DateParse(swTemp);
+       swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec);
+       return JS_DateParse(swTemp.c_str());
 }
 
 double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CFX_WideString & format, FX_BOOL& bWrongFormat)
@@ -807,7 +796,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF
                                                                                CFX_WideString sFullMonths = fullmonths[m];
                                                                                sFullMonths.MakeLower();
 
-                                                                               if (sFullMonths.Find(sMonth, 0) != -1)
+                                                                               if (sFullMonths.Find(sMonth.c_str(), 0) != -1)
                                                                                {
                                                                                        nMonth = m + 1;
                                                                                        i += 4;
@@ -899,7 +888,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF
 
                if (JS_PortIsNan(dRet))
                {
-                       dRet = JS_DateParse(value);
+                       dRet = JS_DateParse(value.c_str());
                }
        }
 
@@ -947,22 +936,22 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, const CFX_WideStr
                                                        sPart += c;
                                                        break;
                                                case 'm':
-                                                       sPart.Format((FX_LPCWSTR)L"%d",nMonth);
+                                                       sPart.Format(L"%d",nMonth);
                                                        break;
                                                case 'd':
-                                                       sPart.Format((FX_LPCWSTR)L"%d",nDay);
+                                                       sPart.Format(L"%d",nDay);
                                                        break;
                                                case 'H':
-                                                       sPart.Format((FX_LPCWSTR)L"%d",nHour);
+                                                       sPart.Format(L"%d",nHour);
                                                        break;
                                                case 'h':
-                                                       sPart.Format((FX_LPCWSTR)L"%d",nHour>12?nHour - 12:nHour);
+                                                       sPart.Format(L"%d",nHour>12?nHour - 12:nHour);
                                                        break;
                                                case 'M':
-                                                       sPart.Format((FX_LPCWSTR)L"%d",nMin);
+                                                       sPart.Format(L"%d",nMin);
                                                        break;
                                                case 's':
-                                                       sPart.Format((FX_LPCWSTR)L"%d",nSec);
+                                                       sPart.Format(L"%d",nSec);
                                                        break;
                                                case 't':
                                                        sPart += nHour>12?'p':'a';
@@ -975,28 +964,28 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, const CFX_WideStr
                                        switch (c)
                                        {
                                                case 'y':
-                                                       sPart.Format((FX_LPCWSTR)L"%02d",nYear - (nYear / 100) * 100);
+                                                       sPart.Format(L"%02d",nYear - (nYear / 100) * 100);
                                                        break;
                                                case 'm':
-                                                       sPart.Format((FX_LPCWSTR)L"%02d",nMonth);
+                                                       sPart.Format(L"%02d",nMonth);
                                                        break;
                                                case 'd':
-                                                       sPart.Format((FX_LPCWSTR)L"%02d",nDay);
+                                                       sPart.Format(L"%02d",nDay);
                                                        break;
                                                case 'H':
-                                                       sPart.Format((FX_LPCWSTR)L"%02d",nHour);
+                                                       sPart.Format(L"%02d",nHour);
                                                        break;
                                                case 'h':
-                                                       sPart.Format((FX_LPCWSTR)L"%02d",nHour>12?nHour - 12:nHour);
+                                                       sPart.Format(L"%02d",nHour>12?nHour - 12:nHour);
                                                        break;
                                                case 'M':
-                                                       sPart.Format((FX_LPCWSTR)L"%02d",nMin);
+                                                       sPart.Format(L"%02d",nMin);
                                                        break;
                                                case 's':
-                                                       sPart.Format((FX_LPCWSTR)L"%02d",nSec);
+                                                       sPart.Format(L"%02d",nSec);
                                                        break;
                                                case 't':
-                                                       sPart = nHour>12? (FX_LPCWSTR)L"pm": (FX_LPCWSTR)L"am";
+                                                       sPart = nHour>12? L"pm": L"am";
                                                        break;
                                        }
                                        i+=2;
@@ -1023,7 +1012,7 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, const CFX_WideStr
                                        switch (c)
                                        {
                                                case 'y':
-                                                       sPart.Format((FX_LPCWSTR)L"%04d",nYear);
+                                                       sPart.Format(L"%04d",nYear);
                                                        i += 4;
                                                        break;
                                                case 'm':
@@ -1061,7 +1050,7 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, const CFX_WideStr
 /* -------------------------------------------------------------------------- */
 
 //function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend)
-FX_BOOL CJS_PublicMethods::AFNumber_Format(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
 #if _FX_OS_ != _FX_ANDROID_
        v8::Isolate* isolate = ::GetIsolate(cc);
@@ -1077,42 +1066,42 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(OBJ_METHOD_PARAMS)
        }
        if(!pEvent->m_pValue)
                return FALSE;
-       CFX_WideString& Value = pEvent->Value();        
+       CFX_WideString& Value = pEvent->Value();
        CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
-       
+
        if (strValue.IsEmpty()) return TRUE;
-       
-       int iDec = params[0];
-       int iSepStyle = params[1];
-       int iNegStyle = params[2];
-       int icurrStyle = params[3]; //it's no use!
-       std::wstring wstrCurrency(params[4].operator CFX_WideString());
-       FX_BOOL bCurrencyPrepend = params[5];
-       
+
+       int iDec = params[0].ToInt();
+       int iSepStyle = params[1].ToInt();
+       int iNegStyle = params[2].ToInt();
+       // params[3] is iCurrStyle, it's not used.
+       std::wstring wstrCurrency(params[4].ToCFXWideString().c_str());
+       FX_BOOL bCurrencyPrepend = params[5].ToBool();
+
        if (iDec < 0) iDec = -iDec;
-       
+
        if (iSepStyle < 0 || iSepStyle > 3)
                iSepStyle = 0;
-       
+
        if (iNegStyle < 0 || iNegStyle > 3)
                iNegStyle = 0;
-       
-       
+
+
        //////////////////////////////////////////////////////
        //for processing decimal places
        strValue.Replace(",", ".");
        double dValue = atof(strValue);
        if (iDec > 0)
-               dValue += DOUBLE_CORRECT;//
-                   
+               dValue += DOUBLE_CORRECT;
+
        int iDec2;
-       FX_BOOL bNagative = FALSE;
+       FX_BOOL bNegative = FALSE;
 
-       strValue = fcvt(dValue,iDec,&iDec2,&bNagative);
+       strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
        if (strValue.IsEmpty())
        {
                dValue = 0;
-               strValue = fcvt(dValue,iDec,&iDec2,&bNagative);
+               strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
                if (strValue.IsEmpty())
                {
                        strValue = "0";
@@ -1128,7 +1117,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(OBJ_METHOD_PARAMS)
                        strValue = "0" + strValue;
                }
                iDec2 = 0;
-               
+
        }
        int iMax = strValue.GetLength();
        if (iDec2 > iMax)
@@ -1137,7 +1126,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(OBJ_METHOD_PARAMS)
                {
                        strValue += "0";
                }
-               iMax = iDec2+1;                 
+               iMax = iDec2+1;
        }
        ///////////////////////////////////////////////////////
     //for processing seperator style
@@ -1153,7 +1142,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(OBJ_METHOD_PARAMS)
                        strValue.Insert(iDec2, ',');
                        iMax++;
                }
-               
+
                if (iDec2 == 0)
                        strValue.Insert(iDec2, '0');
        }
@@ -1164,35 +1153,33 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(OBJ_METHOD_PARAMS)
                        cSeperator = ',';
                else
                        cSeperator = '.';
-               
-               int iDecPositive,iDecNagative;
+
+               int iDecPositive;
                iDecPositive = iDec2;
-               iDecNagative = iDec2;           
-               
+
                for (iDecPositive = iDec2 -3; iDecPositive > 0;iDecPositive -= 3)
                {
                        strValue.Insert(iDecPositive, cSeperator);
                        iMax++;
                }
        }
-       
+
        //////////////////////////////////////////////////////////////////////
     //for processing currency string
 
        Value = CFX_WideString::FromLocal(strValue);
-       
-       std::wstring strValue2(Value);
+       std::wstring strValue2 = Value.c_str();
 
        if (bCurrencyPrepend)
                strValue2 = wstrCurrency + strValue2;
        else
                strValue2 = strValue2 + wstrCurrency;
-       
-       
-       
+
+
+
        /////////////////////////////////////////////////////////////////////////
        //for processing negative style
-       if (bNagative)
+       if (bNegative)
        {
                if (iNegStyle == 0)
                {
@@ -1215,9 +1202,9 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(OBJ_METHOD_PARAMS)
                                arColor.SetElement(1,vColElm);
                                vColElm = 0;
                                arColor.SetElement(2,vColElm);
-                               
+
                                arColor.SetElement(3,vColElm);
-                               
+
                                CJS_PropValue vProp(isolate);
                                vProp.StartGetting();
                                vProp<<arColor;
@@ -1240,11 +1227,11 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(OBJ_METHOD_PARAMS)
                                arColor.SetElement(1,vColElm);
                                arColor.SetElement(2,vColElm);
                                arColor.SetElement(3,vColElm);
-                               
+
                                CJS_PropValue vProp(isolate);
                                vProp.StartGetting();
                                fTarget->textColor(cc,vProp,sError);
-                               
+
                                CJS_Array aProp(isolate);
                                vProp.ConvertToArray(aProp);
 
@@ -1270,47 +1257,46 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(OBJ_METHOD_PARAMS)
 }
 
 //function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend)
-FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        CJS_Context* pContext = (CJS_Context *)cc;
        ASSERT(pContext != NULL);
        CJS_EventHandler* pEvent = pContext->GetEventHandler();
        ASSERT(pEvent != NULL);
-       
+
        if(params.size() < 2)
                return FALSE;
-       int iSepStyle = params[1];
-       
+       int iSepStyle = params[1].ToInt();
+
        if (iSepStyle < 0 || iSepStyle > 3)
                iSepStyle = 0;
        if(!pEvent->m_pValue)
                return FALSE;
-       CFX_WideString & val = pEvent->Value(); 
+       CFX_WideString & val = pEvent->Value();
        CFX_WideString & w_strChange = pEvent->Change();
     CFX_WideString w_strValue = val;
 
        if (pEvent->WillCommit())
        {
                CFX_WideString wstrChange = w_strChange;
-               CFX_WideString wstrValue = StrLTrim(w_strValue);
+               CFX_WideString wstrValue = StrLTrim(w_strValue.c_str());
                if (wstrValue.IsEmpty())
                        return TRUE;
-               
+
                CFX_WideString swTemp = wstrValue;
-               swTemp.Replace((FX_LPCWSTR)L",", (FX_LPCWSTR)L".");
-               if (!IsNumber(swTemp)) //!(IsNumber(wstrChange) && 
+               swTemp.Replace(L",", L".");
+               if (!IsNumber(swTemp.c_str()))
                {
                        pEvent->Rc() = FALSE;
                        sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
-                       Alert(pContext, sError);
+                       Alert(pContext, sError.c_str());
                        return TRUE;
                }
                return TRUE; // it happens after the last keystroke and before validating,
        }
-       
-       std::wstring w_strValue2 (w_strValue);
-       std::wstring w_strChange2(w_strChange);
-       
+
+       std::wstring w_strValue2 = w_strValue.c_str();
+       std::wstring w_strChange2 = w_strChange.c_str();
        std::wstring w_strSelected;
        if(-1 != pEvent->SelStart())
                w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->SelEnd() - pEvent->SelStart()));
@@ -1339,7 +1325,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(OBJ_METHOD_PARAMS)
                cSep = L',';
                break;
        }
-       
+
        FX_BOOL bHasSep = (w_strValue2.find(cSep) != -1);
        for (std::wstring::iterator it = w_strChange2.begin(); it != w_strChange2.end(); it++)
        {
@@ -1380,16 +1366,16 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(OBJ_METHOD_PARAMS)
                        bHasSign = TRUE;
                        continue;
                }
-               
+
                if (!IsDigit(*it))
-               {                       
+               {
                        FX_BOOL &bRc = pEvent->Rc();
                        bRc = FALSE;
                        return TRUE;
                }
        }
-       
-       
+
+
        std::wstring w_prefix = w_strValue2.substr(0,pEvent->SelStart());
        std::wstring w_postfix;
        if (pEvent->SelEnd()<(int)w_strValue2.length())
@@ -1397,12 +1383,12 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(OBJ_METHOD_PARAMS)
        w_strValue2 = w_prefix + w_strChange2 + w_postfix;
        w_strValue = w_strValue2.c_str();
        val = w_strValue;
-       return TRUE;            
-       
+       return TRUE;
+
 }
 
 //function AFPercent_Format(nDec, sepStyle)
-FX_BOOL CJS_PublicMethods::AFPercent_Format(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
 #if _FX_OS_ != _FX_ANDROID_
        CJS_Context* pContext = (CJS_Context *)cc;
@@ -1417,30 +1403,20 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(OBJ_METHOD_PARAMS)
        }
        if(!pEvent->m_pValue)
                return FALSE;
+
        CFX_WideString& Value = pEvent->Value();
-       
-//     HWND hMainFrame = NULL;
-//     
-//     CPDFSDK_FormFillApp *pApp = pContext->GetReaderApp();
-//     ASSERT(pApp);
-//     hMainFrame = pApp->GetMainFrameWnd();
-               
        CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
-       
        if (strValue.IsEmpty())
                return TRUE;
-       
-       int iDec = params[0];
-       int iSepStyle = params[1];
-       
-       //ASSERT(iDec > 0);
+
+       int iDec = params[0].ToInt();
        if (iDec < 0)
                iDec = -iDec;
-       
+
+       int iSepStyle = params[1].ToInt();
        if (iSepStyle < 0 || iSepStyle > 3)
                iSepStyle = 0;
-       
-       
+
        //////////////////////////////////////////////////////
        //for processing decimal places
        double dValue = atof(strValue);
@@ -1449,12 +1425,12 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(OBJ_METHOD_PARAMS)
                dValue += DOUBLE_CORRECT;//УÕý
 
        int iDec2;
-       FX_BOOL bNagative = FALSE;
-       strValue = fcvt(dValue,iDec,&iDec2,&bNagative);
+       FX_BOOL bNegative = FALSE;
+       strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
     if (strValue.IsEmpty())
        {
                dValue = 0;
-               strValue = fcvt(dValue,iDec,&iDec2,&bNagative);
+               strValue = fcvt(dValue,iDec,&iDec2,&bNegative);
        }
 
        if (iDec2 < 0)
@@ -1464,7 +1440,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(OBJ_METHOD_PARAMS)
                        strValue = "0" + strValue;
                }
                iDec2 = 0;
-               
+
        }
        int iMax = strValue.GetLength();
        if (iDec2 > iMax)
@@ -1473,7 +1449,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(OBJ_METHOD_PARAMS)
                {
                        strValue += "0";
                }
-               iMax = iDec2+1;                 
+               iMax = iDec2+1;
        }
        ///////////////////////////////////////////////////////
     //for processing seperator style
@@ -1489,7 +1465,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(OBJ_METHOD_PARAMS)
                        strValue.Insert(iDec2, ',');
                        iMax++;
                }
-               
+
                if (iDec2 == 0)
                        strValue.Insert(iDec2, '0');
        }
@@ -1500,11 +1476,10 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(OBJ_METHOD_PARAMS)
                        cSeperator = ',';
                else
                        cSeperator = '.';
-               
-               int iDecPositive,iDecNagative;
+
+               int iDecPositive;
                iDecPositive = iDec2;
-               iDecNagative = iDec2;
-                       
+
                for (iDecPositive = iDec2 -3; iDecPositive > 0; iDecPositive -= 3)
                {
                        strValue.Insert(iDecPositive,cSeperator);
@@ -1512,8 +1487,8 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(OBJ_METHOD_PARAMS)
                }
        }
        ////////////////////////////////////////////////////////////////////
-       //nagative mark
-       if(bNagative)
+       //negative mark
+       if(bNegative)
                strValue = "-" + strValue;
        strValue += "%";
        Value = CFX_WideString::FromLocal(strValue);
@@ -1521,13 +1496,13 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(OBJ_METHOD_PARAMS)
        return TRUE;
 }
 //AFPercent_Keystroke(nDec, sepStyle)
-FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        return AFNumber_Keystroke(cc,params,vRet,sError);
 }
 
 //function AFDate_FormatEx(cFormat)
-FX_BOOL CJS_PublicMethods::AFDate_FormatEx(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        CJS_Context* pContext = (CJS_Context *)cc;
        ASSERT(pContext != NULL);
@@ -1538,16 +1513,16 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(OBJ_METHOD_PARAMS)
        {
                sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
                return FALSE;
-       }       
+       }
        if(!pEvent->m_pValue)
                return FALSE;
-       CFX_WideString& val = pEvent->Value();
-       
-       CFX_WideString strValue = val;  
-       if (strValue.IsEmpty()) return TRUE;            
 
-       CFX_WideString sFormat = params[0].operator CFX_WideString();
+       CFX_WideString& val = pEvent->Value();
+       CFX_WideString strValue = val;
+       if (strValue.IsEmpty())
+               return TRUE;
 
+       CFX_WideString sFormat = params[0].ToCFXWideString();
        FX_BOOL bWrongFormat = FALSE;
        double dDate = 0.0f;
 
@@ -1565,13 +1540,12 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(OBJ_METHOD_PARAMS)
        if (JS_PortIsNan(dDate))
        {
                CFX_WideString swMsg;
-               swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), (FX_LPCWSTR)sFormat);
-               Alert(pContext, swMsg);
+               swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
+               Alert(pContext, swMsg.c_str());
                return FALSE;
        }
-       
-       val =  MakeFormatDate(dDate,sFormat);
 
+       val =  MakeFormatDate(dDate,sFormat);
        return TRUE;
 }
 
@@ -1593,7 +1567,7 @@ double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue)
        {
                FX_WCHAR c = strValue.GetAt(i);
                if(c == L' ' || c == L':')
-               {       
+               {
                        wsArray.Add(sTemp);
                        sTemp = L"";
                        continue;
@@ -1601,7 +1575,7 @@ double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue)
 
                sTemp += c;
        }
-       
+
        wsArray.Add(sTemp);
        if(wsArray.GetSize() != 8)return 0;
 
@@ -1619,24 +1593,24 @@ double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue)
        if(sTemp.Compare(L"Nov") == 0) nMonth = 11;
        if(sTemp.Compare(L"Dec") == 0) nMonth = 12;
 
-       nDay = (int)ParseStringToNumber(wsArray[2]);
-       nHour = (int)ParseStringToNumber(wsArray[3]);
-       nMin = (int)ParseStringToNumber(wsArray[4]);
-       nSec = (int)ParseStringToNumber(wsArray[5]);
-       nYear = (int)ParseStringToNumber(wsArray[7]);
+       nDay = (int)ParseStringToNumber(wsArray[2].c_str());
+       nHour = (int)ParseStringToNumber(wsArray[3].c_str());
+       nMin = (int)ParseStringToNumber(wsArray[4].c_str());
+       nSec = (int)ParseStringToNumber(wsArray[5].c_str());
+       nYear = (int)ParseStringToNumber(wsArray[7].c_str());
 
        double dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(nHour, nMin, nSec, 0));
 
        if (JS_PortIsNan(dRet))
        {
-               dRet = JS_DateParse(strValue);
+               dRet = JS_DateParse(strValue.c_str());
        }
-       
+
        return dRet;
 }
 
 //AFDate_KeystrokeEx(cFormat)
-FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        CJS_Context* pContext = (CJS_Context *)cc;
        ASSERT(pContext != NULL);
@@ -1647,24 +1621,24 @@ FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(OBJ_METHOD_PARAMS)
        {
                sError = L"AFDate_KeystrokeEx's parameters' size r not correct";
                return FALSE;
-       }       
-       
+       }
+
        if (pEvent->WillCommit())
        {
                if(!pEvent->m_pValue)
                        return FALSE;
                CFX_WideString strValue = pEvent->Value();
-               if (strValue.IsEmpty()) return TRUE;
-
-               CFX_WideString sFormat = params[0].operator CFX_WideString();
+               if (strValue.IsEmpty())
+                       return TRUE;
 
+               CFX_WideString sFormat = params[0].ToCFXWideString();
                FX_BOOL bWrongFormat = FALSE;
                double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat);
                if (bWrongFormat || JS_PortIsNan(dRet))
                {
                        CFX_WideString swMsg;
-                       swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), (FX_LPCWSTR)sFormat);
-                       Alert(pContext, swMsg);
+                       swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
+                       Alert(pContext, swMsg.c_str());
                        pEvent->Rc() = FALSE;
                        return TRUE;
                }
@@ -1672,7 +1646,7 @@ FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(OBJ_METHOD_PARAMS)
        return TRUE;
 }
 
-FX_BOOL CJS_PublicMethods::AFDate_Format(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        v8::Isolate* isolate = ::GetIsolate(cc);
 
@@ -1685,16 +1659,16 @@ FX_BOOL CJS_PublicMethods::AFDate_Format(OBJ_METHOD_PARAMS)
                return FALSE;
        }
 
-       int iIndex = params[0];
-       FX_LPCWSTR cFormats[] =  {(FX_LPCWSTR)L"m/d", (FX_LPCWSTR)L"m/d/yy", (FX_LPCWSTR)L"mm/dd/yy", (FX_LPCWSTR)L"mm/yy", (FX_LPCWSTR)L"d-mmm", (FX_LPCWSTR)L"d-mmm-yy", (FX_LPCWSTR)L"dd-mmm-yy",
-               (FX_LPCWSTR)L"yy-mm-dd", (FX_LPCWSTR)L"mmm-yy", (FX_LPCWSTR)L"mmmm-yy", (FX_LPCWSTR)L"mmm d, yyyy", (FX_LPCWSTR)L"mmmm d, yyyy",
-               (FX_LPCWSTR)L"m/d/yy h:MM tt", (FX_LPCWSTR)L"m/d/yy HH:MM" };
+       int iIndex = params[0].ToInt();
+       FX_LPCWSTR cFormats[] =  {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
+               L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yyyy",
+               L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
 
-       ASSERT(iIndex < sizeof(cFormats)/sizeof(FX_LPCWSTR));
+       ASSERT(iIndex < FX_ArraySize(cFormats));
 
        if (iIndex < 0)
                iIndex = 0;
-       if (iIndex >= sizeof(cFormats)/sizeof(FX_LPCWSTR))
+       if (iIndex >= FX_ArraySize(cFormats))
                iIndex = 0;
        CJS_Parameters newParams;
        CJS_Value val(isolate,cFormats[iIndex]);
@@ -1703,7 +1677,7 @@ FX_BOOL CJS_PublicMethods::AFDate_Format(OBJ_METHOD_PARAMS)
 }
 
 //AFDate_KeystrokeEx(cFormat)
-FX_BOOL CJS_PublicMethods::AFDate_Keystroke(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        v8::Isolate* isolate = ::GetIsolate(cc);
 
@@ -1716,16 +1690,16 @@ FX_BOOL CJS_PublicMethods::AFDate_Keystroke(OBJ_METHOD_PARAMS)
                return FALSE;
        }
 
-       int iIndex = params[0];
-       FX_LPCWSTR cFormats[] =  {(FX_LPCWSTR)L"m/d", (FX_LPCWSTR)L"m/d/yy", (FX_LPCWSTR)L"mm/dd/yy", (FX_LPCWSTR)L"mm/yy", (FX_LPCWSTR)L"d-mmm", (FX_LPCWSTR)L"d-mmm-yy", (FX_LPCWSTR)L"dd-mmm-yy",
-               (FX_LPCWSTR)L"yy-mm-dd", (FX_LPCWSTR)L"mmm-yy", (FX_LPCWSTR)L"mmmm-yy", (FX_LPCWSTR)L"mmm d, yyyy", (FX_LPCWSTR)L"mmmm d, yyyy",
-               (FX_LPCWSTR)L"m/d/yy h:MM tt", (FX_LPCWSTR)L"m/d/yy HH:MM" };
+       int iIndex = params[0].ToInt();
+       FX_LPCWSTR cFormats[] =  {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
+               L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yyyy",
+               L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
 
-       ASSERT(iIndex<sizeof(cFormats)/sizeof(FX_LPCWSTR));
+       ASSERT(iIndex<FX_ArraySize(cFormats));
 
        if (iIndex < 0)
                iIndex = 0;
-       if (iIndex >= sizeof(cFormats)/sizeof(FX_LPCWSTR))
+       if (iIndex >= FX_ArraySize(cFormats))
                iIndex = 0;
        CJS_Parameters newParams;
        CJS_Value val(isolate,cFormats[iIndex]);
@@ -1734,7 +1708,7 @@ FX_BOOL CJS_PublicMethods::AFDate_Keystroke(OBJ_METHOD_PARAMS)
 }
 
 //function AFTime_Format(ptf)
-FX_BOOL CJS_PublicMethods::AFTime_Format(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        v8::Isolate* isolate = ::GetIsolate(cc);
 
@@ -1746,14 +1720,14 @@ FX_BOOL CJS_PublicMethods::AFTime_Format(OBJ_METHOD_PARAMS)
                return FALSE;
        }
 
-       int iIndex = params[0];
-       FX_LPCWSTR cFormats[] = {(FX_LPCWSTR)L"HH:MM", (FX_LPCWSTR)L"h:MM tt", (FX_LPCWSTR)L"HH:MM:ss", (FX_LPCWSTR)L"h:MM:ss tt"};
+       int iIndex = params[0].ToInt();
+       FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"};
 
-       ASSERT(iIndex<sizeof(cFormats)/sizeof(FX_LPCWSTR));
+       ASSERT(iIndex<FX_ArraySize(cFormats));
 
        if (iIndex < 0)
                iIndex = 0;
-       if (iIndex >= sizeof(cFormats)/sizeof(FX_LPCWSTR))
+       if (iIndex >= FX_ArraySize(cFormats))
                iIndex = 0;
        CJS_Parameters newParams;
        CJS_Value val(isolate,cFormats[iIndex]);
@@ -1761,7 +1735,7 @@ FX_BOOL CJS_PublicMethods::AFTime_Format(OBJ_METHOD_PARAMS)
        return AFDate_FormatEx(cc,newParams,vRet,sError);
 }
 
-FX_BOOL CJS_PublicMethods::AFTime_Keystroke(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        v8::Isolate* isolate = ::GetIsolate(cc);
        if (params.size() != 1)
@@ -1772,14 +1746,14 @@ FX_BOOL CJS_PublicMethods::AFTime_Keystroke(OBJ_METHOD_PARAMS)
                return FALSE;
        }
 
-       int iIndex = params[0];
-       FX_LPCWSTR cFormats[] = {(FX_LPCWSTR)L"HH:MM", (FX_LPCWSTR)L"h:MM tt", (FX_LPCWSTR)L"HH:MM:ss", (FX_LPCWSTR)L"h:MM:ss tt"};
+       int iIndex = params[0].ToInt();
+       FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"};
 
-       ASSERT(iIndex<sizeof(cFormats)/sizeof(FX_LPCWSTR));
+       ASSERT(iIndex<FX_ArraySize(cFormats));
 
        if (iIndex < 0)
                iIndex = 0;
-       if (iIndex >= sizeof(cFormats)/sizeof(FX_LPCWSTR))
+       if (iIndex >= FX_ArraySize(cFormats))
                iIndex = 0;
        CJS_Parameters newParams;
        CJS_Value val(isolate,cFormats[iIndex]);
@@ -1787,18 +1761,18 @@ FX_BOOL CJS_PublicMethods::AFTime_Keystroke(OBJ_METHOD_PARAMS)
        return AFDate_KeystrokeEx(cc,newParams,vRet,sError);
 }
 
-FX_BOOL CJS_PublicMethods::AFTime_FormatEx(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        return AFDate_FormatEx(cc,params,vRet,sError);
 }
 
-FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        return AFDate_KeystrokeEx(cc,params,vRet,sError);
 }
 
 //function AFSpecial_Format(psf)
-FX_BOOL CJS_PublicMethods::AFSpecial_Format(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        CJS_Context* pContext = (CJS_Context *)cc;
        ASSERT(pContext != NULL);
@@ -1810,31 +1784,31 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format(OBJ_METHOD_PARAMS)
        }
 
        std::string cFormat;
-       int iIndex = params[0];
+       int iIndex = params[0].ToInt();
 
        CJS_EventHandler* pEvent = pContext->GetEventHandler();
        ASSERT(pEvent != NULL);
 
        if(!pEvent->m_pValue)
                return FALSE;
-       CFX_WideString& Value = pEvent->Value();        
-       std::string strSrc = (FX_LPCSTR)CFX_ByteString::FromUnicode(Value);
-       
-       switch (iIndex) 
+       CFX_WideString& Value = pEvent->Value();
+       std::string strSrc = CFX_ByteString::FromUnicode(Value).c_str();
+
+       switch (iIndex)
        {
-       case 0:                         
+       case 0:
                cFormat = "99999";
                break;
-       case 1:                         
+       case 1:
                cFormat = "99999-9999";
                break;
-       case 2:                         
+       case 2:
                {
                        std::string NumberStr;
-                       util::printx("9999999999", strSrc,NumberStr); 
+                       util::printx("9999999999", strSrc,NumberStr);
                        if (NumberStr.length() >= 10 )
                                cFormat = "(999) 999-9999";
-                       else 
+                       else
                                cFormat = "999-9999";
                        break;
                }
@@ -1842,7 +1816,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format(OBJ_METHOD_PARAMS)
                cFormat = "999-99-9999";
                break;
        }
-       
+
        std::string strDes;
        util::printx(cFormat,strSrc,strDes);
        Value = CFX_WideString::FromLocal(strDes.c_str());
@@ -1851,7 +1825,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format(OBJ_METHOD_PARAMS)
 
 
 //function AFSpecial_KeystrokeEx(mask)
-FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        CJS_Context* pContext = (CJS_Context *)cc;
        ASSERT(pContext != NULL);
@@ -1869,11 +1843,12 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(OBJ_METHOD_PARAMS)
                return FALSE;
        CFX_WideString& valEvent = pEvent->Value();
 
-       CFX_WideString wstrMask = params[0].operator CFX_WideString();
-       if (wstrMask.IsEmpty()) return TRUE;
-       
-       std::wstring wstrValue(valEvent);
-       
+       CFX_WideString wstrMask = params[0].ToCFXWideString();
+       if (wstrMask.IsEmpty())
+               return TRUE;
+
+       std::wstring wstrValue = valEvent.c_str();
+
        if (pEvent->WillCommit())
        {
                if (wstrValue.empty())
@@ -1882,76 +1857,69 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(OBJ_METHOD_PARAMS)
                for (std::wstring::iterator it = wstrValue.begin(); it != wstrValue.end(); it++)
                {
                        wchar_t w_Value = *it;
-            if (!maskSatisfied(w_Value,wstrMask[iIndexMask]))
+                       if (!maskSatisfied(w_Value,wstrMask[iIndexMask]))
                                break;
                        iIndexMask++;
                }
 
                if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrValue.size() && wstrMask.GetLength() != 0))
                {
-                       Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE));
+                       Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
                        pEvent->Rc() = FALSE;
                }
                return TRUE;
        }
 
-       
        CFX_WideString &wideChange = pEvent->Change();
-       std::wstring wChange(wideChange);
-       
+       std::wstring wChange = wideChange.c_str();
        if (wChange.empty())
                return TRUE;
-    int iIndexMask = pEvent->SelStart();
-       //iIndexMask++;
-       
-       
+
+       int iIndexMask = pEvent->SelStart();
+
        if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange.length() > (FX_DWORD)wstrMask.GetLength())
        {
-               Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG));
+               Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
                pEvent->Rc() = FALSE;
                return TRUE;
        }
-       
-       
+
        if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty()))
        {
-               Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG));
+               Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
                pEvent->Rc() = FALSE;
                return TRUE;
        }
-       
+
        for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); it++)
        {
                if (iIndexMask >= wstrMask.GetLength())
                {
-                       Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG));
+                       Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
                        pEvent->Rc() = FALSE;
                        return TRUE;
                }
                wchar_t w_Mask = wstrMask[iIndexMask];
                if (!isReservedMaskChar(w_Mask))
                {
-                       //wChange.insert(it,w_Mask);                            
                        *it = w_Mask;
                }
                wchar_t w_Change = *it;
-               
-        if (!maskSatisfied(w_Change,w_Mask))
+               if (!maskSatisfied(w_Change,w_Mask))
                {
                        pEvent->Rc() = FALSE;
                        return TRUE;
                }
                iIndexMask++;
        }
-       
-       wideChange = wChange.c_str();   
-       
+
+       wideChange = wChange.c_str();
        return TRUE;
 }
 
 
 //function AFSpecial_Keystroke(psf)
-FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        v8::Isolate* isolate = ::GetIsolate(cc);
 
@@ -1967,32 +1935,32 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(OBJ_METHOD_PARAMS)
        }
 
        std::string cFormat;
-       int iIndex = (int)params[0];    
+       int iIndex = params[0].ToInt();
 
        if(!pEvent->m_pValue)
                return FALSE;
        //CJS_Value val = pEvent->Value();
        CFX_WideString& val = pEvent->Value();
-       std::string strSrc = (FX_LPCSTR)CFX_ByteString::FromUnicode(val);
-       std::wstring wstrChange(pEvent->Change());
-       
-       switch (iIndex) 
+       std::string strSrc = CFX_ByteString::FromUnicode(val).c_str();
+       std::wstring wstrChange = pEvent->Change().c_str();
+
+       switch (iIndex)
        {
-       case 0:                         
+       case 0:
                cFormat = "99999";
                break;
-       case 1:                         
+       case 1:
                //cFormat = "99999-9999";
                cFormat = "999999999";
                break;
-       case 2:                         
+       case 2:
                {
                        std::string NumberStr;
-                       util::printx("9999999999", strSrc,NumberStr); 
+                       util::printx("9999999999", strSrc,NumberStr);
                        if (strSrc.length() + wstrChange.length() > 7 )
                                //cFormat = "(999) 999-9999";
                                cFormat = "9999999999";
-                       else 
+                       else
                                //cFormat = "999-9999";
                                cFormat = "9999999";
                        break;
@@ -2002,15 +1970,15 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(OBJ_METHOD_PARAMS)
                cFormat = "999999999";
                break;
        }
-    
+
        CJS_Parameters params2;
        CJS_Value vMask(isolate, cFormat.c_str());
        params2.push_back(vMask);
-       
+
     return AFSpecial_KeystrokeEx(cc,params2,vRet,sError);
 }
 
-FX_BOOL CJS_PublicMethods::AFMergeChange(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        CJS_Context* pContext = (CJS_Context *)cc;
        ASSERT(pContext != NULL);
@@ -2029,7 +1997,7 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(OBJ_METHOD_PARAMS)
 
        if (pEventHandler->WillCommit())
        {
-               vRet = swValue;
+               vRet = swValue.c_str();
                return TRUE;
        }
 
@@ -2045,12 +2013,12 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(OBJ_METHOD_PARAMS)
                postfix = swValue.Mid(pEventHandler->SelEnd(), swValue.GetLength() - pEventHandler->SelEnd());
        else postfix = L"";
 
-       vRet = prefix + pEventHandler->Change() + postfix;
+       vRet = (prefix + pEventHandler->Change() + postfix).c_str();
 
        return TRUE;
 }
 
-FX_BOOL CJS_PublicMethods::AFParseDateEx(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        CJS_Context* pContext = (CJS_Context *)cc;
        ASSERT(pContext != NULL);
@@ -2061,8 +2029,8 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(OBJ_METHOD_PARAMS)
                return FALSE;
        }
 
-       CFX_WideString sValue = params[0].operator CFX_WideString();
-       CFX_WideString sFormat = params[1].operator CFX_WideString();
+       CFX_WideString sValue = params[0].ToCFXWideString();
+       CFX_WideString sFormat = params[1].ToCFXWideString();
 
        FX_BOOL bWrongFormat = FALSE;
        double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat);
@@ -2070,17 +2038,16 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(OBJ_METHOD_PARAMS)
        if (JS_PortIsNan(dDate))
        {
                CFX_WideString swMsg;
-               swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), (FX_LPCWSTR)sFormat);
-               Alert((CJS_Context *)cc, swMsg);
+               swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
+               Alert((CJS_Context *)cc, swMsg.c_str());
                return FALSE;
        }
-       
-       vRet = dDate;
 
+       vRet = dDate;
        return TRUE;
 }
 
-FX_BOOL CJS_PublicMethods::AFSimple(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        if (params.size() != 3)
        {
@@ -2091,11 +2058,11 @@ FX_BOOL CJS_PublicMethods::AFSimple(OBJ_METHOD_PARAMS)
                return FALSE;
        }
 
-       vRet = (double)AF_Simple(params[0].operator CFX_WideString(), (double)params[1], (double)params[2]);
+       vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1].ToDouble(), params[2].ToDouble());
        return TRUE;
 }
 
-FX_BOOL CJS_PublicMethods::AFMakeNumber(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        if (params.size() != 1)
        {
@@ -2105,11 +2072,11 @@ FX_BOOL CJS_PublicMethods::AFMakeNumber(OBJ_METHOD_PARAMS)
                sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
                return FALSE;
        }
-    vRet = ParseStringToNumber(params[0].operator CFX_WideString());
+       vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str());
        return TRUE;
 }
 
-FX_BOOL CJS_PublicMethods::AFSimple_Calculate(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        v8::Isolate* isolate = ::GetIsolate(cc);
 
@@ -2129,7 +2096,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(OBJ_METHOD_PARAMS)
                sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
                return FALSE;
        }
-       
+
        CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument();
     ASSERT(pReaderDoc != NULL);
 
@@ -2140,8 +2107,8 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(OBJ_METHOD_PARAMS)
        ASSERT(pInterForm != NULL);
 
        double dValue;
-       CFX_WideString sFunction = params[0].operator CFX_WideString();
-       if (wcscmp(sFunction, L"PRD") == 0)
+       CFX_WideString sFunction = params[0].ToCFXWideString();
+       if (wcscmp(sFunction.c_str(), L"PRD") == 0)
        dValue = 1.0;
        else
                dValue = 0.0;
@@ -2154,7 +2121,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(OBJ_METHOD_PARAMS)
        {
                CJS_Value jsValue(isolate);
                FieldNameArray.GetElement(i,jsValue);
-        CFX_WideString wsFieldName = jsValue.operator CFX_WideString();
+               CFX_WideString wsFieldName = jsValue.ToCFXWideString();
 
         for (int j=0,jsz=pInterForm->CountFields(wsFieldName); j<jsz; j++)
                {
@@ -2167,7 +2134,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(OBJ_METHOD_PARAMS)
                                case FIELDTYPE_TEXTFIELD:
                                case FIELDTYPE_COMBOBOX:
                                        {
-                                               dTemp = ParseStringToNumber(pFormField->GetValue());
+                                               dTemp = ParseStringToNumber(pFormField->GetValue().c_str());
                                                break;
                                        }
                                case FIELDTYPE_PUSHBUTTON:
@@ -2185,7 +2152,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(OBJ_METHOD_PARAMS)
                                                        {
                                                                if (pFormCtrl->IsChecked())
                                                                {
-                                                                       dTemp += ParseStringToNumber(pFormCtrl->GetExportValue());
+                                                                       dTemp += ParseStringToNumber(pFormCtrl->GetExportValue().c_str());
                                                                        break;
                                                                }
                                                                else
@@ -2201,7 +2168,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(OBJ_METHOD_PARAMS)
                                                        break;
                                                else
                                                {
-                                                       dTemp = ParseStringToNumber(pFormField->GetValue());
+                                                       dTemp = ParseStringToNumber(pFormField->GetValue().c_str());
                                                        break;
                                                }
                                        }
@@ -2209,38 +2176,38 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(OBJ_METHOD_PARAMS)
                                        break;
                                }
 
-                               if (i == 0 && j == 0 && (wcscmp(sFunction,L"MIN") == 0 || wcscmp(sFunction, L"MAX") == 0))
+                               if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(), L"MIN") == 0 || wcscmp(sFunction.c_str(), L"MAX") == 0))
                                        dValue = dTemp;
 
-                               dValue = AF_Simple(sFunction, dValue, dTemp);
+                               dValue = AF_Simple(sFunction.c_str(), dValue, dTemp);
 
                                nFieldsCount++;
                        }
                }
        }
 
-       if (wcscmp(sFunction, L"AVG") == 0 && nFieldsCount > 0)
+       if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0)
                dValue /= nFieldsCount;
 
        dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49) / FXSYS_pow((double)10,(double)6);
        CJS_Value jsValue(isolate,dValue);
        if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue)
-               ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsValue;
+               ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsValue.ToCFXWideString();
 
        return TRUE;
 }
 
-/* This function validates the current event to ensure that its value is 
+/* This function validates the current event to ensure that its value is
 ** within the specified range. */
 
-FX_BOOL CJS_PublicMethods::AFRange_Validate(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        CJS_Context* pContext = (CJS_Context *)cc;
        ASSERT(pContext != NULL);
        CJS_EventHandler* pEvent = pContext->GetEventHandler();
        ASSERT(pEvent != NULL);
 
-       if (params.size() != 4) 
+       if (params.size() != 4)
        {
                sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
                return FALSE;
@@ -2251,45 +2218,47 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(OBJ_METHOD_PARAMS)
        if (pEvent->Value().IsEmpty() )
                return TRUE;
        double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value()));
-       FX_BOOL bGreaterThan, bLessThan;
-       double  dGreaterThan, dLessThan;
-    bGreaterThan = (FX_BOOL)params[0];
+       FX_BOOL bGreaterThan = params[0].ToBool();
+       double dGreaterThan = params[1].ToDouble();
+       FX_BOOL bLessThan = params[2].ToBool();
+       double dLessThan = params[3].ToDouble();
        CFX_WideString swMsg;
-       dGreaterThan = (double)params[1];
-       bLessThan = (FX_BOOL)params[2];
-       dLessThan = (double)params[3];
 
        if (bGreaterThan && bLessThan)
        {
                if (dEentValue < dGreaterThan || dEentValue > dLessThan)
-                       swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1),(FX_LPCWSTR)params[1].operator CFX_WideString(), (FX_LPCWSTR)params[3].operator CFX_WideString());
+                       swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1).c_str(),
+                                                params[1].ToCFXWideString().c_str(),
+                                                params[3].ToCFXWideString().c_str());
        }
        else if (bGreaterThan)
        {
                if (dEentValue < dGreaterThan)
-                       swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2), (FX_LPCWSTR)params[1].operator CFX_WideString());
+                       swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2).c_str(),
+                                                params[1].ToCFXWideString().c_str());
        }
        else if (bLessThan)
        {
                if (dEentValue > dLessThan)
-                       swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3), (FX_LPCWSTR)params[3].operator CFX_WideString());
+                       swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3).c_str(),
+                                                params[3].ToCFXWideString().c_str());
        }
 
        if (!swMsg.IsEmpty())
        {
-               Alert(pContext, swMsg);
+               Alert(pContext, swMsg.c_str());
                pEvent->Rc() = FALSE;
        }
        return TRUE;
 }
 
-FX_BOOL CJS_PublicMethods::AFExtractNums(OBJ_METHOD_PARAMS)
+FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        v8::Isolate* isolate = ::GetIsolate(cc);
        CJS_Context* pContext = (CJS_Context*)cc;
        ASSERT(pContext != NULL);
 
-       if (params.size() != 1) 
+       if (params.size() != 1)
        {
                sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
                return FALSE;
@@ -2297,7 +2266,7 @@ FX_BOOL CJS_PublicMethods::AFExtractNums(OBJ_METHOD_PARAMS)
 
        CJS_Array nums(isolate);
 
-       CFX_WideString str = params[0].operator CFX_WideString();
+       CFX_WideString str = params[0].ToCFXWideString();
        CFX_WideString sPart;
 
        if (str.GetAt(0) == L'.' || str.GetAt(0) == L',')
@@ -2315,7 +2284,7 @@ FX_BOOL CJS_PublicMethods::AFExtractNums(OBJ_METHOD_PARAMS)
                {
                        if (sPart.GetLength() > 0)
                        {
-                               nums.SetElement(nIndex,CJS_Value(isolate,(FX_LPCWSTR)sPart));
+                               nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str()));
                                sPart = L"";
                                nIndex ++;
                        }
@@ -2324,7 +2293,7 @@ FX_BOOL CJS_PublicMethods::AFExtractNums(OBJ_METHOD_PARAMS)
 
        if (sPart.GetLength() > 0)
        {
-               nums.SetElement(nIndex,CJS_Value(isolate,(FX_LPCWSTR)sPart));   
+               nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str()));
        }
 
        if (nums.GetLength() > 0)