From c78e309b162cafc1e5f4bf2acaa3933a06d7932b Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 20 Dec 2024 17:46:13 +0000 Subject: [PATCH] Codefix: Use snake_case instead of camelCase in layouters. --- src/gfx_layout.cpp | 14 +++++++------- src/gfx_layout_fallback.cpp | 6 +++--- src/gfx_layout_fallback.h | 2 +- src/gfx_layout_icu.h | 2 +- src/os/macosx/string_osx.cpp | 14 +++++++------- src/os/macosx/string_osx.h | 4 ++-- src/os/windows/string_uniscribe.cpp | 6 +++--- src/os/windows/string_uniscribe.h | 4 ++-- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp index 628dd2eb5a..5a7da3d963 100644 --- a/src/gfx_layout.cpp +++ b/src/gfx_layout.cpp @@ -68,11 +68,11 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s typename T::CharType *buff_begin = MallocT(str.size() + 1); const typename T::CharType *buffer_last = buff_begin + str.size() + 1; typename T::CharType *buff = buff_begin; - FontMap &fontMapping = line.runs; + FontMap &font_mapping = line.runs; Font *f = Layouter::GetFont(state.fontsize, state.cur_colour); line.buffer = buff_begin; - fontMapping.clear(); + font_mapping.clear(); auto cur = str.begin(); @@ -105,8 +105,8 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s continue; } - if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) { - fontMapping.emplace_back(buff - buff_begin, f); + if (font_mapping.empty() || font_mapping.back().first != buff - buff_begin) { + font_mapping.emplace_back(buff - buff_begin, f); } f = Layouter::GetFont(state.fontsize, state.cur_colour); } @@ -114,10 +114,10 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s /* Better safe than sorry. */ *buff = '\0'; - if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) { - fontMapping.emplace_back(buff - buff_begin, f); + if (font_mapping.empty() || font_mapping.back().first != buff - buff_begin) { + font_mapping.emplace_back(buff - buff_begin, f); } - line.layout = T::GetParagraphLayout(buff_begin, buff, fontMapping); + line.layout = T::GetParagraphLayout(buff_begin, buff, font_mapping); line.state_after = state; } diff --git a/src/gfx_layout_fallback.cpp b/src/gfx_layout_fallback.cpp index 6e2e02474f..d2a43fb602 100644 --- a/src/gfx_layout_fallback.cpp +++ b/src/gfx_layout_fallback.cpp @@ -79,12 +79,12 @@ public: * Get the actual ParagraphLayout for the given buffer. * @param buff The begin of the buffer. * @param buff_end The location after the last element in the buffer. - * @param fontMapping THe mapping of the fonts. + * @param font_mapping The mapping of the fonts. * @return The ParagraphLayout instance. */ -/* static */ std::unique_ptr FallbackParagraphLayoutFactory::GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &fontMapping) +/* static */ std::unique_ptr FallbackParagraphLayoutFactory::GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &font_mapping) { - return std::make_unique(buff, buff_end - buff, fontMapping); + return std::make_unique(buff, buff_end - buff, font_mapping); } /** diff --git a/src/gfx_layout_fallback.h b/src/gfx_layout_fallback.h index ad3f7a3405..bd93ac0ab7 100644 --- a/src/gfx_layout_fallback.h +++ b/src/gfx_layout_fallback.h @@ -22,7 +22,7 @@ public: /** Helper for GetLayouter, to get whether the layouter supports RTL. */ static const bool SUPPORTS_RTL = false; - static std::unique_ptr GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &fontMapping); + static std::unique_ptr GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &font_mapping); static size_t AppendToBuffer(char32_t *buff, const char32_t *buffer_last, char32_t c); }; diff --git a/src/gfx_layout_icu.h b/src/gfx_layout_icu.h index ff9c45c01d..931eb0f7ad 100644 --- a/src/gfx_layout_icu.h +++ b/src/gfx_layout_icu.h @@ -25,7 +25,7 @@ public: /** Helper for GetLayouter, to get whether the layouter supports RTL. */ static const bool SUPPORTS_RTL = true; - static std::unique_ptr GetParagraphLayout(UChar *buff, UChar *buff_end, FontMap &fontMapping); + static std::unique_ptr GetParagraphLayout(UChar *buff, UChar *buff_end, FontMap &font_mapping); static size_t AppendToBuffer(UChar *buff, const UChar *buffer_last, char32_t c); static void InitializeLayouter(); diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp index 56d742ce1f..c757e9560c 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -94,7 +94,7 @@ public: /** A single line worth of VisualRuns. */ class CoreTextLine : public std::vector, public ParagraphLayouter::Line { public: - CoreTextLine(CFAutoRelease line, const FontMap &fontMapping, const CoreTextParagraphLayoutFactory::CharType *buff) + CoreTextLine(CFAutoRelease line, const FontMap &font_mapping, const CoreTextParagraphLayoutFactory::CharType *buff) { CFArrayRef runs = CTLineGetGlyphRuns(line.get()); for (CFIndex i = 0; i < CFArrayGetCount(runs); i++) { @@ -102,7 +102,7 @@ public: /* Extract font information for this run. */ CFRange chars = CTRunGetStringRange(run); - auto map = std::ranges::upper_bound(fontMapping, chars.location, std::less{}, &std::pair::first); + auto map = std::ranges::upper_bound(font_mapping, chars.location, std::less{}, &std::pair::first); this->emplace_back(run, map->second, buff); } @@ -120,7 +120,7 @@ public: } }; - CoreTextParagraphLayout(CFAutoRelease typesetter, const CoreTextParagraphLayoutFactory::CharType *buffer, ptrdiff_t len, const FontMap &fontMapping) : text_buffer(buffer), length(len), font_map(fontMapping), typesetter(std::move(typesetter)) + CoreTextParagraphLayout(CFAutoRelease typesetter, const CoreTextParagraphLayoutFactory::CharType *buffer, ptrdiff_t len, const FontMap &font_mapping) : text_buffer(buffer), length(len), font_map(font_mapping), typesetter(std::move(typesetter)) { this->Reflow(); } @@ -148,7 +148,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = { &SpriteFontGetWidth }; -/* static */ std::unique_ptr CoreTextParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping) +/* static */ std::unique_ptr CoreTextParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &font_mapping) { if (!MacOSVersionIsAtLeast(10, 5, 0)) return nullptr; @@ -157,7 +157,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = { if (length == 0) return nullptr; /* Can't layout our in-built sprite fonts. */ - for (const auto &i : fontMapping) { + for (const auto &i : font_mapping) { if (i.second->fc->IsBuiltInFont()) return nullptr; } @@ -174,7 +174,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = { /* Apply font and colour ranges to our string. This is important to make sure * that we get proper glyph boundaries on style changes. */ int last = 0; - for (const auto &i : fontMapping) { + for (const auto &i : font_mapping) { if (i.first - last == 0) continue; CTFontRef font = (CTFontRef)i.second->fc->GetOSHandle(); @@ -209,7 +209,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = { /* Create and return typesetter for the string. */ CFAutoRelease typesetter(CTTypesetterCreateWithAttributedString(str.get())); - return typesetter ? std::make_unique(std::move(typesetter), buff, length, fontMapping) : nullptr; + return typesetter ? std::make_unique(std::move(typesetter), buff, length, font_mapping) : nullptr; } /* virtual */ std::unique_ptr CoreTextParagraphLayout::NextLine(int max_width) diff --git a/src/os/macosx/string_osx.h b/src/os/macosx/string_osx.h index d8f8fecc27..15ae46c051 100644 --- a/src/os/macosx/string_osx.h +++ b/src/os/macosx/string_osx.h @@ -49,10 +49,10 @@ public: * Get the actual ParagraphLayout for the given buffer. * @param buff The begin of the buffer. * @param buff_end The location after the last element in the buffer. - * @param fontMapping THe mapping of the fonts. + * @param font_mapping The mapping of the fonts. * @return The ParagraphLayout instance. */ - static std::unique_ptr GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping); + static std::unique_ptr GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &font_mapping); /** * Append a wide character to the internal buffer. diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp index 33ce5fd191..1feb8f41ce 100644 --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -276,14 +276,14 @@ static std::vector UniscribeItemizeString(UniscribeParagraphLayoutF return items; } -/* static */ std::unique_ptr UniscribeParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping) +/* static */ std::unique_ptr UniscribeParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &font_mapping) { int32_t length = buff_end - buff; /* Can't layout an empty string. */ if (length == 0) return nullptr; /* Can't layout our in-built sprite fonts. */ - for (auto const &pair : fontMapping) { + for (auto const &pair : font_mapping) { if (pair.second->fc->IsBuiltInFont()) return nullptr; } @@ -297,7 +297,7 @@ static std::vector UniscribeItemizeString(UniscribeParagraphLayoutF int cur_pos = 0; std::vector::iterator cur_item = items.begin(); - for (auto const &i : fontMapping) { + for (auto const &i : font_mapping) { while (cur_pos < i.first && cur_item != items.end() - 1) { /* Add a range that spans the intersection of the remaining item and font run. */ int stop_pos = std::min(i.first, (cur_item + 1)->iCharPos); diff --git a/src/os/windows/string_uniscribe.h b/src/os/windows/string_uniscribe.h index edb21f7c60..896b5f8745 100644 --- a/src/os/windows/string_uniscribe.h +++ b/src/os/windows/string_uniscribe.h @@ -31,10 +31,10 @@ public: * Get the actual ParagraphLayout for the given buffer. * @param buff The begin of the buffer. * @param buff_end The location after the last element in the buffer. - * @param fontMapping THe mapping of the fonts. + * @param font_mapping The mapping of the fonts. * @return The ParagraphLayout instance. */ - static std::unique_ptr GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping); + static std::unique_ptr GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &font_mapping); /** * Append a wide character to the internal buffer.