mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:38:10 +00:00
LibJS: Hook the Intl mathematical value into Intl.NumberFormat
This commit is contained in:
parent
0026e9a4c8
commit
292b8908b5
10 changed files with 201 additions and 305 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Runtime/Intl/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Intl/MathematicalValue.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibUnicode/Locale.h>
|
||||
#include <LibUnicode/NumberFormat.h>
|
||||
|
@ -257,8 +258,8 @@ private:
|
|||
};
|
||||
|
||||
struct FormatResult {
|
||||
String formatted_string; // [[FormattedString]]
|
||||
Value rounded_number { 0.0 }; // [[RoundedNumber]]
|
||||
String formatted_string; // [[FormattedString]]
|
||||
MathematicalValue rounded_number { 0.0 }; // [[RoundedNumber]]
|
||||
};
|
||||
|
||||
struct RawFormatResult : public FormatResult {
|
||||
|
@ -272,18 +273,19 @@ enum class RoundingDecision {
|
|||
};
|
||||
|
||||
int currency_digits(StringView currency);
|
||||
FormatResult format_numeric_to_string(GlobalObject& global_object, NumberFormatBase const& intl_object, Value number);
|
||||
Vector<PatternPartition> partition_number_pattern(GlobalObject& global_object, NumberFormat& number_format, Value number);
|
||||
Vector<PatternPartition> partition_notation_sub_pattern(GlobalObject& global_object, NumberFormat& number_format, Value number, String formatted_string, int exponent);
|
||||
String format_numeric(GlobalObject& global_object, NumberFormat& number_format, Value number);
|
||||
Array* format_numeric_to_parts(GlobalObject& global_object, NumberFormat& number_format, Value number);
|
||||
RawFormatResult to_raw_precision(GlobalObject& global_object, Value number, int min_precision, int max_precision, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
|
||||
RawFormatResult to_raw_fixed(GlobalObject& global_object, Value number, int min_fraction, int max_fraction, int rounding_increment, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
|
||||
Optional<Variant<StringView, String>> get_number_format_pattern(GlobalObject& global_object, NumberFormat& number_format, Value number, Unicode::NumberFormat& found_pattern);
|
||||
FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, MathematicalValue number);
|
||||
Vector<PatternPartition> partition_number_pattern(GlobalObject& global_object, NumberFormat& number_format, MathematicalValue number);
|
||||
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, String formatted_string, int exponent);
|
||||
String format_numeric(GlobalObject& global_object, NumberFormat& number_format, MathematicalValue number);
|
||||
Array* format_numeric_to_parts(GlobalObject& global_object, NumberFormat& number_format, MathematicalValue number);
|
||||
RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precision, int max_precision, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
|
||||
RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction, int max_fraction, int rounding_increment, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
|
||||
Optional<Variant<StringView, String>> get_number_format_pattern(GlobalObject& global_object, NumberFormat& number_format, MathematicalValue const& number, Unicode::NumberFormat& found_pattern);
|
||||
Optional<StringView> get_notation_sub_pattern(NumberFormat& number_format, int exponent);
|
||||
int compute_exponent(GlobalObject& global_object, NumberFormat& number_format, Value number);
|
||||
int compute_exponent(NumberFormat& number_format, MathematicalValue number);
|
||||
int compute_exponent_for_magnitude(NumberFormat& number_format, int magnitude);
|
||||
ThrowCompletionOr<MathematicalValue> to_intl_mathematical_value(GlobalObject& global_object, Value value);
|
||||
NumberFormat::UnsignedRoundingMode get_unsigned_rounding_mode(NumberFormat::RoundingMode rounding_mode, bool is_negative);
|
||||
RoundingDecision apply_unsigned_rounding_mode(GlobalObject& global_object, Value x, Value r1, Value r2, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
|
||||
RoundingDecision apply_unsigned_rounding_mode(MathematicalValue const& x, MathematicalValue const& r1, MathematicalValue const& r2, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue