From c8017b2581b7ade6b05ba086eb7221465414173f Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 31 Jan 2017 13:02:10 -0800 Subject: Remove BC_EXCEPTION_CHECK macros These obfuscate control flow and save very few lines. Mechanical change (mostly), sed + clang-format and adding a few missing semicolons. Change-Id: If8ae06c23edea8c455c79eab589fee5142dc3409 Reviewed-on: https://pdfium-review.googlesource.com/2472 Reviewed-by: dsinclair Commit-Queue: dsinclair --- xfa/fxbarcode/oned/BC_OneDimWriter.cpp | 24 ++++++++++++++++-------- xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp | 6 ++++-- xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp | 6 ++++-- xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp | 12 ++++++++---- xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp | 6 ++++-- xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp | 6 ++++-- xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp | 6 ++++-- 7 files changed, 44 insertions(+), 22 deletions(-) (limited to 'xfa/fxbarcode/oned') diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index 24d257a630..49b1847d9c 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -103,7 +103,8 @@ uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, } else { ret = Encode(contents, outWidth, e); } - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } @@ -113,7 +114,8 @@ uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } @@ -319,7 +321,8 @@ void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, const CFX_WideStringC& contents, int32_t& e) { if (!m_output) - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); pOutBitmap->Clear(m_backgroundColor); @@ -342,7 +345,8 @@ void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { ShowChars(contents, pOutBitmap, nullptr, nullptr, m_barWidth, m_multiple, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } std::unique_ptr pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); @@ -355,7 +359,8 @@ void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, const CFX_WideStringC& contents, int32_t& e) { if (!m_output) - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; CFX_GraphStateData stateData; CFX_PathData path; @@ -382,7 +387,8 @@ void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, } if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { ShowChars(contents, nullptr, device, matrix, m_barWidth, m_multiple, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } } @@ -392,7 +398,8 @@ void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, bool isDevice, int32_t& e) { if (codeLength < 1) { - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } if (m_ModuleHeight < 20.0) { m_ModuleHeight = 20; @@ -456,7 +463,8 @@ void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, break; } m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; } outputX += m_multiple; } diff --git a/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp index fb0d7dcd72..399e5e7d40 100644 --- a/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp @@ -144,7 +144,8 @@ uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, @@ -159,7 +160,8 @@ uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp index ed2d2c1b24..f163b18663 100644 --- a/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp @@ -154,7 +154,8 @@ uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, @@ -163,7 +164,8 @@ uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } bool CBC_OnedCode128Writer::IsDigits(const CFX_ByteString& contents, diff --git a/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp b/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp index 9d5fdda968..a1ba5c8086 100644 --- a/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp @@ -130,7 +130,8 @@ uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, @@ -145,7 +146,8 @@ uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } void CBC_OnedCode39Writer::ToIntArray(int32_t a, int32_t* toReturn) { @@ -263,7 +265,8 @@ CFX_WideString CBC_OnedCode39Writer::encodedContents( CFX_ByteString str = checksumContent.UTF8Encode(); FX_CHAR checksum; checksum = CalcCheckSum(str, e); - BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString()); + if (e != BCExceptionNO) + return CFX_WideString(); str += checksum; encodedContents += checksum; } @@ -275,7 +278,8 @@ void CBC_OnedCode39Writer::RenderResult(const CFX_WideStringC& contents, bool isDevice, int32_t& e) { CFX_WideString encodedCon = encodedContents(contents, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); + if (e != BCExceptionNO) + return; CBC_OneDimWriter::RenderResult(encodedCon.AsStringC(), code, codeLength, isDevice, e); } diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp index 71d9ac6505..d4b21a8325 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -97,7 +97,8 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, @@ -111,7 +112,8 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp index ad3ee6160f..94019627ea 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -100,7 +100,8 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, @@ -115,7 +116,8 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, } uint8_t* ret = CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 42e84b7117..1f9a22d5f7 100644 --- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -87,7 +87,8 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, int32_t& outHeight, int32_t& e) { uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } @@ -105,7 +106,8 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, m_iDataLenth = 13; uint8_t* ret = m_subWriter->Encode(toEAN13String, BCFORMAT_EAN_13, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); + if (e != BCExceptionNO) + return nullptr; return ret; } -- cgit v1.2.3