From bf510b7c520bccbd2edf5bb3e2f91b125ebfd6d7 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 18 Apr 2017 16:35:55 -0400 Subject: Rename IFGAS_Stream to CFGAS_Stream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL replaces IFGAS_Stream with the only implementation CFGAS_Stream. The CreateReadStream and CreateWriteStream methods are removed in favour of calling MakeRetain directly. Change-Id: I882a89258f642e24fc3d631587db05652bd53ded Reviewed-on: https://pdfium-review.googlesource.com/4210 Commit-Queue: dsinclair Reviewed-by: Nicolás Peña Reviewed-by: Tom Sepez --- xfa/fde/xml/cfde_xmldoc.cpp | 2 +- xfa/fde/xml/cfde_xmldoc.h | 6 +-- xfa/fde/xml/cfde_xmlnode.cpp | 2 +- xfa/fde/xml/cfde_xmlnode.h | 4 +- xfa/fde/xml/cfde_xmlparser.cpp | 2 +- xfa/fde/xml/cfde_xmlparser.h | 6 +-- xfa/fde/xml/cfde_xmlsyntaxparser.cpp | 8 +-- xfa/fde/xml/cfde_xmlsyntaxparser.h | 6 +-- xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp | 77 +++++++++++---------------- 9 files changed, 49 insertions(+), 64 deletions(-) (limited to 'xfa/fde/xml') diff --git a/xfa/fde/xml/cfde_xmldoc.cpp b/xfa/fde/xml/cfde_xmldoc.cpp index 209ce9c68f..256164c5f8 100644 --- a/xfa/fde/xml/cfde_xmldoc.cpp +++ b/xfa/fde/xml/cfde_xmldoc.cpp @@ -47,7 +47,7 @@ void CFDE_XMLDoc::CloseXML() { m_pXMLParser.reset(); } -void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr& pXMLStream, +void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr& pXMLStream, CFDE_XMLNode* pINode) { CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; switch (pNode->GetType()) { diff --git a/xfa/fde/xml/cfde_xmldoc.h b/xfa/fde/xml/cfde_xmldoc.h index 6143750428..b84c9c00a0 100644 --- a/xfa/fde/xml/cfde_xmldoc.h +++ b/xfa/fde/xml/cfde_xmldoc.h @@ -12,7 +12,7 @@ #include "core/fxcrt/cfx_retain_ptr.h" #include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fde/xml/cfde_xmlparser.h" -#include "xfa/fgas/crt/ifgas_stream.h" +#include "xfa/fgas/crt/cfgas_stream.h" class CFDE_XMLDoc { public: @@ -24,14 +24,14 @@ class CFDE_XMLDoc { void CloseXML(); CFDE_XMLNode* GetRoot() const { return m_pRoot.get(); } - void SaveXMLNode(const CFX_RetainPtr& pXMLStream, + void SaveXMLNode(const CFX_RetainPtr& pXMLStream, CFDE_XMLNode* pNode); private: int32_t m_iStatus; std::unique_ptr m_pRoot; std::unique_ptr m_pXMLParser; - CFX_RetainPtr m_pStream; + CFX_RetainPtr m_pStream; }; #endif // XFA_FDE_XML_CFDE_XMLDOC_H_ diff --git a/xfa/fde/xml/cfde_xmlnode.cpp b/xfa/fde/xml/cfde_xmlnode.cpp index e4d7880cac..149d18c3d6 100644 --- a/xfa/fde/xml/cfde_xmlnode.cpp +++ b/xfa/fde/xml/cfde_xmlnode.cpp @@ -329,7 +329,7 @@ std::unique_ptr CFDE_XMLNode::Clone() { return nullptr; } -void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr& pXMLStream) { +void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr& pXMLStream) { CFDE_XMLNode* pNode = (CFDE_XMLNode*)this; switch (pNode->GetType()) { case FDE_XMLNODE_Instruction: { diff --git a/xfa/fde/xml/cfde_xmlnode.h b/xfa/fde/xml/cfde_xmlnode.h index 3cfcd5c980..a04bd8c812 100644 --- a/xfa/fde/xml/cfde_xmlnode.h +++ b/xfa/fde/xml/cfde_xmlnode.h @@ -10,7 +10,7 @@ #include #include "core/fxcrt/cfx_retain_ptr.h" -#include "xfa/fgas/crt/ifgas_stream.h" +#include "xfa/fgas/crt/cfgas_stream.h" enum FDE_XMLNODETYPE { FDE_XMLNODE_Unknown = 0, @@ -64,7 +64,7 @@ class CFDE_XMLNode { bool InsertNodeItem(CFDE_XMLNode::NodeItem eItem, CFDE_XMLNode* pNode); CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem); - void SaveXMLNode(const CFX_RetainPtr& pXMLStream); + void SaveXMLNode(const CFX_RetainPtr& pXMLStream); CFDE_XMLNode* m_pParent; CFDE_XMLNode* m_pChild; diff --git a/xfa/fde/xml/cfde_xmlparser.cpp b/xfa/fde/xml/cfde_xmlparser.cpp index 5b8993de1b..c29dfc38ab 100644 --- a/xfa/fde/xml/cfde_xmlparser.cpp +++ b/xfa/fde/xml/cfde_xmlparser.cpp @@ -15,7 +15,7 @@ #include "xfa/fde/xml/cfde_xmltext.h" CFDE_XMLParser::CFDE_XMLParser(CFDE_XMLNode* pParent, - const CFX_RetainPtr& pStream) + const CFX_RetainPtr& pStream) : m_nElementStart(0), m_dwCheckStatus(0), m_dwCurrentCheckStatus(0), diff --git a/xfa/fde/xml/cfde_xmlparser.h b/xfa/fde/xml/cfde_xmlparser.h index 42f590ce21..f1a7888fa7 100644 --- a/xfa/fde/xml/cfde_xmlparser.h +++ b/xfa/fde/xml/cfde_xmlparser.h @@ -16,13 +16,13 @@ class CFDE_XMLElement; class CFDE_XMLNode; -class IFGAS_Stream; +class CFGAS_Stream; class IFX_Pause; class CFDE_XMLParser { public: CFDE_XMLParser(CFDE_XMLNode* pParent, - const CFX_RetainPtr& pStream); + const CFX_RetainPtr& pStream); ~CFDE_XMLParser(); int32_t DoParser(IFX_Pause* pPause); @@ -34,7 +34,7 @@ class CFDE_XMLParser { uint16_t m_dwCurrentCheckStatus; private: - CFX_RetainPtr m_pStream; + CFX_RetainPtr m_pStream; std::unique_ptr m_pParser; CFDE_XMLNode* m_pParent; CFDE_XMLNode* m_pChild; diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser.cpp b/xfa/fde/xml/cfde_xmlsyntaxparser.cpp index 78382058ec..10eefdc012 100644 --- a/xfa/fde/xml/cfde_xmlsyntaxparser.cpp +++ b/xfa/fde/xml/cfde_xmlsyntaxparser.cpp @@ -80,7 +80,7 @@ int32_t GetUTF8EncodeLength(const std::vector& src, } // namespace CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser( - const CFX_RetainPtr& pStream) + const CFX_RetainPtr& pStream) : m_pStream(pStream), m_iXMLPlaneSize(32 * 1024), m_iCurrentPos(0), @@ -144,9 +144,9 @@ FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() { } m_ParsedChars += m_End; m_iParsedBytes = m_iCurrentPos; - if (m_pStream->GetPosition() != m_iCurrentPos) { - m_pStream->Seek(FX_STREAMSEEK_Begin, m_iCurrentPos); - } + if (m_pStream->GetPosition() != m_iCurrentPos) + m_pStream->Seek(CFGAS_Stream::Pos::Begin, m_iCurrentPos); + m_iBufferChars = m_pStream->ReadString(m_Buffer.data(), m_iXMLPlaneSize, &m_bEOS); iPos = m_pStream->GetPosition(); diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser.h b/xfa/fde/xml/cfde_xmlsyntaxparser.h index f229cc02b1..aa4e91827e 100644 --- a/xfa/fde/xml/cfde_xmlsyntaxparser.h +++ b/xfa/fde/xml/cfde_xmlsyntaxparser.h @@ -14,7 +14,7 @@ #include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" #include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fgas/crt/ifgas_stream.h" +#include "xfa/fgas/crt/cfgas_stream.h" enum class FDE_XmlSyntaxResult { None, @@ -36,7 +36,7 @@ enum class FDE_XmlSyntaxResult { class CFDE_XMLSyntaxParser { public: - explicit CFDE_XMLSyntaxParser(const CFX_RetainPtr& pStream); + explicit CFDE_XMLSyntaxParser(const CFX_RetainPtr& pStream); ~CFDE_XMLSyntaxParser(); FDE_XmlSyntaxResult DoSyntaxParse(); @@ -97,7 +97,7 @@ class CFDE_XMLSyntaxParser { void ParseTextChar(wchar_t ch); - CFX_RetainPtr m_pStream; + CFX_RetainPtr m_pStream; FX_STRSIZE m_iXMLPlaneSize; int32_t m_iCurrentPos; int32_t m_iCurrentNodeNum; diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp b/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp index a45bb1276a..aecb3ee39e 100644 --- a/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp +++ b/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp @@ -8,8 +8,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" +#include "xfa/fgas/crt/cfgas_stream.h" #include "xfa/fgas/crt/fgas_codepage.h" -#include "xfa/fgas/crt/ifgas_stream.h" class CFDE_XMLSyntaxParserTest : public pdfium::FPDF_Test {}; @@ -28,9 +28,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CData) { L" app.alert(\"Tclams\");\n" L" "; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -76,9 +75,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CDataWithInnerScript) { L" \n" L" "; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -113,9 +111,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, ArrowBangArrow) { " \n" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -148,9 +145,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, ArrowBangBracketArrow) { " \n" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -178,9 +174,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, IncompleteCData) { " \n" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -208,9 +203,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, UnClosedCData) { " "; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -238,9 +232,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, EmptyCData) { " \n" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -275,9 +268,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, Comment) { " \n" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -309,9 +301,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, IncorrectCommentStart) { " \n" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -343,9 +334,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CommentEmpty) { " \n" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -377,9 +367,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CommentThreeDash) { " \n" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -405,9 +394,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CommentTwoDash) { " \n" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -437,9 +425,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, Entities) { "�" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -469,9 +456,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, EntityOverflowHex) { "�" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -501,9 +487,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, EntityOverflowDecimal) { "�" ""; - CFX_RetainPtr stream = - IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create( - reinterpret_cast(const_cast(input)), strlen(input))); + CFX_RetainPtr stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); -- cgit v1.2.3