mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-2243 rename Utilities to LXUtilities to lessen the chance of name confilcts.
X-SVN-Rev: 12011
This commit is contained in:
parent
81992cfd46
commit
f42d20e808
6 changed files with 144 additions and 19 deletions
99
icu4c/source/layoutex/LXUtilities.cpp
Normal file
99
icu4c/source/layoutex/LXUtilities.cpp
Normal file
|
@ -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
|
26
icu4c/source/layoutex/LXUtilities.h
Normal file
26
icu4c/source/layoutex/LXUtilities.h
Normal file
|
@ -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
|
|
@ -44,7 +44,7 @@ LIBS = $(LIBICUUC) $(LIBICULE) $(DEFAULT_LIBS)
|
|||
|
||||
OBJECTS = ParagraphLayout.o \
|
||||
RunArrays.o \
|
||||
Utilities.o
|
||||
LXUtilities.o
|
||||
|
||||
STATIC_OBJECTS = $(OBJECTS:.o=.$(STATIC_O))
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -130,19 +130,22 @@
|
|||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath="LXUtilities.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ParagraphLayout.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\RunArrays.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Utilities.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath="LXUtilities.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\layout\ParagraphLayout.h">
|
||||
<FileConfiguration
|
||||
|
@ -181,9 +184,6 @@
|
|||
Outputs="..\..\include\layout\RunArrays.h"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Utilities.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
|
|
Loading…
Add table
Reference in a new issue