summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-04-04 11:55:38 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-04 11:55:38 -0700
commit6e56a5ebc88e05fe0bf05624eba9aeed57fa6d60 (patch)
tree298fe044daa5bcee963fc9c8b398fd870c5b9571
parent5838dbd3809d1d16945009c7f9d6111dda3797f0 (diff)
downloadpdfium-6e56a5ebc88e05fe0bf05624eba9aeed57fa6d60.tar.xz
Replace FDE_XMLSYNTAX defines with enum classes.
This CL replaces FDE_XMLSYNTAXMODE_ with FDE_XmlSyntaxState:: and FDE_XMLSYNTAXSTATUS_ with FDE_XmlSyntaxResult::. The various variables also have their names updated to make them clearer. Review URL: https://codereview.chromium.org/1856003002
-rw-r--r--xfa/fde/xml/fde_xml.h34
-rw-r--r--xfa/fde/xml/fde_xml_imp.cpp290
-rw-r--r--xfa/fde/xml/fde_xml_imp.h50
-rw-r--r--xfa/fde/xml/fde_xml_imp_unittest.cpp202
-rw-r--r--xfa/fxfa/parser/xfa_parser_imp.cpp54
-rw-r--r--xfa/fxfa/parser/xfa_parser_imp.h2
6 files changed, 319 insertions, 313 deletions
diff --git a/xfa/fde/xml/fde_xml.h b/xfa/fde/xml/fde_xml.h
index 9d0a869524..61dd4b040e 100644
--- a/xfa/fde/xml/fde_xml.h
+++ b/xfa/fde/xml/fde_xml.h
@@ -10,6 +10,24 @@
#include "xfa/fgas/crt/fgas_stream.h"
#include "xfa/fgas/crt/fgas_utils.h"
+enum class FDE_XmlSyntaxResult {
+ None,
+ InstructionOpen,
+ InstructionClose,
+ ElementOpen,
+ ElementBreak,
+ ElementClose,
+ TargetName,
+ TagName,
+ AttriName,
+ AttriValue,
+ Text,
+ CData,
+ TargetData,
+ Error,
+ EndOfString
+};
+
enum FDE_XMLNODETYPE {
FDE_XMLNODE_Unknown = 0,
FDE_XMLNODE_Instruction,
@@ -45,20 +63,4 @@ struct FDE_XMLREADERHANDLER {
const CFX_WideString& wsValue);
};
-#define FDE_XMLSYNTAXSTATUS_None 0x00
-#define FDE_XMLSYNTAXSTATUS_InstructionOpen 0x01
-#define FDE_XMLSYNTAXSTATUS_InstructionClose 0x02
-#define FDE_XMLSYNTAXSTATUS_ElementOpen 0x03
-#define FDE_XMLSYNTAXSTATUS_ElementBreak 0x04
-#define FDE_XMLSYNTAXSTATUS_ElementClose 0x05
-#define FDE_XMLSYNTAXSTATUS_TargetName 0x06
-#define FDE_XMLSYNTAXSTATUS_TagName 0x07
-#define FDE_XMLSYNTAXSTATUS_AttriName 0x08
-#define FDE_XMLSYNTAXSTATUS_AttriValue 0x09
-#define FDE_XMLSYNTAXSTATUS_Text 0x0A
-#define FDE_XMLSYNTAXSTATUS_CData 0x0B
-#define FDE_XMLSYNTAXSTATUS_TargetData 0x0C
-#define FDE_XMLSYNTAXSTATUS_Error 0xFE
-#define FDE_XMLSYNTAXSTATUS_EOS 0xFF
-
#endif // XFA_FDE_XML_FDE_XML_H_
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp
index 0affe8a621..25c4c5abe5 100644
--- a/xfa/fde/xml/fde_xml_imp.cpp
+++ b/xfa/fde/xml/fde_xml_imp.cpp
@@ -1089,63 +1089,64 @@ CFDE_XMLDOMParser::~CFDE_XMLDOMParser() {
m_ws1.Empty();
m_ws2.Empty();
}
+
int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) {
- uint32_t dwRet;
+ FDE_XmlSyntaxResult syntaxParserResult;
int32_t iCount = 0;
while (TRUE) {
- dwRet = m_pParser->DoSyntaxParse();
- switch (dwRet) {
- case FDE_XMLSYNTAXSTATUS_InstructionOpen:
+ syntaxParserResult = m_pParser->DoSyntaxParse();
+ switch (syntaxParserResult) {
+ case FDE_XmlSyntaxResult::InstructionOpen:
break;
- case FDE_XMLSYNTAXSTATUS_InstructionClose:
+ case FDE_XmlSyntaxResult::InstructionClose:
if (m_pChild->GetType() != FDE_XMLNODE_Instruction) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
m_pChild = m_pParent;
break;
- case FDE_XMLSYNTAXSTATUS_ElementOpen:
- case FDE_XMLSYNTAXSTATUS_ElementBreak:
+ case FDE_XmlSyntaxResult::ElementOpen:
+ case FDE_XmlSyntaxResult::ElementBreak:
break;
- case FDE_XMLSYNTAXSTATUS_ElementClose:
+ case FDE_XmlSyntaxResult::ElementClose:
if (m_pChild->GetType() != FDE_XMLNODE_Element) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
m_pParser->GetTagName(m_ws1);
((CFDE_XMLElement*)m_pChild)->GetTagName(m_ws2);
if (m_ws1.GetLength() > 0 && m_ws1.Compare(m_ws2) != 0) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
m_NodeStack.Pop();
if (m_NodeStack.GetSize() < 1) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
m_pParent = (CFDE_XMLNode*)*m_NodeStack.GetTopElement();
m_pChild = m_pParent;
iCount++;
break;
- case FDE_XMLSYNTAXSTATUS_TargetName:
+ case FDE_XmlSyntaxResult::TargetName:
m_pParser->GetTargetName(m_ws1);
m_pChild = new CFDE_XMLInstruction(m_ws1);
m_pParent->InsertChildNode(m_pChild);
m_ws1.Empty();
break;
- case FDE_XMLSYNTAXSTATUS_TagName:
+ case FDE_XmlSyntaxResult::TagName:
m_pParser->GetTagName(m_ws1);
m_pChild = new CFDE_XMLElement(m_ws1);
m_pParent->InsertChildNode(m_pChild);
m_NodeStack.Push(m_pChild);
m_pParent = m_pChild;
break;
- case FDE_XMLSYNTAXSTATUS_AttriName:
+ case FDE_XmlSyntaxResult::AttriName:
m_pParser->GetAttributeName(m_ws1);
break;
- case FDE_XMLSYNTAXSTATUS_AttriValue:
+ case FDE_XmlSyntaxResult::AttriValue:
if (m_pChild == NULL) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
m_pParser->GetAttributeName(m_ws2);
@@ -1156,22 +1157,22 @@ int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) {
}
m_ws1.Empty();
break;
- case FDE_XMLSYNTAXSTATUS_Text:
+ case FDE_XmlSyntaxResult::Text:
m_pParser->GetTextData(m_ws1);
m_pChild = new CFDE_XMLText(m_ws1);
m_pParent->InsertChildNode(m_pChild);
m_pChild = m_pParent;
break;
- case FDE_XMLSYNTAXSTATUS_CData:
+ case FDE_XmlSyntaxResult::CData:
m_pParser->GetTextData(m_ws1);
m_pChild = new CFDE_XMLCharData(m_ws1);
m_pParent->InsertChildNode(m_pChild);
m_pChild = m_pParent;
break;
- case FDE_XMLSYNTAXSTATUS_TargetData:
+ case FDE_XmlSyntaxResult::TargetData:
if (m_pChild == NULL ||
m_pChild->GetType() != FDE_XMLNODE_Instruction) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
if (!m_ws1.IsEmpty()) {
@@ -1184,8 +1185,8 @@ int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) {
default:
break;
}
- if (dwRet == FDE_XMLSYNTAXSTATUS_Error ||
- dwRet == FDE_XMLSYNTAXSTATUS_EOS) {
+ if (syntaxParserResult == FDE_XmlSyntaxResult::Error ||
+ syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) {
break;
}
if (pPause != NULL && iCount > 500 && pPause->NeedToPauseNow()) {
@@ -1208,28 +1209,28 @@ CFDE_XMLSAXParser::~CFDE_XMLSAXParser() {
m_ws2.Empty();
}
int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
- uint32_t dwRet = 0;
+ FDE_XmlSyntaxResult syntaxParserResult;
int32_t iCount = 0;
while (TRUE) {
- dwRet = m_pParser->DoSyntaxParse();
- switch (dwRet) {
- case FDE_XMLSYNTAXSTATUS_ElementBreak:
+ syntaxParserResult = m_pParser->DoSyntaxParse();
+ switch (syntaxParserResult) {
+ case FDE_XmlSyntaxResult::ElementBreak:
if (m_pTagTop == NULL) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
if (m_pTagTop->eType == FDE_XMLNODE_Element) {
m_pHandler->OnTagBreak(m_pHandler, m_pTagTop->wsTagName);
}
break;
- case FDE_XMLSYNTAXSTATUS_ElementClose:
+ case FDE_XmlSyntaxResult::ElementClose:
if (m_pTagTop == NULL || m_pTagTop->eType != FDE_XMLNODE_Element) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
m_pParser->GetTagName(m_ws1);
if (m_ws1.GetLength() > 0 && m_ws1.Compare(m_pTagTop->wsTagName) != 0) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
} else if (m_ws1.GetLength() == 0) {
m_pHandler->OnTagBreak(m_pHandler, m_pTagTop->wsTagName);
@@ -1238,7 +1239,7 @@ int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
Pop();
iCount++;
break;
- case FDE_XMLSYNTAXSTATUS_TargetName: {
+ case FDE_XmlSyntaxResult::TargetName: {
m_pParser->GetTargetName(m_ws1);
CFDE_XMLTAG xmlTag;
xmlTag.wsTagName = m_ws1;
@@ -1248,7 +1249,7 @@ int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
m_pTagTop->wsTagName);
m_ws1.Empty();
} break;
- case FDE_XMLSYNTAXSTATUS_TagName: {
+ case FDE_XmlSyntaxResult::TagName: {
m_pParser->GetTargetName(m_ws1);
CFDE_XMLTAG xmlTag;
xmlTag.wsTagName = m_ws1;
@@ -1257,13 +1258,13 @@ int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
m_pHandler->OnTagEnter(m_pHandler, FDE_XMLNODE_Element,
m_pTagTop->wsTagName);
} break;
- case FDE_XMLSYNTAXSTATUS_AttriName:
+ case FDE_XmlSyntaxResult::AttriName:
m_pParser->GetTargetName(m_ws1);
break;
- case FDE_XMLSYNTAXSTATUS_AttriValue:
+ case FDE_XmlSyntaxResult::AttriValue:
m_pParser->GetAttributeName(m_ws2);
if (m_pTagTop == NULL) {
- dwRet = FDE_XMLSYNTAXSTATUS_Error;
+ syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
if (m_pTagTop->eType == FDE_XMLNODE_Element) {
@@ -1271,15 +1272,15 @@ int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
}
m_ws1.Empty();
break;
- case FDE_XMLSYNTAXSTATUS_CData:
+ case FDE_XmlSyntaxResult::CData:
m_pParser->GetTextData(m_ws1);
m_pHandler->OnData(m_pHandler, FDE_XMLNODE_CharData, m_ws1);
break;
- case FDE_XMLSYNTAXSTATUS_Text:
+ case FDE_XmlSyntaxResult::Text:
m_pParser->GetTextData(m_ws1);
m_pHandler->OnData(m_pHandler, FDE_XMLNODE_Text, m_ws1);
break;
- case FDE_XMLSYNTAXSTATUS_TargetData:
+ case FDE_XmlSyntaxResult::TargetData:
m_pParser->GetTargetData(m_ws1);
m_pHandler->OnData(m_pHandler, FDE_XMLNODE_Instruction, m_ws1);
m_ws1.Empty();
@@ -1287,8 +1288,8 @@ int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
default:
break;
}
- if (dwRet == FDE_XMLSYNTAXSTATUS_Error ||
- dwRet == FDE_XMLSYNTAXSTATUS_EOS) {
+ if (syntaxParserResult == FDE_XmlSyntaxResult::Error ||
+ syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) {
break;
}
if (pPause != NULL && iCount > 500 && pPause->NeedToPauseNow()) {
@@ -1455,8 +1456,8 @@ CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser()
m_pCurrentBlock(nullptr),
m_iIndexInBlock(0),
m_iTextDataLength(0),
- m_dwStatus(FDE_XMLSYNTAXSTATUS_None),
- m_dwMode(FDE_XMLSYNTAXMODE_Text),
+ m_syntaxParserResult(FDE_XmlSyntaxResult::None),
+ m_syntaxParserState(FDE_XmlSyntaxState::Text),
m_wQuotationMark(0),
m_iEntityStart(-1),
m_SkipStack(16) {
@@ -1483,21 +1484,22 @@ void CFDE_XMLSyntaxParser::Init(IFX_Stream* pStream,
m_iParsedBytes = m_iParsedChars = 0;
m_iBufferChars = 0;
}
-uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
- if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error ||
- m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) {
- return m_dwStatus;
+
+FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() {
+ if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error ||
+ m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) {
+ return m_syntaxParserResult;
}
FXSYS_assert(m_pStream && m_pBuffer && m_BlockBuffer.IsInitialized());
int32_t iStreamLength = m_pStream->GetLength();
int32_t iPos;
- uint32_t dwStatus = FDE_XMLSYNTAXSTATUS_None;
+ FDE_XmlSyntaxResult syntaxParserResult = FDE_XmlSyntaxResult::None;
while (TRUE) {
if (m_pStart >= m_pEnd) {
if (m_bEOS || m_iCurrentPos >= iStreamLength) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_EOS;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::EndOfString;
+ return m_syntaxParserResult;
}
m_iParsedChars += (m_pEnd - m_pBuffer);
m_iParsedBytes = m_iCurrentPos;
@@ -1509,8 +1511,8 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
iPos = m_pStream->GetPosition();
if (m_iBufferChars < 1) {
m_iCurrentPos = iStreamLength;
- m_dwStatus = FDE_XMLSYNTAXSTATUS_EOS;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::EndOfString;
+ return m_syntaxParserResult;
}
m_iCurrentPos = iPos;
m_pStart = m_pBuffer;
@@ -1519,8 +1521,8 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
while (m_pStart < m_pEnd) {
FX_WCHAR ch = *m_pStart;
- switch (m_dwMode) {
- case FDE_XMLSYNTAXMODE_Text:
+ switch (m_syntaxParserState) {
+ case FDE_XmlSyntaxState::Text:
if (ch == L'<') {
if (m_iDataLength > 0) {
m_iTextDataLength = m_iDataLength;
@@ -1528,22 +1530,22 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
m_iEntityStart = -1;
- dwStatus = FDE_XMLSYNTAXSTATUS_Text;
+ syntaxParserResult = FDE_XmlSyntaxResult::Text;
} else {
m_pStart++;
- m_dwMode = FDE_XMLSYNTAXMODE_Node;
+ m_syntaxParserState = FDE_XmlSyntaxState::Node;
}
} else {
ParseTextChar(ch);
}
break;
- case FDE_XMLSYNTAXMODE_Node:
+ case FDE_XmlSyntaxState::Node:
if (ch == L'!') {
m_pStart++;
- m_dwMode = FDE_XMLSYNTAXMODE_SkipCommentOrDecl;
+ m_syntaxParserState = FDE_XmlSyntaxState::SkipCommentOrDecl;
} else if (ch == L'/') {
m_pStart++;
- m_dwMode = FDE_XMLSYNTAXMODE_CloseElement;
+ m_syntaxParserState = FDE_XmlSyntaxState::CloseElement;
} else if (ch == L'?') {
m_iLastNodeNum++;
m_iCurrentNodeNum = m_iLastNodeNum;
@@ -1551,42 +1553,42 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_CurNode.eNodeType = FDE_XMLNODE_Instruction;
m_XMLNodeStack.Push(m_CurNode);
m_pStart++;
- m_dwMode = FDE_XMLSYNTAXMODE_Target;
- dwStatus = FDE_XMLSYNTAXSTATUS_InstructionOpen;
+ m_syntaxParserState = FDE_XmlSyntaxState::Target;
+ syntaxParserResult = FDE_XmlSyntaxResult::InstructionOpen;
} else {
m_iLastNodeNum++;
m_iCurrentNodeNum = m_iLastNodeNum;
m_CurNode.iNodeNum = m_iLastNodeNum;
m_CurNode.eNodeType = FDE_XMLNODE_Element;
m_XMLNodeStack.Push(m_CurNode);
- m_dwMode = FDE_XMLSYNTAXMODE_Tag;
- dwStatus = FDE_XMLSYNTAXSTATUS_ElementOpen;
+ m_syntaxParserState = FDE_XmlSyntaxState::Tag;
+ syntaxParserResult = FDE_XmlSyntaxResult::ElementOpen;
}
break;
- case FDE_XMLSYNTAXMODE_Target:
- case FDE_XMLSYNTAXMODE_Tag:
+ case FDE_XmlSyntaxState::Target:
+ case FDE_XmlSyntaxState::Tag:
if (!FDE_IsXMLNameChar(ch, m_iDataLength < 1)) {
if (m_iDataLength < 1) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
} else {
m_iTextDataLength = m_iDataLength;
m_BlockBuffer.Reset();
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
- if (m_dwMode != FDE_XMLSYNTAXMODE_Target) {
- dwStatus = FDE_XMLSYNTAXSTATUS_TagName;
+ if (m_syntaxParserState != FDE_XmlSyntaxState::Target) {
+ syntaxParserResult = FDE_XmlSyntaxResult::TagName;
} else {
- dwStatus = FDE_XMLSYNTAXSTATUS_TargetName;
+ syntaxParserResult = FDE_XmlSyntaxResult::TargetName;
}
- m_dwMode = FDE_XMLSYNTAXMODE_AttriName;
+ m_syntaxParserState = FDE_XmlSyntaxState::AttriName;
}
} else {
if (m_iIndexInBlock == m_iAllocStep) {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
if (!m_pCurrentBlock) {
- return FDE_XMLSYNTAXSTATUS_Error;
+ return FDE_XmlSyntaxResult::Error;
}
}
m_pCurrentBlock[m_iIndexInBlock++] = ch;
@@ -1594,7 +1596,7 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_pStart++;
}
break;
- case FDE_XMLSYNTAXMODE_AttriName:
+ case FDE_XmlSyntaxState::AttriName:
if (m_iDataLength < 1 && FDE_IsXMLWhiteSpace(ch)) {
m_pStart++;
break;
@@ -1603,24 +1605,24 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
if (m_iDataLength < 1) {
if (m_CurNode.eNodeType == FDE_XMLNODE_Element) {
if (ch == L'>' || ch == L'/') {
- m_dwMode = FDE_XMLSYNTAXMODE_BreakElement;
+ m_syntaxParserState = FDE_XmlSyntaxState::BreakElement;
break;
}
} else if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) {
if (ch == L'?') {
- m_dwMode = FDE_XMLSYNTAXMODE_CloseInstruction;
+ m_syntaxParserState = FDE_XmlSyntaxState::CloseInstruction;
m_pStart++;
} else {
- m_dwMode = FDE_XMLSYNTAXMODE_TargetData;
+ m_syntaxParserState = FDE_XmlSyntaxState::TargetData;
}
break;
}
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
} else {
if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) {
if (ch != '=' && !FDE_IsXMLWhiteSpace(ch)) {
- m_dwMode = FDE_XMLSYNTAXMODE_TargetData;
+ m_syntaxParserState = FDE_XmlSyntaxState::TargetData;
break;
}
}
@@ -1628,15 +1630,15 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_BlockBuffer.Reset();
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
- m_dwMode = FDE_XMLSYNTAXMODE_AttriEqualSign;
- dwStatus = FDE_XMLSYNTAXSTATUS_AttriName;
+ m_syntaxParserState = FDE_XmlSyntaxState::AttriEqualSign;
+ syntaxParserResult = FDE_XmlSyntaxResult::AttriName;
}
} else {
if (m_iIndexInBlock == m_iAllocStep) {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
if (!m_pCurrentBlock) {
- return FDE_XMLSYNTAXSTATUS_Error;
+ return FDE_XmlSyntaxResult::Error;
}
}
m_pCurrentBlock[m_iIndexInBlock++] = ch;
@@ -1644,77 +1646,77 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_pStart++;
}
break;
- case FDE_XMLSYNTAXMODE_AttriEqualSign:
+ case FDE_XmlSyntaxState::AttriEqualSign:
if (FDE_IsXMLWhiteSpace(ch)) {
m_pStart++;
break;
}
if (ch != L'=') {
if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) {
- m_dwMode = FDE_XMLSYNTAXMODE_TargetData;
+ m_syntaxParserState = FDE_XmlSyntaxState::TargetData;
break;
}
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
} else {
- m_dwMode = FDE_XMLSYNTAXMODE_AttriQuotation;
+ m_syntaxParserState = FDE_XmlSyntaxState::AttriQuotation;
m_pStart++;
}
break;
- case FDE_XMLSYNTAXMODE_AttriQuotation:
+ case FDE_XmlSyntaxState::AttriQuotation:
if (FDE_IsXMLWhiteSpace(ch)) {
m_pStart++;
break;
}
if (ch != L'\"' && ch != L'\'') {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
} else {
m_wQuotationMark = ch;
- m_dwMode = FDE_XMLSYNTAXMODE_AttriValue;
+ m_syntaxParserState = FDE_XmlSyntaxState::AttriValue;
m_pStart++;
}
break;
- case FDE_XMLSYNTAXMODE_AttriValue:
+ case FDE_XmlSyntaxState::AttriValue:
if (ch == m_wQuotationMark) {
if (m_iEntityStart > -1) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
}
m_iTextDataLength = m_iDataLength;
m_wQuotationMark = 0;
m_BlockBuffer.Reset();
m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
m_pStart++;
- m_dwMode = FDE_XMLSYNTAXMODE_AttriName;
- dwStatus = FDE_XMLSYNTAXSTATUS_AttriValue;
+ m_syntaxParserState = FDE_XmlSyntaxState::AttriName;
+ syntaxParserResult = FDE_XmlSyntaxResult::AttriValue;
} else {
ParseTextChar(ch);
}
break;
- case FDE_XMLSYNTAXMODE_CloseInstruction:
+ case FDE_XmlSyntaxState::CloseInstruction:
if (ch != L'>') {
if (m_iIndexInBlock == m_iAllocStep) {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
if (!m_pCurrentBlock) {
- return FDE_XMLSYNTAXSTATUS_Error;
+ return FDE_XmlSyntaxResult::Error;
}
}
m_pCurrentBlock[m_iIndexInBlock++] = ch;
m_iDataLength++;
- m_dwMode = FDE_XMLSYNTAXMODE_TargetData;
+ m_syntaxParserState = FDE_XmlSyntaxState::TargetData;
} else if (m_iDataLength > 0) {
m_iTextDataLength = m_iDataLength;
m_BlockBuffer.Reset();
m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
- dwStatus = FDE_XMLSYNTAXSTATUS_TargetData;
+ syntaxParserResult = FDE_XmlSyntaxResult::TargetData;
} else {
m_pStart++;
FDE_XMLNODE* pXMLNode = m_XMLNodeStack.GetTopElement();
if (pXMLNode == NULL) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
}
m_XMLNodeStack.Pop();
pXMLNode = m_XMLNodeStack.GetTopElement();
@@ -1727,29 +1729,29 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_iCurrentNodeNum = m_CurNode.iNodeNum;
m_BlockBuffer.Reset();
m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
- m_dwMode = FDE_XMLSYNTAXMODE_Text;
- dwStatus = FDE_XMLSYNTAXSTATUS_InstructionClose;
+ m_syntaxParserState = FDE_XmlSyntaxState::Text;
+ syntaxParserResult = FDE_XmlSyntaxResult::InstructionClose;
}
break;
- case FDE_XMLSYNTAXMODE_BreakElement:
+ case FDE_XmlSyntaxState::BreakElement:
if (ch == L'>') {
- m_dwMode = FDE_XMLSYNTAXMODE_Text;
- dwStatus = FDE_XMLSYNTAXSTATUS_ElementBreak;
+ m_syntaxParserState = FDE_XmlSyntaxState::Text;
+ syntaxParserResult = FDE_XmlSyntaxResult::ElementBreak;
} else if (ch == L'/') {
- m_dwMode = FDE_XMLSYNTAXMODE_CloseElement;
+ m_syntaxParserState = FDE_XmlSyntaxState::CloseElement;
} else {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
}
m_pStart++;
break;
- case FDE_XMLSYNTAXMODE_CloseElement:
+ case FDE_XmlSyntaxState::CloseElement:
if (!FDE_IsXMLNameChar(ch, m_iDataLength < 1)) {
if (ch == L'>') {
FDE_XMLNODE* pXMLNode = m_XMLNodeStack.GetTopElement();
if (pXMLNode == NULL) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
}
m_XMLNodeStack.Pop();
pXMLNode = m_XMLNodeStack.GetTopElement();
@@ -1764,18 +1766,18 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_BlockBuffer.Reset();
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
- m_dwMode = FDE_XMLSYNTAXMODE_Text;
- dwStatus = FDE_XMLSYNTAXSTATUS_ElementClose;
+ m_syntaxParserState = FDE_XmlSyntaxState::Text;
+ syntaxParserResult = FDE_XmlSyntaxResult::ElementClose;
} else if (!FDE_IsXMLWhiteSpace(ch)) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
}
} else {
if (m_iIndexInBlock == m_iAllocStep) {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
if (!m_pCurrentBlock) {
- return FDE_XMLSYNTAXSTATUS_Error;
+ return FDE_XmlSyntaxResult::Error;
}
}
m_pCurrentBlock[m_iIndexInBlock++] = ch;
@@ -1783,33 +1785,33 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
}
m_pStart++;
break;
- case FDE_XMLSYNTAXMODE_SkipCommentOrDecl:
+ case FDE_XmlSyntaxState::SkipCommentOrDecl:
if (FX_wcsnicmp(m_pStart, L"--", 2) == 0) {
m_pStart += 2;
- m_dwMode = FDE_XMLSYNTAXMODE_SkipComment;
+ m_syntaxParserState = FDE_XmlSyntaxState::SkipComment;
} else if (FX_wcsnicmp(m_pStart, L"[CDATA[", 7) == 0) {
m_pStart += 7;
- m_dwMode = FDE_XMLSYNTAXMODE_SkipCData;
+ m_syntaxParserState = FDE_XmlSyntaxState::SkipCData;
} else {
- m_dwMode = FDE_XMLSYNTAXMODE_SkipDeclNode;
+ m_syntaxParserState = FDE_XmlSyntaxState::SkipDeclNode;
m_SkipChar = L'>';
m_SkipStack.Push(L'>');
}
break;
- case FDE_XMLSYNTAXMODE_SkipCData: {
+ case FDE_XmlSyntaxState::SkipCData: {
if (FX_wcsnicmp(m_pStart, L"]]>", 3) == 0) {
m_pStart += 3;
- dwStatus = FDE_XMLSYNTAXSTATUS_CData;
+ syntaxParserResult = FDE_XmlSyntaxResult::CData;
m_iTextDataLength = m_iDataLength;
m_BlockBuffer.Reset();
m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
- m_dwMode = FDE_XMLSYNTAXMODE_Text;
+ m_syntaxParserState = FDE_XmlSyntaxState::Text;
} else {
if (m_iIndexInBlock == m_iAllocStep) {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
if (!m_pCurrentBlock)
- return FDE_XMLSYNTAXSTATUS_Error;
+ return FDE_XmlSyntaxResult::Error;
}
m_pCurrentBlock[m_iIndexInBlock++] = ch;
m_iDataLength++;
@@ -1817,7 +1819,7 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
}
break;
}
- case FDE_XMLSYNTAXMODE_SkipDeclNode:
+ case FDE_XmlSyntaxState::SkipDeclNode:
if (m_SkipChar == L'\'' || m_SkipChar == L'\"') {
m_pStart++;
if (ch != m_SkipChar)
@@ -1826,7 +1828,7 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_SkipStack.Pop();
uint32_t* pDWord = m_SkipStack.GetTopElement();
if (!pDWord)
- m_dwMode = FDE_XMLSYNTAXMODE_Text;
+ m_syntaxParserState = FDE_XmlSyntaxState::Text;
else
m_SkipChar = (FX_WCHAR)*pDWord;
} else {
@@ -1864,7 +1866,7 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_BlockBuffer.Reset();
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
- m_dwMode = FDE_XMLSYNTAXMODE_Text;
+ m_syntaxParserState = FDE_XmlSyntaxState::Text;
} else {
m_SkipChar = static_cast<FX_WCHAR>(*pDWord);
}
@@ -1876,7 +1878,7 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
if (!m_pCurrentBlock) {
- return FDE_XMLSYNTAXSTATUS_Error;
+ return FDE_XmlSyntaxResult::Error;
}
}
m_pCurrentBlock[m_iIndexInBlock++] = ch;
@@ -1885,15 +1887,15 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_pStart++;
}
break;
- case FDE_XMLSYNTAXMODE_SkipComment:
+ case FDE_XmlSyntaxState::SkipComment:
if (FX_wcsnicmp(m_pStart, L"-->", 3) == 0) {
m_pStart += 2;
- m_dwMode = FDE_XMLSYNTAXMODE_Text;
+ m_syntaxParserState = FDE_XmlSyntaxState::Text;
}
m_pStart++;
break;
- case FDE_XMLSYNTAXMODE_TargetData:
+ case FDE_XmlSyntaxState::TargetData:
if (FDE_IsXMLWhiteSpace(ch)) {
if (m_iDataLength < 1) {
m_pStart++;
@@ -1905,12 +1907,12 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
m_pStart++;
- dwStatus = FDE_XMLSYNTAXSTATUS_TargetData;
+ syntaxParserResult = FDE_XmlSyntaxResult::TargetData;
break;
}
}
if (ch == '?') {
- m_dwMode = FDE_XMLSYNTAXMODE_CloseInstruction;
+ m_syntaxParserState = FDE_XmlSyntaxState::CloseInstruction;
m_pStart++;
} else if (ch == '\"') {
if (m_wQuotationMark == 0) {
@@ -1923,17 +1925,17 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
m_pStart++;
- dwStatus = FDE_XMLSYNTAXSTATUS_TargetData;
+ syntaxParserResult = FDE_XmlSyntaxResult::TargetData;
} else {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
- return m_dwStatus;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return m_syntaxParserResult;
}
} else {
if (m_iIndexInBlock == m_iAllocStep) {
m_pCurrentBlock =
m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
if (!m_pCurrentBlock) {
- return FDE_XMLSYNTAXSTATUS_Error;
+ return FDE_XmlSyntaxResult::Error;
}
}
m_pCurrentBlock[m_iIndexInBlock++] = ch;
@@ -1944,11 +1946,11 @@ uint32_t CFDE_XMLSyntaxParser::DoSyntaxParse() {
default:
break;
}
- if (dwStatus != FDE_XMLSYNTAXSTATUS_None)
- return dwStatus;
+ if (syntaxParserResult != FDE_XmlSyntaxResult::None)
+ return syntaxParserResult;
}
}
- return 0;
+ return FDE_XmlSyntaxResult::Text;
}
CFDE_XMLSyntaxParser::~CFDE_XMLSyntaxParser() {
@@ -1966,10 +1968,10 @@ int32_t CFDE_XMLSyntaxParser::GetStatus() const {
if (iStreamLength < 1) {
return 100;
}
- if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error) {
+ if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) {
return -1;
}
- if (m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) {
+ if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) {
return 100;
}
return m_iParsedBytes * 100 / iStreamLength;
diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h
index 0f252c12dd..396423a0c1 100644
--- a/xfa/fde/xml/fde_xml_imp.h
+++ b/xfa/fde/xml/fde_xml_imp.h
@@ -291,27 +291,6 @@ class CFDE_BlockBuffer : public CFX_Target {
int32_t m_iStartPosition;
};
-#define FDE_XMLSYNTAXMODE_Text 0
-#define FDE_XMLSYNTAXMODE_Node 1
-#define FDE_XMLSYNTAXMODE_Target 2
-#define FDE_XMLSYNTAXMODE_Tag 3
-#define FDE_XMLSYNTAXMODE_AttriName 4
-#define FDE_XMLSYNTAXMODE_AttriEqualSign 5
-#define FDE_XMLSYNTAXMODE_AttriQuotation 6
-#define FDE_XMLSYNTAXMODE_AttriValue 7
-#define FDE_XMLSYNTAXMODE_Entity 8
-#define FDE_XMLSYNTAXMODE_EntityDecimal 9
-#define FDE_XMLSYNTAXMODE_EntityHex 10
-#define FDE_XMLSYNTAXMODE_CloseInstruction 11
-#define FDE_XMLSYNTAXMODE_BreakElement 12
-#define FDE_XMLSYNTAXMODE_CloseElement 13
-#define FDE_XMLSYNTAXMODE_SkipDeclNode 14
-#define FDE_XMLSYNTAXMODE_DeclCharData 15
-#define FDE_XMLSYNTAXMODE_SkipComment 16
-#define FDE_XMLSYNTAXMODE_SkipCommentOrDecl 17
-#define FDE_XMLSYNTAXMODE_SkipCData 18
-#define FDE_XMLSYNTAXMODE_TargetData 19
-
class CFDE_XMLSyntaxParser : public CFX_Target {
public:
CFDE_XMLSyntaxParser();
@@ -320,7 +299,7 @@ class CFDE_XMLSyntaxParser : public CFX_Target {
void Init(IFX_Stream* pStream,
int32_t iXMLPlaneSize,
int32_t iTextDataSize = 256);
- uint32_t DoSyntaxParse();
+ FDE_XmlSyntaxResult DoSyntaxParse();
int32_t GetStatus() const;
int32_t GetCurrentPos() const {
return m_iParsedChars + (m_pStart - m_pBuffer);
@@ -349,6 +328,29 @@ class CFDE_XMLSyntaxParser : public CFX_Target {
}
protected:
+ enum class FDE_XmlSyntaxState {
+ Text,
+ Node,
+ Target,
+ Tag,
+ AttriName,
+ AttriEqualSign,
+ AttriQuotation,
+ AttriValue,
+ Entity,
+ EntityDecimal,
+ EntityHex,
+ CloseInstruction,
+ BreakElement,
+ CloseElement,
+ SkipDeclNode,
+ DeclCharData,
+ SkipComment,
+ SkipCommentOrDecl,
+ SkipCData,
+ TargetData
+ };
+
IFX_Stream* m_pStream;
int32_t m_iXMLPlaneSize;
int32_t m_iCurrentPos;
@@ -369,8 +371,8 @@ class CFDE_XMLSyntaxParser : public CFX_Target {
FX_WCHAR* m_pCurrentBlock;
int32_t m_iIndexInBlock;
int32_t m_iTextDataLength;
- uint32_t m_dwStatus;
- uint32_t m_dwMode;
+ FDE_XmlSyntaxResult m_syntaxParserResult;
+ FDE_XmlSyntaxState m_syntaxParserState;
FX_WCHAR m_wQuotationMark;
int32_t m_iEntityStart;
CFX_DWordStack m_SkipStack;
diff --git a/xfa/fde/xml/fde_xml_imp_unittest.cpp b/xfa/fde/xml/fde_xml_imp_unittest.cpp
index 42119ebe37..0db63e4965 100644
--- a/xfa/fde/xml/fde_xml_imp_unittest.cpp
+++ b/xfa/fde/xml/fde_xml_imp_unittest.cpp
@@ -31,36 +31,36 @@ TEST(CFDE_XMLSyntaxParser, CData) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_CData, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::CData, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(cdata, data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementClose, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, CDataWithInnerScript) {
@@ -89,36 +89,36 @@ TEST(CFDE_XMLSyntaxParser, CDataWithInnerScript) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_CData, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::CData, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(cdata, data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementClose, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, ArrowBangArrow) {
@@ -136,32 +136,32 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangArrow) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementClose, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, ArrowBangBracketArrow) {
@@ -179,26 +179,26 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangBracketArrow) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
// Parser walks to end of input.
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, IncompleteCData) {
@@ -216,26 +216,26 @@ TEST(CFDE_XMLSyntaxParser, IncompleteCData) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
// Parser walks to end of input.
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, UnClosedCData) {
@@ -253,26 +253,26 @@ TEST(CFDE_XMLSyntaxParser, UnClosedCData) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
// Parser walks to end of input.
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, EmptyCData) {
@@ -290,36 +290,36 @@ TEST(CFDE_XMLSyntaxParser, EmptyCData) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_CData, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::CData, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementClose, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, Comment) {
@@ -337,32 +337,32 @@ TEST(CFDE_XMLSyntaxParser, Comment) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementClose, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, IncorrectCommentStart) {
@@ -380,32 +380,32 @@ TEST(CFDE_XMLSyntaxParser, IncorrectCommentStart) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementClose, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, CommentEmpty) {
@@ -423,32 +423,32 @@ TEST(CFDE_XMLSyntaxParser, CommentEmpty) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementClose, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, CommentThreeDash) {
@@ -466,24 +466,24 @@ TEST(CFDE_XMLSyntaxParser, CommentThreeDash) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
TEST(CFDE_XMLSyntaxParser, CommentTwoDash) {
@@ -501,22 +501,22 @@ TEST(CFDE_XMLSyntaxParser, CommentTwoDash) {
CFX_WideString data;
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementOpen, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_TagName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriName, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse());
parser.GetAttributeName(data);
EXPECT_EQ(L"contentType", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_AttriValue, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse());
parser.GetAttributeValue(data);
EXPECT_EQ(L"application/x-javascript", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_ElementBreak, parser.DoSyntaxParse());
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_Text, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse());
parser.GetTextData(data);
EXPECT_EQ(L"\n ", data);
- EXPECT_EQ(FDE_XMLSYNTAXSTATUS_EOS, parser.DoSyntaxParse());
+ EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse());
}
diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp
index 71c37755f9..f4a479d7c3 100644
--- a/xfa/fxfa/parser/xfa_parser_imp.cpp
+++ b/xfa/fxfa/parser/xfa_parser_imp.cpp
@@ -1406,7 +1406,7 @@ CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream)
m_pParent(pRoot),
m_pChild(nullptr),
m_NodeStack(16),
- m_dwStatus(FDE_XMLSYNTAXSTATUS_None) {
+ m_syntaxParserResult(FDE_XmlSyntaxResult::None) {
ASSERT(m_pParent && m_pStream);
m_NodeStack.Push(m_pParent);
m_pParser = new CFDE_XMLSyntaxParser;
@@ -1421,48 +1421,47 @@ CXFA_XMLParser::~CXFA_XMLParser() {
m_ws2.Empty();
}
int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
- if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error) {
+ if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error)
return -1;
- }
- if (m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) {
+ if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString)
return 100;
- }
+
int32_t iCount = 0;
while (TRUE) {
- m_dwStatus = m_pParser->DoSyntaxParse();
- switch (m_dwStatus) {
- case FDE_XMLSYNTAXSTATUS_InstructionOpen:
+ m_syntaxParserResult = m_pParser->DoSyntaxParse();
+ switch (m_syntaxParserResult) {
+ case FDE_XmlSyntaxResult::InstructionOpen:
break;
- case FDE_XMLSYNTAXSTATUS_InstructionClose:
+ case FDE_XmlSyntaxResult::InstructionClose:
if (m_pChild) {
if (m_pChild->GetType() != FDE_XMLNODE_Instruction) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
}
m_pChild = m_pParent;
break;
- case FDE_XMLSYNTAXSTATUS_ElementOpen:
+ case FDE_XmlSyntaxResult::ElementOpen:
if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 2) {
m_nElementStart = m_pParser->GetCurrentPos() - 1;
}
break;
- case FDE_XMLSYNTAXSTATUS_ElementBreak:
+ case FDE_XmlSyntaxResult::ElementBreak:
break;
- case FDE_XMLSYNTAXSTATUS_ElementClose:
+ case FDE_XmlSyntaxResult::ElementClose:
if (m_pChild->GetType() != FDE_XMLNODE_Element) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
m_pParser->GetTagName(m_ws1);
static_cast<CFDE_XMLElement*>(m_pChild)->GetTagName(m_ws2);
if (m_ws1.GetLength() > 0 && m_ws1 != m_ws2) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
m_NodeStack.Pop();
if (m_NodeStack.GetSize() < 1) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
} else if (m_dwCurrentCheckStatus != 0 && m_NodeStack.GetSize() == 2) {
m_nSize[m_dwCurrentCheckStatus - 1] =
@@ -1475,7 +1474,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
m_pChild = m_pParent;
iCount++;
break;
- case FDE_XMLSYNTAXSTATUS_TargetName:
+ case FDE_XmlSyntaxResult::TargetName:
m_pParser->GetTargetName(m_ws1);
if (m_ws1 == FX_WSTRC(L"originalXFAVersion") ||
m_ws1 == FX_WSTRC(L"acrobat")) {
@@ -1486,7 +1485,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
}
m_ws1.Empty();
break;
- case FDE_XMLSYNTAXSTATUS_TagName:
+ case FDE_XmlSyntaxResult::TagName:
m_pParser->GetTagName(m_ws1);
m_pChild = new CFDE_XMLElement(m_ws1);
m_pParent->InsertChildNode(m_pChild);
@@ -1509,10 +1508,10 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
}
}
break;
- case FDE_XMLSYNTAXSTATUS_AttriName:
+ case FDE_XmlSyntaxResult::AttriName:
m_pParser->GetAttributeName(m_ws1);
break;
- case FDE_XMLSYNTAXSTATUS_AttriValue:
+ case FDE_XmlSyntaxResult::AttriValue:
if (m_pChild) {
m_pParser->GetAttributeName(m_ws2);
if (m_pChild->GetType() == FDE_XMLNODE_Element) {
@@ -1521,22 +1520,22 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
}
m_ws1.Empty();
break;
- case FDE_XMLSYNTAXSTATUS_Text:
+ case FDE_XmlSyntaxResult::Text:
m_pParser->GetTextData(m_ws1);
m_pChild = new CFDE_XMLText(m_ws1);
m_pParent->InsertChildNode(m_pChild);
m_pChild = m_pParent;
break;
- case FDE_XMLSYNTAXSTATUS_CData:
+ case FDE_XmlSyntaxResult::CData:
m_pParser->GetTextData(m_ws1);
m_pChild = new CFDE_XMLCharData(m_ws1);
m_pParent->InsertChildNode(m_pChild);
m_pChild = m_pParent;
break;
- case FDE_XMLSYNTAXSTATUS_TargetData:
+ case FDE_XmlSyntaxResult::TargetData:
if (m_pChild) {
if (m_pChild->GetType() != FDE_XMLNODE_Instruction) {
- m_dwStatus = FDE_XMLSYNTAXSTATUS_Error;
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
}
if (!m_ws1.IsEmpty()) {
@@ -1550,15 +1549,16 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
default:
break;
}
- if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error ||
- m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) {
+ if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error ||
+ m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) {
break;
}
if (pPause && iCount > 500 && pPause->NeedToPauseNow()) {
break;
}
}
- return (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error || m_NodeStack.GetSize() != 1)
+ return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error ||
+ m_NodeStack.GetSize() != 1)
? -1
: m_pParser->GetStatus();
}
diff --git a/xfa/fxfa/parser/xfa_parser_imp.h b/xfa/fxfa/parser/xfa_parser_imp.h
index d81637516d..2485ddfcd2 100644
--- a/xfa/fxfa/parser/xfa_parser_imp.h
+++ b/xfa/fxfa/parser/xfa_parser_imp.h
@@ -134,7 +134,7 @@ class CXFA_XMLParser : public CFDE_XMLParser {
CXFA_XMLNodeStack m_NodeStack;
CFX_WideString m_ws1;
CFX_WideString m_ws2;
- uint32_t m_dwStatus;
+ FDE_XmlSyntaxResult m_syntaxParserResult;
};
#endif // XFA_FXFA_PARSER_XFA_PARSER_IMP_H_