mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Meta: Remove GenerateCSSEasingFunctions
This commit is contained in:
parent
667e313731
commit
ac35f76e67
Notes:
sideshowbarker
2024-07-17 17:40:13 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/LadybirdBrowser/ladybird/commit/ac35f76e67 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/173
6 changed files with 0 additions and 251 deletions
|
@ -1,13 +1,5 @@
|
|||
function (generate_css_implementation)
|
||||
set(LIBWEB_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
invoke_generator(
|
||||
"EasingFunctions.cpp"
|
||||
Lagom::GenerateCSSEasingFunctions
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/EasingFunctions.json"
|
||||
"CSS/EasingFunctions.h"
|
||||
"CSS/EasingFunctions.cpp"
|
||||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/EasingFunctions.json"
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
"Enums.cpp"
|
||||
|
@ -105,7 +97,6 @@ function (generate_css_implementation)
|
|||
)
|
||||
|
||||
set(CSS_GENERATED_TO_INSTALL
|
||||
"CSS/EasingFunctions.h"
|
||||
"CSS/Enums.h"
|
||||
"CSS/MathFunctions.h"
|
||||
"CSS/MediaFeatureID.h"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
set(SOURCES "") # avoid pulling SOURCES from parent scope
|
||||
|
||||
lagom_tool(GenerateCSSEasingFunctions SOURCES GenerateCSSEasingFunctions.cpp LIBS LibMain)
|
||||
lagom_tool(GenerateCSSEnums SOURCES GenerateCSSEnums.cpp LIBS LibMain)
|
||||
lagom_tool(GenerateCSSMathFunctions SOURCES GenerateCSSMathFunctions.cpp LIBS LibMain)
|
||||
lagom_tool(GenerateCSSMediaFeatureID SOURCES GenerateCSSMediaFeatureID.cpp LIBS LibMain)
|
||||
|
|
|
@ -1,214 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "GeneratorUtil.h"
|
||||
#include <AK/GenericLexer.h>
|
||||
#include <AK/SourceGenerator.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
ErrorOr<void> generate_header_file(JsonObject&, Core::File&);
|
||||
ErrorOr<void> generate_implementation_file(JsonObject&, Core::File&);
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView generated_header_path;
|
||||
StringView generated_implementation_path;
|
||||
StringView functions_json_path;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(generated_header_path, "Path to the EasingFunctions header file to generate", "generated-header-path", 'h', "generated-header-path");
|
||||
args_parser.add_option(generated_implementation_path, "Path to the EasingFunctions implementation file to generate", "generated-implementation-path", 'c', "generated-implementation-path");
|
||||
args_parser.add_option(functions_json_path, "Path to the JSON file to read from", "json-path", 'j', "json-path");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto json = TRY(read_entire_file_as_json(functions_json_path));
|
||||
VERIFY(json.is_object());
|
||||
auto easing_data = json.as_object();
|
||||
|
||||
auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write));
|
||||
auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write));
|
||||
|
||||
TRY(generate_header_file(easing_data, *generated_header_file));
|
||||
TRY(generate_implementation_file(easing_data, *generated_implementation_file));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ErrorOr<void> generate_header_file(JsonObject& easing_data, Core::File& file)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
||||
generator.append(R"~~~(
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
)~~~");
|
||||
|
||||
generator.appendln("enum class EasingFunction {");
|
||||
easing_data.for_each_member([&](auto& name, auto&) {
|
||||
auto member_generator = generator.fork();
|
||||
member_generator.set("name:titlecase", title_casify(name));
|
||||
member_generator.appendln(" @name:titlecase@,");
|
||||
});
|
||||
generator.appendln("};");
|
||||
|
||||
generator.appendln("Optional<EasingFunction> easing_function_from_string(StringView);");
|
||||
generator.appendln("StringView to_string(EasingFunction);");
|
||||
|
||||
generator.append(R"~~~(
|
||||
enum class EasingFunctionParameterType {
|
||||
Integer,
|
||||
Number,
|
||||
NumberZeroToOne,
|
||||
StepPosition,
|
||||
};
|
||||
|
||||
struct EasingFunctionParameter {
|
||||
EasingFunctionParameterType type;
|
||||
bool is_optional { false };
|
||||
};
|
||||
|
||||
struct EasingFunctionMetadata {
|
||||
Vector<EasingFunctionParameter> parameters;
|
||||
};
|
||||
EasingFunctionMetadata easing_function_metadata(EasingFunction);
|
||||
)~~~");
|
||||
|
||||
generator.appendln("\n}");
|
||||
|
||||
TRY(file.write_until_depleted(generator.as_string_view().bytes()));
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> generate_implementation_file(JsonObject& easing_data, Core::File& file)
|
||||
{
|
||||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
||||
generator.append(R"~~~(
|
||||
#include <LibWeb/CSS/EasingFunctions.h>
|
||||
#include <AK/Assertions.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
)~~~");
|
||||
|
||||
generator.append(R"~~~(
|
||||
Optional<EasingFunction> easing_function_from_string(StringView name)
|
||||
{
|
||||
)~~~");
|
||||
easing_data.for_each_member([&](auto& name, auto&) {
|
||||
auto member_generator = generator.fork();
|
||||
member_generator.set("name", name);
|
||||
member_generator.set("name:titlecase", title_casify(name));
|
||||
member_generator.append(R"~~~(
|
||||
if (name.equals_ignoring_ascii_case("@name@"sv))
|
||||
return EasingFunction::@name:titlecase@;
|
||||
)~~~");
|
||||
});
|
||||
generator.append(R"~~~(
|
||||
return {};
|
||||
}
|
||||
)~~~");
|
||||
|
||||
generator.append(R"~~~(
|
||||
StringView to_string(EasingFunction easing_function)
|
||||
{
|
||||
switch (easing_function) {
|
||||
)~~~");
|
||||
easing_data.for_each_member([&](auto& name, auto&) {
|
||||
auto member_generator = generator.fork();
|
||||
member_generator.set("name", name);
|
||||
member_generator.set("name:titlecase", title_casify(name));
|
||||
member_generator.append(R"~~~(
|
||||
case EasingFunction::@name:titlecase@:
|
||||
return "@name@"sv;
|
||||
)~~~");
|
||||
});
|
||||
generator.append(R"~~~(
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
)~~~");
|
||||
|
||||
generator.append(R"~~~(
|
||||
EasingFunctionMetadata easing_function_metadata(EasingFunction easing_function)
|
||||
{
|
||||
switch (easing_function) {
|
||||
)~~~");
|
||||
easing_data.for_each_member([&](auto& name, auto& value) {
|
||||
VERIFY(value.is_object());
|
||||
|
||||
auto member_generator = generator.fork();
|
||||
member_generator.set("name:titlecase", title_casify(name));
|
||||
member_generator.append(R"~~~(
|
||||
case EasingFunction::@name:titlecase@:
|
||||
return EasingFunctionMetadata {
|
||||
.parameters = {)~~~");
|
||||
|
||||
if (auto parameters = value.as_object().get_array("parameters"sv); parameters.has_value()) {
|
||||
bool first = true;
|
||||
// parameters: [ "<foo>", "<foo [0, 1]>" ]
|
||||
parameters.value().for_each([&](JsonValue const& value) {
|
||||
GenericLexer lexer { value.as_string() };
|
||||
VERIFY(lexer.consume_specific('<'));
|
||||
auto parameter_type_name = lexer.consume_until([](char ch) { return ch == ' ' || ch == '>'; });
|
||||
auto has_bounds = false;
|
||||
auto is_optional = false;
|
||||
if (lexer.consume_specific(" ["sv)) {
|
||||
has_bounds = true;
|
||||
auto contents = lexer.consume_until(']');
|
||||
VERIFY(contents == "0, 1"sv);
|
||||
VERIFY(lexer.consume_specific(']'));
|
||||
}
|
||||
VERIFY(lexer.consume_specific('>'));
|
||||
if (lexer.consume_specific('?'))
|
||||
is_optional = true;
|
||||
|
||||
StringView parameter_type = ""sv;
|
||||
if (parameter_type_name == "number"sv)
|
||||
parameter_type = has_bounds ? "NumberZeroToOne"sv : "Number"sv;
|
||||
else if (parameter_type_name == "integer"sv)
|
||||
parameter_type = "Integer"sv;
|
||||
else if (parameter_type_name == "step-position"sv)
|
||||
parameter_type = "StepPosition"sv;
|
||||
else
|
||||
VERIFY_NOT_REACHED();
|
||||
|
||||
member_generator.append(first ? " "sv : ", "sv);
|
||||
first = false;
|
||||
|
||||
member_generator.append(MUST(String::formatted(
|
||||
"{{ EasingFunctionParameterType::{}, {} }}",
|
||||
parameter_type,
|
||||
is_optional ? "true"sv : "false"sv)));
|
||||
});
|
||||
}
|
||||
|
||||
member_generator.append(R"~~~( }
|
||||
};
|
||||
)~~~");
|
||||
});
|
||||
generator.append(R"~~~(
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
)~~~");
|
||||
|
||||
generator.appendln("\n}");
|
||||
|
||||
TRY(file.write_until_depleted(generator.as_string_view().bytes()));
|
||||
return {};
|
||||
}
|
|
@ -12,14 +12,6 @@ lagom_tool("GenerateAriaRoles") {
|
|||
]
|
||||
}
|
||||
|
||||
lagom_tool("GenerateCSSEasingFunctions") {
|
||||
sources = [ "GenerateCSSEasingFunctions.cpp" ]
|
||||
deps = [
|
||||
":headers",
|
||||
"//Userland/Libraries/LibMain",
|
||||
]
|
||||
}
|
||||
|
||||
lagom_tool("GenerateCSSEnums") {
|
||||
sources = [ "GenerateCSSEnums.cpp" ]
|
||||
deps = [
|
||||
|
|
|
@ -100,23 +100,6 @@ compiled_action("generate_aria_roles") {
|
|||
]
|
||||
}
|
||||
|
||||
compiled_action("generate_css_easing_functions") {
|
||||
tool = "//Meta/Lagom/Tools/CodeGenerators/LibWeb:GenerateCSSEasingFunctions"
|
||||
inputs = [ "CSS/EasingFunctions.json" ]
|
||||
outputs = [
|
||||
"$target_gen_dir/CSS/EasingFunctions.h",
|
||||
"$target_gen_dir/CSS/EasingFunctions.cpp",
|
||||
]
|
||||
args = [
|
||||
"-h",
|
||||
rebase_path(outputs[0], root_build_dir),
|
||||
"-c",
|
||||
rebase_path(outputs[1], root_build_dir),
|
||||
"-j",
|
||||
rebase_path(inputs[0], root_build_dir),
|
||||
]
|
||||
}
|
||||
|
||||
compiled_action("generate_css_enums") {
|
||||
tool = "//Meta/Lagom/Tools/CodeGenerators/LibWeb:GenerateCSSEnums"
|
||||
inputs = [ "CSS/Enums.json" ]
|
||||
|
@ -270,7 +253,6 @@ source_set("all_generated") {
|
|||
":WebWorkerClientEndpoint",
|
||||
":WebWorkerServerEndpoint",
|
||||
":generate_aria_roles",
|
||||
":generate_css_easing_functions",
|
||||
":generate_css_enums",
|
||||
":generate_css_math_functions",
|
||||
":generate_css_media_feature_id",
|
||||
|
|
|
@ -735,7 +735,6 @@ generate_css_implementation()
|
|||
set(GENERATED_SOURCES
|
||||
ARIA/AriaRoles.cpp
|
||||
CSS/DefaultStyleSheetSource.cpp
|
||||
CSS/EasingFunctions.cpp
|
||||
CSS/Enums.cpp
|
||||
CSS/MathFunctions.cpp
|
||||
CSS/MediaFeatureID.cpp
|
||||
|
|
Loading…
Reference in a new issue