Make CBC_SymbolInfo::Lookup() return a const pointer.
Change-Id: I69b4db3f4882dfcf7de12c16fde592d66f56770f
Reviewed-on: https://pdfium-review.googlesource.com/c/46074
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
index db03022..5d60fbf 100644
--- a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
+++ b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
@@ -47,7 +47,7 @@
std::unique_ptr<CBC_CommonByteMatrix> encodeLowLevel(
CBC_DefaultPlacement* placement,
- CBC_SymbolInfo* symbolInfo) {
+ const CBC_SymbolInfo* symbolInfo) {
int32_t symbolWidth = symbolInfo->getSymbolDataWidth();
ASSERT(symbolWidth);
int32_t symbolHeight = symbolInfo->getSymbolDataHeight();
@@ -117,10 +117,12 @@
CBC_HighLevelEncoder::EncodeHighLevel(contents, ecLevel, false);
if (encoded.IsEmpty())
return nullptr;
- CBC_SymbolInfo* pSymbolInfo =
+
+ const CBC_SymbolInfo* pSymbolInfo =
CBC_SymbolInfo::Lookup(encoded.GetLength(), false);
if (!pSymbolInfo)
return nullptr;
+
WideString codewords =
CBC_ErrorCorrection::EncodeECC200(encoded, pSymbolInfo);
if (codewords.IsEmpty())
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.h b/fxbarcode/datamatrix/BC_EncoderContext.h
index afd202d..13f0037 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.h
+++ b/fxbarcode/datamatrix/BC_EncoderContext.h
@@ -41,7 +41,7 @@
WideString m_codewords;
size_t m_pos = 0;
int32_t m_newEncoding = -1;
- UnownedPtr<CBC_SymbolInfo> m_symbolInfo;
+ UnownedPtr<const CBC_SymbolInfo> m_symbolInfo;
private:
size_t getTotalMessageCharCount();
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
index 7ba8153..92f0f97 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.cpp
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
@@ -109,8 +109,8 @@
CBC_SymbolInfo::~CBC_SymbolInfo() = default;
-CBC_SymbolInfo* CBC_SymbolInfo::Lookup(int32_t iDataCodewords,
- bool bAllowRectangular) {
+const CBC_SymbolInfo* CBC_SymbolInfo::Lookup(int32_t iDataCodewords,
+ bool bAllowRectangular) {
for (size_t i = 0; i < kSymbolsCount; i++) {
CBC_SymbolInfo* symbol = g_symbols[i];
if (symbol->m_rectangular && !bAllowRectangular)
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.h b/fxbarcode/datamatrix/BC_SymbolInfo.h
index 75d7149..4655cb7 100644
--- a/fxbarcode/datamatrix/BC_SymbolInfo.h
+++ b/fxbarcode/datamatrix/BC_SymbolInfo.h
@@ -22,7 +22,8 @@
static void Initialize();
static void Finalize();
static void overrideSymbolSet(CBC_SymbolInfo* override);
- static CBC_SymbolInfo* Lookup(int32_t iDataCodewords, bool bAllowRectangular);
+ static const CBC_SymbolInfo* Lookup(int32_t iDataCodewords,
+ bool bAllowRectangular);
int32_t getSymbolDataWidth() const;
int32_t getSymbolDataHeight() const;