Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / src / fxfa / src / fm2js / xfa_lexer.cpp
index 448d734..7ce3355 100644 (file)
@@ -16,7 +16,7 @@ struct XFA_FMDChar {
         --p;\r
         return p;\r
     }\r
-    static FX_UINT16 get(FX_LPCWSTR p)\r
+    static uint16_t get(FX_LPCWSTR p)\r
     {\r
         return *p;\r
     }\r
@@ -50,7 +50,7 @@ struct XFA_FMDChar {
     }\r
     static FX_BOOL isAvalid(FX_LPCWSTR p, FX_BOOL flag = 0);\r
     static FX_BOOL string2number(FX_LPCWSTR s, FX_DOUBLE *pValue, FX_LPCWSTR &pEnd);\r
-    static FX_BOOL isUnicodeAlpha(FX_UINT16 ch);\r
+    static FX_BOOL isUnicodeAlpha(uint16_t ch);\r
 };\r
 inline FX_BOOL XFA_FMDChar::isAvalid(FX_LPCWSTR p, FX_BOOL flag)\r
 {\r
@@ -74,7 +74,7 @@ inline FX_BOOL XFA_FMDChar::string2number(FX_LPCWSTR s, FX_DOUBLE *pValue, FX_LP
     }\r
     return 0;\r
 }\r
-inline FX_BOOL XFA_FMDChar::isUnicodeAlpha(FX_UINT16 ch)\r
+inline FX_BOOL XFA_FMDChar::isUnicodeAlpha(uint16_t ch)\r
 {\r
     if (ch == 0 || ch == 0x0A || ch == 0x0D || ch == 0x09 || ch == 0x0B || ch == 0x0C || ch == 0x20 || ch == '.'\r
             || ch == ';' || ch == '"' || ch == '=' || ch == '<' || ch == '>' || ch == ',' || ch == '(' || ch == ')'\r
@@ -85,65 +85,65 @@ inline FX_BOOL XFA_FMDChar::isUnicodeAlpha(FX_UINT16 ch)
     }\r
 }\r
 static XFA_FMKeyword keyWords[] = {\r
-    {TOKand,           0x00000026,             (FX_LPCWSTR)(L"&")},\r
-    {TOKlparen,                0x00000028,             (FX_LPCWSTR)(L"(")},\r
-    {TOKrparen,                0x00000029,             (FX_LPCWSTR)(L")")},\r
-    {TOKmul,           0x0000002a,             (FX_LPCWSTR)(L"*")},\r
-    {TOKplus,          0x0000002b,             (FX_LPCWSTR)(L"+")},\r
-    {TOKcomma,         0x0000002c,             (FX_LPCWSTR)(L",")},\r
-    {TOKminus,         0x0000002d,             (FX_LPCWSTR)(L"-")},\r
-    {TOKdot,           0x0000002e,             (FX_LPCWSTR)(L".")},\r
-    {TOKdiv,           0x0000002f,             (FX_LPCWSTR)(L"/")},\r
-    {TOKlt,                    0x0000003c,             (FX_LPCWSTR)(L"<")},\r
-    {TOKassign,                0x0000003d,             (FX_LPCWSTR)(L"=")},\r
-    {TOKgt,                    0x0000003e,             (FX_LPCWSTR)(L">")},\r
-    {TOKlbracket,      0x0000005b,             (FX_LPCWSTR)(L"[")},\r
-    {TOKrbracket,      0x0000005d,             (FX_LPCWSTR)(L"]")},\r
-    {TOKor,                    0x0000007c,             (FX_LPCWSTR)(L"|")},\r
-    {TOKdotscream,     0x0000ec11,             (FX_LPCWSTR)(L".#")},\r
-    {TOKdotstar,       0x0000ec18,             (FX_LPCWSTR)(L".*")},\r
-    {TOKdotdot,                0x0000ec1c,             (FX_LPCWSTR)(L"..")},\r
-    {TOKle,                    0x000133f9,             (FX_LPCWSTR)(L"<=")},\r
-    {TOKne,                    0x000133fa,             (FX_LPCWSTR)(L"<>")},\r
-    {TOKeq,                    0x0001391a,             (FX_LPCWSTR)(L"==")},\r
-    {TOKge,                    0x00013e3b,             (FX_LPCWSTR)(L">=")},\r
-    {TOKdo,                    0x00020153,             (FX_LPCWSTR)(L"do")},\r
-    {TOKkseq,          0x00020676,             (FX_LPCWSTR)(L"eq")},\r
-    {TOKksge,          0x000210ac,             (FX_LPCWSTR)(L"ge")},\r
-    {TOKksgt,          0x000210bb,             (FX_LPCWSTR)(L"gt")},\r
-    {TOKif,                    0x00021aef,             (FX_LPCWSTR)(L"if")},\r
-    {TOKin,                    0x00021af7,             (FX_LPCWSTR)(L"in")},\r
-    {TOKksle,          0x00022a51,             (FX_LPCWSTR)(L"le")},\r
-    {TOKkslt,          0x00022a60,             (FX_LPCWSTR)(L"lt")},\r
-    {TOKksne,          0x00023493,             (FX_LPCWSTR)(L"ne")},\r
-    {TOKksor,          0x000239c1,             (FX_LPCWSTR)(L"or")},\r
-    {TOKnull,          0x052931bb,             (FX_LPCWSTR)(L"null")},\r
-    {TOKbreak,         0x05518c25,             (FX_LPCWSTR)(L"break")},\r
-    {TOKksand,         0x09f9db33,             (FX_LPCWSTR)(L"and")},\r
-    {TOKend,           0x0a631437,             (FX_LPCWSTR)(L"end")},\r
-    {TOKeof,           0x0a63195a,             (FX_LPCWSTR)(L"eof")},\r
-    {TOKfor,           0x0a7d67a7,             (FX_LPCWSTR)(L"for")},\r
-    {TOKnan,           0x0b4f91dd,             (FX_LPCWSTR)(L"nan")},\r
-    {TOKksnot,         0x0b4fd9b1,             (FX_LPCWSTR)(L"not")},\r
-    {TOKvar,           0x0c2203e9,             (FX_LPCWSTR)(L"var")},\r
-    {TOKthen,          0x2d5738cf,             (FX_LPCWSTR)(L"then")},\r
-    {TOKelse,          0x45f65ee9,             (FX_LPCWSTR)(L"else")},\r
-    {TOKexit,          0x4731d6ba,             (FX_LPCWSTR)(L"exit")},\r
-    {TOKdownto,                0x4caadc3b,             (FX_LPCWSTR)(L"downto")},\r
-    {TOKreturn,                0x4db8bd60,             (FX_LPCWSTR)(L"return")},\r
-    {TOKinfinity,      0x5c0a010a,             (FX_LPCWSTR)(L"infinity")},\r
-    {TOKendwhile,      0x5c64bff0,             (FX_LPCWSTR)(L"endwhile")},\r
-    {TOKforeach,       0x67e31f38,             (FX_LPCWSTR)(L"foreach")},\r
-    {TOKendfunc,       0x68f984a3,             (FX_LPCWSTR)(L"endfunc")},\r
-    {TOKelseif,                0x78253218,             (FX_LPCWSTR)(L"elseif")},\r
-    {TOKwhile,         0x84229259,             (FX_LPCWSTR)(L"while")},\r
-    {TOKendfor,                0x8ab49d7e,             (FX_LPCWSTR)(L"endfor")},\r
-    {TOKthrow,         0x8db05c94,             (FX_LPCWSTR)(L"throw")},\r
-    {TOKstep,          0xa7a7887c,             (FX_LPCWSTR)(L"step")},\r
-    {TOKupto,          0xb5155328,             (FX_LPCWSTR)(L"upto")},\r
-    {TOKcontinue,      0xc0340685,             (FX_LPCWSTR)(L"continue")},\r
-    {TOKfunc,          0xcdce60ec,             (FX_LPCWSTR)(L"func")},\r
-    {TOKendif,         0xe0e8fee6,             (FX_LPCWSTR)(L"endif")},\r
+    {TOKand,           0x00000026,             L"&"},\r
+    {TOKlparen,                0x00000028,             L"("},\r
+    {TOKrparen,                0x00000029,             L")"},\r
+    {TOKmul,           0x0000002a,             L"*"},\r
+    {TOKplus,          0x0000002b,             L"+"},\r
+    {TOKcomma,         0x0000002c,             L","},\r
+    {TOKminus,         0x0000002d,             L"-"},\r
+    {TOKdot,           0x0000002e,             L"."},\r
+    {TOKdiv,           0x0000002f,             L"/"},\r
+    {TOKlt,                    0x0000003c,             L"<"},\r
+    {TOKassign,                0x0000003d,             L"="},\r
+    {TOKgt,                    0x0000003e,             L">"},\r
+    {TOKlbracket,      0x0000005b,             L"["},\r
+    {TOKrbracket,      0x0000005d,             L"]"},\r
+    {TOKor,                    0x0000007c,             L"|"},\r
+    {TOKdotscream,     0x0000ec11,             L".#"},\r
+    {TOKdotstar,       0x0000ec18,             L".*"},\r
+    {TOKdotdot,                0x0000ec1c,             L".."},\r
+    {TOKle,                    0x000133f9,             L"<="},\r
+    {TOKne,                    0x000133fa,             L"<>"},\r
+    {TOKeq,                    0x0001391a,             L"=="},\r
+    {TOKge,                    0x00013e3b,             L">="},\r
+    {TOKdo,                    0x00020153,             L"do"},\r
+    {TOKkseq,          0x00020676,             L"eq"},\r
+    {TOKksge,          0x000210ac,             L"ge"},\r
+    {TOKksgt,          0x000210bb,             L"gt"},\r
+    {TOKif,                    0x00021aef,             L"if"},\r
+    {TOKin,                    0x00021af7,             L"in"},\r
+    {TOKksle,          0x00022a51,             L"le"},\r
+    {TOKkslt,          0x00022a60,             L"lt"},\r
+    {TOKksne,          0x00023493,             L"ne"},\r
+    {TOKksor,          0x000239c1,             L"or"},\r
+    {TOKnull,          0x052931bb,             L"null"},\r
+    {TOKbreak,         0x05518c25,             L"break"},\r
+    {TOKksand,         0x09f9db33,             L"and"},\r
+    {TOKend,           0x0a631437,             L"end"},\r
+    {TOKeof,           0x0a63195a,             L"eof"},\r
+    {TOKfor,           0x0a7d67a7,             L"for"},\r
+    {TOKnan,           0x0b4f91dd,             L"nan"},\r
+    {TOKksnot,         0x0b4fd9b1,             L"not"},\r
+    {TOKvar,           0x0c2203e9,             L"var"},\r
+    {TOKthen,          0x2d5738cf,             L"then"},\r
+    {TOKelse,          0x45f65ee9,             L"else"},\r
+    {TOKexit,          0x4731d6ba,             L"exit"},\r
+    {TOKdownto,                0x4caadc3b,             L"downto"},\r
+    {TOKreturn,                0x4db8bd60,             L"return"},\r
+    {TOKinfinity,      0x5c0a010a,             L"infinity"},\r
+    {TOKendwhile,      0x5c64bff0,             L"endwhile"},\r
+    {TOKforeach,       0x67e31f38,             L"foreach"},\r
+    {TOKendfunc,       0x68f984a3,             L"endfunc"},\r
+    {TOKelseif,                0x78253218,             L"elseif"},\r
+    {TOKwhile,         0x84229259,             L"while"},\r
+    {TOKendfor,                0x8ab49d7e,             L"endfor"},\r
+    {TOKthrow,         0x8db05c94,             L"throw"},\r
+    {TOKstep,          0xa7a7887c,             L"step"},\r
+    {TOKupto,          0xb5155328,             L"upto"},\r
+    {TOKcontinue,      0xc0340685,             L"continue"},\r
+    {TOKfunc,          0xcdce60ec,             L"func"},\r
+    {TOKendif,         0xe0e8fee6,             L"endif"},\r
 };\r
 static const FX_WORD KEYWORD_START = TOKdo;\r
 static const FX_WORD KEYWORD_END = TOKendif;\r
