Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 772b2da

Browse files
committed
Prefix enums, remove DLLEXPORT from GetResultCode
Move SortHandle out of public API header, it is opaque structure
1 parent c152ba9 commit 772b2da

11 files changed

+152
-145
lines changed

src/corefx/System.Globalization.Native/pal_calendarData.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ ResultCode GlobalizationNative_GetCalendarInfo(
193193

194194
switch (dataType)
195195
{
196-
case NativeName:
196+
case CalendarData_NativeName:
197197
return GetNativeCalendarName(locale, calendarId, result, resultCapacity);
198-
case MonthDay:
198+
case CalendarData_MonthDay:
199199
return GetMonthDayPattern(locale, result, resultCapacity);
200200
default:
201201
assert(FALSE);
@@ -488,41 +488,41 @@ int32_t GlobalizationNative_EnumCalendarInfo(EnumCalendarInfoCallback callback,
488488

489489
switch (dataType)
490490
{
491-
case ShortDates:
491+
case CalendarData_ShortDates:
492492
// ShortDates to map kShort and kMedium in ICU, but also adding the "yMd"
493493
// skeleton as well, as this closely matches what is used on Windows
494494
return InvokeCallbackForDatePattern(locale, UDAT_SHORT, callback, context) &&
495495
InvokeCallbackForDatePattern(locale, UDAT_MEDIUM, callback, context) &&
496496
InvokeCallbackForDateTimePattern(locale, UDAT_YEAR_NUM_MONTH_DAY_UCHAR, callback, context);
497-
case LongDates:
497+
case CalendarData_LongDates:
498498
// LongDates map to kFull and kLong in ICU.
499499
return InvokeCallbackForDatePattern(locale, UDAT_FULL, callback, context) &&
500500
InvokeCallbackForDatePattern(locale, UDAT_LONG, callback, context);
501-
case YearMonths:
501+
case CalendarData_YearMonths:
502502
return InvokeCallbackForDateTimePattern(locale, UDAT_YEAR_MONTH_UCHAR, callback, context);
503-
case DayNames:
503+
case CalendarData_DayNames:
504504
return EnumSymbols(locale, calendarId, UDAT_STANDALONE_WEEKDAYS, 1, callback, context);
505-
case AbbrevDayNames:
505+
case CalendarData_AbbrevDayNames:
506506
return EnumSymbols(locale, calendarId, UDAT_STANDALONE_SHORT_WEEKDAYS, 1, callback, context);
507-
case MonthNames:
507+
case CalendarData_MonthNames:
508508
return EnumSymbols(locale, calendarId, UDAT_STANDALONE_MONTHS, 0, callback, context);
509-
case AbbrevMonthNames:
509+
case CalendarData_AbbrevMonthNames:
510510
return EnumSymbols(locale, calendarId, UDAT_STANDALONE_SHORT_MONTHS, 0, callback, context);
511-
case SuperShortDayNames:
511+
case CalendarData_SuperShortDayNames:
512512
// UDAT_STANDALONE_SHORTER_WEEKDAYS was added in ICU 51, and CentOS 7 currently uses ICU 50.
513513
// fallback to UDAT_STANDALONE_NARROW_WEEKDAYS in that case.
514514
#if HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS
515515
return EnumSymbols(locale, calendarId, UDAT_STANDALONE_SHORTER_WEEKDAYS, 1, callback, context);
516516
#else
517517
return EnumSymbols(locale, calendarId, UDAT_STANDALONE_NARROW_WEEKDAYS, 1, callback, context);
518518
#endif
519-
case MonthGenitiveNames:
519+
case CalendarData_MonthGenitiveNames:
520520
return EnumSymbols(locale, calendarId, UDAT_MONTHS, 0, callback, context);
521-
case AbbrevMonthGenitiveNames:
521+
case CalendarData_AbbrevMonthGenitiveNames:
522522
return EnumSymbols(locale, calendarId, UDAT_SHORT_MONTHS, 0, callback, context);
523-
case EraNames:
523+
case CalendarData_EraNames:
524524
return EnumSymbols(locale, calendarId, UDAT_ERAS, 0, callback, context);
525-
case AbbrevEraNames:
525+
case CalendarData_AbbrevEraNames:
526526
return EnumAbbrevEraNames(locale, calendarId, callback, context);
527527
default:
528528
assert(FALSE);

src/corefx/System.Globalization.Native/pal_calendarData.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ typedef uint16_t CalendarId;
4848
*/
4949
typedef enum
5050
{
51-
Uninitialized = 0,
52-
NativeName = 1,
53-
MonthDay = 2,
54-
ShortDates = 3,
55-
LongDates = 4,
56-
YearMonths = 5,
57-
DayNames = 6,
58-
AbbrevDayNames = 7,
59-
MonthNames = 8,
60-
AbbrevMonthNames = 9,
61-
SuperShortDayNames = 10,
62-
MonthGenitiveNames = 11,
63-
AbbrevMonthGenitiveNames = 12,
64-
EraNames = 13,
65-
AbbrevEraNames = 14,
51+
CalendarData_Uninitialized = 0,
52+
CalendarData_NativeName = 1,
53+
CalendarData_MonthDay = 2,
54+
CalendarData_ShortDates = 3,
55+
CalendarData_LongDates = 4,
56+
CalendarData_YearMonths = 5,
57+
CalendarData_DayNames = 6,
58+
CalendarData_AbbrevDayNames = 7,
59+
CalendarData_MonthNames = 8,
60+
CalendarData_AbbrevMonthNames = 9,
61+
CalendarData_SuperShortDayNames = 10,
62+
CalendarData_MonthGenitiveNames = 11,
63+
CalendarData_AbbrevMonthGenitiveNames = 12,
64+
CalendarData_EraNames = 13,
65+
CalendarData_AbbrevEraNames = 14,
6666
} CalendarDataType;
6767

6868
// the function pointer definition for the callback used in EnumCalendarInfo

src/corefx/System.Globalization.Native/pal_collation.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,24 @@ const int32_t CompareOptionsIgnoreWidth = 0x10;
3232
// change ICU's default behavior here isn't really justified unless someone has a strong reason
3333
// for !StringSort to behave differently.
3434

35+
typedef struct { int32_t key; UCollator* UCollator; } TCollatorMap;
36+
37+
/*
38+
* For increased performance, we cache the UCollator objects for a locale and
39+
* share them across threads. This is safe (and supported in ICU) if we ensure
40+
* multiple threads are only ever dealing with const UCollators.
41+
*/
42+
struct SortHandle
43+
{
44+
UCollator* regular;
45+
TCollatorMap* collatorsPerOption;
46+
pthread_mutex_t collatorsLockObject;
47+
void* pRoot;
48+
};
49+
3550
typedef struct { UChar* items; size_t capacity; size_t size; } UCharList;
3651

37-
int TreeComparer(const void* left, const void* right)
52+
static int TreeComparer(const void* left, const void* right)
3853
{
3954
const TCollatorMap* leftMap = left;
4055
const TCollatorMap* rightMap = right;

src/corefx/System.Globalization.Native/pal_collation.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,7 @@
66
#include "pal_locale.h"
77
#include "pal_errors.h"
88

9-
typedef struct { int32_t key; UCollator* UCollator; } TCollatorMap;
10-
11-
/*
12-
* For increased performance, we cache the UCollator objects for a locale and
13-
* share them across threads. This is safe (and supported in ICU) if we ensure
14-
* multiple threads are only ever dealing with const UCollators.
15-
*/
16-
typedef struct
17-
{
18-
UCollator* regular;
19-
TCollatorMap* collatorsPerOption;
20-
pthread_mutex_t collatorsLockObject;
21-
void* pRoot;
22-
} SortHandle;
9+
typedef struct SortHandle SortHandle;
2310

2411
DLLEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle);
2512

src/corefx/System.Globalization.Native/pal_errors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef enum
2121
/*
2222
Converts a UErrorCode to a ResultCode.
2323
*/
24-
DLLEXPORT static ResultCode GetResultCode(UErrorCode err)
24+
static ResultCode GetResultCode(UErrorCode err)
2525
{
2626
if (err == U_BUFFER_OVERFLOW_ERROR || err == U_STRING_NOT_TERMINATED_WARNING)
2727
{

src/corefx/System.Globalization.Native/pal_localeNumberData.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,13 @@ int32_t GlobalizationNative_GetLocaleInfoInt(
417417

418418
switch (localeNumberData)
419419
{
420-
case LanguageId:
420+
case LocaleNumber_LanguageId:
421421
*value = uloc_getLCID(locale);
422422
break;
423-
case MeasurementSystem:
423+
case LocaleNumber_MeasurementSystem:
424424
status = GetMeasurementSystem(locale, value);
425425
break;
426-
case FractionalDigitsCount:
426+
case LocaleNumber_FractionalDigitsCount:
427427
{
428428
UNumberFormat* numformat = unum_open(UNUM_DECIMAL, NULL, 0, locale, NULL, &status);
429429
if (U_SUCCESS(status))
@@ -433,10 +433,10 @@ int32_t GlobalizationNative_GetLocaleInfoInt(
433433
}
434434
break;
435435
}
436-
case NegativeNumberFormat:
436+
case LocaleNumber_NegativeNumberFormat:
437437
*value = GetNumberNegativePattern(locale);
438438
break;
439-
case MonetaryFractionalDigitsCount:
439+
case LocaleNumber_MonetaryFractionalDigitsCount:
440440
{
441441
UNumberFormat* numformat = unum_open(UNUM_CURRENCY, NULL, 0, locale, NULL, &status);
442442
if (U_SUCCESS(status))
@@ -446,13 +446,13 @@ int32_t GlobalizationNative_GetLocaleInfoInt(
446446
}
447447
break;
448448
}
449-
case PositiveMonetaryNumberFormat:
449+
case LocaleNumber_PositiveMonetaryNumberFormat:
450450
*value = GetCurrencyPositivePattern(locale);
451451
break;
452-
case NegativeMonetaryNumberFormat:
452+
case LocaleNumber_NegativeMonetaryNumberFormat:
453453
*value = GetCurrencyNegativePattern(locale);
454454
break;
455-
case FirstWeekOfYear:
455+
case LocaleNumber_FirstWeekOfYear:
456456
{
457457
// corresponds to DateTimeFormat.CalendarWeekRule
458458
UCalendar* pCal = ucal_open(NULL, 0, locale, UCAL_TRADITIONAL, &status);
@@ -463,15 +463,15 @@ int32_t GlobalizationNative_GetLocaleInfoInt(
463463
int minDaysInWeek = ucal_getAttribute(pCal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK);
464464
if (minDaysInWeek == 1)
465465
{
466-
*value = FirstDay;
466+
*value = WeekRule_FirstDay;
467467
}
468468
else if (minDaysInWeek == 7)
469469
{
470-
*value = FirstFullWeek;
470+
*value = WeekRule_FirstFullWeek;
471471
}
472472
else if (minDaysInWeek >= 4)
473473
{
474-
*value = FirstFourDayWeek;
474+
*value = WeekRule_FirstFourDayWeek;
475475
}
476476
else
477477
{
@@ -481,7 +481,7 @@ int32_t GlobalizationNative_GetLocaleInfoInt(
481481
ucal_close(pCal);
482482
break;
483483
}
484-
case ReadingLayout:
484+
case LocaleNumber_ReadingLayout:
485485
{
486486
// coresponds to values 0 and 1 in LOCALE_IREADINGLAYOUT (values 2 and 3 not
487487
// used in coreclr)
@@ -496,7 +496,7 @@ int32_t GlobalizationNative_GetLocaleInfoInt(
496496
}
497497
break;
498498
}
499-
case FirstDayofWeek:
499+
case LocaleNumber_FirstDayofWeek:
500500
{
501501
UCalendar* pCal = ucal_open(NULL, 0, locale, UCAL_TRADITIONAL, &status);
502502

@@ -507,10 +507,10 @@ int32_t GlobalizationNative_GetLocaleInfoInt(
507507
ucal_close(pCal);
508508
break;
509509
}
510-
case NegativePercentFormat:
510+
case LocaleNumber_NegativePercentFormat:
511511
*value = GetPercentNegativePattern(locale);
512512
break;
513-
case PositivePercentFormat:
513+
case LocaleNumber_PositivePercentFormat:
514514
*value = GetPercentPositivePattern(locale);
515515
break;
516516
default:
@@ -544,10 +544,10 @@ int32_t GlobalizationNative_GetLocaleInfoGroupingSizes(
544544
UNumberFormatStyle style;
545545
switch (localeGroupingData)
546546
{
547-
case Digit:
547+
case LocaleNumber_Digit:
548548
style = UNUM_DECIMAL;
549549
break;
550-
case Monetary:
550+
case LocaleNumber_Monetary:
551551
style = UNUM_CURRENCY;
552552
break;
553553
default:

src/corefx/System.Globalization.Native/pal_localeNumberData.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@
1010
// The numeric values of the enum members match their Win32 counterparts.
1111
typedef enum
1212
{
13-
LanguageId = 0x01,
14-
MeasurementSystem = 0x0D,
15-
FractionalDigitsCount = 0x00000011,
16-
NegativeNumberFormat = 0x00001010,
17-
MonetaryFractionalDigitsCount = 0x00000019,
18-
PositiveMonetaryNumberFormat = 0x0000001B,
19-
NegativeMonetaryNumberFormat = 0x0000001C,
20-
FirstDayofWeek = 0x0000100C,
21-
FirstWeekOfYear = 0x0000100D,
22-
ReadingLayout = 0x00000070,
23-
NegativePercentFormat = 0x00000074,
24-
PositivePercentFormat = 0x00000075,
25-
Digit = 0x00000010,
26-
Monetary = 0x00000018
13+
LocaleNumber_LanguageId = 0x01,
14+
LocaleNumber_MeasurementSystem = 0x0D,
15+
LocaleNumber_FractionalDigitsCount = 0x00000011,
16+
LocaleNumber_NegativeNumberFormat = 0x00001010,
17+
LocaleNumber_MonetaryFractionalDigitsCount = 0x00000019,
18+
LocaleNumber_PositiveMonetaryNumberFormat = 0x0000001B,
19+
LocaleNumber_NegativeMonetaryNumberFormat = 0x0000001C,
20+
LocaleNumber_FirstDayofWeek = 0x0000100C,
21+
LocaleNumber_FirstWeekOfYear = 0x0000100D,
22+
LocaleNumber_ReadingLayout = 0x00000070,
23+
LocaleNumber_NegativePercentFormat = 0x00000074,
24+
LocaleNumber_PositivePercentFormat = 0x00000075,
25+
LocaleNumber_Digit = 0x00000010,
26+
LocaleNumber_Monetary = 0x00000018
2727
} LocaleNumberData;
2828

2929
// Enum that corresponds to managed enum System.Globalization.CalendarWeekRule
3030
typedef enum
3131
{
32-
FirstDay = 0,
33-
FirstFullWeek = 1,
34-
FirstFourDayWeek = 2
32+
WeekRule_FirstDay = 0,
33+
WeekRule_FirstFullWeek = 1,
34+
WeekRule_FirstFourDayWeek = 2
3535
} CalendarWeekRule;
3636

3737
DLLEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName,

0 commit comments

Comments
 (0)