mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibUnicode: Convert UnicodeNumberFormat to link with weak symbols
Currently, we load the generated Unicode symbols with dlopen at runtime.
This is unnecessary as of 565a880ce5
.
Applications that want Unicode data now link directly against the shared
library holding that data. So the same functionality can be achieved
with weak symbols.
This commit is contained in:
parent
ffb3ba3079
commit
98709d9be1
4 changed files with 17 additions and 62 deletions
|
@ -742,19 +742,19 @@ static void generate_unicode_locale_implementation(Core::File& file, UnicodeLoca
|
||||||
#include <LibUnicode/NumberFormat.h>
|
#include <LibUnicode/NumberFormat.h>
|
||||||
#include <LibUnicode/UnicodeNumberFormat.h>
|
#include <LibUnicode/UnicodeNumberFormat.h>
|
||||||
|
|
||||||
namespace Unicode::Detail {
|
namespace Unicode {
|
||||||
)~~~");
|
)~~~");
|
||||||
|
|
||||||
locale_data.unique_strings.generate(generator);
|
locale_data.unique_strings.generate(generator);
|
||||||
|
|
||||||
generator.append(R"~~~(
|
generator.append(R"~~~(
|
||||||
struct NumberFormat {
|
struct NumberFormatImpl {
|
||||||
Unicode::NumberFormat to_unicode_number_format() const {
|
NumberFormat to_unicode_number_format() const {
|
||||||
Unicode::NumberFormat number_format {};
|
NumberFormat number_format {};
|
||||||
|
|
||||||
number_format.magnitude = magnitude;
|
number_format.magnitude = magnitude;
|
||||||
number_format.exponent = exponent;
|
number_format.exponent = exponent;
|
||||||
number_format.plurality = static_cast<Unicode::NumberFormat::Plurality>(plurality);
|
number_format.plurality = static_cast<NumberFormat::Plurality>(plurality);
|
||||||
number_format.zero_format = s_string_list[zero_format];
|
number_format.zero_format = s_string_list[zero_format];
|
||||||
number_format.positive_format = s_string_list[positive_format];
|
number_format.positive_format = s_string_list[positive_format];
|
||||||
number_format.negative_format = s_string_list[negative_format];
|
number_format.negative_format = s_string_list[negative_format];
|
||||||
|
@ -803,7 +803,7 @@ struct Unit {
|
||||||
};
|
};
|
||||||
)~~~");
|
)~~~");
|
||||||
|
|
||||||
locale_data.unique_formats.generate(generator, "NumberFormat"sv, "s_number_formats"sv, 10);
|
locale_data.unique_formats.generate(generator, "NumberFormatImpl"sv, "s_number_formats"sv, 10);
|
||||||
locale_data.unique_format_lists.generate(generator, s_number_format_index_type, "s_number_format_lists"sv);
|
locale_data.unique_format_lists.generate(generator, s_number_format_index_type, "s_number_format_lists"sv);
|
||||||
locale_data.unique_symbols.generate(generator, s_string_index_type, "s_numeric_symbol_lists"sv);
|
locale_data.unique_symbols.generate(generator, s_string_index_type, "s_numeric_symbol_lists"sv);
|
||||||
locale_data.unique_systems.generate(generator, "NumberSystem"sv, "s_number_systems"sv, 10);
|
locale_data.unique_systems.generate(generator, "NumberSystem"sv, "s_number_systems"sv, 10);
|
||||||
|
@ -850,8 +850,7 @@ static NumberSystem const* find_number_system(StringView locale, StringView syst
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<StringView> get_number_system_symbol(StringView locale, StringView system, Unicode::NumericSymbol symbol) asm("unicode_get_number_system_symbol");
|
Optional<StringView> get_number_system_symbol(StringView locale, StringView system, NumericSymbol symbol)
|
||||||
Optional<StringView> get_number_system_symbol(StringView locale, StringView system, Unicode::NumericSymbol symbol)
|
|
||||||
{
|
{
|
||||||
if (auto const* number_system = find_number_system(locale, system); number_system != nullptr) {
|
if (auto const* number_system = find_number_system(locale, system); number_system != nullptr) {
|
||||||
auto symbols = s_numeric_symbol_lists.at(number_system->symbols);
|
auto symbols = s_numeric_symbol_lists.at(number_system->symbols);
|
||||||
|
@ -866,7 +865,6 @@ Optional<StringView> get_number_system_symbol(StringView locale, StringView syst
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<NumberGroupings> get_number_system_groupings(StringView locale, StringView system) asm("unicode_get_number_system_groupings");
|
|
||||||
Optional<NumberGroupings> get_number_system_groupings(StringView locale, StringView system)
|
Optional<NumberGroupings> get_number_system_groupings(StringView locale, StringView system)
|
||||||
{
|
{
|
||||||
if (auto const* number_system = find_number_system(locale, system); number_system != nullptr)
|
if (auto const* number_system = find_number_system(locale, system); number_system != nullptr)
|
||||||
|
@ -874,8 +872,7 @@ Optional<NumberGroupings> get_number_system_groupings(StringView locale, StringV
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Unicode::NumberFormat> get_standard_number_system_format(StringView locale, StringView system, StandardNumberFormatType type) asm("unicode_get_standard_number_system_format");
|
Optional<NumberFormat> get_standard_number_system_format(StringView locale, StringView system, StandardNumberFormatType type)
|
||||||
Optional<Unicode::NumberFormat> get_standard_number_system_format(StringView locale, StringView system, StandardNumberFormatType type)
|
|
||||||
{
|
{
|
||||||
if (auto const* number_system = find_number_system(locale, system); number_system != nullptr) {
|
if (auto const* number_system = find_number_system(locale, system); number_system != nullptr) {
|
||||||
@number_format_index_type@ format_index = 0;
|
@number_format_index_type@ format_index = 0;
|
||||||
|
@ -904,10 +901,9 @@ Optional<Unicode::NumberFormat> get_standard_number_system_format(StringView loc
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<Unicode::NumberFormat> get_compact_number_system_formats(StringView locale, StringView system, CompactNumberFormatType type) asm("unicode_get_compact_number_system_formats");
|
Vector<NumberFormat> get_compact_number_system_formats(StringView locale, StringView system, CompactNumberFormatType type)
|
||||||
Vector<Unicode::NumberFormat> get_compact_number_system_formats(StringView locale, StringView system, CompactNumberFormatType type)
|
|
||||||
{
|
{
|
||||||
Vector<Unicode::NumberFormat> formats;
|
Vector<NumberFormat> formats;
|
||||||
|
|
||||||
if (auto const* number_system = find_number_system(locale, system); number_system != nullptr) {
|
if (auto const* number_system = find_number_system(locale, system); number_system != nullptr) {
|
||||||
@number_format_list_index_type@ number_format_list_index { 0 };
|
@number_format_list_index_type@ number_format_list_index { 0 };
|
||||||
|
@ -956,10 +952,9 @@ static Unit const* find_units(StringView locale, StringView unit)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<Unicode::NumberFormat> get_unit_formats(StringView locale, StringView unit, Style style) asm("unicode_get_unit_formats");
|
Vector<NumberFormat> get_unit_formats(StringView locale, StringView unit, Style style)
|
||||||
Vector<Unicode::NumberFormat> get_unit_formats(StringView locale, StringView unit, Style style)
|
|
||||||
{
|
{
|
||||||
Vector<Unicode::NumberFormat> formats;
|
Vector<NumberFormat> formats;
|
||||||
|
|
||||||
if (auto const* units = find_units(locale, unit); units != nullptr) {
|
if (auto const* units = find_units(locale, unit); units != nullptr) {
|
||||||
@number_format_list_index_type@ number_format_list_index { 0 };
|
@number_format_list_index_type@ number_format_list_index { 0 };
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <LibUnicode/CharacterTypes.h>
|
#include <LibUnicode/CharacterTypes.h>
|
||||||
#include <LibUnicode/Locale.h>
|
#include <LibUnicode/Locale.h>
|
||||||
#include <LibUnicode/NumberFormat.h>
|
#include <LibUnicode/NumberFormat.h>
|
||||||
#include <LibUnicode/UnicodeSymbols.h>
|
|
||||||
|
|
||||||
#if ENABLE_UNICODE_DATA
|
#if ENABLE_UNICODE_DATA
|
||||||
# include <LibUnicode/UnicodeData.h>
|
# include <LibUnicode/UnicodeData.h>
|
||||||
|
@ -16,35 +15,11 @@
|
||||||
|
|
||||||
namespace Unicode {
|
namespace Unicode {
|
||||||
|
|
||||||
Optional<StringView> get_number_system_symbol(StringView locale, StringView system, NumericSymbol symbol)
|
Optional<StringView> __attribute__((weak)) get_number_system_symbol(StringView, StringView, NumericSymbol) { return {}; }
|
||||||
{
|
Optional<NumberGroupings> __attribute__((weak)) get_number_system_groupings(StringView, StringView) { return {}; }
|
||||||
static auto const& symbols = Detail::Symbols::ensure_loaded();
|
Optional<NumberFormat> __attribute__((weak)) get_standard_number_system_format(StringView, StringView, StandardNumberFormatType) { return {}; }
|
||||||
return symbols.get_number_system_symbol(locale, system, symbol);
|
Vector<NumberFormat> __attribute__((weak)) get_compact_number_system_formats(StringView, StringView, CompactNumberFormatType) { return {}; }
|
||||||
}
|
Vector<NumberFormat> __attribute__((weak)) get_unit_formats(StringView, StringView, Style) { return {}; }
|
||||||
|
|
||||||
Optional<NumberGroupings> get_number_system_groupings(StringView locale, StringView system)
|
|
||||||
{
|
|
||||||
static auto const& symbols = Detail::Symbols::ensure_loaded();
|
|
||||||
return symbols.get_number_system_groupings(locale, system);
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<NumberFormat> get_standard_number_system_format(StringView locale, StringView system, StandardNumberFormatType type)
|
|
||||||
{
|
|
||||||
static auto const& symbols = Detail::Symbols::ensure_loaded();
|
|
||||||
return symbols.get_standard_number_system_format(locale, system, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<NumberFormat> get_compact_number_system_formats(StringView locale, StringView system, CompactNumberFormatType type)
|
|
||||||
{
|
|
||||||
static auto const& symbols = Detail::Symbols::ensure_loaded();
|
|
||||||
return symbols.get_compact_number_system_formats(locale, system, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<NumberFormat> get_unit_formats(StringView locale, StringView unit, Style style)
|
|
||||||
{
|
|
||||||
static auto const& symbols = Detail::Symbols::ensure_loaded();
|
|
||||||
return symbols.get_unit_formats(locale, unit, style);
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<NumberFormat> select_pattern_with_plurality(Vector<NumberFormat> const& formats, double number)
|
Optional<NumberFormat> select_pattern_with_plurality(Vector<NumberFormat> const& formats, double number)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
# include <AK/Function.h>
|
# include <AK/Function.h>
|
||||||
# include <LibUnicode/DateTimeFormat.h>
|
# include <LibUnicode/DateTimeFormat.h>
|
||||||
# include <LibUnicode/Locale.h>
|
# include <LibUnicode/Locale.h>
|
||||||
# include <LibUnicode/NumberFormat.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Unicode::Detail {
|
namespace Unicode::Detail {
|
||||||
|
@ -112,12 +111,6 @@ Symbols const& Symbols::ensure_loaded()
|
||||||
load_symbol(symbols.add_likely_subtags, "unicode_add_likely_subtags");
|
load_symbol(symbols.add_likely_subtags, "unicode_add_likely_subtags");
|
||||||
load_symbol(symbols.resolve_most_likely_territory, "unicode_resolve_most_likely_territory");
|
load_symbol(symbols.resolve_most_likely_territory, "unicode_resolve_most_likely_territory");
|
||||||
|
|
||||||
load_symbol(symbols.get_number_system_symbol, "unicode_get_number_system_symbol");
|
|
||||||
load_symbol(symbols.get_number_system_groupings, "unicode_get_number_system_groupings");
|
|
||||||
load_symbol(symbols.get_standard_number_system_format, "unicode_get_standard_number_system_format");
|
|
||||||
load_symbol(symbols.get_compact_number_system_formats, "unicode_get_compact_number_system_formats");
|
|
||||||
load_symbol(symbols.get_unit_formats, "unicode_get_unit_formats");
|
|
||||||
|
|
||||||
load_symbol(symbols.get_regional_hour_cycles, "unicode_get_regional_hour_cycles");
|
load_symbol(symbols.get_regional_hour_cycles, "unicode_get_regional_hour_cycles");
|
||||||
load_symbol(symbols.get_calendar_date_format, "unicode_get_calendar_date_format");
|
load_symbol(symbols.get_calendar_date_format, "unicode_get_calendar_date_format");
|
||||||
load_symbol(symbols.get_calendar_time_format, "unicode_get_calendar_time_format");
|
load_symbol(symbols.get_calendar_time_format, "unicode_get_calendar_time_format");
|
||||||
|
|
|
@ -64,14 +64,6 @@ struct Symbols {
|
||||||
Optional<LanguageID> (*add_likely_subtags)(LanguageID const&);
|
Optional<LanguageID> (*add_likely_subtags)(LanguageID const&);
|
||||||
Optional<String> (*resolve_most_likely_territory)(LanguageID const&);
|
Optional<String> (*resolve_most_likely_territory)(LanguageID const&);
|
||||||
|
|
||||||
// Loaded from UnicodeNumberFormat.cpp:
|
|
||||||
|
|
||||||
Optional<StringView> (*get_number_system_symbol)(StringView, StringView, NumericSymbol);
|
|
||||||
Optional<NumberGroupings> (*get_number_system_groupings)(StringView, StringView);
|
|
||||||
Optional<NumberFormat> (*get_standard_number_system_format)(StringView, StringView, StandardNumberFormatType);
|
|
||||||
Vector<NumberFormat> (*get_compact_number_system_formats)(StringView, StringView, CompactNumberFormatType);
|
|
||||||
Vector<NumberFormat> (*get_unit_formats)(StringView, StringView, Style);
|
|
||||||
|
|
||||||
// Loaded from UnicodeDateTimeFormat.cpp:
|
// Loaded from UnicodeDateTimeFormat.cpp:
|
||||||
|
|
||||||
Vector<HourCycle> (*get_regional_hour_cycles)(StringView) { nullptr };
|
Vector<HourCycle> (*get_regional_hour_cycles)(StringView) { nullptr };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue