Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: xfa/fxfa/fm2js/xfa_lexer.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/fm2js/xfa_lexer.h ('k') | xfa/fxfa/fm2js/xfa_simpleexpression.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_lexer.h" 7 #include "xfa/fxfa/fm2js/xfa_lexer.h"
8 8
9 #include "core/fxcrt/fx_ext.h" 9 #include "core/fxcrt/fx_ext.h"
10 10
11 namespace { 11 namespace {
12 12
13 struct XFA_FMDChar { 13 struct XFA_FMDChar {
14 static const FX_WCHAR* inc(const FX_WCHAR*& p) { 14 static const FX_WCHAR* inc(const FX_WCHAR*& p) {
15 ++p; 15 ++p;
16 return p; 16 return p;
17 } 17 }
18 static const FX_WCHAR* dec(const FX_WCHAR*& p) { 18 static const FX_WCHAR* dec(const FX_WCHAR*& p) {
19 --p; 19 --p;
20 return p; 20 return p;
21 } 21 }
22 static uint16_t get(const FX_WCHAR* p) { return *p; } 22 static uint16_t get(const FX_WCHAR* p) { return *p; }
23 static FX_BOOL isWhiteSpace(const FX_WCHAR* p) { 23 static bool isWhiteSpace(const FX_WCHAR* p) {
24 return (*p) == 0x09 || (*p) == 0x0b || (*p) == 0x0c || (*p) == 0x20; 24 return (*p) == 0x09 || (*p) == 0x0b || (*p) == 0x0c || (*p) == 0x20;
25 } 25 }
26 static FX_BOOL isLineTerminator(const FX_WCHAR* p) { 26 static bool isLineTerminator(const FX_WCHAR* p) {
27 return *p == 0x0A || *p == 0x0D; 27 return *p == 0x0A || *p == 0x0D;
28 } 28 }
29 static FX_BOOL isBinary(const FX_WCHAR* p) { 29 static bool isBinary(const FX_WCHAR* p) { return (*p) >= '0' && (*p) <= '1'; }
30 return (*p) >= '0' && (*p) <= '1'; 30 static bool isOctal(const FX_WCHAR* p) { return (*p) >= '0' && (*p) <= '7'; }
31 } 31 static bool isDigital(const FX_WCHAR* p) {
32 static FX_BOOL isOctal(const FX_WCHAR* p) {
33 return (*p) >= '0' && (*p) <= '7';
34 }
35 static FX_BOOL isDigital(const FX_WCHAR* p) {
36 return (*p) >= '0' && (*p) <= '9'; 32 return (*p) >= '0' && (*p) <= '9';
37 } 33 }
38 static FX_BOOL isHex(const FX_WCHAR* p) { 34 static bool isHex(const FX_WCHAR* p) {
39 return isDigital(p) || ((*p) >= 'a' && (*p) <= 'f') || 35 return isDigital(p) || ((*p) >= 'a' && (*p) <= 'f') ||
40 ((*p) >= 'A' && (*p) <= 'F'); 36 ((*p) >= 'A' && (*p) <= 'F');
41 } 37 }
42 static FX_BOOL isAlpha(const FX_WCHAR* p) { 38 static bool isAlpha(const FX_WCHAR* p) {
43 return ((*p) <= 'z' && (*p) >= 'a') || ((*p) <= 'Z' && (*p) >= 'A'); 39 return ((*p) <= 'z' && (*p) >= 'a') || ((*p) <= 'Z' && (*p) >= 'A');
44 } 40 }
45 static FX_BOOL isAvalid(const FX_WCHAR* p, FX_BOOL flag = 0); 41 static bool isAvalid(const FX_WCHAR* p, bool flag = 0);
46 static FX_BOOL string2number(const FX_WCHAR* s, 42 static bool string2number(const FX_WCHAR* s,
47 FX_DOUBLE* pValue, 43 FX_DOUBLE* pValue,
48 const FX_WCHAR*& pEnd); 44 const FX_WCHAR*& pEnd);
49 static FX_BOOL isUnicodeAlpha(uint16_t ch); 45 static bool isUnicodeAlpha(uint16_t ch);
50 }; 46 };
51 47
52 inline FX_BOOL XFA_FMDChar::isAvalid(const FX_WCHAR* p, FX_BOOL flag) { 48 inline bool XFA_FMDChar::isAvalid(const FX_WCHAR* p, bool flag) {
53 if (*p == 0) { 49 if (*p == 0) {
54 return 1; 50 return 1;
55 } 51 }
56 if ((*p <= 0x0A && *p >= 0x09) || *p == 0x0D || 52 if ((*p <= 0x0A && *p >= 0x09) || *p == 0x0D ||
57 (*p <= 0xd7ff && *p >= 0x20) || (*p <= 0xfffd && *p >= 0xe000)) { 53 (*p <= 0xd7ff && *p >= 0x20) || (*p <= 0xfffd && *p >= 0xe000)) {
58 return 1; 54 return 1;
59 } 55 }
60 if (!flag) { 56 if (!flag) {
61 if (*p == 0x0B || *p == 0x0C) { 57 if (*p == 0x0B || *p == 0x0C) {
62 return 1; 58 return 1;
63 } 59 }
64 } 60 }
65 return 0; 61 return 0;
66 } 62 }
67 63
68 inline FX_BOOL XFA_FMDChar::string2number(const FX_WCHAR* s, 64 inline bool XFA_FMDChar::string2number(const FX_WCHAR* s,
69 FX_DOUBLE* pValue, 65 FX_DOUBLE* pValue,
70 const FX_WCHAR*& pEnd) { 66 const FX_WCHAR*& pEnd) {
71 if (s) { 67 if (s) {
72 *pValue = wcstod((wchar_t*)s, (wchar_t**)&pEnd); 68 *pValue = wcstod((wchar_t*)s, (wchar_t**)&pEnd);
73 } 69 }
74 return 0; 70 return 0;
75 } 71 }
76 72
77 inline FX_BOOL XFA_FMDChar::isUnicodeAlpha(uint16_t ch) { 73 inline bool XFA_FMDChar::isUnicodeAlpha(uint16_t ch) {
78 if (ch == 0 || ch == 0x0A || ch == 0x0D || ch == 0x09 || ch == 0x0B || 74 if (ch == 0 || ch == 0x0A || ch == 0x0D || ch == 0x09 || ch == 0x0B ||
79 ch == 0x0C || ch == 0x20 || ch == '.' || ch == ';' || ch == '"' || 75 ch == 0x0C || ch == 0x20 || ch == '.' || ch == ';' || ch == '"' ||
80 ch == '=' || ch == '<' || ch == '>' || ch == ',' || ch == '(' || 76 ch == '=' || ch == '<' || ch == '>' || ch == ',' || ch == '(' ||
81 ch == ')' || ch == ']' || ch == '[' || ch == '&' || ch == '|' || 77 ch == ')' || ch == ']' || ch == '[' || ch == '&' || ch == '|' ||
82 ch == '+' || ch == '-' || ch == '*' || ch == '/') { 78 ch == '+' || ch == '-' || ch == '*' || ch == '/') {
83 return FALSE; 79 return false;
84 } 80 }
85 return TRUE; 81 return true;
86 } 82 }
87 83
88 const XFA_FMKeyword keyWords[] = { 84 const XFA_FMKeyword keyWords[] = {
89 {TOKand, 0x00000026, L"&"}, 85 {TOKand, 0x00000026, L"&"},
90 {TOKlparen, 0x00000028, L"("}, 86 {TOKlparen, 0x00000028, L"("},
91 {TOKrparen, 0x00000029, L")"}, 87 {TOKrparen, 0x00000029, L")"},
92 {TOKmul, 0x0000002a, L"*"}, 88 {TOKmul, 0x0000002a, L"*"},
93 {TOKplus, 0x0000002b, L"+"}, 89 {TOKplus, 0x0000002b, L"+"},
94 {TOKcomma, 0x0000002c, L","}, 90 {TOKcomma, 0x0000002c, L","},
95 {TOKminus, 0x0000002d, L"-"}, 91 {TOKminus, 0x0000002d, L"-"},
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } 531 }
536 532
537 void CXFA_FMLexer::Error(const FX_WCHAR* msg, ...) { 533 void CXFA_FMLexer::Error(const FX_WCHAR* msg, ...) {
538 m_pErrorInfo->linenum = m_uCurrentLine; 534 m_pErrorInfo->linenum = m_uCurrentLine;
539 va_list ap; 535 va_list ap;
540 va_start(ap, msg); 536 va_start(ap, msg);
541 m_pErrorInfo->message.FormatV(msg, ap); 537 m_pErrorInfo->message.FormatV(msg, ap);
542 va_end(ap); 538 va_end(ap);
543 } 539 }
544 540
545 FX_BOOL CXFA_FMLexer::HasError() const { 541 bool CXFA_FMLexer::HasError() const {
546 if (m_pErrorInfo->message.IsEmpty()) { 542 if (m_pErrorInfo->message.IsEmpty()) {
547 return FALSE; 543 return false;
548 } 544 }
549 return TRUE; 545 return true;
550 } 546 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_lexer.h ('k') | xfa/fxfa/fm2js/xfa_simpleexpression.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698