[metadata] Fix leaks when handling a few attributes (#16675)
[mono-project.git] / mono / metadata / culture-info.h
blob38b17cd6ca24c3bfaae85cfc9ad1e5d6c72e562a
1 /**
2 * \file
3 */
5 #ifndef _MONO_METADATA_CULTURE_INFO_H_
6 #define _MONO_METADATA_CULTURE_INFO_H_ 1
8 #include <glib.h>
9 #include <mono/metadata/object.h>
11 #define NUM_DAYS 7
12 #define NUM_MONTHS 13
13 #define GROUP_SIZE 2
14 #define NUM_CALENDARS 4
16 #define NUM_SHORT_DATE_PATTERNS 14
17 #define NUM_LONG_DATE_PATTERNS 10
18 #define NUM_SHORT_TIME_PATTERNS 12
19 #define NUM_LONG_TIME_PATTERNS 9
20 #define NUM_YEAR_MONTH_PATTERNS 8
22 #define idx2string(idx) (locale_strings + (idx))
23 #define pattern2string(idx) (patterns + (idx))
24 #define dtidx2string(idx) (datetime_strings + (idx))
26 /* need to change this if the string data ends up to not fit in a 64KB array. */
27 typedef guint16 stridx_t;
29 typedef struct {
30 stridx_t month_day_pattern;
31 stridx_t am_designator;
32 stridx_t pm_designator;
34 stridx_t day_names [NUM_DAYS];
35 stridx_t abbreviated_day_names [NUM_DAYS];
36 stridx_t shortest_day_names [NUM_DAYS];
37 stridx_t month_names [NUM_MONTHS];
38 stridx_t month_genitive_names [NUM_MONTHS];
39 stridx_t abbreviated_month_names [NUM_MONTHS];
40 stridx_t abbreviated_month_genitive_names [NUM_MONTHS];
42 gint8 calendar_week_rule;
43 gint8 first_day_of_week;
45 stridx_t date_separator;
46 stridx_t time_separator;
48 stridx_t short_date_patterns [NUM_SHORT_DATE_PATTERNS];
49 stridx_t long_date_patterns [NUM_LONG_DATE_PATTERNS];
50 stridx_t short_time_patterns [NUM_SHORT_TIME_PATTERNS];
51 stridx_t long_time_patterns [NUM_LONG_TIME_PATTERNS];
52 stridx_t year_month_patterns [NUM_YEAR_MONTH_PATTERNS];
53 } DateTimeFormatEntry;
55 typedef struct {
56 // 12x ushort -- 6 ints
57 stridx_t currency_decimal_separator;
58 stridx_t currency_group_separator;
59 stridx_t number_decimal_separator;
60 stridx_t number_group_separator;
62 stridx_t currency_symbol;
63 stridx_t percent_symbol;
64 stridx_t nan_symbol;
65 stridx_t per_mille_symbol;
66 stridx_t negative_infinity_symbol;
67 stridx_t positive_infinity_symbol;
69 stridx_t negative_sign;
70 stridx_t positive_sign;
72 // 7x gint8 -- FIXME expand to 8, or sort by size.
73 // For this reason, copy the data to a simpler "managed" form.
74 gint8 currency_negative_pattern;
75 gint8 currency_positive_pattern;
76 gint8 percent_negative_pattern;
77 gint8 percent_positive_pattern;
78 gint8 number_negative_pattern;
80 gint8 currency_decimal_digits;
81 gint8 number_decimal_digits;
83 gint currency_group_sizes [2];
84 gint number_group_sizes [2];
85 } NumberFormatEntry;
87 // Due to the questionable layout of NumberFormatEntry, in particular
88 // 7x byte, make something more guaranteed to match between native and managed.
89 // mono/metadta/culture-info.h NumberFormatEntryManaged must match
90 // mcs/class/corlib/ReferenceSources/CultureData.cs NumberFormatEntryManaged.
91 // This is sorted alphabetically.
92 struct NumberFormatEntryManaged {
93 gint32 currency_decimal_digits;
94 gint32 currency_decimal_separator;
95 gint32 currency_group_separator;
96 gint32 currency_group_sizes0;
97 gint32 currency_group_sizes1;
98 gint32 currency_negative_pattern;
99 gint32 currency_positive_pattern;
100 gint32 currency_symbol;
101 gint32 nan_symbol;
102 gint32 negative_infinity_symbol;
103 gint32 negative_sign;
104 gint32 number_decimal_digits;
105 gint32 number_decimal_separator;
106 gint32 number_group_separator;
107 gint32 number_group_sizes0;
108 gint32 number_group_sizes1;
109 gint32 number_negative_pattern;
110 gint32 per_mille_symbol;
111 gint32 percent_negative_pattern;
112 gint32 percent_positive_pattern;
113 gint32 percent_symbol;
114 gint32 positive_infinity_symbol;
115 gint32 positive_sign;
118 typedef struct {
119 gint ansi;
120 gint ebcdic;
121 gint mac;
122 gint oem;
123 MonoBoolean is_right_to_left;
124 char list_sep;
125 } TextInfoEntry;
127 typedef struct {
128 gint16 lcid;
129 gint16 parent_lcid;
130 gint16 calendar_type;
131 gint16 region_entry_index;
132 stridx_t name;
133 stridx_t englishname;
134 stridx_t nativename;
135 stridx_t win3lang;
136 stridx_t iso3lang;
137 stridx_t iso2lang;
138 stridx_t territory;
139 stridx_t native_calendar_names [NUM_CALENDARS];
141 gint16 datetime_format_index;
142 gint16 number_format_index;
144 TextInfoEntry text_info;
145 } CultureInfoEntry;
147 typedef struct {
148 stridx_t name;
149 gint16 culture_entry_index;
150 } CultureInfoNameEntry;
152 typedef struct {
153 gint16 geo_id;
154 stridx_t iso2name;
155 stridx_t iso3name;
156 stridx_t win3name;
157 stridx_t english_name;
158 stridx_t native_name;
159 stridx_t currency_symbol;
160 stridx_t iso_currency_symbol;
161 stridx_t currency_english_name;
162 stridx_t currency_native_name;
163 } RegionInfoEntry;
165 typedef struct {
166 stridx_t name;
167 gint16 region_entry_index;
168 } RegionInfoNameEntry;
170 #endif