@@ -195,7 +195,7 @@ CXFA_FMToken *CXFA_FMLexer::NextToken()
 }\r
 CXFA_FMToken * CXFA_FMLexer::Scan()\r
 {\r
-    FX_UINT16 ch = 0;\r
+    uint16_t ch = 0;\r
     CXFA_FMToken * p = FX_NEW CXFA_FMToken(m_uCurrentLine);\r
     if (!XFA_FMDChar::isAvalid(m_ptr)) {\r
         ch = XFA_FMDChar::get(m_ptr);\r
@@ -444,7 +444,7 @@ FX_DWORD CXFA_FMLexer::Number(CXFA_FMToken *t, FX_LPCWSTR p, FX_LPCWSTR &pEnd)
 FX_DWORD CXFA_FMLexer::String(CXFA_FMToken *t, FX_LPCWSTR p, FX_LPCWSTR &pEnd)\r
 {\r
     FX_LPCWSTR pStart = p;\r
-    FX_UINT16 ch = 0;\r
+    uint16_t ch = 0;\r
     XFA_FMDChar::inc(p);\r
     ch = XFA_FMDChar::get(p);\r
     while (ch) {\r
@@ -482,7 +482,7 @@ NEXT:
 FX_DWORD CXFA_FMLexer::Identifiers(CXFA_FMToken *t, FX_LPCWSTR p, FX_LPCWSTR &pEnd)\r
 {\r
     FX_LPCWSTR pStart = p;\r
-    FX_UINT16 ch = 0;\r
+    uint16_t ch = 0;\r
     ch = XFA_FMDChar::get(p);\r
     XFA_FMDChar::inc(p);\r
     if (!XFA_FMDChar::isAvalid(p)) {\r
@@ -536,10 +536,10 @@ void CXFA_FMLexer::Comment( FX_LPCWSTR p, FX_LPCWSTR &pEnd )
 }\r
 XFA_FM_TOKEN CXFA_FMLexer::IsKeyword(FX_WSTR str)\r
 {\r
-    FX_INT32 iLength = str.GetLength();\r
-    FX_UINT32 uHash = FX_HashCode_String_GetW(str.GetPtr(), iLength, TRUE);\r
-    FX_INT32 iStart = KEYWORD_START, iEnd = KEYWORD_END;\r
-    FX_INT32 iMid = (iStart + iEnd) / 2;\r
+    int32_t iLength = str.GetLength();\r
+    uint32_t uHash = FX_HashCode_String_GetW(str.GetPtr(), iLength, TRUE);\r
+    int32_t iStart = KEYWORD_START, iEnd = KEYWORD_END;\r
+    int32_t iMid = (iStart + iEnd) / 2;\r
     XFA_FMKeyword keyword;\r
     do {\r
         iMid = (iStart + iEnd) / 2;\r