From 937840e1722d1f2b77d80575d6e710d760662c9c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 20 Oct 2015 13:30:34 -0400 Subject: Revert "Add type cast definitions for CPDF_Dictionary." This reverts commit 4816432671eef6467354aa252f22bb80acc315b7. Reason, broke the javascript_test Rendering PDF file /mnt/data/b/build/slave/linux/build/pdfium/out/Debug/gen/pdfium/testing/javascript/document_methods.pdf. Non-linearized path... FAILURE: document_methods.in; Command '['/mnt/data/b/build/slave/linux/build/pdfium/out/Debug/pdfium_test', '/mnt/data/b/build/slave/linux/build/pdfium/out/Debug/gen/pdfium/testing/javascript/document_methods.pdf']' returned non-zero exit status -11 BUG=pdfium:201 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1412413002 . --- .../fpdfapi/fpdf_parser/fpdf_parser_objects.cpp | 32 ++++++++-------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp') diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index 317f96d1dc..e1e821c4c5 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -28,7 +28,7 @@ void CPDF_Object::Destroy() { delete (CPDF_Array*)this; break; case PDFOBJ_DICTIONARY: - delete this->AsDictionary(); + delete (CPDF_Dictionary*)this; break; case PDFOBJ_STREAM: delete (CPDF_Stream*)this; @@ -138,9 +138,7 @@ int CPDF_Object::GetInteger() const { CPDF_Dictionary* CPDF_Object::GetDict() const { switch (m_Type) { case PDFOBJ_DICTIONARY: - // The method should be made non-const if we want to not be const. - // See bug #234. - return const_cast(this->AsDictionary()); + return (CPDF_Dictionary*)this; case PDFOBJ_STREAM: return ((CPDF_Stream*)this)->GetDict(); case PDFOBJ_REFERENCE: { @@ -217,7 +215,7 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const { case PDFOBJ_ARRAY: return (((CPDF_Array*)this)->Identical((CPDF_Array*)pOther)); case PDFOBJ_DICTIONARY: - return this->AsDictionary()->Identical(pOther->AsDictionary()); + return (((CPDF_Dictionary*)this)->Identical((CPDF_Dictionary*)pOther)); case PDFOBJ_NULL: return TRUE; case PDFOBJ_STREAM: @@ -266,7 +264,7 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, } case PDFOBJ_DICTIONARY: { CPDF_Dictionary* pCopy = new CPDF_Dictionary(); - const CPDF_Dictionary* pThis = this->AsDictionary(); + CPDF_Dictionary* pThis = (CPDF_Dictionary*)this; FX_POSITION pos = pThis->m_Map.GetStartPosition(); while (pos) { CFX_ByteString key; @@ -285,9 +283,9 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, acc.LoadAllData(pThis, TRUE); FX_DWORD streamSize = acc.GetSize(); CPDF_Dictionary* pDict = pThis->GetDict(); - if (pDict) { - pDict = pDict->CloneInternal(bDirect, visited)->AsDictionary(); - } + if (pDict) + pDict = (CPDF_Dictionary*)((CPDF_Object*)pDict) + ->CloneInternal(bDirect, visited); return new CPDF_Stream(acc.DetachData(), streamSize, pDict); } case PDFOBJ_REFERENCE: { @@ -337,14 +335,6 @@ void CPDF_Object::SetUnicodeText(const FX_WCHAR* pUnicodes, int len) { } } -CPDF_Dictionary* CPDF_Object::AsDictionary() { - return IsDictionary() ? static_cast(this) : nullptr; -} - -const CPDF_Dictionary* CPDF_Object::AsDictionary() const { - return IsDictionary() ? static_cast(this) : nullptr; -} - CPDF_Number::CPDF_Number(int value) : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(TRUE), m_Integer(value) {} @@ -452,8 +442,8 @@ CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const { if (!p) { return NULL; } - if (CPDF_Dictionary* pDict = p->AsDictionary()) { - return pDict; + if (p->GetType() == PDFOBJ_DICTIONARY) { + return (CPDF_Dictionary*)p; } if (p->GetType() == PDFOBJ_STREAM) { return ((CPDF_Stream*)p)->GetDict(); @@ -673,8 +663,8 @@ CPDF_Dictionary* CPDF_Dictionary::GetDict(const CFX_ByteStringC& key) const { if (!p) { return nullptr; } - if (CPDF_Dictionary* pDict = p->AsDictionary()) { - return pDict; + if (p->GetType() == PDFOBJ_DICTIONARY) { + return (CPDF_Dictionary*)p; } if (p->GetType() == PDFOBJ_STREAM) { return ((CPDF_Stream*)p)->GetDict(); -- cgit v1.2.3