From ad18d2fba9dd5833a2e34bfe90c8e3c9a485e805 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Wed, 9 May 2018 23:25:53 +0000 Subject: Use enum class instead of int in CJBig2_Context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL changes CJBig2_Context return methods as follows: * Internal methods return JBig2_Result instead of int. * Public methods return a bool (for success/failure) instead of int. In a followup, several of the enum class values may be merged together since they are not all needed. Change-Id: Ifdab83b8037262370cd7c4a80e94aa94d59aa589 Reviewed-on: https://pdfium-review.googlesource.com/32310 Reviewed-by: Lei Zhang Commit-Queue: Nicolás Peña Moreno --- core/fxcodec/codec/ccodec_jbig2module.h | 3 ++- core/fxcodec/codec/fx_codec_jbig.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'core/fxcodec/codec') diff --git a/core/fxcodec/codec/ccodec_jbig2module.h b/core/fxcodec/codec/ccodec_jbig2module.h index 306b079846..534c0a3ab6 100644 --- a/core/fxcodec/codec/ccodec_jbig2module.h +++ b/core/fxcodec/codec/ccodec_jbig2module.h @@ -51,7 +51,8 @@ class CCodec_Jbig2Module { PauseIndicatorIface* pPause); private: - FXCODEC_STATUS Decode(CCodec_Jbig2Context* pJbig2Context, int result); + FXCODEC_STATUS Decode(CCodec_Jbig2Context* pJbig2Context, + bool decode_success); }; #endif // CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_ diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp index d8d112bab0..36d6a0609e 100644 --- a/core/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/fxcodec/codec/fx_codec_jbig.cpp @@ -64,26 +64,26 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode( pJbig2Context->m_pContext = pdfium::MakeUnique( global_stream, src_stream, pJBig2DocumentContext->GetSymbolDictCache(), false); - int ret = pJbig2Context->m_pContext->GetFirstPage(dest_buf, width, height, - dest_pitch, pPause); - return Decode(pJbig2Context, ret); + bool succeeded = pJbig2Context->m_pContext->GetFirstPage( + dest_buf, width, height, dest_pitch, pPause); + return Decode(pJbig2Context, succeeded); } FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode( CCodec_Jbig2Context* pJbig2Context, PauseIndicatorIface* pPause) { - int ret = pJbig2Context->m_pContext->Continue(pPause); - return Decode(pJbig2Context, ret); + bool succeeded = pJbig2Context->m_pContext->Continue(pPause); + return Decode(pJbig2Context, succeeded); } FXCODEC_STATUS CCodec_Jbig2Module::Decode(CCodec_Jbig2Context* pJbig2Context, - int result) { + bool decode_success) { FXCODEC_STATUS status = pJbig2Context->m_pContext->GetProcessingStatus(); if (status != FXCODEC_STATUS_DECODE_FINISH) return status; pJbig2Context->m_pContext.reset(); - if (result != JBIG2_SUCCESS) + if (!decode_success) return FXCODEC_STATUS_ERROR; int dword_size = pJbig2Context->m_height * pJbig2Context->m_dest_pitch / 4; -- cgit v1.2.3