From 797ca5cad52edde7c65da45a15216f20b1bfd8fd Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 25 May 2017 12:03:18 -0700 Subject: Mass conversion of all const-lifetime class members Sed + minimal conversions to compile, including moving some constructors into the .cpp file. Any that caused ASAN issues during the tests were omitted rather than trying to resolve the underlying issue. Change-Id: I00a421f33b253eb4071ffd9af3f2922c7443b335 Reviewed-on: https://pdfium-review.googlesource.com/5891 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- fpdfsdk/cpdfsdk_baannot.cpp | 2 +- fpdfsdk/cpdfsdk_baannot.h | 2 +- fpdfsdk/cpdfsdk_widget.h | 4 ++-- fpdfsdk/fpdfxfa/cpdfxfa_page.h | 5 +++-- fpdfsdk/fsdk_pauseadapter.cpp | 2 +- fpdfsdk/fsdk_pauseadapter.h | 2 +- fpdfsdk/javascript/Document.cpp | 2 +- fpdfsdk/javascript/JS_Object.h | 4 ++-- fpdfsdk/javascript/JS_Value.cpp | 42 ++++++++++++++++++++--------------------- fpdfsdk/javascript/JS_Value.h | 4 ++-- fpdfsdk/pdfwindow/PWL_FontMap.h | 2 +- 11 files changed, 36 insertions(+), 35 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp index 129491c210..4f11f77f0b 100644 --- a/fpdfsdk/cpdfsdk_baannot.cpp +++ b/fpdfsdk/cpdfsdk_baannot.cpp @@ -27,7 +27,7 @@ CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_BAAnnot::~CPDFSDK_BAAnnot() {} CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot() const { - return m_pAnnot; + return m_pAnnot.Get(); } CPDF_Annot* CPDFSDK_BAAnnot::GetPDFPopupAnnot() const { diff --git a/fpdfsdk/cpdfsdk_baannot.h b/fpdfsdk/cpdfsdk_baannot.h index 2da5723eb4..4bf8f73823 100644 --- a/fpdfsdk/cpdfsdk_baannot.h +++ b/fpdfsdk/cpdfsdk_baannot.h @@ -100,7 +100,7 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot { void SetOpenState(bool bState); protected: - CPDF_Annot* const m_pAnnot; + CFX_UnownedPtr const m_pAnnot; }; #endif // FPDFSDK_CPDFSDK_BAANNOT_H_ diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h index 9f58cc1d61..a5e5b702dc 100644 --- a/fpdfsdk/cpdfsdk_widget.h +++ b/fpdfsdk/cpdfsdk_widget.h @@ -117,7 +117,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { PDFSDK_FieldAction& data, CPDFSDK_PageView* pPageView); - CPDFSDK_InterForm* GetInterForm() const { return m_pInterForm; } + CPDFSDK_InterForm* GetInterForm() const { return m_pInterForm.Get(); } CPDF_FormField* GetFormField() const; CPDF_FormControl* GetFormControl() const; static CPDF_FormControl* GetFormControl(CPDF_InterForm* pInterForm, @@ -160,7 +160,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { void AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage); void RemoveAppearance(const CFX_ByteString& sAPType); - CPDFSDK_InterForm* const m_pInterForm; + CFX_UnownedPtr const m_pInterForm; bool m_bAppModified; int32_t m_nAppAge; int32_t m_nValueAge; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h index d990813282..de2d19837d 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.h @@ -10,6 +10,7 @@ #include #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" class CFX_Matrix; @@ -25,7 +26,7 @@ class CPDFXFA_Page : public CFX_Retainable { bool LoadPage(); bool LoadPDFPage(CPDF_Dictionary* pageDict); - CPDFXFA_Context* GetContext() const { return m_pContext; } + CPDFXFA_Context* GetContext() const { return m_pContext.Get(); } int GetPageIndex() const { return m_iPageIndex; } CPDF_Page* GetPDFPage() const { return m_pPDFPage.get(); } CXFA_FFPageView* GetXFAPageView() const { return m_pXFAPageView; } @@ -73,7 +74,7 @@ class CPDFXFA_Page : public CFX_Retainable { private: std::unique_ptr m_pPDFPage; CXFA_FFPageView* m_pXFAPageView; - CPDFXFA_Context* const m_pContext; + CFX_UnownedPtr const m_pContext; const int m_iPageIndex; int m_iRef; }; diff --git a/fpdfsdk/fsdk_pauseadapter.cpp b/fpdfsdk/fsdk_pauseadapter.cpp index 237266b88b..cf99253ff9 100644 --- a/fpdfsdk/fsdk_pauseadapter.cpp +++ b/fpdfsdk/fsdk_pauseadapter.cpp @@ -12,5 +12,5 @@ IFSDK_PAUSE_Adapter::IFSDK_PAUSE_Adapter(IFSDK_PAUSE* IPause) IFSDK_PAUSE_Adapter::~IFSDK_PAUSE_Adapter() {} bool IFSDK_PAUSE_Adapter::NeedToPauseNow() { - return m_IPause->NeedToPauseNow && m_IPause->NeedToPauseNow(m_IPause); + return m_IPause->NeedToPauseNow && m_IPause->NeedToPauseNow(m_IPause.Get()); } diff --git a/fpdfsdk/fsdk_pauseadapter.h b/fpdfsdk/fsdk_pauseadapter.h index bd302f2613..66a628aa09 100644 --- a/fpdfsdk/fsdk_pauseadapter.h +++ b/fpdfsdk/fsdk_pauseadapter.h @@ -19,7 +19,7 @@ class IFSDK_PAUSE_Adapter : public IFX_Pause { bool NeedToPauseNow() override; private: - IFSDK_PAUSE* const m_IPause; + CFX_UnownedPtr const m_IPause; }; #endif // FPDFSDK_FSDK_PAUSEADAPTER_H_ diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index 38a4c12177..a760ad9956 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -1646,5 +1646,5 @@ void Document::DoFieldDelay(const CFX_WideString& sFieldName, } CJS_Document* Document::GetCJSDoc() const { - return static_cast(m_pJSObject); + return static_cast(m_pJSObject.Get()); } diff --git a/fpdfsdk/javascript/JS_Object.h b/fpdfsdk/javascript/JS_Object.h index 2e5c75c948..e32b8515b5 100644 --- a/fpdfsdk/javascript/JS_Object.h +++ b/fpdfsdk/javascript/JS_Object.h @@ -23,10 +23,10 @@ class CJS_EmbedObj { explicit CJS_EmbedObj(CJS_Object* pJSObject); virtual ~CJS_EmbedObj(); - CJS_Object* GetJSObject() const { return m_pJSObject; } + CJS_Object* GetJSObject() const { return m_pJSObject.Get(); } protected: - CJS_Object* const m_pJSObject; + CFX_UnownedPtr const m_pJSObject; }; class CJS_Object { diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index e9fa9a0fbe..dba0b76115 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -199,107 +199,107 @@ CJS_PropValue::~CJS_PropValue() {} void CJS_PropValue::operator<<(int iValue) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, iValue); + m_Value = CJS_Value(m_pJSRuntime.Get(), iValue); } void CJS_PropValue::operator>>(int& iValue) const { ASSERT(m_bIsSetting); - iValue = m_Value.ToInt(m_pJSRuntime); + iValue = m_Value.ToInt(m_pJSRuntime.Get()); } void CJS_PropValue::operator<<(bool bValue) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, bValue); + m_Value = CJS_Value(m_pJSRuntime.Get(), bValue); } void CJS_PropValue::operator>>(bool& bValue) const { ASSERT(m_bIsSetting); - bValue = m_Value.ToBool(m_pJSRuntime); + bValue = m_Value.ToBool(m_pJSRuntime.Get()); } void CJS_PropValue::operator<<(double dValue) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, dValue); + m_Value = CJS_Value(m_pJSRuntime.Get(), dValue); } void CJS_PropValue::operator>>(double& dValue) const { ASSERT(m_bIsSetting); - dValue = m_Value.ToDouble(m_pJSRuntime); + dValue = m_Value.ToDouble(m_pJSRuntime.Get()); } void CJS_PropValue::operator<<(CJS_Object* pObj) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, pObj); + m_Value = CJS_Value(m_pJSRuntime.Get(), pObj); } void CJS_PropValue::operator>>(CJS_Object*& ppObj) const { ASSERT(m_bIsSetting); - ppObj = m_Value.ToCJSObject(m_pJSRuntime); + ppObj = m_Value.ToCJSObject(m_pJSRuntime.Get()); } void CJS_PropValue::operator<<(CJS_Document* pJsDoc) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, pJsDoc); + m_Value = CJS_Value(m_pJSRuntime.Get(), pJsDoc); } void CJS_PropValue::operator>>(CJS_Document*& ppJsDoc) const { ASSERT(m_bIsSetting); - ppJsDoc = static_cast(m_Value.ToCJSObject(m_pJSRuntime)); + ppJsDoc = static_cast(m_Value.ToCJSObject(m_pJSRuntime.Get())); } void CJS_PropValue::operator<<(v8::Local pObj) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, pObj); + m_Value = CJS_Value(m_pJSRuntime.Get(), pObj); } void CJS_PropValue::operator>>(v8::Local& ppObj) const { ASSERT(m_bIsSetting); - ppObj = m_Value.ToV8Object(m_pJSRuntime); + ppObj = m_Value.ToV8Object(m_pJSRuntime.Get()); } void CJS_PropValue::operator<<(CFX_ByteString str) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, str.c_str()); + m_Value = CJS_Value(m_pJSRuntime.Get(), str.c_str()); } void CJS_PropValue::operator>>(CFX_ByteString& str) const { ASSERT(m_bIsSetting); - str = m_Value.ToCFXByteString(m_pJSRuntime); + str = m_Value.ToCFXByteString(m_pJSRuntime.Get()); } void CJS_PropValue::operator<<(const wchar_t* str) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, str); + m_Value = CJS_Value(m_pJSRuntime.Get(), str); } void CJS_PropValue::operator>>(CFX_WideString& wide_string) const { ASSERT(m_bIsSetting); - wide_string = m_Value.ToCFXWideString(m_pJSRuntime); + wide_string = m_Value.ToCFXWideString(m_pJSRuntime.Get()); } void CJS_PropValue::operator<<(CFX_WideString wide_string) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, wide_string.c_str()); + m_Value = CJS_Value(m_pJSRuntime.Get(), wide_string.c_str()); } void CJS_PropValue::operator>>(CJS_Array& array) const { ASSERT(m_bIsSetting); - m_Value.ConvertToArray(m_pJSRuntime, array); + m_Value.ConvertToArray(m_pJSRuntime.Get(), array); } void CJS_PropValue::operator<<(CJS_Array& array) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, array.ToV8Array(m_pJSRuntime)); + m_Value = CJS_Value(m_pJSRuntime.Get(), array.ToV8Array(m_pJSRuntime.Get())); } void CJS_PropValue::operator>>(CJS_Date& date) const { ASSERT(m_bIsSetting); - m_Value.ConvertToDate(m_pJSRuntime, date); + m_Value.ConvertToDate(m_pJSRuntime.Get(), date); } void CJS_PropValue::operator<<(CJS_Date& date) { ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime, date); + m_Value = CJS_Value(m_pJSRuntime.Get(), date); } CJS_Array::CJS_Array() {} diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h index 0c19701587..1a6d47fcea 100644 --- a/fpdfsdk/javascript/JS_Value.h +++ b/fpdfsdk/javascript/JS_Value.h @@ -89,7 +89,7 @@ class CJS_PropValue { void StartGetting() { m_bIsSetting = false; } bool IsSetting() const { return m_bIsSetting; } bool IsGetting() const { return !m_bIsSetting; } - CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; } + CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime.Get(); } CJS_Value* GetJSValue() { return &m_Value; } // These calls may re-enter JS (and hence invalidate objects). @@ -118,7 +118,7 @@ class CJS_PropValue { private: bool m_bIsSetting; CJS_Value m_Value; - CJS_Runtime* const m_pJSRuntime; + CFX_UnownedPtr const m_pJSRuntime; }; class CJS_Array { diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.h b/fpdfsdk/pdfwindow/PWL_FontMap.h index 2a532197cb..ca3ab231bd 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.h +++ b/fpdfsdk/pdfwindow/PWL_FontMap.h @@ -90,7 +90,7 @@ class CPWL_FontMap : public IPVT_FontMap { uint8_t nCharset); std::unique_ptr m_pPDFDoc; - CFX_SystemHandler* const m_pSystemHandler; + CFX_UnownedPtr const m_pSystemHandler; }; #endif // FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ -- cgit v1.2.3