1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

AK+GMLCompiler+LibWeb: Remove JsonValue::is_double

This concludes a series of patches which remove the ability to observe
which arithmetic type is used to store number in JsonValue.
This commit is contained in:
Dan Klishch 2023-11-14 01:15:54 -05:00 committed by Andrew Kaster
parent faef802229
commit c49819cced
5 changed files with 6 additions and 21 deletions

View file

@ -235,7 +235,8 @@ static ErrorOr<String> generate_initializer_for(Optional<StringView> property_na
HANDLE_TYPE(i64, is_integer<i64>)
HANDLE_TYPE(u64, is_integer<u64>)
HANDLE_TYPE(bool, is_bool)
HANDLE_TYPE(double, is_double)
// FIXME: Do we want to allow precision loss when C++ compiler parses these doubles?
HANDLE_TYPE(double, is_number)
return Error::from_string_view("Inconsistent contained type in JSON array"sv);
#undef HANDLE_TYPE
}

View file

@ -764,11 +764,11 @@ size_t property_maximum_value_count(PropertyID property_id)
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
if (value.as_object().has("max-values"sv)) {
auto max_values = value.as_object().get("max-values"sv);
VERIFY(max_values.has_value() && max_values->is_number() && !max_values->is_double());
JsonValue max_values = value.as_object().get("max-values"sv).release_value();
VERIFY(max_values.is_integer<size_t>());
auto property_generator = generator.fork();
property_generator.set("name:titlecase", title_casify(name));
property_generator.set("max_values", max_values->template serialized<StringBuilder>());
property_generator.set("max_values", MUST(String::formatted("{}", max_values.as_integer<size_t>())));
property_generator.append(R"~~~(
case PropertyID::@name:titlecase@:
return @max_values@;