From d20dfba2ae10e8aeb328328f09da79ff904110a8 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 24 Dec 2015 19:00:05 -0800 Subject: Switch from nonstd::unique_ptr to std::unique_ptr. R=thakis@chromium.org Review URL: https://codereview.chromium.org/1547833002 . --- BUILD.gn | 1 - core/include/fpdfapi/fpdf_module.h | 7 +- core/include/fpdfapi/fpdf_parser.h | 6 +- core/include/fpdfapi/fpdf_render.h | 4 +- core/include/fpdfdoc/fpdf_doc.h | 6 +- core/include/fxcodec/fx_codec.h | 16 +- core/include/fxcrt/fx_basic.h | 2 +- core/include/fxge/fx_font.h | 4 +- core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp | 2 +- core/src/fpdfapi/fpdf_font/fpdf_font.cpp | 2 +- core/src/fpdfapi/fpdf_font/ttgsubtable.cpp | 5 +- core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp | 4 +- .../src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 2 +- core/src/fpdfapi/fpdf_page/pageint.h | 4 +- .../src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 30 +- .../fpdf_parser/fpdf_parser_parser_unittest.cpp | 2 +- core/src/fpdfapi/fpdf_render/fpdf_render.cpp | 12 +- core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp | 12 +- .../fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 9 +- core/src/fpdfapi/fpdf_render/render_int.h | 10 +- core/src/fpdfdoc/doc_annot.cpp | 1 - core/src/fpdfdoc/doc_bookmark.cpp | 4 +- core/src/fpdftext/fpdf_text.cpp | 10 +- core/src/fpdftext/fpdf_text_int.cpp | 8 +- core/src/fxcodec/codec/codec_int.h | 7 +- core/src/fxcodec/codec/fx_codec.cpp | 2 +- core/src/fxcodec/codec/fx_codec_flate.cpp | 10 +- core/src/fxcodec/codec/fx_codec_jpx_opj.cpp | 2 +- core/src/fxcodec/jbig2/JBig2_Context.cpp | 80 ++--- core/src/fxcodec/jbig2/JBig2_Context.h | 12 +- core/src/fxcodec/jbig2/JBig2_GrdProc.cpp | 19 +- core/src/fxcodec/jbig2/JBig2_GrrdProc.cpp | 11 +- core/src/fxcodec/jbig2/JBig2_GsidProc.cpp | 13 +- core/src/fxcodec/jbig2/JBig2_HtrdProc.cpp | 13 +- core/src/fxcodec/jbig2/JBig2_PddProc.cpp | 11 +- core/src/fxcodec/jbig2/JBig2_SddProc.cpp | 118 +++--- core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp | 4 +- core/src/fxcodec/jbig2/JBig2_SymbolDict.h | 4 +- core/src/fxcodec/jbig2/JBig2_TrdProc.cpp | 15 +- fpdfsdk/include/fsdk_actionhandler.h | 5 +- fpdfsdk/include/fsdk_mgr.h | 18 +- fpdfsdk/src/fpdfformfill.cpp | 7 +- fpdfsdk/src/fpdfppo.cpp | 5 +- fpdfsdk/src/fpdfview.cpp | 5 +- fpdfsdk/src/fsdk_baseform.cpp | 7 +- fpdfsdk/src/fsdk_mgr.cpp | 6 +- fpdfsdk/src/javascript/Field.cpp | 2 +- fpdfsdk/src/javascript/JS_Object.h | 4 +- fpdfsdk/src/javascript/JS_Runtime_Stub.cpp | 5 +- fpdfsdk/src/javascript/app.cpp | 5 +- pdfium.gyp | 1 - testing/embedder_test.h | 4 +- testing/js_embedder_test.h | 4 +- third_party/BUILD.gn | 2 - third_party/base/nonstd_unique_ptr.h | 398 --------------------- third_party/base/nonstd_unique_ptr_unittest.cpp | 391 -------------------- third_party/base/numerics/safe_conversions_impl.h | 1 - third_party/base/numerics/safe_math.h | 6 +- third_party/base/numerics/safe_math_impl.h | 111 +++--- third_party/base/template_util.h | 79 ---- third_party/third_party.gyp | 2 - 61 files changed, 345 insertions(+), 1207 deletions(-) delete mode 100644 third_party/base/nonstd_unique_ptr.h delete mode 100644 third_party/base/nonstd_unique_ptr_unittest.cpp delete mode 100644 third_party/base/template_util.h diff --git a/BUILD.gn b/BUILD.gn index 7df4e38672..1377b68af5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -737,7 +737,6 @@ test("pdfium_unittests") { "core/src/fxcrt/fx_bidi_unittest.cpp", "core/src/fxcrt/fx_extension_unittest.cpp", "core/src/fxcrt/fx_system_unittest.cpp", - "third_party/base/nonstd_unique_ptr_unittest.cpp", ] deps = [ "//testing/gtest", diff --git a/core/include/fpdfapi/fpdf_module.h b/core/include/fpdfapi/fpdf_module.h index 00aed45d1f..e22b63e544 100644 --- a/core/include/fpdfapi/fpdf_module.h +++ b/core/include/fpdfapi/fpdf_module.h @@ -7,9 +7,10 @@ #ifndef CORE_INCLUDE_FPDFAPI_FPDF_MODULE_H_ #define CORE_INCLUDE_FPDFAPI_FPDF_MODULE_H_ +#include + #include "core/include/fxcrt/fx_coordinates.h" #include "core/include/fxcrt/fx_system.h" -#include "third_party/base/nonstd_unique_ptr.h" class CCodec_ModuleMgr; class CFX_BitmapDevice; @@ -78,8 +79,8 @@ class CPDF_ModuleMgr { ~CPDF_ModuleMgr(); CCodec_ModuleMgr* m_pCodecModule; - nonstd::unique_ptr m_pRenderModule; - nonstd::unique_ptr m_pPageModule; + std::unique_ptr m_pRenderModule; + std::unique_ptr m_pPageModule; FX_BOOL (*m_pDownloadCallback)(const FX_CHAR* module_name); CFX_PrivateData m_privateData; }; diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h index 752df789da..a49fb29d9c 100644 --- a/core/include/fpdfapi/fpdf_parser.h +++ b/core/include/fpdfapi/fpdf_parser.h @@ -8,10 +8,10 @@ #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ #include +#include #include "core/include/fxcrt/fx_system.h" #include "fpdf_objects.h" -#include "third_party/base/nonstd_unique_ptr.h" class CFDF_Document; class CFDF_Parser; @@ -347,7 +347,7 @@ class CPDF_SyntaxParser { FX_FILESIZE m_BufOffset; - nonstd::unique_ptr m_pCryptoHandler; + std::unique_ptr m_pCryptoHandler; uint8_t m_WordBuffer[257]; @@ -496,7 +496,7 @@ class CPDF_Parser { FX_BOOL m_bXRefStream; - nonstd::unique_ptr m_pSecurityHandler; + std::unique_ptr m_pSecurityHandler; FX_BOOL m_bForceUseSecurityHandler; diff --git a/core/include/fpdfapi/fpdf_render.h b/core/include/fpdfapi/fpdf_render.h index 245a85d502..1c8a99ac7d 100644 --- a/core/include/fpdfapi/fpdf_render.h +++ b/core/include/fpdfapi/fpdf_render.h @@ -8,10 +8,10 @@ #define CORE_INCLUDE_FPDFAPI_FPDF_RENDER_H_ #include +#include #include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fxge/fx_ge.h" -#include "third_party/base/nonstd_unique_ptr.h" class CFX_GraphStateData; class CFX_PathData; @@ -151,7 +151,7 @@ class CPDF_ProgressiveRenderer { CPDF_RenderContext* const m_pContext; CFX_RenderDevice* const m_pDevice; const CPDF_RenderOptions* const m_pOptions; - nonstd::unique_ptr m_pRenderStatus; + std::unique_ptr m_pRenderStatus; CFX_FloatRect m_ClipRect; FX_DWORD m_LayerIndex; FX_DWORD m_ObjectIndex; diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h index 4712f60706..09c93d6c3a 100644 --- a/core/include/fpdfdoc/fpdf_doc.h +++ b/core/include/fpdfdoc/fpdf_doc.h @@ -8,11 +8,11 @@ #define CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_ #include +#include #include #include "core/include/fpdfapi/fpdf_parser.h" #include "core/include/fpdfapi/fpdf_render.h" -#include "third_party/base/nonstd_unique_ptr.h" class CFieldTree; class CPDF_AAction; @@ -700,7 +700,7 @@ class CPDF_InterForm : public CFX_PrivateData { std::map m_ControlMap; - nonstd::unique_ptr m_pFieldTree; + std::unique_ptr m_pFieldTree; CFX_ByteString m_bsEncoding; @@ -1060,7 +1060,7 @@ class CPDF_Metadata { const CXML_Element* GetRoot() const; private: - nonstd::unique_ptr m_pXmlElement; + std::unique_ptr m_pXmlElement; }; class CPDF_ViewerPreferences { diff --git a/core/include/fxcodec/fx_codec.h b/core/include/fxcodec/fx_codec.h index 1d4d333b33..343b342530 100644 --- a/core/include/fxcodec/fx_codec.h +++ b/core/include/fxcodec/fx_codec.h @@ -7,11 +7,11 @@ #ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_H_ #define CORE_INCLUDE_FXCODEC_FX_CODEC_H_ +#include #include #include "core/include/fxcrt/fx_basic.h" #include "fx_codec_def.h" -#include "third_party/base/nonstd_unique_ptr.h" class CFX_DIBSource; class CJPX_Decoder; @@ -42,13 +42,13 @@ class CCodec_ModuleMgr { ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } protected: - nonstd::unique_ptr m_pBasicModule; - nonstd::unique_ptr m_pFaxModule; - nonstd::unique_ptr m_pJpegModule; - nonstd::unique_ptr m_pJpxModule; - nonstd::unique_ptr m_pJbig2Module; - nonstd::unique_ptr m_pIccModule; - nonstd::unique_ptr m_pFlateModule; + std::unique_ptr m_pBasicModule; + std::unique_ptr m_pFaxModule; + std::unique_ptr m_pJpegModule; + std::unique_ptr m_pJpxModule; + std::unique_ptr m_pJbig2Module; + std::unique_ptr m_pIccModule; + std::unique_ptr m_pFlateModule; }; class ICodec_BasicModule { public: diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h index ef5b204049..bb34e2bc15 100644 --- a/core/include/fxcrt/fx_basic.h +++ b/core/include/fxcrt/fx_basic.h @@ -955,7 +955,7 @@ struct FxFreeDeleter { inline void operator()(void* ptr) const { FX_Free(ptr); } }; -// Used with nonstd::unique_ptr to Release() objects that can't be deleted. +// Used with std::unique_ptr to Release() objects that can't be deleted. template struct ReleaseDeleter { inline void operator()(T* ptr) const { ptr->Release(); } diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h index 8234458fe5..d6e3359c61 100644 --- a/core/include/fxge/fx_font.h +++ b/core/include/fxge/fx_font.h @@ -8,10 +8,10 @@ #define CORE_INCLUDE_FXGE_FX_FONT_H_ #include +#include #include "core/include/fxcrt/fx_system.h" #include "fx_dib.h" -#include "third_party/base/nonstd_unique_ptr.h" typedef struct FT_FaceRec_* FXFT_Face; typedef void* FXFT_Library; @@ -212,7 +212,7 @@ class CFX_FontMgr { FXFT_Library GetFTLibrary() const { return m_FTLibrary; } private: - nonstd::unique_ptr m_pBuiltinMapper; + std::unique_ptr m_pBuiltinMapper; std::map m_FaceMap; FXFT_Library m_FTLibrary; }; diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index 9c96a3027c..e1c39fbb16 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -846,7 +846,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { } CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; pBaseDict->SetAtName("Type", "Font"); - nonstd::unique_ptr pEncoding( + std::unique_ptr pEncoding( new CFX_UnicodeEncoding(pFont)); CPDF_Dictionary* pFontDict = pBaseDict; if (!bCJK) { diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp index a3de6f2777..003825b898 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp @@ -1700,7 +1700,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) { if (!pStream) return nullptr; - nonstd::unique_ptr pNewChar(new CPDF_Type3Char(new CPDF_Form( + std::unique_ptr pNewChar(new CPDF_Type3Char(new CPDF_Form( m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources, pStream, nullptr))); diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp index b10aa6952a..09930bee2d 100644 --- a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp +++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp @@ -6,9 +6,10 @@ #include "ttgsubtable.h" +#include + #include "core/include/fxge/fx_freetype.h" #include "core/include/fxge/fx_ge.h" -#include "third_party/base/nonstd_unique_ptr.h" #include "third_party/base/stl_util.h" CFX_GlyphMap::CFX_GlyphMap() {} @@ -405,7 +406,7 @@ IFX_GSUBTable* IFX_GSUBTable::Create(CFX_Font* pFont) { FXFT_Load_Sfnt_Table(pFont->GetFace(), FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, pFont->GetSubData(), NULL); if (!error && pFont->GetSubData()) { - nonstd::unique_ptr pGsubTable(new CFX_GSUBTable); + std::unique_ptr pGsubTable(new CFX_GSUBTable); if (pGsubTable->m_GsubImp.LoadGSUBTable((FT_Bytes)pFont->GetSubData())) { return pGsubTable.release(); } diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp index 118f1cd5a3..15222fc594 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp @@ -8,12 +8,12 @@ #include +#include #include #include "core/include/fpdfapi/fpdf_module.h" #include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fxcrt/fx_safe_types.h" -#include "third_party/base/nonstd_unique_ptr.h" #include "third_party/base/numerics/safe_conversions_impl.h" class CPDF_PSEngine; @@ -768,7 +768,7 @@ FX_BOOL CPDF_StitchFunc::v_Init(CPDF_Object* pObj) { if (pSub == pObj) { return FALSE; } - nonstd::unique_ptr pFunc(CPDF_Function::Load(pSub)); + std::unique_ptr pFunc(CPDF_Function::Load(pSub)); if (!pFunc) { return FALSE; } diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 02ac27ac0f..1c4cc24208 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -92,7 +92,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1, m_pSyntax->GetWordSize() - 1); - nonstd::unique_ptr> pObj( + std::unique_ptr> pObj( m_pSyntax->ReadNextObject()); if (!key.IsEmpty()) { FX_DWORD dwObjNum = pObj ? pObj->GetObjNum() : 0; diff --git a/core/src/fpdfapi/fpdf_page/pageint.h b/core/src/fpdfapi/fpdf_page/pageint.h index d5a035fe2b..f41a987e34 100644 --- a/core/src/fpdfapi/fpdf_page/pageint.h +++ b/core/src/fpdfapi/fpdf_page/pageint.h @@ -8,10 +8,10 @@ #define CORE_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_ #include +#include #include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_pageobj.h" -#include "third_party/base/nonstd_unique_ptr.h" class CPDF_AllStates; class CPDF_ParseOptions; @@ -319,7 +319,7 @@ class CPDF_StreamContentParser { FX_DWORD m_ParamStartPos; FX_DWORD m_ParamCount; CPDF_StreamParser* m_pSyntax; - nonstd::unique_ptr m_pCurStates; + std::unique_ptr m_pCurStates; CPDF_ContentMark m_CurContentMark; CFX_ArrayTemplate m_ClipTextList; CPDF_TextObject* m_pLastTextObject; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index 05f407bfd3..1115a1e560 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -6,6 +6,7 @@ #include "parser_int.h" +#include #include #include #include @@ -16,7 +17,6 @@ #include "core/include/fxcrt/fx_ext.h" #include "core/include/fxcrt/fx_safe_types.h" #include "core/src/fpdfapi/fpdf_page/pageint.h" -#include "third_party/base/nonstd_unique_ptr.h" #include "third_party/base/stl_util.h" namespace { @@ -94,7 +94,7 @@ bool CanReadFromBitStream(const CFX_BitStream* hStream, // TODO(thestig) Using unique_ptr with ReleaseDeleter is still not ideal. // Come up or wait for something better. using ScopedFileStream = - nonstd::unique_ptr>; + std::unique_ptr>; FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) { CPDF_Object* pType = pDict->GetElementValue("Type"); @@ -307,7 +307,7 @@ FX_DWORD CPDF_Parser::SetEncryptHandler() { if (!m_pSecurityHandler->OnInit(this, m_pEncryptDict)) { return err; } - nonstd::unique_ptr pCryptoHandler( + std::unique_ptr pCryptoHandler( m_pSecurityHandler->CreateCryptoHandler()); if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) { return PDFPARSE_ERROR_HANDLER; @@ -315,7 +315,7 @@ FX_DWORD CPDF_Parser::SetEncryptHandler() { m_Syntax.SetEncrypt(pCryptoHandler.release()); } else if (m_pEncryptDict) { CFX_ByteString filter = m_pEncryptDict->GetString("Filter"); - nonstd::unique_ptr pSecurityHandler; + std::unique_ptr pSecurityHandler; FX_DWORD err = PDFPARSE_ERROR_HANDLER; if (filter == "Standard") { pSecurityHandler.reset(FPDF_CreateStandardSecurityHandler()); @@ -328,7 +328,7 @@ FX_DWORD CPDF_Parser::SetEncryptHandler() { return err; } m_pSecurityHandler = std::move(pSecurityHandler); - nonstd::unique_ptr pCryptoHandler( + std::unique_ptr pCryptoHandler( m_pSecurityHandler->CreateCryptoHandler()); if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) { return PDFPARSE_ERROR_HANDLER; @@ -385,7 +385,7 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) { while (xrefpos) { CrossRefList.InsertAt(0, xrefpos); LoadCrossRefV4(xrefpos, 0, TRUE); - nonstd::unique_ptr> pDict( + std::unique_ptr> pDict( LoadTrailerV4()); if (!pDict) return FALSE; @@ -1456,7 +1456,7 @@ CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() { if (m_Syntax.GetKeyword() != "trailer") return nullptr; - nonstd::unique_ptr> pObj( + std::unique_ptr> pObj( m_Syntax.GetObject(m_pDocument, 0, 0, 0)); if (!ToDictionary(pObj.get())) return nullptr; @@ -2095,7 +2095,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, int32_t nKeys = 0; FX_FILESIZE dwSignValuePos = 0; - nonstd::unique_ptr> pDict( + std::unique_ptr> pDict( new CPDF_Dictionary); while (1) { FX_BOOL bIsNumber; @@ -2233,7 +2233,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( if (word == "[") { if (bTypeOnly) return (CPDF_Object*)PDFOBJ_ARRAY; - nonstd::unique_ptr> pArray( + std::unique_ptr> pArray( new CPDF_Array); while (CPDF_Object* pObj = GetObject(pObjList, objnum, gennum)) pArray->Add(pObj); @@ -2251,7 +2251,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( if (pContext) pContext->m_DictStart = SavedPos; - nonstd::unique_ptr> pDict( + std::unique_ptr> pDict( new CPDF_Dictionary); while (1) { FX_BOOL bIsNumber; @@ -2271,7 +2271,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( continue; key = PDF_NameDecode(key); - nonstd::unique_ptr> obj( + std::unique_ptr> obj( GetObject(pObjList, objnum, gennum)); if (!obj) { uint8_t ch; @@ -2884,7 +2884,7 @@ class CPDF_DataAvail final : public IPDF_DataAvail { std::set m_pageMapCheckState; std::set m_pagesLoadState; - nonstd::unique_ptr m_pHintTables; + std::unique_ptr m_pHintTables; FX_BOOL m_bSupportHintTable; }; @@ -3599,9 +3599,9 @@ FX_BOOL CPDF_DataAvail::CheckHintTables(IFX_DownloadHints* pHints) { return FALSE; } m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); - nonstd::unique_ptr pHintTables( + std::unique_ptr pHintTables( new CPDF_HintTables(this, pDict)); - nonstd::unique_ptr> pHintStream( + std::unique_ptr> pHintStream( ParseIndirectObjectAt(szHSStart, 0)); CPDF_Stream* pStream = ToStream(pHintStream.get()); if (pStream && pHintTables->LoadHintStream(pStream)) @@ -3981,7 +3981,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) { } ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); m_syntaxParser.InitParser(file.get(), 0); - nonstd::unique_ptr> pTrailer( + std::unique_ptr> pTrailer( m_syntaxParser.GetObject(nullptr, 0, 0)); if (!pTrailer) { m_Pos += m_syntaxParser.SavePos(); diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp index 3fd8dcf35a..3014ca280e 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp @@ -97,7 +97,7 @@ class CPDF_TestParser : public CPDF_Parser { // TODO(thestig) Using unique_ptr with ReleaseDeleter is still not ideal. // Come up or wait for something better. using ScopedFileStream = - nonstd::unique_ptr>; + std::unique_ptr>; TEST(fpdf_parser_parser, ReadHexString) { { diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp index 1c46583e59..6a821ec069 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp @@ -650,7 +650,7 @@ void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, return; } - nonstd::unique_ptr pTextClippingPath; + std::unique_ptr pTextClippingPath; for (int i = 0; i < textcount; ++i) { CPDF_TextObject* pText = ClipPath.GetText(i); if (pText) { @@ -811,7 +811,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); CFX_FxgeDevice bitmap_device; - nonstd::unique_ptr oriDevice; + std::unique_ptr oriDevice; if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { oriDevice.reset(new CFX_DIBitmap); if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) @@ -827,7 +827,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, CFX_Matrix new_matrix = *pObj2Device; new_matrix.TranslateI(-rect.left, -rect.top); new_matrix.Scale(scaleX, scaleY); - nonstd::unique_ptr pTextMask; + std::unique_ptr pTextMask; if (bTextClip) { pTextMask.reset(new CFX_DIBitmap); if (!pTextMask->Create(width, height, FXDIB_8bppMask)) @@ -861,7 +861,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, sizeof smask_matrix); smask_matrix.Concat(*pObj2Device); - nonstd::unique_ptr pSMaskSource( + std::unique_ptr pSMaskSource( LoadSMask(pSMaskDict, &rect, &smask_matrix)); if (pSMaskSource) bitmap->MultiplyAlpha(pSMaskSource.get()); @@ -896,7 +896,7 @@ CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); int width = FXSYS_round(bbox.Width() * scaleX); int height = FXSYS_round(bbox.Height() * scaleY); - nonstd::unique_ptr pBackdrop(new CFX_DIBitmap); + std::unique_ptr pBackdrop(new CFX_DIBitmap); if (bBackAlphaRequired && !m_bDropObjects) pBackdrop->Create(width, height, FXDIB_Argb); else @@ -1190,7 +1190,7 @@ CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { return pTransferCounter->AddRef(); } - nonstd::unique_ptr pFuncs[3]; + std::unique_ptr pFuncs[3]; FX_BOOL bUniTransfer = TRUE; FX_BOOL bIdentity = TRUE; if (CPDF_Array* pArray = pObj->AsArray()) { diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp index d39d30f2a3..640adb14da 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -107,7 +107,7 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, int back_left, back_top; FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), top + pDIBitmap->GetHeight()); - nonstd::unique_ptr pBackdrop( + std::unique_ptr pBackdrop( GetBackdrop(m_pCurObj, rect, back_left, back_top, blend_mode > FXDIB_BLEND_NORMAL && bIsolated)); if (!pBackdrop) @@ -123,7 +123,7 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, pDIBitmap, mask_argb, 0, 0, blend_mode); } - nonstd::unique_ptr pBackdrop1(new CFX_DIBitmap); + std::unique_ptr pBackdrop1(new CFX_DIBitmap); pBackdrop1->Create(pBackdrop->GetWidth(), pBackdrop->GetHeight(), FXDIB_Rgb32); pBackdrop1->Clear((FX_DWORD)-1); @@ -760,7 +760,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() { FX_RECT dest_clip( dest_rect.left - image_rect.left, dest_rect.top - image_rect.top, dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top); - nonstd::unique_ptr pStretched( + std::unique_ptr pStretched( m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip)); if (pStretched) { m_pRenderStatus->CompositeDIBitmap(pStretched.get(), dest_rect.left, @@ -785,7 +785,7 @@ FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) { int left, top; - nonstd::unique_ptr pTransformed( + std::unique_ptr pTransformed( pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); if (!pTransformed) return TRUE; @@ -874,7 +874,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, if (!pGroup) { return NULL; } - nonstd::unique_ptr pFunc; + std::unique_ptr pFunc; CPDF_Object* pFuncObj = pSMaskDict->GetElementValue("TR"); if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) pFunc.reset(CPDF_Function::Load(pFuncObj)); @@ -947,7 +947,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0, pCS ? pCS->GetFamily() : 0, bLuminosity); status.RenderObjectList(&form, &matrix); - nonstd::unique_ptr pMask(new CFX_DIBitmap); + std::unique_ptr pMask(new CFX_DIBitmap); if (!pMask->Create(width, height, FXDIB_8bppMask)) return nullptr; diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 6bb8033686..c74aea9a21 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -6,6 +6,7 @@ #include "render_int.h" +#include #include #include "core/include/fpdfapi/fpdf_module.h" @@ -15,7 +16,6 @@ #include "core/include/fxcrt/fx_safe_types.h" #include "core/include/fxge/fx_ge.h" #include "core/src/fpdfapi/fpdf_page/pageint.h" -#include "third_party/base/nonstd_unique_ptr.h" namespace { @@ -63,7 +63,7 @@ bool IsAllowedBPCValue(int bpc) { return bpc == 1 || bpc == 2 || bpc == 4 || bpc == 8 || bpc == 16; } -// Wrapper class to use with nonstd::unique_ptr for CJPX_Decoder. +// Wrapper class to use with std::unique_ptr for CJPX_Decoder. class JpxBitMapContext { public: explicit JpxBitMapContext(ICodec_JpxModule* jpx_module) @@ -199,7 +199,7 @@ CFX_DIBitmap* CPDF_DIBSource::GetBitmap() const { return m_pCachedBitmap ? m_pCachedBitmap.get() : Clone(); } void CPDF_DIBSource::ReleaseBitmap(CFX_DIBitmap* pBitmap) const { - if (pBitmap && pBitmap != m_pCachedBitmap) { + if (pBitmap && pBitmap != m_pCachedBitmap.get()) { delete pBitmap; } } @@ -682,8 +682,7 @@ void CPDF_DIBSource::LoadJpxBitmap() { if (!pJpxModule) return; - nonstd::unique_ptr context( - new JpxBitMapContext(pJpxModule)); + std::unique_ptr context(new JpxBitMapContext(pJpxModule)); context->set_decoder(pJpxModule->CreateDecoder( m_pStreamAcc->GetData(), m_pStreamAcc->GetSize(), m_pColorSpace)); if (!context->decoder()) diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h index 6a63f61c06..5530754ab0 100644 --- a/core/src/fpdfapi/fpdf_render/render_int.h +++ b/core/src/fpdfapi/fpdf_render/render_int.h @@ -8,10 +8,10 @@ #define CORE_SRC_FPDFAPI_FPDF_RENDER_RENDER_INT_H_ #include +#include #include "core/include/fpdfapi/fpdf_pageobj.h" #include "core/include/fpdfapi/fpdf_render.h" -#include "third_party/base/nonstd_unique_ptr.h" class CFX_GlyphBitmap; class CFX_ImageTransformer; @@ -254,7 +254,7 @@ class CPDF_RenderStatus { const CPDF_PageObject* m_pStopObj; CPDF_GraphicStates m_InitialStates; int m_HalftoneLimit; - nonstd::unique_ptr m_pObjectRenderer; + std::unique_ptr m_pObjectRenderer; FX_BOOL m_bPrint; int m_Transparency; int m_DitherBits; @@ -392,7 +392,7 @@ class CPDF_ScaledRenderBuffer { CPDF_RenderContext* m_pContext; FX_RECT m_Rect; const CPDF_PageObject* m_pObject; - nonstd::unique_ptr m_pBitmapDevice; + std::unique_ptr m_pBitmapDevice; CFX_Matrix m_Matrix; }; @@ -414,7 +414,7 @@ class CPDF_DeviceBuffer { CPDF_RenderContext* m_pContext; FX_RECT m_Rect; const CPDF_PageObject* m_pObject; - nonstd::unique_ptr m_pBitmap; + std::unique_ptr m_pBitmap; CFX_Matrix m_Matrix; }; @@ -589,7 +589,7 @@ class CPDF_DIBSource : public CFX_DIBSource { DIB_COMP_DATA* m_pCompData; uint8_t* m_pLineBuf; uint8_t* m_pMaskedLine; - nonstd::unique_ptr m_pCachedBitmap; + std::unique_ptr m_pCachedBitmap; ICodec_ScanlineDecoder* m_pDecoder; }; diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp index f4a75e6afc..814496ff7f 100644 --- a/core/src/fpdfdoc/doc_annot.cpp +++ b/core/src/fpdfdoc/doc_annot.cpp @@ -6,7 +6,6 @@ #include "core/include/fpdfapi/fpdf_pageobj.h" #include "core/include/fpdfdoc/fpdf_doc.h" -#include "third_party/base/nonstd_unique_ptr.h" CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) : m_pDocument(pPage->m_pDocument) { diff --git a/core/src/fpdfdoc/doc_bookmark.cpp b/core/src/fpdfdoc/doc_bookmark.cpp index c59b1955a8..b435fc619c 100644 --- a/core/src/fpdfdoc/doc_bookmark.cpp +++ b/core/src/fpdfdoc/doc_bookmark.cpp @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include #include #include "core/include/fpdfdoc/fpdf_doc.h" -#include "third_party/base/nonstd_unique_ptr.h" CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild( const CPDF_Bookmark& parent) const { @@ -60,7 +60,7 @@ CFX_WideString CPDF_Bookmark::GetTitle() const { if (!len) { return CFX_WideString(); } - nonstd::unique_ptr buf(new FX_WCHAR[len]); + std::unique_ptr buf(new FX_WCHAR[len]); for (int i = 0; i < len; i++) { FX_WCHAR w = title[i]; buf[i] = w > 0x20 ? w : 0x20; diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp index 1e56bf901d..4aea797c39 100644 --- a/core/src/fpdftext/fpdf_text.cpp +++ b/core/src/fpdftext/fpdf_text.cpp @@ -4,6 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include +#include +#include + #include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_pageobj.h" #include "core/include/fpdfapi/fpdf_resource.h" @@ -11,12 +15,8 @@ #include "core/include/fxcrt/fx_bidi.h" #include "core/include/fxcrt/fx_ucd.h" #include "text_int.h" -#include "third_party/base/nonstd_unique_ptr.h" #include "txtproc.h" -#include -#include - CFX_ByteString CharFromUnicodeAlt(FX_WCHAR unicode, int destcp, const FX_CHAR* defchar) { @@ -314,7 +314,7 @@ void NormalizeString(CFX_WideString& str) { return; } CFX_WideString sBuffer; - nonstd::unique_ptr pBidiChar(new CFX_BidiChar); + std::unique_ptr pBidiChar(new CFX_BidiChar); CFX_WordArray order; FX_BOOL bR2L = FALSE; int32_t start = 0, count = 0, i = 0; diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp index d7a9c47519..cf6cde1169 100644 --- a/core/src/fpdftext/fpdf_text_int.cpp +++ b/core/src/fpdftext/fpdf_text_int.cpp @@ -4,9 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include #include #include -#include +#include #include "core/include/fpdfapi/fpdf_module.h" #include "core/include/fpdfapi/fpdf_page.h" @@ -17,7 +18,6 @@ #include "core/include/fxcrt/fx_ext.h" #include "core/include/fxcrt/fx_ucd.h" #include "text_int.h" -#include "third_party/base/nonstd_unique_ptr.h" namespace { @@ -1053,7 +1053,7 @@ void CPDF_TextPage::CloseTempLine() { if (count1 <= 0) { return; } - nonstd::unique_ptr pBidiChar(new CFX_BidiChar); + std::unique_ptr pBidiChar(new CFX_BidiChar); CFX_WideString str = m_TempTextBuf.GetWideString(); CFX_WordArray order; FX_BOOL bR2L = FALSE; @@ -1441,7 +1441,7 @@ void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend, FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, const CPDF_Font* pFont, int nItems) const { - nonstd::unique_ptr pBidiChar(new CFX_BidiChar); + std::unique_ptr pBidiChar(new CFX_BidiChar); int32_t nR2L = 0; int32_t nL2R = 0; int32_t start = 0, count = 0; diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h index 0f2d565046..91062bb69e 100644 --- a/core/src/fxcodec/codec/codec_int.h +++ b/core/src/fxcodec/codec/codec_int.h @@ -8,12 +8,13 @@ #define CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ #include + #include #include +#include #include "core/include/fxcodec/fx_codec.h" #include "core/src/fxcodec/jbig2/JBig2_Context.h" -#include "third_party/base/nonstd_unique_ptr.h" #include "third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T. class CFX_IccProfileCache; @@ -78,7 +79,7 @@ class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { const int m_Height; const FX_DWORD m_Pitch; int m_nCachedLines; - nonstd::unique_ptr m_Data; + std::unique_ptr m_Data; }; virtual FX_BOOL v_Rewind() = 0; @@ -98,7 +99,7 @@ class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { FX_BOOL m_bColorTransformed; int m_NextLine; uint8_t* m_pLastScanline; - nonstd::unique_ptr m_pDataCache; + std::unique_ptr m_pDataCache; }; class CCodec_FaxModule : public ICodec_FaxModule { diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp index b7b5563b29..3ac2f79312 100644 --- a/core/src/fxcodec/codec/fx_codec.cpp +++ b/core/src/fxcodec/codec/fx_codec.cpp @@ -134,7 +134,7 @@ void CCodec_ScanlineDecoder::DownScale(int dest_width, int dest_height) { return; } - nonstd::unique_ptr cache( + std::unique_ptr cache( new ImageDataCache(m_OutputWidth, m_OutputHeight, m_Pitch)); if (!cache->AllocateCache()) return; diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp index b293781318..17f20da1de 100644 --- a/core/src/fxcodec/codec/fx_codec_flate.cpp +++ b/core/src/fxcodec/codec/fx_codec_flate.cpp @@ -5,9 +5,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "codec_int.h" + +#include + #include "core/include/fxcodec/fx_codec.h" #include "core/include/fxcodec/fx_codec_flate.h" -#include "third_party/base/nonstd_unique_ptr.h" #include "third_party/zlib_v128/zlib.h" extern "C" { @@ -639,7 +641,7 @@ void FlateUncompress(const uint8_t* src_buf, if (!context) return; - nonstd::unique_ptr guess_buf( + std::unique_ptr guess_buf( FX_Alloc(uint8_t, guess_size + 1)); guess_buf.get()[guess_size] = '\0'; @@ -933,7 +935,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, } if (bLZW) { { - nonstd::unique_ptr decoder(new CLZWDecoder); + std::unique_ptr decoder(new CLZWDecoder); dest_size = (FX_DWORD)-1; offset = src_size; int err = decoder->Decode(NULL, dest_size, src_buf, offset, bEarlyChange); @@ -942,7 +944,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, } } { - nonstd::unique_ptr decoder(new CLZWDecoder); + std::unique_ptr decoder(new CLZWDecoder); dest_buf = FX_Alloc(uint8_t, dest_size + 1); dest_buf[dest_size] = '\0'; decoder->Decode(dest_buf, dest_size, src_buf, offset, bEarlyChange); diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp index d3276450c9..c185d224f0 100644 --- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -865,7 +865,7 @@ CCodec_JpxModule::~CCodec_JpxModule() { CJPX_Decoder* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, CPDF_ColorSpace* cs) { - nonstd::unique_ptr decoder(new CJPX_Decoder(cs)); + std::unique_ptr decoder(new CJPX_Decoder(cs)); return decoder->Init(src_buf, src_size) ? decoder.release() : nullptr; } diff --git a/core/src/fxcodec/jbig2/JBig2_Context.cpp b/core/src/fxcodec/jbig2/JBig2_Context.cpp index 9503fed95e..566b84e54d 100644 --- a/core/src/fxcodec/jbig2/JBig2_Context.cpp +++ b/core/src/fxcodec/jbig2/JBig2_Context.cpp @@ -138,7 +138,7 @@ int32_t CJBig2_Context::decode_EmbedOrgnazation(IFX_Pause* pPause) { int32_t CJBig2_Context::decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause) { int32_t nRet; while (m_pStream->getByteLeft() > JBIG2_MIN_SEGMENT_SIZE) { - nonstd::unique_ptr pSegment(new CJBig2_Segment); + std::unique_ptr pSegment(new CJBig2_Segment); nRet = parseSegmentHeader(pSegment.get()); if (nRet != JBIG2_SUCCESS) { return nRet; @@ -377,7 +377,7 @@ int32_t CJBig2_Context::ProcessingParseSegmentData(CJBig2_Segment* pSegment, return parseGenericRefinementRegion(pSegment); case 48: { FX_WORD wTemp; - nonstd::unique_ptr pPageInfo(new JBig2PageInfo); + std::unique_ptr pPageInfo(new JBig2PageInfo); if (m_pStream->readInteger(&pPageInfo->m_dwWidth) != 0 || m_pStream->readInteger(&pPageInfo->m_dwHeight) != 0 || m_pStream->readInteger(&pPageInfo->m_dwResolutionX) != 0 || @@ -436,7 +436,7 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment, if (m_pStream->readShortInteger(&wFlags) != 0) return JBIG2_ERROR_TOO_SHORT; - nonstd::unique_ptr pSymbolDictDecoder(new CJBig2_SDDProc); + std::unique_ptr pSymbolDictDecoder(new CJBig2_SDDProc); pSymbolDictDecoder->SDHUFF = wFlags & 0x0001; pSymbolDictDecoder->SDREFAGG = (wFlags >> 1) & 0x0001; pSymbolDictDecoder->SDTEMPLATE = (wFlags >> 10) & 0x0003; @@ -482,7 +482,7 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment, } } - nonstd::unique_ptr SDINSYMS; + std::unique_ptr SDINSYMS; if (pSymbolDictDecoder->SDNUMINSYMS != 0) { SDINSYMS.reset(FX_Alloc(CJBig2_Image*, pSymbolDictDecoder->SDNUMINSYMS)); FX_DWORD dwTemp = 0; @@ -499,11 +499,11 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment, } pSymbolDictDecoder->SDINSYMS = SDINSYMS.get(); - nonstd::unique_ptr Table_B1; - nonstd::unique_ptr Table_B2; - nonstd::unique_ptr Table_B3; - nonstd::unique_ptr Table_B4; - nonstd::unique_ptr Table_B5; + std::unique_ptr Table_B1; + std::unique_ptr Table_B2; + std::unique_ptr Table_B3; + std::unique_ptr Table_B4; + std::unique_ptr Table_B5; if (pSymbolDictDecoder->SDHUFF == 1) { if (cSDHUFFDH == 2 || cSDHUFFDW == 2) return JBIG2_ERROR_FATAL; @@ -607,7 +607,7 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment, for (auto it = m_pSymbolDictCache->begin(); it != m_pSymbolDictCache->end(); ++it) { if (it->first == key) { - nonstd::unique_ptr copy(it->second->DeepCopy()); + std::unique_ptr copy(it->second->DeepCopy()); pSegment->m_Result.sd = copy.release(); m_pSymbolDictCache->push_front(*it); m_pSymbolDictCache->erase(it); @@ -618,7 +618,7 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment, } if (!cache_hit) { if (bUseGbContext) { - nonstd::unique_ptr pArithDecoder( + std::unique_ptr pArithDecoder( new CJBig2_ArithDecoder(m_pStream.get())); pSegment->m_Result.sd = pSymbolDictDecoder->decode_Arith( pArithDecoder.get(), &gbContext, &grContext); @@ -635,7 +635,7 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment, m_pStream->alignByte(); } if (m_bIsGlobal && kSymbolDictCacheMaxSize > 0) { - nonstd::unique_ptr value = + std::unique_ptr value = pSegment->m_Result.sd->DeepCopy(); while (m_pSymbolDictCache->size() >= kSymbolDictCacheMaxSize) { delete m_pSymbolDictCache->back().second; @@ -661,7 +661,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) { return JBIG2_ERROR_TOO_SHORT; } - nonstd::unique_ptr pTRD(new CJBig2_TRDProc); + std::unique_ptr pTRD(new CJBig2_TRDProc); pTRD->SBW = ri.width; pTRD->SBH = ri.height; pTRD->SBHUFF = wFlags & 0x0001; @@ -722,7 +722,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) { } } - nonstd::unique_ptr SBSYMS; + std::unique_ptr SBSYMS; if (pTRD->SBNUMSYMS > 0) { SBSYMS.reset(FX_Alloc(CJBig2_Image*, pTRD->SBNUMSYMS)); dwTemp = 0; @@ -741,7 +741,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) { pTRD->SBSYMS = NULL; } - nonstd::unique_ptr SBSYMCODES; + std::unique_ptr SBSYMCODES; if (pTRD->SBHUFF == 1) { SBSYMCODES.reset( decodeSymbolIDHuffmanTable(m_pStream.get(), pTRD->SBNUMSYMS)); @@ -758,17 +758,17 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) { pTRD->SBSYMCODELEN = (uint8_t)dwTemp; } - nonstd::unique_ptr Table_B1; - nonstd::unique_ptr Table_B6; - nonstd::unique_ptr Table_B7; - nonstd::unique_ptr Table_B8; - nonstd::unique_ptr Table_B9; - nonstd::unique_ptr Table_B10; - nonstd::unique_ptr Table_B11; - nonstd::unique_ptr Table_B12; - nonstd::unique_ptr Table_B13; - nonstd::unique_ptr Table_B14; - nonstd::unique_ptr Table_B15; + std::unique_ptr Table_B1; + std::unique_ptr Table_B6; + std::unique_ptr Table_B7; + std::unique_ptr Table_B8; + std::unique_ptr Table_B9; + std::unique_ptr Table_B10; + std::unique_ptr Table_B11; + std::unique_ptr Table_B12; + std::unique_ptr Table_B13; + std::unique_ptr Table_B14; + std::unique_ptr Table_B15; if (pTRD->SBHUFF == 1) { if (cSBHUFFFS == 2 || cSBHUFFRDW == 2 || cSBHUFFRDH == 2 || cSBHUFFRDX == 2 || cSBHUFFRDY == 2) { @@ -929,14 +929,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) { pTRD->SBHUFFRSIZE = pSeg->m_Result.ht; } } - nonstd::unique_ptr grContext; + std::unique_ptr grContext; if (pTRD->SBREFINE == 1) { const size_t size = GetRefAggContextSize(pTRD->SBRTEMPLATE); grContext.reset(FX_Alloc(JBig2ArithCtx, size)); JBIG2_memset(grContext.get(), 0, sizeof(JBig2ArithCtx) * size); } if (pTRD->SBHUFF == 0) { - nonstd::unique_ptr pArithDecoder( + std::unique_ptr pArithDecoder( new CJBig2_ArithDecoder(m_pStream.get())); pSegment->m_nResultType = JBIG2_IMAGE_POINTER; pSegment->m_Result.im = @@ -972,7 +972,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) { int32_t CJBig2_Context::parsePatternDict(CJBig2_Segment* pSegment, IFX_Pause* pPause) { uint8_t cFlags; - nonstd::unique_ptr pPDD(new CJBig2_PDDProc); + std::unique_ptr pPDD(new CJBig2_PDDProc); if (m_pStream->read1Byte(&cFlags) != 0 || m_pStream->read1Byte(&pPDD->HDPW) != 0 || m_pStream->read1Byte(&pPDD->HDPH) != 0 || @@ -987,10 +987,10 @@ int32_t CJBig2_Context::parsePatternDict(CJBig2_Segment* pSegment, pSegment->m_nResultType = JBIG2_PATTERN_DICT_POINTER; if (pPDD->HDMMR == 0) { const size_t size = GetHuffContextSize(pPDD->HDTEMPLATE); - nonstd::unique_ptr gbContext( + std::unique_ptr gbContext( FX_Alloc(JBig2ArithCtx, size)); JBIG2_memset(gbContext.get(), 0, sizeof(JBig2ArithCtx) * size); - nonstd::unique_ptr pArithDecoder( + std::unique_ptr pArithDecoder( new CJBig2_ArithDecoder(m_pStream.get())); pSegment->m_Result.pd = pPDD->decode_Arith(pArithDecoder.get(), gbContext.get(), pPause); @@ -1012,7 +1012,7 @@ int32_t CJBig2_Context::parseHalftoneRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause) { uint8_t cFlags; JBig2RegionInfo ri; - nonstd::unique_ptr pHRD(new CJBig2_HTRDProc); + std::unique_ptr pHRD(new CJBig2_HTRDProc); if (parseRegionInfo(&ri) != JBIG2_SUCCESS || m_pStream->read1Byte(&cFlags) != 0 || m_pStream->readInteger(&pHRD->HGW) != 0 || @@ -1053,10 +1053,10 @@ int32_t CJBig2_Context::parseHalftoneRegion(CJBig2_Segment* pSegment, pSegment->m_nResultType = JBIG2_IMAGE_POINTER; if (pHRD->HMMR == 0) { const size_t size = GetHuffContextSize(pHRD->HTEMPLATE); - nonstd::unique_ptr gbContext( + std::unique_ptr gbContext( FX_Alloc(JBig2ArithCtx, size)); JBIG2_memset(gbContext.get(), 0, sizeof(JBig2ArithCtx) * size); - nonstd::unique_ptr pArithDecoder( + std::unique_ptr pArithDecoder( new CJBig2_ArithDecoder(m_pStream.get())); pSegment->m_Result.im = pHRD->decode_Arith(pArithDecoder.get(), gbContext.get(), pPause); @@ -1090,7 +1090,7 @@ int32_t CJBig2_Context::parseHalftoneRegion(CJBig2_Segment* pSegment, int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause) { if (!m_pGRD) { - nonstd::unique_ptr pGRD(new CJBig2_GRDProc); + std::unique_ptr pGRD(new CJBig2_GRDProc); uint8_t cFlags; if (parseRegionInfo(&m_ri) != JBIG2_SUCCESS || m_pStream->read1Byte(&cFlags) != 0) { @@ -1203,7 +1203,7 @@ int32_t CJBig2_Context::parseGenericRefinementRegion(CJBig2_Segment* pSegment) { m_pStream->read1Byte(&cFlags) != 0) { return JBIG2_ERROR_TOO_SHORT; } - nonstd::unique_ptr pGRRD(new CJBig2_GRRDProc); + std::unique_ptr pGRRD(new CJBig2_GRRDProc); pGRRD->GRW = ri.width; pGRRD->GRH = ri.height; pGRRD->GRTEMPLATE = cFlags & 0x01; @@ -1237,10 +1237,10 @@ int32_t CJBig2_Context::parseGenericRefinementRegion(CJBig2_Segment* pSegment) { pGRRD->GRREFERENCEDX = 0; pGRRD->GRREFERENCEDY = 0; const size_t size = GetRefAggContextSize(pGRRD->GRTEMPLATE); - nonstd::unique_ptr grContext( + std::unique_ptr grContext( FX_Alloc(JBig2ArithCtx, size)); JBIG2_memset(grContext.get(), 0, sizeof(JBig2ArithCtx) * size); - nonstd::unique_ptr pArithDecoder( + std::unique_ptr pArithDecoder( new CJBig2_ArithDecoder(m_pStream.get())); pSegment->m_nResultType = JBIG2_IMAGE_POINTER; pSegment->m_Result.im = pGRRD->decode(pArithDecoder.get(), grContext.get()); @@ -1268,7 +1268,7 @@ int32_t CJBig2_Context::parseGenericRefinementRegion(CJBig2_Segment* pSegment) { int32_t CJBig2_Context::parseTable(CJBig2_Segment* pSegment) { pSegment->m_nResultType = JBIG2_HUFFMAN_TABLE_POINTER; pSegment->m_Result.ht = nullptr; - nonstd::unique_ptr pHuff( + std::unique_ptr pHuff( new CJBig2_HuffmanTable(m_pStream.get())); if (!pHuff->IsOK()) return JBIG2_ERROR_FATAL; @@ -1301,7 +1301,7 @@ JBig2HuffmanCode* CJBig2_Context::decodeSymbolIDHuffmanTable( } huffman_assign_code(runcodes, runcodes_len, kRunCodesSize); - nonstd::unique_ptr SBSYMCODES( + std::unique_ptr SBSYMCODES( FX_Alloc(JBig2HuffmanCode, SBNUMSYMS)); int32_t run; int32_t i = 0; diff --git a/core/src/fxcodec/jbig2/JBig2_Context.h b/core/src/fxcodec/jbig2/JBig2_Context.h index 1b8b391f9d..dd63bcd1b0 100644 --- a/core/src/fxcodec/jbig2/JBig2_Context.h +++ b/core/src/fxcodec/jbig2/JBig2_Context.h @@ -8,6 +8,7 @@ #define CORE_SRC_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ #include +#include #include #include "JBig2_List.h" @@ -15,7 +16,6 @@ #include "JBig2_Segment.h" #include "core/include/fpdfapi/fpdf_objects.h" #include "core/include/fxcodec/fx_codec_def.h" -#include "third_party/base/nonstd_unique_ptr.h" class CJBig2_ArithDecoder; class CJBig2_GRDProc; @@ -110,20 +110,20 @@ class CJBig2_Context { private: CJBig2_Context* m_pGlobalContext; - nonstd::unique_ptr m_pStream; + std::unique_ptr m_pStream; CJBig2_List m_SegmentList; CJBig2_List m_PageInfoList; - nonstd::unique_ptr m_pPage; + std::unique_ptr m_pPage; size_t m_nSegmentDecoded; bool m_bInPage; bool m_bBufSpecified; int32_t m_PauseStep; IFX_Pause* m_pPause; FXCODEC_STATUS m_ProcessingStatus; - nonstd::unique_ptr m_pArithDecoder; - nonstd::unique_ptr m_pGRD; + std::unique_ptr m_pArithDecoder; + std::unique_ptr m_pGRD; JBig2ArithCtx* m_gbContext; - nonstd::unique_ptr m_pSegment; + std::unique_ptr m_pSegment; FX_DWORD m_dwOffset; JBig2RegionInfo m_ri; std::list* const m_pSymbolDictCache; diff --git a/core/src/fxcodec/jbig2/JBig2_GrdProc.cpp b/core/src/fxcodec/jbig2/JBig2_GrdProc.cpp index fc654c0da8..803e4a70d4 100644 --- a/core/src/fxcodec/jbig2/JBig2_GrdProc.cpp +++ b/core/src/fxcodec/jbig2/JBig2_GrdProc.cpp @@ -6,11 +6,12 @@ #include "JBig2_GrdProc.h" +#include + #include "JBig2_ArithDecoder.h" #include "JBig2_BitStream.h" #include "JBig2_Image.h" #include "core/include/fxcodec/fx_codec.h" -#include "third_party/base/nonstd_unique_ptr.h" CJBig2_GRDProc::CJBig2_GRDProc() : m_loopIndex(0), @@ -71,7 +72,7 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt3( int32_t nStride, nStride2, k; int32_t nLineBytes, nBitsLeft, cc; LTP = 0; - nonstd::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); + std::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); if (!GBREG->m_pData) return nullptr; @@ -158,7 +159,7 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_unopt( FX_DWORD CONTEXT; FX_DWORD line1, line2, line3; LTP = 0; - nonstd::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); + std::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); GBREG->fill(0); for (FX_DWORD h = 0; h < GBH; h++) { if (TPGDON) { @@ -209,7 +210,7 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt3( int32_t nStride, nStride2, k; int32_t nLineBytes, nBitsLeft, cc; LTP = 0; - nonstd::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); + std::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); if (!GBREG->m_pData) return nullptr; @@ -295,7 +296,7 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_unopt( FX_DWORD CONTEXT; FX_DWORD line1, line2, line3; LTP = 0; - nonstd::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); + std::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); GBREG->fill(0); for (FX_DWORD h = 0; h < GBH; h++) { if (TPGDON) { @@ -343,7 +344,7 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt3( int32_t nStride, nStride2, k; int32_t nLineBytes, nBitsLeft, cc; LTP = 0; - nonstd::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); + std::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); if (!GBREG->m_pData) return nullptr; @@ -429,7 +430,7 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_unopt( FX_DWORD CONTEXT; FX_DWORD line1, line2, line3; LTP = 0; - nonstd::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); + std::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); GBREG->fill(0); for (FX_DWORD h = 0; h < GBH; h++) { if (TPGDON) { @@ -476,7 +477,7 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_opt3( int32_t nStride, k; int32_t nLineBytes, nBitsLeft, cc; LTP = 0; - nonstd::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); + std::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); if (!GBREG->m_pData) return nullptr; @@ -548,7 +549,7 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_unopt( FX_DWORD CONTEXT; FX_DWORD line1, line2; LTP = 0; - nonstd::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); + std::unique_ptr GBREG(new CJBig2_Image(GBW, GBH)); GBREG->fill(0); for (FX_DWORD h = 0; h < GBH; h++) { if (TPGDON) { diff --git a/core/src/fxcodec/jbig2/JBig2_GrrdProc.cpp b/core/src/fxcodec/jbig2/JBig2_GrrdProc.cpp index 549669a72f..e1c5e19fa6 100644 --- a/core/src/fxcodec/jbig2/JBig2_GrrdProc.cpp +++ b/core/src/fxcodec/jbig2/JBig2_GrrdProc.cpp @@ -6,10 +6,11 @@ #include "JBig2_GrrdProc.h" +#include + #include "JBig2_ArithDecoder.h" #include "JBig2_BitStream.h" #include "JBig2_Image.h" -#include "third_party/base/nonstd_unique_ptr.h" CJBig2_Image* CJBig2_GRRDProc::decode(CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* grContext) { @@ -37,7 +38,7 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_unopt( FX_DWORD CONTEXT; FX_DWORD line1, line2, line3, line4, line5; LTP = 0; - nonstd::unique_ptr GRREG(new CJBig2_Image(GRW, GRH)); + std::unique_ptr GRREG(new CJBig2_Image(GRW, GRH)); GRREG->fill(0); for (FX_DWORD h = 0; h < GRH; h++) { if (TPGRON) { @@ -162,7 +163,7 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_opt( GRW = (int32_t)CJBig2_GRRDProc::GRW; GRH = (int32_t)CJBig2_GRRDProc::GRH; LTP = 0; - nonstd::unique_ptr GRREG(new CJBig2_Image(GRW, GRH)); + std::unique_ptr GRREG(new CJBig2_Image(GRW, GRH)); if (!GRREG->m_pData) return nullptr; @@ -289,7 +290,7 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template1_unopt( FX_DWORD CONTEXT; FX_DWORD line1, line2, line3, line4, line5; LTP = 0; - nonstd::unique_ptr GRREG(new CJBig2_Image(GRW, GRH)); + std::unique_ptr GRREG(new CJBig2_Image(GRW, GRH)); GRREG->fill(0); for (FX_DWORD h = 0; h < GRH; h++) { if (TPGRON) { @@ -400,7 +401,7 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template1_opt( GRW = (int32_t)CJBig2_GRRDProc::GRW; GRH = (int32_t)CJBig2_GRRDProc::GRH; LTP = 0; - nonstd::unique_ptr GRREG(new CJBig2_Image(GRW, GRH)); + std::unique_ptr GRREG(new CJBig2_Image(GRW, GRH)); if (!GRREG->m_pData) return nullptr; diff --git a/core/src/fxcodec/jbig2/JBig2_GsidProc.cpp b/core/src/fxcodec/jbig2/JBig2_GsidProc.cpp index 53af1fd16e..5871efb16d 100644 --- a/core/src/fxcodec/jbig2/JBig2_GsidProc.cpp +++ b/core/src/fxcodec/jbig2/JBig2_GsidProc.cpp @@ -6,17 +6,18 @@ #include "JBig2_GsidProc.h" +#include + #include "JBig2_BitStream.h" #include "JBig2_GrdProc.h" #include "JBig2_Image.h" #include "JBig2_List.h" #include "core/include/fxcrt/fx_basic.h" -#include "third_party/base/nonstd_unique_ptr.h" FX_DWORD* CJBig2_GSIDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* gbContext, IFX_Pause* pPause) { - nonstd::unique_ptr pGRD(new CJBig2_GRDProc()); + std::unique_ptr pGRD(new CJBig2_GRDProc()); pGRD->MMR = GSMMR; pGRD->GBW = GSW; pGRD->GBH = GSH; @@ -55,7 +56,7 @@ FX_DWORD* CJBig2_GSIDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, if (i < GSBPP - 1) pImage->composeFrom(0, 0, GSPLANES.get(i + 1), JBIG2_COMPOSE_XOR); } - nonstd::unique_ptr GSVALS( + std::unique_ptr GSVALS( FX_Alloc2D(FX_DWORD, GSW, GSH)); JBIG2_memset(GSVALS.get(), 0, sizeof(FX_DWORD) * GSW * GSH); for (FX_DWORD y = 0; y < GSH; ++y) { @@ -70,12 +71,12 @@ FX_DWORD* CJBig2_GSIDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, FX_DWORD* CJBig2_GSIDProc::decode_MMR(CJBig2_BitStream* pStream, IFX_Pause* pPause) { - nonstd::unique_ptr pGRD(new CJBig2_GRDProc()); + std::unique_ptr pGRD(new CJBig2_GRDProc()); pGRD->MMR = GSMMR; pGRD->GBW = GSW; pGRD->GBH = GSH; - nonstd::unique_ptr GSPLANES(FX_Alloc(CJBig2_Image*, GSBPP)); + std::unique_ptr GSPLANES(FX_Alloc(CJBig2_Image*, GSBPP)); JBIG2_memset(GSPLANES.get(), 0, sizeof(CJBig2_Image*) * GSBPP); FXCODEC_STATUS status = pGRD->Start_decode_MMR(&GSPLANES.get()[GSBPP - 1], pStream, nullptr); @@ -106,7 +107,7 @@ FX_DWORD* CJBig2_GSIDProc::decode_MMR(CJBig2_BitStream* pStream, JBIG2_COMPOSE_XOR); J = J - 1; } - nonstd::unique_ptr GSVALS(FX_Alloc2D(FX_DWORD, GSW, GSH)); + std::unique_ptr GSVALS(FX_Alloc2D(FX_DWORD, GSW, GSH)); JBIG2_memset(GSVALS.get(), 0, sizeof(FX_DWORD) * GSW * GSH); for (FX_DWORD y = 0; y < GSH; ++y) { for (FX_DWORD x = 0; x < GSW; ++x) { diff --git a/core/src/fxcodec/jbig2/JBig2_HtrdProc.cpp b/core/src/fxcodec/jbig2/JBig2_HtrdProc.cpp index 127ef0333c..377af58dfa 100644 --- a/core/src/fxcodec/jbig2/JBig2_HtrdProc.cpp +++ b/core/src/fxcodec/jbig2/JBig2_HtrdProc.cpp @@ -6,9 +6,10 @@ #include "JBig2_HtrdProc.h" +#include + #include "JBig2_GsidProc.h" #include "core/include/fxcrt/fx_basic.h" -#include "third_party/base/nonstd_unique_ptr.h" CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* gbContext, @@ -17,8 +18,8 @@ CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, int32_t x, y; FX_DWORD HBPP; FX_DWORD* GI; - nonstd::unique_ptr HSKIP; - nonstd::unique_ptr HTREG(new CJBig2_Image(HBW, HBH)); + std::unique_ptr HSKIP; + std::unique_ptr HTREG(new CJBig2_Image(HBW, HBH)); HTREG->fill(HDEFPIXEL); if (HENABLESKIP == 1) { HSKIP.reset(new CJBig2_Image(HGW, HGH)); @@ -39,7 +40,7 @@ CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, while ((FX_DWORD)(1 << HBPP) < HNUMPATS) { HBPP++; } - nonstd::unique_ptr pGID(new CJBig2_GSIDProc()); + std::unique_ptr pGID(new CJBig2_GSIDProc()); pGID->GSMMR = HMMR; pGID->GSW = HGW; pGID->GSH = HGH; @@ -71,13 +72,13 @@ CJBig2_Image* CJBig2_HTRDProc::decode_MMR(CJBig2_BitStream* pStream, FX_DWORD ng, mg; int32_t x, y; FX_DWORD* GI; - nonstd::unique_ptr HTREG(new CJBig2_Image(HBW, HBH)); + std::unique_ptr HTREG(new CJBig2_Image(HBW, HBH)); HTREG->fill(HDEFPIXEL); FX_DWORD HBPP = 1; while ((FX_DWORD)(1 << HBPP) < HNUMPATS) { HBPP++; } - nonstd::unique_ptr pGID(new CJBig2_GSIDProc()); + std::unique_ptr pGID(new CJBig2_GSIDProc()); pGID->GSMMR = HMMR; pGID->GSW = HGW; pGID->GSH = HGH; diff --git a/core/src/fxcodec/jbig2/JBig2_PddProc.cpp b/core/src/fxcodec/jbig2/JBig2_PddProc.cpp index fbe9e4b17f..179077466c 100644 --- a/core/src/fxcodec/jbig2/JBig2_PddProc.cpp +++ b/core/src/fxcodec/jbig2/JBig2_PddProc.cpp @@ -6,10 +6,11 @@ #include "JBig2_PddProc.h" +#include + #include "JBig2_GrdProc.h" #include "JBig2_Image.h" #include "JBig2_PatternDict.h" -#include "third_party/base/nonstd_unique_ptr.h" CJBig2_PatternDict* CJBig2_PDDProc::decode_Arith( CJBig2_ArithDecoder* pArithDecoder, @@ -17,12 +18,12 @@ CJBig2_PatternDict* CJBig2_PDDProc::decode_Arith( IFX_Pause* pPause) { FX_DWORD GRAY; CJBig2_Image* BHDC = nullptr; - nonstd::unique_ptr pDict(new CJBig2_PatternDict()); + std::unique_ptr pDict(new CJBig2_PatternDict()); pDict->NUMPATS = GRAYMAX + 1; pDict->HDPATS = FX_Alloc(CJBig2_Image*, pDict->NUMPATS); JBIG2_memset(pDict->HDPATS, 0, sizeof(CJBig2_Image*) * pDict->NUMPATS); - nonstd::unique_ptr pGRD(new CJBig2_GRDProc()); + std::unique_ptr pGRD(new CJBig2_GRDProc()); pGRD->MMR = HDMMR; pGRD->GBW = (GRAYMAX + 1) * HDPW; pGRD->GBH = HDPH; @@ -60,12 +61,12 @@ CJBig2_PatternDict* CJBig2_PDDProc::decode_MMR(CJBig2_BitStream* pStream, IFX_Pause* pPause) { FX_DWORD GRAY; CJBig2_Image* BHDC = nullptr; - nonstd::unique_ptr pDict(new CJBig2_PatternDict()); + std::unique_ptr pDict(new CJBig2_PatternDict()); pDict->NUMPATS = GRAYMAX + 1; pDict->HDPATS = FX_Alloc(CJBig2_Image*, pDict->NUMPATS); JBIG2_memset(pDict->HDPATS, 0, sizeof(CJBig2_Image*) * pDict->NUMPATS); - nonstd::unique_ptr pGRD(new CJBig2_GRDProc()); + std::unique_ptr pGRD(new CJBig2_GRDProc()); pGRD->MMR = HDMMR; pGRD->GBW = (GRAYMAX + 1) * HDPW; pGRD->GBH = HDPH; diff --git a/core/src/fxcodec/jbig2/JBig2_SddProc.cpp b/core/src/fxcodec/jbig2/JBig2_SddProc.cpp index e9ce932d91..faa70621ab 100644 --- a/core/src/fxcodec/jbig2/JBig2_SddProc.cpp +++ b/core/src/fxcodec/jbig2/JBig2_SddProc.cpp @@ -6,6 +6,7 @@ #include "core/src/fxcodec/jbig2/JBig2_SddProc.h" +#include #include #include "core/include/fxcrt/fx_basic.h" @@ -17,7 +18,6 @@ #include "core/src/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h" #include "core/src/fxcodec/jbig2/JBig2_SymbolDict.h" #include "core/src/fxcodec/jbig2/JBig2_TrdProc.h" -#include "third_party/base/nonstd_unique_ptr.h" CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( CJBig2_ArithDecoder* pArithDecoder, @@ -39,21 +39,21 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( uint8_t SBSYMCODELEN; int32_t RDXI, RDYI; CJBig2_Image** SBSYMS; - nonstd::unique_ptr IAID; - nonstd::unique_ptr pDict; - nonstd::unique_ptr IADH(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IADW(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IAAI(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IARDX(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IARDY(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IAEX(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IADT(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IAFS(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IADS(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IAIT(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IARI(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IARDW(new CJBig2_ArithIntDecoder); - nonstd::unique_ptr IARDH(new CJBig2_ArithIntDecoder); + std::unique_ptr IAID; + std::unique_ptr pDict; + std::unique_ptr IADH(new CJBig2_ArithIntDecoder); + std::unique_ptr IADW(new CJBig2_ArithIntDecoder); + std::unique_ptr IAAI(new CJBig2_ArithIntDecoder); + std::unique_ptr IARDX(new CJBig2_ArithIntDecoder); + std::unique_ptr IARDY(new CJBig2_ArithIntDecoder); + std::unique_ptr IAEX(new CJBig2_ArithIntDecoder); + std::unique_ptr IADT(new CJBig2_ArithIntDecoder); + std::unique_ptr IAFS(new CJBig2_ArithIntDecoder); + std::unique_ptr IADS(new CJBig2_ArithIntDecoder); + std::unique_ptr IAIT(new CJBig2_ArithIntDecoder); + std::unique_ptr IARI(new CJBig2_ArithIntDecoder); + std::unique_ptr IARDW(new CJBig2_ArithIntDecoder); + std::unique_ptr IARDH(new CJBig2_ArithIntDecoder); nTmp = 0; while ((FX_DWORD)(1 << nTmp) < (SDNUMINSYMS + SDNUMNEWSYMS)) { nTmp++; @@ -92,7 +92,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( } TOTWIDTH = TOTWIDTH + SYMWIDTH; if (SDREFAGG == 0) { - nonstd::unique_ptr pGRD(new CJBig2_GRDProc()); + std::unique_ptr pGRD(new CJBig2_GRDProc()); pGRD->MMR = 0; pGRD->GBW = SYMWIDTH; pGRD->GBH = HCHEIGHT; @@ -114,7 +114,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( } else { IAAI->decode(pArithDecoder, (int*)&REFAGGNINST); if (REFAGGNINST > 1) { - nonstd::unique_ptr pDecoder(new CJBig2_TRDProc()); + std::unique_ptr pDecoder(new CJBig2_TRDProc()); pDecoder->SBHUFF = SDHUFF; pDecoder->SBREFINE = 1; pDecoder->SBW = SYMWIDTH; @@ -139,35 +139,32 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( pDecoder->TRANSPOSED = 0; pDecoder->REFCORNER = JBIG2_CORNER_TOPLEFT; pDecoder->SBDSOFFSET = 0; - nonstd::unique_ptr SBHUFFFS( - new CJBig2_HuffmanTable(HuffmanTable_B6, - FX_ArraySize(HuffmanTable_B6), - HuffmanTable_HTOOB_B6)); - nonstd::unique_ptr SBHUFFDS( - new CJBig2_HuffmanTable(HuffmanTable_B8, - FX_ArraySize(HuffmanTable_B8), - HuffmanTable_HTOOB_B8)); - nonstd::unique_ptr SBHUFFDT( - new CJBig2_HuffmanTable(HuffmanTable_B11, - FX_ArraySize(HuffmanTable_B11), - HuffmanTable_HTOOB_B11)); - nonstd::unique_ptr SBHUFFRDW( + std::unique_ptr SBHUFFFS(new CJBig2_HuffmanTable( + HuffmanTable_B6, FX_ArraySize(HuffmanTable_B6), + HuffmanTable_HTOOB_B6)); + std::unique_ptr SBHUFFDS(new CJBig2_HuffmanTable( + HuffmanTable_B8, FX_ArraySize(HuffmanTable_B8), + HuffmanTable_HTOOB_B8)); + std::unique_ptr SBHUFFDT(new CJBig2_HuffmanTable( + HuffmanTable_B11, FX_ArraySize(HuffmanTable_B11), + HuffmanTable_HTOOB_B11)); + std::unique_ptr SBHUFFRDW( new CJBig2_HuffmanTable(HuffmanTable_B15, FX_ArraySize(HuffmanTable_B15), HuffmanTable_HTOOB_B15)); - nonstd::unique_ptr SBHUFFRDH( + std::unique_ptr SBHUFFRDH( new CJBig2_HuffmanTable(HuffmanTable_B15, FX_ArraySize(HuffmanTable_B15), HuffmanTable_HTOOB_B15)); - nonstd::unique_ptr SBHUFFRDX( + std::unique_ptr SBHUFFRDX( new CJBig2_HuffmanTable(HuffmanTable_B15, FX_ArraySize(HuffmanTable_B15), HuffmanTable_HTOOB_B15)); - nonstd::unique_ptr SBHUFFRDY( + std::unique_ptr SBHUFFRDY( new CJBig2_HuffmanTable(HuffmanTable_B15, FX_ArraySize(HuffmanTable_B15), HuffmanTable_HTOOB_B15)); - nonstd::unique_ptr SBHUFFRSIZE( + std::unique_ptr SBHUFFRSIZE( new CJBig2_HuffmanTable(HuffmanTable_B1, FX_ArraySize(HuffmanTable_B1), HuffmanTable_HTOOB_B1)); @@ -218,7 +215,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( FX_Free(SBSYMS); goto failed; } - nonstd::unique_ptr pGRRD(new CJBig2_GRRDProc()); + std::unique_ptr pGRRD(new CJBig2_GRRDProc()); pGRRD->GRW = SYMWIDTH; pGRRD->GRH = HCHEIGHT; pGRRD->GRTEMPLATE = SDRTEMPLATE; @@ -315,7 +312,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( FX_DWORD BMSIZE; FX_DWORD stride; CJBig2_Image** SBSYMS; - nonstd::unique_ptr pHuffmanDecoder( + std::unique_ptr pHuffmanDecoder( new CJBig2_HuffmanDecoder(pStream)); SDNEWSYMS = FX_Alloc(CJBig2_Image*, SDNUMNEWSYMS); FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*)); @@ -325,8 +322,8 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( SDNEWSYMWIDTHS = FX_Alloc(FX_DWORD, SDNUMNEWSYMS); FXSYS_memset(SDNEWSYMWIDTHS, 0, SDNUMNEWSYMS * sizeof(FX_DWORD)); } - nonstd::unique_ptr pDict(new CJBig2_SymbolDict()); - nonstd::unique_ptr pTable; + std::unique_ptr pDict(new CJBig2_SymbolDict()); + std::unique_ptr pTable; HCHEIGHT = 0; NSYMSDECODED = 0; @@ -370,7 +367,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( } BS = nullptr; if (REFAGGNINST > 1) { - nonstd::unique_ptr pDecoder(new CJBig2_TRDProc()); + std::unique_ptr pDecoder(new CJBig2_TRDProc()); pDecoder->SBHUFF = SDHUFF; pDecoder->SBREFINE = 1; pDecoder->SBW = SYMWIDTH; @@ -399,35 +396,32 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( pDecoder->TRANSPOSED = 0; pDecoder->REFCORNER = JBIG2_CORNER_TOPLEFT; pDecoder->SBDSOFFSET = 0; - nonstd::unique_ptr SBHUFFFS( - new CJBig2_HuffmanTable(HuffmanTable_B6, - FX_ArraySize(HuffmanTable_B6), - HuffmanTable_HTOOB_B6)); - nonstd::unique_ptr SBHUFFDS( - new CJBig2_HuffmanTable(HuffmanTable_B8, - FX_ArraySize(HuffmanTable_B8), - HuffmanTable_HTOOB_B8)); - nonstd::unique_ptr SBHUFFDT( - new CJBig2_HuffmanTable(HuffmanTable_B11, - FX_ArraySize(HuffmanTable_B11), - HuffmanTable_HTOOB_B11)); - nonstd::unique_ptr SBHUFFRDW( + std::unique_ptr SBHUFFFS(new CJBig2_HuffmanTable( + HuffmanTable_B6, FX_ArraySize(HuffmanTable_B6), + HuffmanTable_HTOOB_B6)); + std::unique_ptr SBHUFFDS(new CJBig2_HuffmanTable( + HuffmanTable_B8, FX_ArraySize(HuffmanTable_B8), + HuffmanTable_HTOOB_B8)); + std::unique_ptr SBHUFFDT(new CJBig2_HuffmanTable( + HuffmanTable_B11, FX_ArraySize(HuffmanTable_B11), + HuffmanTable_HTOOB_B11)); + std::unique_ptr SBHUFFRDW( new CJBig2_HuffmanTable(HuffmanTable_B15, FX_ArraySize(HuffmanTable_B15), HuffmanTable_HTOOB_B15)); - nonstd::unique_ptr SBHUFFRDH( + std::unique_ptr SBHUFFRDH( new CJBig2_HuffmanTable(HuffmanTable_B15, FX_ArraySize(HuffmanTable_B15), HuffmanTable_HTOOB_B15)); - nonstd::unique_ptr SBHUFFRDX( + std::unique_ptr SBHUFFRDX( new CJBig2_HuffmanTable(HuffmanTable_B15, FX_ArraySize(HuffmanTable_B15), HuffmanTable_HTOOB_B15)); - nonstd::unique_ptr SBHUFFRDY( + std::unique_ptr SBHUFFRDY( new CJBig2_HuffmanTable(HuffmanTable_B15, FX_ArraySize(HuffmanTable_B15), HuffmanTable_HTOOB_B15)); - nonstd::unique_ptr SBHUFFRSIZE( + std::unique_ptr SBHUFFRSIZE( new CJBig2_HuffmanTable(HuffmanTable_B1, FX_ArraySize(HuffmanTable_B1), HuffmanTable_HTOOB_B1)); @@ -483,11 +477,11 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( } } FX_Free(SBSYMCODES); - nonstd::unique_ptr SBHUFFRDX( + std::unique_ptr SBHUFFRDX( new CJBig2_HuffmanTable(HuffmanTable_B15, FX_ArraySize(HuffmanTable_B15), HuffmanTable_HTOOB_B15)); - nonstd::unique_ptr SBHUFFRSIZE( + std::unique_ptr SBHUFFRSIZE( new CJBig2_HuffmanTable(HuffmanTable_B1, FX_ArraySize(HuffmanTable_B1), HuffmanTable_HTOOB_B1)); @@ -502,7 +496,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, NSYMSDECODED * sizeof(CJBig2_Image*)); - nonstd::unique_ptr pGRRD(new CJBig2_GRRDProc()); + std::unique_ptr pGRRD(new CJBig2_GRRDProc()); pGRRD->GRW = SYMWIDTH; pGRRD->GRH = HCHEIGHT; pGRRD->GRTEMPLATE = SDRTEMPLATE; @@ -514,7 +508,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( pGRRD->GRAT[1] = SDRAT[1]; pGRRD->GRAT[2] = SDRAT[2]; pGRRD->GRAT[3] = SDRAT[3]; - nonstd::unique_ptr pArithDecoder( + std::unique_ptr pArithDecoder( new CJBig2_ArithDecoder(pStream)); BS = pGRRD->decode(pArithDecoder.get(), grContext->data()); if (!BS) { @@ -555,7 +549,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( goto failed; } } else { - nonstd::unique_ptr pGRD(new CJBig2_GRDProc()); + std::unique_ptr pGRD(new CJBig2_GRDProc()); pGRD->MMR = 1; pGRD->GBW = TOTWIDTH; pGRD->GBH = HCHEIGHT; diff --git a/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp b/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp index b1e56c0061..1e949c5d26 100644 --- a/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp +++ b/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp @@ -15,9 +15,9 @@ CJBig2_SymbolDict::CJBig2_SymbolDict() { CJBig2_SymbolDict::~CJBig2_SymbolDict() { } -nonstd::unique_ptr CJBig2_SymbolDict::DeepCopy() const { +std::unique_ptr CJBig2_SymbolDict::DeepCopy() const { const CJBig2_SymbolDict* src = this; - nonstd::unique_ptr dst(new CJBig2_SymbolDict); + std::unique_ptr dst(new CJBig2_SymbolDict); for (size_t i = 0; i < src->m_SDEXSYMS.size(); ++i) { CJBig2_Image* image = src->m_SDEXSYMS.get(i); dst->m_SDEXSYMS.push_back(image ? new CJBig2_Image(*image) : nullptr); diff --git a/core/src/fxcodec/jbig2/JBig2_SymbolDict.h b/core/src/fxcodec/jbig2/JBig2_SymbolDict.h index 5c7fe3c479..6f6b303640 100644 --- a/core/src/fxcodec/jbig2/JBig2_SymbolDict.h +++ b/core/src/fxcodec/jbig2/JBig2_SymbolDict.h @@ -7,12 +7,12 @@ #ifndef CORE_SRC_FXCODEC_JBIG2_JBIG2_SYMBOLDICT_H_ #define CORE_SRC_FXCODEC_JBIG2_JBIG2_SYMBOLDICT_H_ +#include #include #include "JBig2_ArithDecoder.h" #include "JBig2_List.h" #include "core/include/fxcrt/fx_basic.h" -#include "third_party/base/nonstd_unique_ptr.h" class CJBig2_Image; @@ -21,7 +21,7 @@ class CJBig2_SymbolDict { CJBig2_SymbolDict(); ~CJBig2_SymbolDict(); - nonstd::unique_ptr DeepCopy() const; + std::unique_ptr DeepCopy() const; // Takes ownership of |image|. void AddImage(CJBig2_Image* image) { m_SDEXSYMS.push_back(image); } diff --git a/core/src/fxcodec/jbig2/JBig2_TrdProc.cpp b/core/src/fxcodec/jbig2/JBig2_TrdProc.cpp index d76beea8e2..e3fd47894e 100644 --- a/core/src/fxcodec/jbig2/JBig2_TrdProc.cpp +++ b/core/src/fxcodec/jbig2/JBig2_TrdProc.cpp @@ -6,11 +6,12 @@ #include "JBig2_TrdProc.h" +#include + #include "JBig2_ArithDecoder.h" #include "JBig2_ArithIntDecoder.h" #include "JBig2_GrrdProc.h" #include "JBig2_HuffmanDecoder.h" -#include "third_party/base/nonstd_unique_ptr.h" CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, JBig2ArithCtx* grContext) { @@ -28,9 +29,9 @@ CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, FX_BOOL bFirst; FX_DWORD nTmp; int32_t nVal, nBits; - nonstd::unique_ptr pHuffmanDecoder( + std::unique_ptr pHuffmanDecoder( new CJBig2_HuffmanDecoder(pStream)); - nonstd::unique_ptr SBREG(new CJBig2_Image(SBW, SBH)); + std::unique_ptr SBREG(new CJBig2_Image(SBW, SBH)); SBREG->fill(SBDEFPIXEL); if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &STRIPT) != 0) return nullptr; @@ -123,7 +124,7 @@ CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) return nullptr; - nonstd::unique_ptr pGRRD(new CJBig2_GRRDProc()); + std::unique_ptr pGRRD(new CJBig2_GRRDProc()); pGRRD->GRW = WOI + RDWI; pGRRD->GRH = HOI + RDHI; pGRRD->GRTEMPLATE = SBRTEMPLATE; @@ -137,7 +138,7 @@ CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, pGRRD->GRAT[3] = SBRAT[3]; { - nonstd::unique_ptr pArithDecoder( + std::unique_ptr pArithDecoder( new CJBig2_ArithDecoder(pStream)); IBI = pGRRD->decode(pArithDecoder.get(), grContext); if (!IBI) @@ -255,7 +256,7 @@ CJBig2_Image* CJBig2_TRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, IAID = new CJBig2_ArithIaidDecoder(SBSYMCODELEN); bRetained = FALSE; } - nonstd::unique_ptr SBREG(new CJBig2_Image(SBW, SBH)); + std::unique_ptr SBREG(new CJBig2_Image(SBW, SBH)); SBREG->fill(SBDEFPIXEL); IADT->decode(pArithDecoder, &STRIPT); STRIPT *= SBSTRIPS; @@ -312,7 +313,7 @@ CJBig2_Image* CJBig2_TRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) { goto failed; } - nonstd::unique_ptr pGRRD(new CJBig2_GRRDProc()); + std::unique_ptr pGRRD(new CJBig2_GRRDProc()); pGRRD->GRW = WOI + RDWI; pGRRD->GRH = HOI + RDHI; pGRRD->GRTEMPLATE = SBRTEMPLATE; diff --git a/fpdfsdk/include/fsdk_actionhandler.h b/fpdfsdk/include/fsdk_actionhandler.h index 4417280a83..33f127d8c9 100644 --- a/fpdfsdk/include/fsdk_actionhandler.h +++ b/fpdfsdk/include/fsdk_actionhandler.h @@ -7,10 +7,11 @@ #ifndef FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_ #define FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_ +#include + #include "core/include/fpdfdoc/fpdf_doc.h" #include "core/include/fxcrt/fx_string.h" #include "fsdk_baseform.h" -#include "third_party/base/nonstd_unique_ptr.h" class CFX_PtrList; class CPDFSDK_Annot; @@ -116,7 +117,7 @@ class CPDFSDK_ActionHandler { void DoAction_SetOCGState(CPDFSDK_Document* pDocument, const CPDF_Action& action); - nonstd::unique_ptr m_pFormActionHandler; + std::unique_ptr m_pFormActionHandler; }; #endif // FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_ diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index 409b49f6a9..a314be8d87 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -8,6 +8,7 @@ #define FPDFSDK_INCLUDE_FSDK_MGR_H_ #include +#include #include "core/include/fpdftext/fpdf_text.h" #include "fsdk_actionhandler.h" @@ -20,7 +21,6 @@ #include "javascript/IJavaScript.h" #include "public/fpdf_formfill.h" #include "public/fpdf_fwlevent.h" // cross platform keycode and events define. -#include "third_party/base/nonstd_unique_ptr.h" class CFFL_IFormFiller; class CPDFSDK_ActionHandler; @@ -216,14 +216,14 @@ class CPDFDoc_Environment final { CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. private: - nonstd::unique_ptr m_pAnnotHandlerMgr; - nonstd::unique_ptr m_pActionHandler; - nonstd::unique_ptr m_pJSRuntime; + std::unique_ptr m_pAnnotHandlerMgr; + std::unique_ptr m_pActionHandler; + std::unique_ptr m_pJSRuntime; FPDF_FORMFILLINFO* const m_pInfo; CPDFSDK_Document* m_pSDKDoc; UnderlyingDocumentType* const m_pUnderlyingDoc; - nonstd::unique_ptr m_pIFormFiller; - nonstd::unique_ptr m_pSysHandler; + std::unique_ptr m_pIFormFiller; + std::unique_ptr m_pSysHandler; }; class CPDFSDK_Document { @@ -283,10 +283,10 @@ class CPDFSDK_Document { private: std::map m_pageMap; UnderlyingDocumentType* m_pDoc; - nonstd::unique_ptr m_pInterForm; + std::unique_ptr m_pInterForm; CPDFSDK_Annot* m_pFocusAnnot; CPDFDoc_Environment* m_pEnv; - nonstd::unique_ptr m_pOccontent; + std::unique_ptr m_pOccontent; FX_BOOL m_bChangeMask; FX_BOOL m_bBeingDestroyed; }; @@ -354,7 +354,7 @@ class CPDFSDK_PageView final { CFX_Matrix m_curMatrix; UnderlyingPageType* m_page; - nonstd::unique_ptr m_pAnnotList; + std::unique_ptr m_pAnnotList; std::vector m_fxAnnotArray; CPDFSDK_Document* m_pSDKDoc; CPDFSDK_Widget* m_CaptureWidget; diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp index 93cfab8bdf..93b25ffec1 100644 --- a/fpdfsdk/src/fpdfformfill.cpp +++ b/fpdfsdk/src/fpdfformfill.cpp @@ -6,10 +6,11 @@ #include "public/fpdf_formfill.h" +#include + #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "public/fpdfview.h" -#include "third_party/base/nonstd_unique_ptr.h" namespace { @@ -228,9 +229,9 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, clip.bottom = start_y + size_y; #ifdef _SKIA_SUPPORT_ - nonstd::unique_ptr pDevice(new CFX_SkiaDevice); + std::unique_ptr pDevice(new CFX_SkiaDevice); #else - nonstd::unique_ptr pDevice(new CFX_FxgeDevice); + std::unique_ptr pDevice(new CFX_FxgeDevice); #endif pDevice->Attach((CFX_DIBitmap*)bitmap); pDevice->SaveState(); diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp index 2fce7adfc4..50ef262560 100644 --- a/fpdfsdk/src/fpdfppo.cpp +++ b/fpdfsdk/src/fpdfppo.cpp @@ -6,8 +6,9 @@ #include "public/fpdf_ppo.h" +#include + #include "fpdfsdk/include/fsdk_define.h" -#include "third_party/base/nonstd_unique_ptr.h" class CPDF_PageOrganizer { public: @@ -91,7 +92,7 @@ FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, int nIndex) { int curpage = nIndex; - nonstd::unique_ptr pObjNumberMap(new ObjectNumberMap); + std::unique_ptr pObjNumberMap(new ObjectNumberMap); for (int i = 0; i < nPageNum->GetSize(); ++i) { CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage); diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index daf9cfcbcf..1e1eb2a845 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -6,6 +6,8 @@ #include "public/fpdfview.h" +#include + #include "core/include/fxcodec/fx_codec.h" #include "core/include/fxcrt/fx_safe_types.h" #include "fpdfsdk/include/fsdk_define.h" @@ -14,7 +16,6 @@ #include "fpdfsdk/include/javascript/IJavaScript.h" #include "public/fpdf_ext.h" #include "public/fpdf_progressive.h" -#include "third_party/base/nonstd_unique_ptr.h" #include "third_party/base/numerics/safe_conversions_impl.h" UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) { @@ -606,7 +607,7 @@ DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha) { - nonstd::unique_ptr pBitmap(new CFX_DIBitmap); + std::unique_ptr pBitmap(new CFX_DIBitmap); if (!pBitmap->Create(width, height, alpha ? FXDIB_Argb : FXDIB_Rgb32)) { return NULL; } diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index 3b35d99026..4c6fc4bafd 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" #include "fpdfsdk/include/fsdk_actionhandler.h" #include "fpdfsdk/include/fsdk_baseannot.h" @@ -11,7 +13,6 @@ #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/javascript/IJavaScript.h" -#include "third_party/base/nonstd_unique_ptr.h" #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) @@ -1449,7 +1450,7 @@ FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const { - nonstd::unique_ptr pIterator( + std::unique_ptr pIterator( new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", "")); if (bNext) { @@ -1917,7 +1918,7 @@ FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( const std::vector& fields, FX_BOOL bIncludeOrExclude, CFX_ByteTextBuf& textBuf) { - nonstd::unique_ptr pFDF(m_pInterForm->ExportToFDF( + std::unique_ptr pFDF(m_pInterForm->ExportToFDF( m_pDocument->GetPath(), fields, bIncludeOrExclude)); return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; } diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp index 03edd83891..ecef863d61 100644 --- a/fpdfsdk/src/fsdk_mgr.cpp +++ b/fpdfsdk/src/fsdk_mgr.cpp @@ -5,6 +5,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include +#include #include "fpdfsdk/include/fsdk_mgr.h" @@ -12,7 +13,6 @@ #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/javascript/IJavaScript.h" #include "public/fpdf_ext.h" -#include "third_party/base/nonstd_unique_ptr.h" #include "third_party/base/stl_util.h" #if _FX_OS_ == _FX_ANDROID_ @@ -273,7 +273,7 @@ CFX_WideString CPDFDoc_Environment::JS_fieldBrowse() { if (nRequiredLen <= 0) return L""; - nonstd::unique_ptr pBuff(new char[nRequiredLen]); + std::unique_ptr pBuff(new char[nRequiredLen]); memset(pBuff.get(), 0, nRequiredLen); const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse( m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); @@ -296,7 +296,7 @@ CFX_WideString CPDFDoc_Environment::JS_docGetFilePath() { if (nRequiredLen <= 0) return L""; - nonstd::unique_ptr pBuff(new char[nRequiredLen]); + std::unique_ptr pBuff(new char[nRequiredLen]); memset(pBuff.get(), 0, nRequiredLen); const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp index 288ab5e747..959e8dcadd 100644 --- a/fpdfsdk/src/javascript/Field.cpp +++ b/fpdfsdk/src/javascript/Field.cpp @@ -3141,7 +3141,7 @@ FX_BOOL Field::getArray(IJS_Context* cc, CJS_Array FormFieldArray(pRuntime); for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { - nonstd::unique_ptr pStr(swSort.GetAt(j)); + std::unique_ptr pStr(swSort.GetAt(j)); v8::Local pObj = FXJS_NewFxDynamicObj( pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); ASSERT(!pObj.IsEmpty()); diff --git a/fpdfsdk/src/javascript/JS_Object.h b/fpdfsdk/src/javascript/JS_Object.h index d72696caeb..fe9e5ec5d2 100644 --- a/fpdfsdk/src/javascript/JS_Object.h +++ b/fpdfsdk/src/javascript/JS_Object.h @@ -8,11 +8,11 @@ #define FPDFSDK_SRC_JAVASCRIPT_JS_OBJECT_H_ #include +#include #include "JS_Runtime.h" #include "fpdfsdk/include/fsdk_define.h" // For FX_UINT #include "fpdfsdk/include/jsapi/fxjs_v8.h" -#include "third_party/base/nonstd_unique_ptr.h" class CJS_Context; class CJS_Object; @@ -68,7 +68,7 @@ class CJS_Object { v8::Isolate* GetIsolate() { return m_pIsolate; } protected: - nonstd::unique_ptr m_pEmbedObj; + std::unique_ptr m_pEmbedObj; v8::Global m_pV8Object; v8::Isolate* m_pIsolate; }; diff --git a/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp index f7b1124a6e..ad8d27dae3 100644 --- a/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp @@ -4,9 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. #include "fpdfsdk/include/javascript/IJavaScript.h" -#include "third_party/base/nonstd_unique_ptr.h" class CJS_ContextStub final : public IJS_Context { public: @@ -144,7 +145,7 @@ class CJS_RuntimeStub final : public IJS_Runtime { protected: CPDFSDK_Document* m_pDoc; - nonstd::unique_ptr m_pContext; + std::unique_ptr m_pContext; }; // static diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp index 0ed280740d..5959b9a1b5 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -6,6 +6,8 @@ #include "app.h" +#include + #include "Document.h" #include "JS_Context.h" #include "JS_Define.h" @@ -16,7 +18,6 @@ #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. #include "fpdfsdk/include/javascript/IJavaScript.h" #include "resource.h" -#include "third_party/base/nonstd_unique_ptr.h" BEGIN_JS_STATIC_CONST(CJS_TimerObj) END_JS_STATIC_CONST() @@ -769,7 +770,7 @@ FX_BOOL app::response(IJS_Context* cc, CPDFDoc_Environment* pApp = pContext->GetReaderApp(); const int MAX_INPUT_BYTES = 2048; - nonstd::unique_ptr pBuff(new char[MAX_INPUT_BYTES + 2]); + std::unique_ptr pBuff(new char[MAX_INPUT_BYTES + 2]); memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2); int nLengthBytes = pApp->JS_appResponse( swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(), diff --git a/pdfium.gyp b/pdfium.gyp index 37a9f1c698..8401dcc5b9 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -732,7 +732,6 @@ 'core/src/fxcrt/fx_system_unittest.cpp', 'testing/fx_string_testhelpers.h', 'testing/fx_string_testhelpers.cpp', - 'third_party/base/nonstd_unique_ptr_unittest.cpp', ], }, { diff --git a/testing/embedder_test.h b/testing/embedder_test.h index df2e40a2e8..a544f26543 100644 --- a/testing/embedder_test.h +++ b/testing/embedder_test.h @@ -6,6 +6,7 @@ #define TESTING_EMBEDDER_TEST_H_ #include +#include #include #include "public/fpdf_dataavail.h" @@ -13,7 +14,6 @@ #include "public/fpdf_formfill.h" #include "public/fpdfview.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/nonstd_unique_ptr.h" #ifdef PDF_ENABLE_V8 #include "v8/include/v8.h" @@ -108,7 +108,7 @@ class EmbedderTest : public ::testing::Test, protected: Delegate* delegate_; - nonstd::unique_ptr default_delegate_; + std::unique_ptr default_delegate_; FPDF_DOCUMENT document_; FPDF_FORMHANDLE form_handle_; FPDF_AVAIL avail_; diff --git a/testing/js_embedder_test.h b/testing/js_embedder_test.h index 167aea7ed5..319bd40728 100644 --- a/testing/js_embedder_test.h +++ b/testing/js_embedder_test.h @@ -5,11 +5,11 @@ #ifndef TESTING_JS_EMBEDDER_TEST_H_ #define TESTING_JS_EMBEDDER_TEST_H_ +#include #include #include "fpdfsdk/include/jsapi/fxjs_v8.h" #include "testing/embedder_test.h" -#include "third_party/base/nonstd_unique_ptr.h" class JSEmbedderTest : public EmbedderTest { public: @@ -23,7 +23,7 @@ class JSEmbedderTest : public EmbedderTest { v8::Local GetV8Context(); private: - nonstd::unique_ptr m_pArrayBufferAllocator; + std::unique_ptr m_pArrayBufferAllocator; v8::Isolate* m_pIsolate; v8::Global m_pPersistentContext; std::vector*> m_StaticObjects; diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn index 214614c8b6..a688ba3a5e 100644 --- a/third_party/BUILD.gn +++ b/third_party/BUILD.gn @@ -303,12 +303,10 @@ source_set("pdfium_base") { sources = [ "base/logging.h", "base/macros.h", - "base/nonstd_unique_ptr.h", "base/numerics/safe_conversions.h", "base/numerics/safe_conversions_impl.h", "base/numerics/safe_math.h", "base/numerics/safe_math_impl.h", "base/stl_util.h", - "base/template_util.h", ] } diff --git a/third_party/base/nonstd_unique_ptr.h b/third_party/base/nonstd_unique_ptr.h deleted file mode 100644 index f056e50397..0000000000 --- a/third_party/base/nonstd_unique_ptr.h +++ /dev/null @@ -1,398 +0,0 @@ -// Copyright 2013 Google Inc. All Rights Reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This is a copy of breakpad's standalone scoped_ptr, which has been -// renamed to nonstd::unique_ptr, and from which more complicated classes -// have been removed. The reset() method has also been tweaked to more -// closely match c++11, and an implicit conversion to bool has been added. - -// Scopers help you manage ownership of a pointer, helping you easily manage the -// a pointer within a scope, and automatically destroying the pointer at the -// end of a scope. -// -// A unique_ptr is like a T*, except that the destructor of unique_ptr -// automatically deletes the pointer it holds (if any). -// That is, unique_ptr owns the T object that it points to. -// Like a T*, a unique_ptr may hold either NULL or a pointer to a T object. -// Also like T*, unique_ptr is thread-compatible, and once you -// dereference it, you get the thread safety guarantees of T. -// -// Example usage (unique_ptr): -// { -// unique_ptr foo(new Foo("wee")); -// } // foo goes out of scope, releasing the pointer with it. -// -// { -// unique_ptr foo; // No pointer managed. -// foo.reset(new Foo("wee")); // Now a pointer is managed. -// foo.reset(new Foo("wee2")); // Foo("wee") was destroyed. -// foo.reset(new Foo("wee3")); // Foo("wee2") was destroyed. -// foo->Method(); // Foo::Method() called. -// foo.get()->Method(); // Foo::Method() called. -// SomeFunc(foo.release()); // SomeFunc takes ownership, foo no longer -// // manages a pointer. -// foo.reset(new Foo("wee4")); // foo manages a pointer again. -// foo.reset(); // Foo("wee4") destroyed, foo no longer -// // manages a pointer. -// } // foo wasn't managing a pointer, so nothing was destroyed. -// -// The size of a unique_ptr is small: sizeof(unique_ptr) == sizeof(C*) - -#ifndef NONSTD_UNIQUE_PTR_H_ -#define NONSTD_UNIQUE_PTR_H_ - -// This is an implementation designed to match the anticipated future C++11 -// implementation of the unique_ptr class. - -#include -#include -#include - -#include -#include - -#include "template_util.h" - -namespace nonstd { - -// Function object which deletes its parameter, which must be a pointer. -// If C is an array type, invokes 'delete[]' on the parameter; otherwise, -// invokes 'delete'. The default deleter for unique_ptr. -template -struct DefaultDeleter { - DefaultDeleter() {} - template - DefaultDeleter(const DefaultDeleter& other) { - // IMPLEMENTATION NOTE: C++11 20.7.1.1.2p2 only provides this constructor - // if U* is implicitly convertible to T* and U is not an array type. - // - // Correct implementation should use SFINAE to disable this - // constructor. However, since there are no other 1-argument constructors, - // using a static_assert() based on is_convertible<> and requiring - // complete types is simpler and will cause compile failures for equivalent - // misuses. - // - // Note, the is_convertible check also ensures that U is not an - // array. T is guaranteed to be a non-array, so any U* where U is an array - // cannot convert to T*. - enum { T_must_be_complete = sizeof(T) }; - enum { U_must_be_complete = sizeof(U) }; - static_assert((pdfium::base::is_convertible::value), - "U_ptr_must_implicitly_convert_to_T_ptr"); - } - inline void operator()(T* ptr) const { - enum { type_must_be_complete = sizeof(T) }; - delete ptr; - } -}; - -// Specialization of DefaultDeleter for array types. -template -struct DefaultDeleter { - inline void operator()(T* ptr) const { - enum { type_must_be_complete = sizeof(T) }; - delete[] ptr; - } - - private: - // Disable this operator for any U != T because it is undefined to execute - // an array delete when the static type of the array mismatches the dynamic - // type. - // - // References: - // C++98 [expr.delete]p3 - // http://cplusplus.github.com/LWG/lwg-defects.html#938 - template - void operator()(U* array) const; -}; - -template -struct DefaultDeleter { - // Never allow someone to declare something like unique_ptr. - static_assert(sizeof(T) == -1, "do_not_use_array_with_size_as_type"); -}; - -namespace internal { - -// Common implementation for both pointers to elements and pointers to -// arrays. These are differentiated below based on the need to invoke -// delete vs. delete[] as appropriate. -template -class unique_ptr_base { - public: - // The element type - typedef C element_type; - - explicit unique_ptr_base(C* p) : data_(p) {} - - // Initializer for deleters that have data parameters. - unique_ptr_base(C* p, const D& d) : data_(p, d) {} - - // Move constructor. - unique_ptr_base(unique_ptr_base&& that) - : data_(that.release(), that.get_deleter()) {} - - ~unique_ptr_base() { - enum { type_must_be_complete = sizeof(C) }; - if (data_.ptr != nullptr) { - // Not using get_deleter() saves one function call in non-optimized - // builds. - static_cast(data_)(data_.ptr); - } - } - - void reset(C* p = nullptr) { - C* old = data_.ptr; - data_.ptr = p; - if (old != nullptr) - static_cast(data_)(old); - } - - C* get() const { return data_.ptr; } - D& get_deleter() { return data_; } - const D& get_deleter() const { return data_; } - - // Comparison operators. - // These return whether two unique_ptr refer to the same object, not just to - // two different but equal objects. - bool operator==(C* p) const { return data_.ptr == p; } - bool operator!=(C* p) const { return data_.ptr != p; } - - // Swap two unique pointers. - void swap(unique_ptr_base& p2) { - Data tmp = data_; - data_ = p2.data_; - p2.data_ = tmp; - } - - // Release a pointer. - // The return value is the current pointer held by this object. - // If this object holds a NULL pointer, the return value is NULL. - // After this operation, this object will hold a NULL pointer, - // and will not own the object any more. - C* release() { - C* ptr = data_.ptr; - data_.ptr = nullptr; - return ptr; - } - - // Allow promotion to bool for conditional statements. - explicit operator bool() const { return data_.ptr != nullptr; } - - protected: - // Use the empty base class optimization to allow us to have a D - // member, while avoiding any space overhead for it when D is an - // empty class. See e.g. http://www.cantrip.org/emptyopt.html for a good - // discussion of this technique. - struct Data : public D { - explicit Data(C* ptr_in) : ptr(ptr_in) {} - Data(C* ptr_in, const D& other) : D(other), ptr(ptr_in) {} - C* ptr; - }; - - Data data_; -}; - -} // namespace internal - -// Implementation for ordinary pointers using delete. -template > -class unique_ptr : public internal::unique_ptr_base { - public: - // Constructor. Defaults to initializing with nullptr. - unique_ptr() : internal::unique_ptr_base(nullptr) {} - - // Constructor. Takes ownership of p. - explicit unique_ptr(C* p) : internal::unique_ptr_base(p) {} - - // Constructor. Allows initialization of a stateful deleter. - unique_ptr(C* p, const D& d) : internal::unique_ptr_base(p, d) {} - - // Constructor. Allows construction from a nullptr. - unique_ptr(decltype(nullptr)) : internal::unique_ptr_base(nullptr) {} - - // Move constructor. - unique_ptr(unique_ptr&& that) - : internal::unique_ptr_base(std::move(that)) {} - - // operator=. Allows assignment from a nullptr. Deletes the currently owned - // object, if any. - unique_ptr& operator=(decltype(nullptr)) { - this->reset(); - return *this; - } - - // Move assignment. - unique_ptr& operator=(unique_ptr&& that) { - this->reset(that.release()); - return *this; - } - - // Accessors to get the owned object. - // operator* and operator-> will assert() if there is no current object. - C& operator*() const { - assert(this->data_.ptr != nullptr); - return *this->data_.ptr; - } - C* operator->() const { - assert(this->data_.ptr != nullptr); - return this->data_.ptr; - } - - // Comparison operators. - // These return whether two unique_ptr refer to the same object, not just to - // two different but equal objects. - bool operator==(const C* p) const { return this->get() == p; } - bool operator!=(const C* p) const { return this->get() != p; } - - private: - // Disallow evil constructors. It doesn't make sense to make a copy of - // something that's allegedly unique. - unique_ptr(const unique_ptr&) = delete; - void operator=(const unique_ptr&) = delete; - - // Forbid comparison of unique_ptr types. If U != C, it totally - // doesn't make sense, and if U == C, it still doesn't make sense - // because you should never have the same object owned by two different - // unique_ptrs. - template - bool operator==(unique_ptr const& p2) const; - template - bool operator!=(unique_ptr const& p2) const; -}; - -// Specialization for arrays using delete[]. -template -class unique_ptr : public internal::unique_ptr_base { - public: - // Constructor. Defaults to initializing with nullptr. - unique_ptr() : internal::unique_ptr_base(nullptr) {} - - // Constructor. Stores the given array. Note that the argument's type - // must exactly match T*. In particular: - // - it cannot be a pointer to a type derived from T, because it is - // inherently unsafe in the general case to access an array through a - // pointer whose dynamic type does not match its static type (eg., if - // T and the derived types had different sizes access would be - // incorrectly calculated). Deletion is also always undefined - // (C++98 [expr.delete]p3). If you're doing this, fix your code. - // - it cannot be const-qualified differently from T per unique_ptr spec - // (http://cplusplus.github.com/LWG/lwg-active.html#2118). Users wanting - // to work around this may use const_cast(). - explicit unique_ptr(C* p) : internal::unique_ptr_base(p) {} - - // Constructor. Allows construction from a nullptr. - unique_ptr(decltype(nullptr)) : internal::unique_ptr_base(nullptr) {} - - // Move constructor. - unique_ptr(unique_ptr&& that) - : internal::unique_ptr_base(std::move(that)) {} - - // operator=. Allows assignment from a nullptr. Deletes the currently owned - // array, if any. - unique_ptr& operator=(decltype(nullptr)) { - this->reset(); - return *this; - } - - // Move assignment. - unique_ptr& operator=(unique_ptr&& that) { - this->reset(that.release()); - return *this; - } - - // Reset. Deletes the currently owned array, if any. - // Then takes ownership of a new object, if given. - void reset(C* array = nullptr) { - static_cast*>(this)->reset(array); - } - - // Support indexing since it is holding array. - C& operator[](size_t i) { return this->data_.ptr[i]; } - - // Comparison operators. - // These return whether two unique_ptr refer to the same object, not just to - // two different but equal objects. - bool operator==(C* array) const { return this->get() == array; } - bool operator!=(C* array) const { return this->get() != array; } - - private: - // Disable initialization from any type other than element_type*, by - // providing a constructor that matches such an initialization, but is - // private and has no definition. This is disabled because it is not safe to - // call delete[] on an array whose static type does not match its dynamic - // type. - template - explicit unique_ptr(U* array); - explicit unique_ptr(int disallow_construction_from_null); - - // Disable reset() from any type other than element_type*, for the same - // reasons as the constructor above. - template - void reset(U* array); - void reset(int disallow_reset_from_null); - - // Disallow evil constructors. It doesn't make sense to make a copy of - // something that's allegedly unique. - unique_ptr(const unique_ptr&) = delete; - void operator=(const unique_ptr&) = delete; - - // Forbid comparison of unique_ptr types. If U != C, it totally - // doesn't make sense, and if U == C, it still doesn't make sense - // because you should never have the same object owned by two different - // unique_ptrs. - template - bool operator==(unique_ptr const& p2) const; - template - bool operator!=(unique_ptr const& p2) const; -}; - -// Free functions -template -void swap(unique_ptr& p1, unique_ptr& p2) { - p1.swap(p2); -} - -template -bool operator==(C* p1, const unique_ptr& p2) { - return p1 == p2.get(); -} - -template -bool operator!=(C* p1, const unique_ptr& p2) { - return p1 != p2.get(); -} - -template -std::ostream& operator<<(std::ostream& out, const unique_ptr& p) { - return out << p.get(); -} - -} // namespace nonstd - -#endif // NONSTD_UNIQUE_PTR_H_ diff --git a/third_party/base/nonstd_unique_ptr_unittest.cpp b/third_party/base/nonstd_unique_ptr_unittest.cpp deleted file mode 100644 index 1dcfe48b02..0000000000 --- a/third_party/base/nonstd_unique_ptr_unittest.cpp +++ /dev/null @@ -1,391 +0,0 @@ -// Copyright 2015 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include -#include - -#include "testing/gtest/include/gtest/gtest.h" -#include "macros.h" -#include "nonstd_unique_ptr.h" - -using nonstd::unique_ptr; - -namespace { - -// Used to test depth subtyping. -class CtorDtorLoggerParent { - public: - virtual ~CtorDtorLoggerParent() {} - - virtual void SetPtr(int* ptr) = 0; - - virtual int SomeMeth(int x) const = 0; -}; - -class CtorDtorLogger : public CtorDtorLoggerParent { - public: - CtorDtorLogger() : ptr_(nullptr) {} - explicit CtorDtorLogger(int* ptr) { SetPtr(ptr); } - ~CtorDtorLogger() override { --*ptr_; } - - void SetPtr(int* ptr) override { - ptr_ = ptr; - ++*ptr_; - } - - int SomeMeth(int x) const override { return x; } - - private: - int* ptr_; - - // Disallow evil constructors. - CtorDtorLogger(const CtorDtorLogger&) = delete; - void operator=(const CtorDtorLogger&) = delete; -}; - -struct CountingDeleter { - explicit CountingDeleter(int* count) : count_(count) {} - inline void operator()(double* ptr) const { (*count_)++; } - int* count_; -}; - -// Do not delete this function! It's existence is to test that you can -// return a temporarily constructed version of the scoper. -unique_ptr TestReturnOfType(int* constructed) { - return unique_ptr(new CtorDtorLogger(constructed)); -} - -} // namespace - -TEST(UniquePtrTest, MoveTest) { - int constructed = 0; - int constructed4 = 0; - { - unique_ptr ptr1(new CtorDtorLogger(&constructed)); - EXPECT_EQ(1, constructed); - EXPECT_TRUE(ptr1); - - unique_ptr ptr2(std::move(ptr1)); - EXPECT_EQ(1, constructed); - EXPECT_FALSE(ptr1); - EXPECT_TRUE(ptr2); - - unique_ptr ptr3; - ptr3 = std::move(ptr2); - EXPECT_EQ(1, constructed); - EXPECT_FALSE(ptr2); - EXPECT_TRUE(ptr3); - - unique_ptr ptr4(new CtorDtorLogger(&constructed4)); - EXPECT_EQ(1, constructed4); - ptr4 = std::move(ptr3); - EXPECT_EQ(0, constructed4); - EXPECT_FALSE(ptr3); - EXPECT_TRUE(ptr4); - } - EXPECT_EQ(0, constructed); -} - -TEST(UniquePtrTest, UniquePtr) { - int constructed = 0; - - // Ensure size of unique_ptr<> doesn't increase unexpectedly. - static_assert(sizeof(int*) >= sizeof(unique_ptr), - "unique_ptr_larger_than_raw_ptr"); - - { - unique_ptr scoper(new CtorDtorLogger(&constructed)); - EXPECT_EQ(1, constructed); - EXPECT_TRUE(scoper.get()); - - EXPECT_EQ(10, scoper->SomeMeth(10)); - EXPECT_EQ(10, scoper.get()->SomeMeth(10)); - EXPECT_EQ(10, (*scoper).SomeMeth(10)); - } - EXPECT_EQ(0, constructed); - - // Test reset() and release() - { - unique_ptr scoper(new CtorDtorLogger(&constructed)); - EXPECT_EQ(1, constructed); - EXPECT_TRUE(scoper.get()); - - scoper.reset(new CtorDtorLogger(&constructed)); - EXPECT_EQ(1, constructed); - EXPECT_TRUE(scoper.get()); - - scoper.reset(); - EXPECT_EQ(0, constructed); - EXPECT_FALSE(scoper.get()); - - scoper.reset(new CtorDtorLogger(&constructed)); - EXPECT_EQ(1, constructed); - EXPECT_TRUE(scoper.get()); - - CtorDtorLogger* take = scoper.release(); - EXPECT_EQ(1, constructed); - EXPECT_FALSE(scoper.get()); - delete take; - EXPECT_EQ(0, constructed); - - scoper.reset(new CtorDtorLogger(&constructed)); - EXPECT_EQ(1, constructed); - EXPECT_TRUE(scoper.get()); - } - EXPECT_EQ(0, constructed); - - // Test swap(), == and != - { - unique_ptr scoper1; - unique_ptr scoper2; - EXPECT_TRUE(scoper1 == scoper2.get()); - EXPECT_FALSE(scoper1 != scoper2.get()); - - CtorDtorLogger* logger = new CtorDtorLogger(&constructed); - scoper1.reset(logger); - EXPECT_EQ(logger, scoper1.get()); - EXPECT_FALSE(scoper2.get()); - EXPECT_FALSE(scoper1 == scoper2.get()); - EXPECT_TRUE(scoper1 != scoper2.get()); - - scoper2.swap(scoper1); - EXPECT_EQ(logger, scoper2.get()); - EXPECT_FALSE(scoper1.get()); - EXPECT_FALSE(scoper1 == scoper2.get()); - EXPECT_TRUE(scoper1 != scoper2.get()); - } - EXPECT_EQ(0, constructed); -} - -TEST(UniquePtrTest, UniquePtrWithArray) { - static const int kNumLoggers = 12; - - int constructed = 0; - - { - unique_ptr scoper(new CtorDtorLogger[kNumLoggers]); - EXPECT_TRUE(scoper); - EXPECT_EQ(&scoper[0], scoper.get()); - for (int i = 0; i < kNumLoggers; ++i) { - scoper[i].SetPtr(&constructed); - } - EXPECT_EQ(12, constructed); - - EXPECT_EQ(10, scoper.get()->SomeMeth(10)); - EXPECT_EQ(10, scoper[2].SomeMeth(10)); - } - EXPECT_EQ(0, constructed); - - // Test reset() and release() - { - unique_ptr scoper; - EXPECT_FALSE(scoper.get()); - EXPECT_FALSE(scoper.release()); - EXPECT_FALSE(scoper.get()); - scoper.reset(); - EXPECT_FALSE(scoper.get()); - - scoper.reset(new CtorDtorLogger[kNumLoggers]); - for (int i = 0; i < kNumLoggers; ++i) { - scoper[i].SetPtr(&constructed); - } - EXPECT_EQ(12, constructed); - scoper.reset(); - EXPECT_EQ(0, constructed); - - scoper.reset(new CtorDtorLogger[kNumLoggers]); - for (int i = 0; i < kNumLoggers; ++i) { - scoper[i].SetPtr(&constructed); - } - EXPECT_EQ(12, constructed); - CtorDtorLogger* ptr = scoper.release(); - EXPECT_EQ(12, constructed); - delete[] ptr; - EXPECT_EQ(0, constructed); - } - EXPECT_EQ(0, constructed); - - // Test swap(), ==, !=, and type-safe Boolean. - { - unique_ptr scoper1; - unique_ptr scoper2; - EXPECT_TRUE(scoper1 == scoper2.get()); - EXPECT_FALSE(scoper1 != scoper2.get()); - - CtorDtorLogger* loggers = new CtorDtorLogger[kNumLoggers]; - for (int i = 0; i < kNumLoggers; ++i) { - loggers[i].SetPtr(&constructed); - } - scoper1.reset(loggers); - EXPECT_TRUE(scoper1); - EXPECT_EQ(loggers, scoper1.get()); - EXPECT_FALSE(scoper2); - EXPECT_FALSE(scoper2.get()); - EXPECT_FALSE(scoper1 == scoper2.get()); - EXPECT_TRUE(scoper1 != scoper2.get()); - - scoper2.swap(scoper1); - EXPECT_EQ(loggers, scoper2.get()); - EXPECT_FALSE(scoper1.get()); - EXPECT_FALSE(scoper1 == scoper2.get()); - EXPECT_TRUE(scoper1 != scoper2.get()); - } - EXPECT_EQ(0, constructed); -} - -TEST(UniquePtrTest, ReturnTypeBehavior) { - int constructed = 0; - - // Test that we can return a unique_ptr. - { - CtorDtorLogger* logger = new CtorDtorLogger(&constructed); - unique_ptr scoper(logger); - EXPECT_EQ(1, constructed); - } - EXPECT_EQ(0, constructed); - - // Test uncaught return type not leak. - { - CtorDtorLogger* logger = new CtorDtorLogger(&constructed); - unique_ptr scoper(logger); - EXPECT_EQ(1, constructed); - } - EXPECT_EQ(0, constructed); - - // Call TestReturnOfType() so the compiler doesn't warn for an unused - // function. - { TestReturnOfType(&constructed); } - EXPECT_EQ(0, constructed); -} - -TEST(UniquePtrTest, CustomDeleter) { - double dummy_value; // Custom deleter never touches this value. - int deletes = 0; - int alternate_deletes = 0; - - // Normal delete support. - { - deletes = 0; - unique_ptr scoper(&dummy_value, - CountingDeleter(&deletes)); - EXPECT_EQ(0, deletes); - EXPECT_TRUE(scoper.get()); - } - EXPECT_EQ(1, deletes); - - // Test reset() and release(). - deletes = 0; - { - unique_ptr scoper(nullptr, - CountingDeleter(&deletes)); - EXPECT_FALSE(scoper.get()); - EXPECT_FALSE(scoper.release()); - EXPECT_FALSE(scoper.get()); - scoper.reset(); - EXPECT_FALSE(scoper.get()); - EXPECT_EQ(0, deletes); - - scoper.reset(&dummy_value); - scoper.reset(); - EXPECT_EQ(1, deletes); - - scoper.reset(&dummy_value); - EXPECT_EQ(&dummy_value, scoper.release()); - } - EXPECT_EQ(1, deletes); - - // Test get_deleter(). - deletes = 0; - alternate_deletes = 0; - { - unique_ptr scoper(&dummy_value, - CountingDeleter(&deletes)); - // Call deleter manually. - EXPECT_EQ(0, deletes); - scoper.get_deleter()(&dummy_value); - EXPECT_EQ(1, deletes); - - // Deleter is still there after reset. - scoper.reset(); - EXPECT_EQ(2, deletes); - scoper.get_deleter()(&dummy_value); - EXPECT_EQ(3, deletes); - - // Deleter can be assigned into (matches C++11 unique_ptr<> spec). - scoper.get_deleter() = CountingDeleter(&alternate_deletes); - scoper.reset(&dummy_value); - EXPECT_EQ(0, alternate_deletes); - } - EXPECT_EQ(3, deletes); - EXPECT_EQ(1, alternate_deletes); - - // Test swap(), ==, !=, and type-safe Boolean. - { - unique_ptr scoper1(nullptr, - CountingDeleter(&deletes)); - unique_ptr scoper2(nullptr, - CountingDeleter(&deletes)); - EXPECT_TRUE(scoper1 == scoper2.get()); - EXPECT_FALSE(scoper1 != scoper2.get()); - - scoper1.reset(&dummy_value); - EXPECT_TRUE(scoper1); - EXPECT_EQ(&dummy_value, scoper1.get()); - EXPECT_FALSE(scoper2); - EXPECT_FALSE(scoper2.get()); - EXPECT_FALSE(scoper1 == scoper2.get()); - EXPECT_TRUE(scoper1 != scoper2.get()); - - scoper2.swap(scoper1); - EXPECT_EQ(&dummy_value, scoper2.get()); - EXPECT_FALSE(scoper1.get()); - EXPECT_FALSE(scoper1 == scoper2.get()); - EXPECT_TRUE(scoper1 != scoper2.get()); - } -} - -unique_ptr NullIntReturn() { - return nullptr; -} - -TEST(UniquePtrTest, Nullptr) { - unique_ptr scoper1(nullptr); - unique_ptr scoper2(new int); - scoper2 = nullptr; - unique_ptr scoper3(NullIntReturn()); - unique_ptr scoper4 = NullIntReturn(); - EXPECT_EQ(nullptr, scoper1.get()); - EXPECT_EQ(nullptr, scoper2.get()); - EXPECT_EQ(nullptr, scoper3.get()); - EXPECT_EQ(nullptr, scoper4.get()); -} - -unique_ptr NullIntArrayReturn() { - return nullptr; -} - -TEST(UniquePtrTest, NullptrArray) { - unique_ptr scoper1(nullptr); - unique_ptr scoper2(new int[3]); - scoper2 = nullptr; - unique_ptr scoper3(NullIntArrayReturn()); - unique_ptr scoper4 = NullIntArrayReturn(); - EXPECT_EQ(nullptr, scoper1.get()); - EXPECT_EQ(nullptr, scoper2.get()); - EXPECT_EQ(nullptr, scoper3.get()); - EXPECT_EQ(nullptr, scoper4.get()); -} - -// Logging a unique_ptr to an ostream shouldn't convert it to a boolean -// value first. -TEST(ScopedPtrTest, LoggingDoesntConvertToBoolean) { - unique_ptr x(new int); - std::stringstream s1; - s1 << x; - - std::stringstream s2; - s2 << x.get(); - - EXPECT_EQ(s2.str(), s1.str()); -} diff --git a/third_party/base/numerics/safe_conversions_impl.h b/third_party/base/numerics/safe_conversions_impl.h index c974ee0590..e1c4c3b756 100644 --- a/third_party/base/numerics/safe_conversions_impl.h +++ b/third_party/base/numerics/safe_conversions_impl.h @@ -9,7 +9,6 @@ #include #include "third_party/base/macros.h" -#include "third_party/base/template_util.h" namespace pdfium { namespace base { diff --git a/third_party/base/numerics/safe_math.h b/third_party/base/numerics/safe_math.h index 9540e83321..013af1eb60 100644 --- a/third_party/base/numerics/safe_math.h +++ b/third_party/base/numerics/safe_math.h @@ -166,15 +166,15 @@ class CheckedNumeric { template static CheckedNumeric cast( Src u, - typename enable_if::is_specialized, int>::type = - 0) { + typename std::enable_if::is_specialized, + int>::type = 0) { return u; } template static CheckedNumeric cast( const CheckedNumeric& u, - typename enable_if::value, int>::type = 0) { + typename std::enable_if::value, int>::type = 0) { return u; } diff --git a/third_party/base/numerics/safe_math_impl.h b/third_party/base/numerics/safe_math_impl.h index 4209446694..f219cf52bb 100644 --- a/third_party/base/numerics/safe_math_impl.h +++ b/third_party/base/numerics/safe_math_impl.h @@ -10,10 +10,10 @@ #include #include #include +#include #include "safe_conversions.h" #include "third_party/base/macros.h" -#include "third_party/base/template_util.h" namespace pdfium { namespace base { @@ -65,21 +65,21 @@ struct IntegerForSizeAndSign<8, false> { template struct UnsignedIntegerForSize { - typedef typename enable_if< + typedef typename std::enable_if< std::numeric_limits::is_integer, typename IntegerForSizeAndSign::type>::type type; }; template struct SignedIntegerForSize { - typedef typename enable_if< + typedef typename std::enable_if< std::numeric_limits::is_integer, typename IntegerForSizeAndSign::type>::type type; }; template struct TwiceWiderInteger { - typedef typename enable_if< + typedef typename std::enable_if< std::numeric_limits::is_integer, typename IntegerForSizeAndSign< sizeof(Integer) * 2, @@ -88,8 +88,9 @@ struct TwiceWiderInteger { template struct PositionOfSignBit { - static const typename enable_if::is_integer, - size_t>::type value = 8 * sizeof(Integer) - 1; + static const typename std::enable_if::is_integer, + size_t>::type value = + 8 * sizeof(Integer) - 1; }; // Helper templates for integer manipulations. @@ -112,7 +113,7 @@ T BinaryComplement(T x) { // way to coalesce things into the CheckedNumericState specializations below. template -typename enable_if::is_integer, T>::type +typename std::enable_if::is_integer, T>::type CheckedAdd(T x, T y, RangeConstraint* validity) { // Since the value of x+y is undefined if we have a signed type, we compute // it using the unsigned type of the same size. @@ -135,7 +136,7 @@ CheckedAdd(T x, T y, RangeConstraint* validity) { } template -typename enable_if::is_integer, T>::type +typename std::enable_if::is_integer, T>::type CheckedSub(T x, T y, RangeConstraint* validity) { // Since the value of x+y is undefined if we have a signed type, we compute // it using the unsigned type of the same size. @@ -162,9 +163,9 @@ CheckedSub(T x, T y, RangeConstraint* validity) { // slow case we need to manually check that the result won't be truncated by // checking with division against the appropriate bound. template -typename enable_if< - std::numeric_limits::is_integer && sizeof(T) * 2 <= sizeof(uintmax_t), - T>::type +typename std::enable_if::is_integer && + sizeof(T) * 2 <= sizeof(uintmax_t), + T>::type CheckedMul(T x, T y, RangeConstraint* validity) { typedef typename TwiceWiderInteger::type IntermediateType; IntermediateType tmp = @@ -174,9 +175,10 @@ CheckedMul(T x, T y, RangeConstraint* validity) { } template -typename enable_if::is_integer&& std::numeric_limits< - T>::is_signed&&(sizeof(T) * 2 > sizeof(uintmax_t)), - T>::type +typename std::enable_if::is_integer && + std::numeric_limits::is_signed && + (sizeof(T) * 2 > sizeof(uintmax_t)), + T>::type CheckedMul(T x, T y, RangeConstraint* validity) { // If either side is zero then the result will be zero. if (!x || !y) { @@ -203,10 +205,10 @@ CheckedMul(T x, T y, RangeConstraint* validity) { } template -typename enable_if::is_integer && - !std::numeric_limits::is_signed && - (sizeof(T) * 2 > sizeof(uintmax_t)), - T>::type +typename std::enable_if::is_integer && + !std::numeric_limits::is_signed && + (sizeof(T) * 2 > sizeof(uintmax_t)), + T>::type CheckedMul(T x, T y, RangeConstraint* validity) { *validity = (y == 0 || x <= std::numeric_limits::max() / y) ? RANGE_VALID @@ -216,11 +218,11 @@ CheckedMul(T x, T y, RangeConstraint* validity) { // Division just requires a check for an invalid negation on signed min/-1. template -T CheckedDiv( - T x, - T y, - RangeConstraint* validity, - typename enable_if::is_integer, int>::type = 0) { +T CheckedDiv(T x, + T y, + RangeConstraint* validity, + typename std::enable_if::is_integer, + int>::type = 0) { if (std::numeric_limits::is_signed && x == std::numeric_limits::min() && y == static_cast(-1)) { *validity = RANGE_OVERFLOW; @@ -232,27 +234,27 @@ T CheckedDiv( } template -typename enable_if< - std::numeric_limits::is_integer&& std::numeric_limits::is_signed, - T>::type +typename std::enable_if::is_integer && + std::numeric_limits::is_signed, + T>::type CheckedMod(T x, T y, RangeConstraint* validity) { *validity = y > 0 ? RANGE_VALID : RANGE_INVALID; return x % y; } template -typename enable_if< - std::numeric_limits::is_integer && !std::numeric_limits::is_signed, - T>::type +typename std::enable_if::is_integer && + !std::numeric_limits::is_signed, + T>::type CheckedMod(T x, T y, RangeConstraint* validity) { *validity = RANGE_VALID; return x % y; } template -typename enable_if< - std::numeric_limits::is_integer&& std::numeric_limits::is_signed, - T>::type +typename std::enable_if::is_integer && + std::numeric_limits::is_signed, + T>::type CheckedNeg(T value, RangeConstraint* validity) { *validity = value != std::numeric_limits::min() ? RANGE_VALID : RANGE_OVERFLOW; @@ -261,9 +263,9 @@ CheckedNeg(T value, RangeConstraint* validity) { } template -typename enable_if< - std::numeric_limits::is_integer && !std::numeric_limits::is_signed, - T>::type +typename std::enable_if::is_integer && + !std::numeric_limits::is_signed, + T>::type CheckedNeg(T value, RangeConstraint* validity) { // The only legal unsigned negation is zero. *validity = value ? RANGE_UNDERFLOW : RANGE_VALID; @@ -272,9 +274,9 @@ CheckedNeg(T value, RangeConstraint* validity) { } template -typename enable_if< - std::numeric_limits::is_integer&& std::numeric_limits::is_signed, - T>::type +typename std::enable_if::is_integer && + std::numeric_limits::is_signed, + T>::type CheckedAbs(T value, RangeConstraint* validity) { *validity = value != std::numeric_limits::min() ? RANGE_VALID : RANGE_OVERFLOW; @@ -282,9 +284,9 @@ CheckedAbs(T value, RangeConstraint* validity) { } template -typename enable_if< - std::numeric_limits::is_integer && !std::numeric_limits::is_signed, - T>::type +typename std::enable_if::is_integer && + !std::numeric_limits::is_signed, + T>::type CheckedAbs(T value, RangeConstraint* validity) { // Absolute value of a positive is just its identiy. *validity = RANGE_VALID; @@ -293,12 +295,12 @@ CheckedAbs(T value, RangeConstraint* validity) { // These are the floating point stubs that the compiler needs to see. Only the // negation operation is ever called. -#define BASE_FLOAT_ARITHMETIC_STUBS(NAME) \ - template \ - typename enable_if::is_iec559, T>::type \ - Checked##NAME(T, T, RangeConstraint*) { \ - NOTREACHED(); \ - return 0; \ +#define BASE_FLOAT_ARITHMETIC_STUBS(NAME) \ + template \ + typename std::enable_if::is_iec559, T>::type \ + Checked##NAME(T, T, RangeConstraint*) { \ + NOTREACHED(); \ + return 0; \ } BASE_FLOAT_ARITHMETIC_STUBS(Add) @@ -310,14 +312,14 @@ BASE_FLOAT_ARITHMETIC_STUBS(Mod) #undef BASE_FLOAT_ARITHMETIC_STUBS template -typename enable_if::is_iec559, T>::type CheckedNeg( +typename std::enable_if::is_iec559, T>::type CheckedNeg( T value, RangeConstraint*) { return -value; } template -typename enable_if::is_iec559, T>::type CheckedAbs( +typename std::enable_if::is_iec559, T>::type CheckedAbs( T value, RangeConstraint*) { return std::abs(value); @@ -377,8 +379,8 @@ class CheckedNumericState { template explicit CheckedNumericState( Src value, - typename enable_if::is_specialized, int>::type = - 0) + typename std::enable_if::is_specialized, + int>::type = 0) : value_(static_cast(value)), validity_(DstRangeRelationToSrcRange(value)) {} @@ -402,7 +404,8 @@ class CheckedNumericState { CheckedNumericState( Src value, RangeConstraint validity, - typename enable_if::is_integer, int>::type = 0) { + typename std::enable_if::is_integer, int>::type = + 0) { switch (DstRangeRelationToSrcRange(value)) { case RANGE_VALID: value_ = static_cast(value); @@ -428,8 +431,8 @@ class CheckedNumericState { template explicit CheckedNumericState( Src value, - typename enable_if::is_specialized, int>::type = - 0) + typename std::enable_if::is_specialized, + int>::type = 0) : value_(static_cast(value)) {} // Copy constructor. diff --git a/third_party/base/template_util.h b/third_party/base/template_util.h deleted file mode 100644 index 719f3f1c3a..0000000000 --- a/third_party/base/template_util.h +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PDFIUM_THIRD_PARTY_BASE_TEMPLATE_UTIL_H_ -#define PDFIUM_THIRD_PARTY_BASE_TEMPLATE_UTIL_H_ - -#include // For size_t. - -namespace pdfium { -namespace base { - -template -struct integral_constant { - static const T value = v; - typedef T value_type; - typedef integral_constant type; -}; - -typedef integral_constant true_type; -typedef integral_constant false_type; - -template struct is_same : public false_type {}; -template -struct is_same : true_type {}; - -template -struct enable_if {}; - -template -struct enable_if { typedef T type; }; - -namespace internal { - -// Types YesType and NoType are guaranteed such that sizeof(YesType) < -// sizeof(NoType). -typedef char YesType; - -struct NoType { - YesType dummy[2]; -}; - -// This class is an implementation detail for is_convertible, and you -// don't need to know how it works to use is_convertible. For those -// who care: we declare two different functions, one whose argument is -// of type To and one with a variadic argument list. We give them -// return types of different size, so we can use sizeof to trick the -// compiler into telling us which function it would have chosen if we -// had called it with an argument of type From. See Alexandrescu's -// _Modern C++ Design_ for more details on this sort of trick. - -struct ConvertHelper { - template - static YesType Test(To); - - template - static NoType Test(...); - - template - static From& Create(); -}; - -} // namespace internal - -// Inherits from true_type if From is convertible to To, false_type otherwise. -// -// Note that if the type is convertible, this will be a true_type REGARDLESS -// of whether or not the conversion would emit a warning. -template -struct is_convertible - : integral_constant( - internal::ConvertHelper::Create())) == - sizeof(internal::YesType)> {}; - -} // namespace base -} // namespace pdfium - -#endif // PDFIUM_THIRD_PARTY_BASE_TEMPLATE_UTIL_H_ diff --git a/third_party/third_party.gyp b/third_party/third_party.gyp index a8360e3c26..9bc9e04411 100644 --- a/third_party/third_party.gyp +++ b/third_party/third_party.gyp @@ -286,13 +286,11 @@ 'sources': [ 'base/logging.h', 'base/macros.h', - 'base/nonstd_unique_ptr.h', 'base/numerics/safe_conversions.h', 'base/numerics/safe_conversions_impl.h', 'base/numerics/safe_math.h', 'base/numerics/safe_math_impl.h', 'base/stl_util.h', - 'base/template_util.h', ], }, ], -- cgit v1.2.3