From f42d20e80861c0117310be06e5ad7c9034b25fdd Mon Sep 17 00:00:00 2001 From: Eric Mader Date: Mon, 19 May 2003 21:50:48 +0000 Subject: [PATCH] ICU-2243 rename Utilities to LXUtilities to lessen the chance of name confilcts. X-SVN-Rev: 12011 --- icu4c/source/layoutex/LXUtilities.cpp | 99 +++++++++++++++++++++++ icu4c/source/layoutex/LXUtilities.h | 26 ++++++ icu4c/source/layoutex/Makefile.in | 2 +- icu4c/source/layoutex/ParagraphLayout.cpp | 8 +- icu4c/source/layoutex/layoutex.dsp | 16 ++-- icu4c/source/layoutex/layoutex.vcproj | 12 +-- 6 files changed, 144 insertions(+), 19 deletions(-) create mode 100644 icu4c/source/layoutex/LXUtilities.cpp create mode 100644 icu4c/source/layoutex/LXUtilities.h diff --git a/icu4c/source/layoutex/LXUtilities.cpp b/icu4c/source/layoutex/LXUtilities.cpp new file mode 100644 index 00000000000..d2ecb33dbf8 --- /dev/null +++ b/icu4c/source/layoutex/LXUtilities.cpp @@ -0,0 +1,99 @@ +/* + ********************************************************************** + * Copyright (C) 2002, International Business Machines + * Corporation and others. All Rights Reserved. + ********************************************************************** + */ + +#include "layout/LETypes.h" +#include "LXUtilities.h" + +U_NAMESPACE_BEGIN + +// +// Finds the high bit by binary searching +// through the bits in n. +// +le_int8 LXUtilities::highBit(le_int32 value) +{ + if (value <= 0) { + return -32; + } + + le_int8 bit = 0; + + if (value >= 1 << 16) { + value >>= 16; + bit += 16; + } + + if (value >= 1 << 8) { + value >>= 8; + bit += 8; + } + + if (value >= 1 << 4) { + value >>= 4; + bit += 4; + } + + if (value >= 1 << 2) { + value >>= 2; + bit += 2; + } + + if (value >= 1 << 1) { + value >>= 1; + bit += 1; + } + + return bit; +} + +le_int32 LXUtilities::search(le_int32 value, const le_int32 array[], le_int32 count) +{ + le_int32 power = 1 << highBit(count); + le_int32 extra = count - power; + le_int32 probe = power; + le_int32 index = 0; + + if (value >= array[extra]) { + index = extra; + } + + while (probe > (1 << 0)) { + probe >>= 1; + + if (value >= array[index + probe]) { + index += probe; + } + } + + return index; +} + +void LXUtilities::reverse(le_int32 array[], le_int32 length) +{ + le_int32 front, back; + + for (front = 0, back = length - 1; front < back; front += 1, back -= 1) { + le_int32 swap = array[front]; + + array[front] = array[back]; + array[back] = swap; + } +} + +void LXUtilities::reverse(float array[], le_int32 length) +{ + le_int32 front, back; + + for (front = 0, back = length - 1; front < back; front += 1, back -= 1) { + float swap = array[front]; + + array[front] = array[back]; + array[back] = swap; + } +} + +U_NAMESPACE_END diff --git a/icu4c/source/layoutex/LXUtilities.h b/icu4c/source/layoutex/LXUtilities.h new file mode 100644 index 00000000000..308b65f281b --- /dev/null +++ b/icu4c/source/layoutex/LXUtilities.h @@ -0,0 +1,26 @@ +/* + ********************************************************************** + * Copyright (C) 2003, International Business Machines + * Corporation and others. All Rights Reserved. + ********************************************************************** + */ + +#ifndef __LXUTILITIES_H + +#define __LXUTILITIES_H + +#include "layout/LETypes.h" + +U_NAMESPACE_BEGIN + +class LXUtilities +{ +public: + static le_int8 highBit(le_int32 value); + static le_int32 search(le_int32 value, const le_int32 array[], le_int32 count); + static void reverse(le_int32 array[], le_int32 count); + static void reverse(float array[], le_int32 count); +}; + +U_NAMESPACE_END +#endif diff --git a/icu4c/source/layoutex/Makefile.in b/icu4c/source/layoutex/Makefile.in index f5cf45c8e08..92f83437a8b 100644 --- a/icu4c/source/layoutex/Makefile.in +++ b/icu4c/source/layoutex/Makefile.in @@ -44,7 +44,7 @@ LIBS = $(LIBICUUC) $(LIBICULE) $(DEFAULT_LIBS) OBJECTS = ParagraphLayout.o \ RunArrays.o \ -Utilities.o +LXUtilities.o STATIC_OBJECTS = $(OBJECTS:.o=.$(STATIC_O)) diff --git a/icu4c/source/layoutex/ParagraphLayout.cpp b/icu4c/source/layoutex/ParagraphLayout.cpp index 9a1c9117ff9..dce0062a1bf 100644 --- a/icu4c/source/layoutex/ParagraphLayout.cpp +++ b/icu4c/source/layoutex/ParagraphLayout.cpp @@ -14,7 +14,7 @@ #include "unicode/uchriter.h" #include "unicode/brkiter.h" -#include "Utilities.h" +#include "LXUtilities.h" #include "usc_impl.h" /* this is currently private! */ #include "cstring.h" /* this too! */ @@ -307,10 +307,10 @@ ParagraphLayout::ParagraphLayout(const LEUnicode chars[], le_int32 count, } if ((fStyleRunInfo[run].level & 1) != 0) { - Utilities::reverse(&fGlyphWidths[glyphBase], glyphCount); - Utilities::reverse(&fGlyphToCharMap[glyphBase], glyphCount); + LXUtilities::reverse(&fGlyphWidths[glyphBase], glyphCount); + LXUtilities::reverse(&fGlyphToCharMap[glyphBase], glyphCount); - // Utilities::reverse(&fCharToGlyphMap[runStart], fStyleRunLimits[run] - runStart); + // LXUtilities::reverse(&fCharToGlyphMap[runStart], fStyleRunLimits[run] - runStart); // convert from visual to logical glyph indices for (glyph = glyphBase; glyph < glyphBase + glyphCount; glyph += 1) { le_int32 ch = fGlyphToCharMap[glyph]; diff --git a/icu4c/source/layoutex/layoutex.dsp b/icu4c/source/layoutex/layoutex.dsp index 6daed58ad35..7b89205089d 100644 --- a/icu4c/source/layoutex/layoutex.dsp +++ b/icu4c/source/layoutex/layoutex.dsp @@ -150,22 +150,26 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File +SOURCE=.\LXUtilities.cpp +# End Source File +# Begin Source File + SOURCE=.\ParagraphLayout.cpp # End Source File # Begin Source File SOURCE=.\RunArrays.cpp # End Source File -# Begin Source File - -SOURCE=.\Utilities.cpp -# End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=.\LXUtilities.h +# End Source File +# Begin Source File + SOURCE=.\layout\ParagraphLayout.h !IF "$(CFG)" == "layoutex - Win32 Release" @@ -257,10 +261,6 @@ InputPath=.\layout\RunArrays.h !ENDIF -# End Source File -# Begin Source File - -SOURCE=.\Utilities.h # End Source File # End Group # Begin Group "Resource Files" diff --git a/icu4c/source/layoutex/layoutex.vcproj b/icu4c/source/layoutex/layoutex.vcproj index 1d4cafea3ba..e20134dc2c8 100644 --- a/icu4c/source/layoutex/layoutex.vcproj +++ b/icu4c/source/layoutex/layoutex.vcproj @@ -130,19 +130,22 @@ + + - - + + - -