From b89669975f6156fce4ced5c8998125a845f8e7dc Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 21 Sep 2017 14:51:57 -0400 Subject: Move CFX_AutoRestorer to fxcrt::AutoRestorer This CL renames CFX_AutoRestorer to just AutoRestorer and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: Id9f36df94e95f3b2a55054bc198ca1bfd249ee3d Reviewed-on: https://pdfium-review.googlesource.com/14450 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- core/fpdfapi/parser/cpdf_syntax_parser.cpp | 10 +++++----- core/fpdfapi/render/cpdf_renderstatus.cpp | 4 ++-- core/fxcrt/autorestorer.h | 26 ++++++++++++++++++++++++++ core/fxcrt/cfx_autorestorer.h | 20 -------------------- 4 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 core/fxcrt/autorestorer.h delete mode 100644 core/fxcrt/cfx_autorestorer.h (limited to 'core') diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index 4412105c7b..4556dc9627 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -25,7 +25,7 @@ #include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfapi/parser/fpdf_parser_decode.h" #include "core/fpdfapi/parser/fpdf_parser_utility.h" -#include "core/fxcrt/cfx_autorestorer.h" +#include "core/fxcrt/autorestorer.h" #include "core/fxcrt/cfx_binarybuf.h" #include "core/fxcrt/fx_extension.h" #include "third_party/base/numerics/safe_math.h" @@ -55,7 +55,7 @@ CPDF_SyntaxParser::~CPDF_SyntaxParser() { } bool CPDF_SyntaxParser::GetCharAt(FX_FILESIZE pos, uint8_t& ch) { - CFX_AutoRestorer save_pos(&m_Pos); + AutoRestorer save_pos(&m_Pos); m_Pos = pos; return GetNextChar(ch); } @@ -352,7 +352,7 @@ ByteString CPDF_SyntaxParser::GetNextWord(bool* bIsNumber) { } ByteString CPDF_SyntaxParser::PeekNextWord(bool* bIsNumber) { - const CFX_AutoRestorer save_pos(&m_Pos); + AutoRestorer save_pos(&m_Pos); return GetNextWord(bIsNumber); } @@ -379,7 +379,7 @@ std::unique_ptr CPDF_SyntaxParser::GetObjectInternal( uint32_t gennum, bool bDecrypt, ParseType parse_type) { - CFX_AutoRestorer restorer(&s_CurrentRecursionDepth); + AutoRestorer restorer(&s_CurrentRecursionDepth); if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) return nullptr; @@ -485,7 +485,7 @@ std::unique_ptr CPDF_SyntaxParser::GetObjectInternal( // contents to the un-decrypted form. if (m_pCryptoHandler && bDecrypt && pDict->IsSignatureDict() && dwSignValuePos) { - CFX_AutoRestorer save_pos(&m_Pos); + AutoRestorer save_pos(&m_Pos); m_Pos = dwSignValuePos; pDict->SetFor("Contents", GetObject(pObjList, objnum, gennum, false)); } diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 6d7e7f1372..26eed112c5 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -45,7 +45,7 @@ #include "core/fpdfapi/render/cpdf_transferfunc.h" #include "core/fpdfapi/render/cpdf_type3cache.h" #include "core/fpdfdoc/cpdf_occontext.h" -#include "core/fxcrt/cfx_autorestorer.h" +#include "core/fxcrt/autorestorer.h" #include "core/fxcrt/cfx_fixedbufgrow.h" #include "core/fxcrt/cfx_maybe_owned.h" #include "core/fxcrt/fx_safe_types.h" @@ -1079,7 +1079,7 @@ void CPDF_RenderStatus::RenderSingleObject(CPDF_PageObject* pObj, #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif - CFX_AutoRestorer restorer(&s_CurrentRecursionDepth); + AutoRestorer restorer(&s_CurrentRecursionDepth); if (++s_CurrentRecursionDepth > kRenderMaxRecursionDepth) { return; } diff --git a/core/fxcrt/autorestorer.h b/core/fxcrt/autorestorer.h new file mode 100644 index 0000000000..745a56fff2 --- /dev/null +++ b/core/fxcrt/autorestorer.h @@ -0,0 +1,26 @@ +// Copyright 2017 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. + +#ifndef CORE_FXCRT_AUTORESTORER_H_ +#define CORE_FXCRT_AUTORESTORER_H_ + +namespace fxcrt { + +template +class AutoRestorer { + public: + explicit AutoRestorer(T* location) + : m_Location(location), m_OldValue(*location) {} + ~AutoRestorer() { *m_Location = m_OldValue; } + + private: + T* const m_Location; + const T m_OldValue; +}; + +} // namespace fxcrt + +using fxcrt::AutoRestorer; + +#endif // CORE_FXCRT_AUTORESTORER_H_ diff --git a/core/fxcrt/cfx_autorestorer.h b/core/fxcrt/cfx_autorestorer.h deleted file mode 100644 index a8c5125c4e..0000000000 --- a/core/fxcrt/cfx_autorestorer.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 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. - -#ifndef CORE_FXCRT_CFX_AUTORESTORER_H_ -#define CORE_FXCRT_CFX_AUTORESTORER_H_ - -template -class CFX_AutoRestorer { - public: - explicit CFX_AutoRestorer(T* location) - : m_Location(location), m_OldValue(*location) {} - ~CFX_AutoRestorer() { *m_Location = m_OldValue; } - - private: - T* const m_Location; - const T m_OldValue; -}; - -#endif // CORE_FXCRT_CFX_AUTORESTORER_H_ -- cgit v1.2.3