1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 12:08:14 +00:00

CodeGenerators: Replace uses of JsonObject::get_deprecated()/get_ptr()

This commit is contained in:
Sam Atkins 2022-12-21 14:37:27 +00:00 committed by Tim Flynn
parent 77e15ff4da
commit ad9b2043dd
9 changed files with 323 additions and 326 deletions

View file

@ -138,9 +138,9 @@ bool media_feature_type_is_range(MediaFeatureID media_feature_id)
auto member_generator = generator.fork();
member_generator.set("name:titlecase", title_casify(name));
VERIFY(feature.has("type"sv));
auto feature_type = feature.get_deprecated("type"sv);
VERIFY(feature_type.is_string());
member_generator.set("is_range", feature_type.as_string() == "range" ? "true" : "false");
auto feature_type = feature.get_deprecated_string("type"sv);
VERIFY(feature_type.has_value());
member_generator.set("is_range", feature_type.value() == "range" ? "true" : "false");
member_generator.append(R"~~~(
case MediaFeatureID::@name:titlecase@:
return @is_range@;)~~~");
@ -173,9 +173,9 @@ bool media_feature_accepts_type(MediaFeatureID media_feature_id, MediaFeatureVal
}
have_output_value_type_switch = true;
};
auto& values = feature.get_deprecated("values"sv);
VERIFY(values.is_array());
auto& values_array = values.as_array();
auto values = feature.get_array("values"sv);
VERIFY(values.has_value());
auto& values_array = values.value();
for (auto& type : values_array.values()) {
VERIFY(type.is_string());
auto type_name = type.as_string();
@ -251,9 +251,9 @@ bool media_feature_accepts_identifier(MediaFeatureID media_feature_id, ValueID i
}
have_output_identifier_switch = true;
};
auto& values = feature.get_deprecated("values"sv);
VERIFY(values.is_array());
auto& values_array = values.as_array();
auto values = feature.get_array("values"sv);
VERIFY(values.has_value());
auto& values_array = values.value();
for (auto& identifier : values_array.values()) {
VERIFY(identifier.is_string());
auto identifier_name = identifier.as_string();

View file

@ -230,9 +230,9 @@ bool is_inherited_property(PropertyID property_id)
bool inherited = false;
if (value.as_object().has("inherited"sv)) {
auto& inherited_value = value.as_object().get_deprecated("inherited"sv);
VERIFY(inherited_value.is_bool());
inherited = inherited_value.as_bool();
auto inherited_value = value.as_object().get_bool("inherited"sv);
VERIFY(inherited_value.has_value());
inherited = inherited_value.value();
}
if (inherited) {
@ -261,7 +261,7 @@ bool property_affects_layout(PropertyID property_id)
bool affects_layout = true;
if (value.as_object().has("affects-layout"sv))
affects_layout = value.as_object().get_deprecated("affects-layout"sv).to_bool();
affects_layout = value.as_object().get_bool("affects-layout"sv).value_or(false);
if (affects_layout) {
auto member_generator = generator.fork();
@ -289,7 +289,7 @@ bool property_affects_stacking_context(PropertyID property_id)
bool affects_stacking_context = false;
if (value.as_object().has("affects-stacking-context"sv))
affects_stacking_context = value.as_object().get_deprecated("affects-stacking-context"sv).to_bool();
affects_stacking_context = value.as_object().get_bool("affects-stacking-context"sv).value_or(false);
if (affects_stacking_context) {
auto member_generator = generator.fork();
@ -326,9 +326,9 @@ NonnullRefPtr<StyleValue> property_initial_value(PropertyID property_id)
dbgln("No initial value specified for property '{}'", name);
VERIFY_NOT_REACHED();
}
auto& initial_value = object.get_deprecated("initial"sv);
VERIFY(initial_value.is_string());
auto initial_value_string = initial_value.as_string();
auto initial_value = object.get_deprecated_string("initial"sv);
VERIFY(initial_value.has_value());
auto& initial_value_string = initial_value.value();
auto member_generator = generator.fork();
member_generator.set("name:titlecase", title_casify(name));
@ -370,9 +370,9 @@ bool property_has_quirk(PropertyID property_id, Quirk quirk)
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
if (value.as_object().has("quirks"sv)) {
auto& quirks_value = value.as_object().get_deprecated("quirks"sv);
VERIFY(quirks_value.is_array());
auto& quirks = quirks_value.as_array();
auto quirks_value = value.as_object().get_array("quirks"sv);
VERIFY(quirks_value.has_value());
auto& quirks = quirks_value.value();
if (!quirks.is_empty()) {
auto property_generator = generator.fork();
@ -461,9 +461,9 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
};
if (has_valid_types) {
auto valid_types_value = object.get_deprecated("valid-types"sv);
VERIFY(valid_types_value.is_array());
auto valid_types = valid_types_value.as_array();
auto valid_types_value = object.get_array("valid-types"sv);
VERIFY(valid_types_value.has_value());
auto& valid_types = valid_types_value.value();
if (!valid_types.is_empty()) {
for (auto& type : valid_types.values()) {
VERIFY(type.is_string());
@ -536,9 +536,9 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
}
if (has_valid_identifiers) {
auto valid_identifiers_value = object.get_deprecated("valid-identifiers"sv);
VERIFY(valid_identifiers_value.is_array());
auto valid_identifiers = valid_identifiers_value.as_array();
auto valid_identifiers_value = object.get_array("valid-identifiers"sv);
VERIFY(valid_identifiers_value.has_value());
auto& valid_identifiers = valid_identifiers_value.value();
if (!valid_identifiers.is_empty()) {
property_generator.append(R"~~~(
switch (style_value.to_identifier()) {
@ -581,11 +581,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_deprecated("max-values"sv);
VERIFY(max_values.is_number() && !max_values.is_double());
auto max_values = value.as_object().get("max-values"sv);
VERIFY(max_values.has_value() && max_values->is_number() && !max_values->is_double());
auto property_generator = generator.fork();
property_generator.set("name:titlecase", title_casify(name));
property_generator.set("max_values", max_values.to_deprecated_string());
property_generator.set("max_values", max_values->to_deprecated_string());
property_generator.append(R"~~~(
case PropertyID::@name:titlecase@:
return @max_values@;

View file

@ -166,10 +166,10 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor
return TransformFunctionMetadata {
.parameters = {)~~~");
const JsonArray& parameters = value.as_object().get_deprecated("parameters"sv).as_array();
JsonArray const& parameters = value.as_object().get_array("parameters"sv).value();
bool first = true;
parameters.for_each([&](JsonValue const& value) {
GenericLexer lexer { value.as_object().get_deprecated("type"sv).as_string() };
GenericLexer lexer { value.as_object().get_deprecated_string("type"sv).value() };
VERIFY(lexer.consume_specific('<'));
auto parameter_type_name = lexer.consume_until('>');
VERIFY(lexer.consume_specific('>'));
@ -189,7 +189,7 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor
member_generator.append(first ? " "sv : ", "sv);
first = false;
member_generator.append(DeprecatedString::formatted("{{ TransformFunctionParameterType::{}, {}}}", parameter_type, value.as_object().get_deprecated("required"sv).to_deprecated_string()));
member_generator.append(DeprecatedString::formatted("{{ TransformFunctionParameterType::{}, {}}}", parameter_type, value.as_object().get("required"sv)->to_deprecated_string()));
});
member_generator.append(R"~~~( }