summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-07 12:10:20 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-07 12:10:20 -0800
commit7cda31ac2f2884166f044937619478a6103198cf (patch)
tree640f14ab5c81696cfffdedf0644eac4b1f2bc47f /xfa/fde
parentab5a20d9de8c801b8376bfe2d6f7cf9ac7d26028 (diff)
downloadpdfium-7cda31ac2f2884166f044937619478a6103198cf.tar.xz
Refcount IFGAS_ streams all the time, too
IFGAS_Streams are not part of the IFX_Stream hierarchy, but can be made from such. Review-Url: https://codereview.chromium.org/2559763002
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp3
-rw-r--r--xfa/fde/cfde_txtedtengine.h3
-rw-r--r--xfa/fde/css/fde_css.h2
-rw-r--r--xfa/fde/css/fde_cssstylesheet.cpp12
-rw-r--r--xfa/fde/css/fde_cssstylesheet.h2
-rw-r--r--xfa/fde/css/fde_csssyntax.cpp21
-rw-r--r--xfa/fde/css/fde_csssyntax.h7
-rw-r--r--xfa/fde/xml/fde_xml_imp.cpp10
-rw-r--r--xfa/fde/xml/fde_xml_imp.h13
-rw-r--r--xfa/fde/xml/fde_xml_imp_unittest.cpp165
10 files changed, 117 insertions, 121 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 1250043fc7..d9e321f382 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -107,7 +107,8 @@ IFDE_TxtEdtPage* CFDE_TxtEdtEngine::GetPage(int32_t nIndex) {
return m_PagePtrArray[nIndex];
}
-void CFDE_TxtEdtEngine::SetTextByStream(IFGAS_Stream* pStream) {
+void CFDE_TxtEdtEngine::SetTextByStream(
+ const CFX_RetainPtr<IFGAS_Stream>& pStream) {
ResetEngine();
int32_t nIndex = 0;
if (pStream && pStream->GetLength()) {
diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h
index bd02c9b9e7..a01f7565fc 100644
--- a/xfa/fde/cfde_txtedtengine.h
+++ b/xfa/fde/cfde_txtedtengine.h
@@ -9,6 +9,7 @@
#include <memory>
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "xfa/fde/ifde_txtedtengine.h"
class CFDE_TxtEdtBuf;
@@ -28,7 +29,7 @@ class CFDE_TxtEdtEngine {
int32_t CountPages() const;
IFDE_TxtEdtPage* GetPage(int32_t nIndex);
- void SetTextByStream(IFGAS_Stream* pStream);
+ void SetTextByStream(const CFX_RetainPtr<IFGAS_Stream>& pStream);
void SetText(const CFX_WideString& wsText);
int32_t GetTextLength() const;
CFX_WideString GetText(int32_t nStart, int32_t nCount = -1) const;
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
index 3c216290d2..15468c2c4a 100644
--- a/xfa/fde/css/fde_css.h
+++ b/xfa/fde/css/fde_css.h
@@ -751,7 +751,7 @@ class IFDE_CSSStyleSheet : public IFX_Retainable {
static IFDE_CSSStyleSheet* LoadHTMLStandardStyleSheet();
static IFDE_CSSStyleSheet* LoadFromStream(
const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
uint16_t wCodePage,
uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
static IFDE_CSSStyleSheet* LoadFromBuffer(
diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp
index 9c91e43cce..fbecf4325b 100644
--- a/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/xfa/fde/css/fde_cssstylesheet.cpp
@@ -8,6 +8,7 @@
#include <memory>
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/css/fde_cssdatatable.h"
#include "xfa/fde/css/fde_csssyntax.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -49,7 +50,7 @@ IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadHTMLStandardStyleSheet() {
IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream(
const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
uint16_t wCodePage,
uint32_t dwMediaList) {
CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList);
@@ -143,10 +144,11 @@ IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
return m_RuleArray.GetAt(index);
}
-bool CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
- uint16_t wCodePage) {
- std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+bool CFDE_CSSStyleSheet::LoadFromStream(
+ const CFX_WideString& szUrl,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
+ uint16_t wCodePage) {
+ auto pSyntax = pdfium::MakeUnique<CFDE_CSSSyntaxParser>();
if (pStream->GetCodePage() != wCodePage)
pStream->SetCodePage(wCodePage);
diff --git a/xfa/fde/css/fde_cssstylesheet.h b/xfa/fde/css/fde_cssstylesheet.h
index 2460959a97..ad1f8dfbe3 100644
--- a/xfa/fde/css/fde_cssstylesheet.h
+++ b/xfa/fde/css/fde_cssstylesheet.h
@@ -111,7 +111,7 @@ class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target {
IFDE_CSSRule* GetRule(int32_t index) override;
bool LoadFromStream(const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
uint16_t wCodePage);
bool LoadFromBuffer(const CFX_WideString& szUrl,
const FX_WCHAR* pBuffer,
diff --git a/xfa/fde/css/fde_csssyntax.cpp b/xfa/fde/css/fde_csssyntax.cpp
index bdad0155d5..50ad190857 100644
--- a/xfa/fde/css/fde_csssyntax.cpp
+++ b/xfa/fde/css/fde_csssyntax.cpp
@@ -35,7 +35,7 @@ CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() {
m_TextPlane.Reset();
}
-bool CFDE_CSSSyntaxParser::Init(IFGAS_Stream* pStream,
+bool CFDE_CSSSyntaxParser::Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iCSSPlaneSize,
int32_t iTextDataSize,
bool bOnlyDeclaration) {
@@ -433,22 +433,25 @@ bool CFDE_CSSTextBuf::EstimateSize(int32_t iAllocSize) {
m_bExtBuf = false;
return ExpandBuf(iAllocSize);
}
-int32_t CFDE_CSSTextBuf::LoadFromStream(IFGAS_Stream* pTxtStream,
- int32_t iStreamOffset,
- int32_t iMaxChars,
- bool& bEOS) {
+
+int32_t CFDE_CSSTextBuf::LoadFromStream(
+ const CFX_RetainPtr<IFGAS_Stream>& pTxtStream,
+ int32_t iStreamOffset,
+ int32_t iMaxChars,
+ bool& bEOS) {
ASSERT(iStreamOffset >= 0 && iMaxChars > 0);
Clear();
m_bExtBuf = false;
- if (!ExpandBuf(iMaxChars)) {
+ if (!ExpandBuf(iMaxChars))
return 0;
- }
- if (pTxtStream->GetPosition() != iStreamOffset) {
+
+ if (pTxtStream->GetPosition() != iStreamOffset)
pTxtStream->Seek(FX_STREAMSEEK_Begin, iStreamOffset);
- }
+
m_iDatLen = pTxtStream->ReadString(m_pBuffer, iMaxChars, bEOS);
return m_iDatLen;
}
+
bool CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
if (m_bExtBuf) {
return false;
diff --git a/xfa/fde/css/fde_csssyntax.h b/xfa/fde/css/fde_csssyntax.h
index 03662037d9..6417df07d4 100644
--- a/xfa/fde/css/fde_csssyntax.h
+++ b/xfa/fde/css/fde_csssyntax.h
@@ -7,6 +7,7 @@
#ifndef XFA_FDE_CSS_FDE_CSSSYNTAX_H_
#define XFA_FDE_CSS_FDE_CSSSYNTAX_H_
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "xfa/fde/css/fde_css.h"
#include "xfa/fgas/crt/fgas_memory.h"
#include "xfa/fgas/crt/fgas_stream.h"
@@ -18,7 +19,7 @@ class CFDE_CSSTextBuf : public CFX_Target {
bool AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen);
bool EstimateSize(int32_t iAllocSize);
- int32_t LoadFromStream(IFGAS_Stream* pTxtStream,
+ int32_t LoadFromStream(const CFX_RetainPtr<IFGAS_Stream>& pTxtStream,
int32_t iStreamOffset,
int32_t iMaxChars,
bool& bEOS);
@@ -80,7 +81,7 @@ class CFDE_CSSSyntaxParser : public CFX_Target {
CFDE_CSSSyntaxParser();
~CFDE_CSSSyntaxParser() override;
- bool Init(IFGAS_Stream* pStream,
+ bool Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iCSSPlaneSize,
int32_t iTextDataSize = 32,
bool bOnlyDeclaration = false);
@@ -106,7 +107,7 @@ class CFDE_CSSSyntaxParser : public CFX_Target {
bool IsImportEnabled() const;
void DisableImport() { m_dwCheck = 0; }
- IFGAS_Stream* m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
int32_t m_iStreamPos;
int32_t m_iPlaneSize;
CFDE_CSSTextBuf m_TextData;
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp
index 1fbb1cdda7..f333b4fcda 100644
--- a/xfa/fde/xml/fde_xml_imp.cpp
+++ b/xfa/fde/xml/fde_xml_imp.cpp
@@ -394,7 +394,7 @@ CFDE_XMLNode* CFDE_XMLNode::Clone(bool bRecursive) {
return nullptr;
}
-void CFDE_XMLNode::SaveXMLNode(IFGAS_Stream* pXMLStream) {
+void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream) {
CFDE_XMLNode* pNode = (CFDE_XMLNode*)this;
switch (pNode->GetType()) {
case FDE_XMLNODE_Instruction: {
@@ -986,7 +986,8 @@ void CFDE_XMLDoc::CloseXML() {
ReleaseParser();
}
-void CFDE_XMLDoc::SaveXMLNode(IFGAS_Stream* pXMLStream, CFDE_XMLNode* pINode) {
+void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
+ CFDE_XMLNode* pINode) {
CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode;
switch (pNode->GetType()) {
case FDE_XMLNODE_Instruction: {
@@ -1096,7 +1097,8 @@ void CFDE_XMLDoc::SaveXMLNode(IFGAS_Stream* pXMLStream, CFDE_XMLNode* pINode) {
}
}
-void CFDE_XMLDoc::SaveXML(IFGAS_Stream* pXMLStream, bool bSaveBOM) {
+void CFDE_XMLDoc::SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
+ bool bSaveBOM) {
if (!pXMLStream || pXMLStream == m_pStream) {
m_pStream->Seek(FX_STREAMSEEK_Begin, 0);
pXMLStream = m_pStream;
@@ -1288,7 +1290,7 @@ CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser()
m_CurNode.eNodeType = FDE_XMLNODE_Unknown;
}
-void CFDE_XMLSyntaxParser::Init(IFGAS_Stream* pStream,
+void CFDE_XMLSyntaxParser::Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iXMLPlaneSize,
int32_t iTextDataSize) {
ASSERT(!m_pStream && !m_pBuffer);
diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h
index 924f958b86..283184aadc 100644
--- a/xfa/fde/xml/fde_xml_imp.h
+++ b/xfa/fde/xml/fde_xml_imp.h
@@ -63,7 +63,7 @@ class CFDE_XMLNode : public CFX_Target {
bool InsertNodeItem(CFDE_XMLNode::NodeItem eItem, CFDE_XMLNode* pNode);
CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem);
- void SaveXMLNode(IFGAS_Stream* pXMLStream);
+ void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream);
CFDE_XMLNode* m_pParent;
CFDE_XMLNode* m_pChild;
@@ -197,14 +197,15 @@ class CFDE_XMLDoc : public CFX_Target {
int32_t DoLoad(IFX_Pause* pPause = nullptr);
void CloseXML();
CFDE_XMLNode* GetRoot() const { return m_pRoot; }
- void SaveXML(IFGAS_Stream* pXMLStream = nullptr, bool bSaveBOM = true);
- void SaveXMLNode(IFGAS_Stream* pXMLStream, CFDE_XMLNode* pNode);
+ void SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream, bool bSaveBOM = true);
+ void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
+ CFDE_XMLNode* pNode);
protected:
void Reset(bool bInitRoot);
void ReleaseParser();
- IFGAS_Stream* m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
int32_t m_iStatus;
CFDE_XMLNode* m_pRoot;
CFDE_XMLSyntaxParser* m_pSyntaxParser;
@@ -261,7 +262,7 @@ class CFDE_XMLSyntaxParser : public CFX_Target {
~CFDE_XMLSyntaxParser() override;
void Release() { delete this; }
- void Init(IFGAS_Stream* pStream,
+ void Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iXMLPlaneSize,
int32_t iTextDataSize = 256);
@@ -320,7 +321,7 @@ class CFDE_XMLSyntaxParser : public CFX_Target {
void ParseTextChar(FX_WCHAR ch);
- IFGAS_Stream* m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
int32_t m_iXMLPlaneSize;
int32_t m_iCurrentPos;
int32_t m_iCurrentNodeNum;
diff --git a/xfa/fde/xml/fde_xml_imp_unittest.cpp b/xfa/fde/xml/fde_xml_imp_unittest.cpp
index 553afffd86..6db1b1905a 100644
--- a/xfa/fde/xml/fde_xml_imp_unittest.cpp
+++ b/xfa/fde/xml/fde_xml_imp_unittest.cpp
@@ -26,15 +26,14 @@ TEST(CFDE_XMLSyntaxParser, CData) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -84,15 +83,14 @@ TEST(CFDE_XMLSyntaxParser, CDataWithInnerScript) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -131,15 +129,14 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangArrow) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -174,15 +171,14 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangBracketArrow) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -211,15 +207,14 @@ TEST(CFDE_XMLSyntaxParser, IncompleteCData) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -248,15 +243,14 @@ TEST(CFDE_XMLSyntaxParser, UnClosedCData) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -285,15 +279,14 @@ TEST(CFDE_XMLSyntaxParser, EmptyCData) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -332,15 +325,14 @@ TEST(CFDE_XMLSyntaxParser, Comment) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -375,15 +367,14 @@ TEST(CFDE_XMLSyntaxParser, IncorrectCommentStart) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -418,15 +409,14 @@ TEST(CFDE_XMLSyntaxParser, CommentEmpty) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -461,15 +451,14 @@ TEST(CFDE_XMLSyntaxParser, CommentThreeDash) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -496,15 +485,14 @@ TEST(CFDE_XMLSyntaxParser, CommentTwoDash) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -535,15 +523,14 @@ TEST(CFDE_XMLSyntaxParser, Entities) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -575,15 +562,14 @@ TEST(CFDE_XMLSyntaxParser, EntityOverflowHex) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -615,15 +601,14 @@ TEST(CFDE_XMLSyntaxParser, EntityOverflowDecimal) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);