Skip to content

Commit a49d3d2

Browse files
committed
Fix x86 build of ChakraICU
1 parent 5fd7a32 commit a49d3d2

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

deps/Chakra.ICU/Chakra.ICU.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
<!-- ICU warning output is exceptionally noisy -->
66
<WarningLevel>TurnOffAllWarnings</WarningLevel>
77
<TreatWarningAsError>false</TreatWarningAsError>
8+
9+
<!-- ICU uses RTTI internally, while the rest of ChakraCore does not -->
810
<RuntimeTypeInfo>true</RuntimeTypeInfo>
911

12+
<!-- Common.Build.props sets the calling convention to stdcall for x86 and chpe, while ICU just wants the default -->
13+
<CallingConvention></CallingConvention>
14+
1015
<PreprocessorDefinitions Condition="'$(ChakraICU)'!='shared'">
1116
U_STATIC_IMPLEMENTATION=1;
1217
%(PreprocessorDefinitions)

lib/Runtime/Library/IntlEngineInterfaceExtensionObject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,8 @@ namespace Js
800800
}
801801

802802
#ifdef INTL_ICU
803-
typedef const char * (*GetAvailableLocaleFunc)(int);
804-
typedef int (*CountAvailableLocaleFunc)(void);
803+
typedef const char * (__cdecl *GetAvailableLocaleFunc)(int);
804+
typedef int (__cdecl *CountAvailableLocaleFunc)(void);
805805
static bool findLocale(JavascriptString *langtag, CountAvailableLocaleFunc countAvailable, GetAvailableLocaleFunc getAvailable)
806806
{
807807
char localeID[ULOC_FULLNAME_CAPACITY] = { 0 };

lib/Runtime/PlatformAgnostic/Platform/Common/UnicodeText.ICU.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ namespace PlatformAgnostic
6161
// Otherwise, we treat the char before as the invalid one and return index - 1
6262
// This function has defined behavior only for null-terminated strings.
6363
// If the string is not null terminated, the behavior is undefined (likely hang)
64-
static bool IsUtf16StringValid(const UChar* str, size_t length, int32* invalidIndex)
64+
static bool IsUtf16StringValid(const UChar* str, size_t length, size_t* invalidIndex)
6565
{
6666
Assert(invalidIndex != nullptr);
67-
*invalidIndex = -1;
67+
*invalidIndex = static_cast<size_t>(-1);
6868

69-
int32 i = 0;
69+
size_t i = 0;
7070
for (;;)
7171
{
7272
// Iterate through the UTF16-LE string
@@ -172,11 +172,11 @@ namespace PlatformAgnostic
172172
// is a malformed utf16 string. Maintain the same behavior here.
173173
// Note that Windows returns this failure only if the dest buffer
174174
// is passed in, not in the estimation case
175-
int32 invalidIndex = 0;
175+
size_t invalidIndex = 0;
176176
if (destString != nullptr && !IsUtf16StringValid((const UChar*) sourceString, sourceLength, &invalidIndex))
177177
{
178178
*pErrorOut = InvalidUnicodeText;
179-
return -1 * invalidIndex; // mimicking the behavior of Win32 NormalizeString
179+
return -1 * static_cast<int32>(invalidIndex); // mimicking the behavior of Win32 NormalizeString
180180
}
181181

182182
const UNormalizer2 *normalizer = StaticUNormalizerFactory(normalizationForm);
@@ -203,7 +203,7 @@ namespace PlatformAgnostic
203203

204204
// On Windows, IsNormalizedString returns failure if the string
205205
// is a malformed utf16 string. Maintain the same behavior here.
206-
int32 invalidIndex = 0;
206+
size_t invalidIndex = 0;
207207
if (!IsUtf16StringValid((const UChar*) testString, testStringLength, &invalidIndex))
208208
{
209209
return false;

0 commit comments

Comments
 (0)