Everywhere: Rename serenity_main to ladybird_main

No functional changes.
This commit is contained in:
Jelle Raaijmakers 2025-07-08 12:14:08 +02:00 committed by Tim Flynn
commit ead0a2c78a
Notes: github-actions[bot] 2025-07-08 13:18:23 +00:00
34 changed files with 40 additions and 40 deletions

View file

@ -110,10 +110,10 @@ private:
} }
``` ```
## The `serenity_main(..)` program entry point ## The `ladybird_main(..)` program entry point
Ladybird has moved to a pattern where executables do not expose a normal C Ladybird has moved to a pattern where executables do not expose a normal C
main function. A `serenity_main(..)` is exposed instead. The main reasoning main function. A `ladybird_main(..)` is exposed instead. The main reasoning
is that the `Main::Arguments` struct can provide arguments in a more idiomatic is that the `Main::Arguments` struct can provide arguments in a more idiomatic
way that fits with the Ladybird's internal API surface area. The ErrorOr<int> likewise way that fits with the Ladybird's internal API surface area. The ErrorOr<int> likewise
allows the program to propagate errors seamlessly with the `TRY(...)` macro, allows the program to propagate errors seamlessly with the `TRY(...)` macro,
@ -121,7 +121,7 @@ avoiding a significant amount of clunky C style error handling.
These executables are then linked with the `LibMain` library, which will link in These executables are then linked with the `LibMain` library, which will link in
the normal C `int main(int, char**)` function which will call into the programs the normal C `int main(int, char**)` function which will call into the programs
`serenity_main(..)` on program startup. `ladybird_main(..)` on program startup.
The creation of the pattern was documented in the following video: The creation of the pattern was documented in the following video:
[OS hacking: A better main() for SerenityOS C++ programs](https://www.youtube.com/watch?v=5PciKJW1rUc) [OS hacking: A better main() for SerenityOS C++ programs](https://www.youtube.com/watch?v=5PciKJW1rUc)
@ -137,14 +137,14 @@ int main(int argc, char** argv)
} }
``` ```
Instead, `serenity_main(..)` is defined like this: Instead, `ladybird_main(..)` is defined like this:
```cpp ```cpp
#include <LibMain/Main.h> #include <LibMain/Main.h>
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
return 0; return 0;
} }
``` ```

View file

@ -36,7 +36,7 @@ int main(int argc, char** argv)
for (int i = 0; i < argc; ++i) for (int i = 0; i < argc; ++i)
arguments.unchecked_append({ argv[i], strlen(argv[i]) }); arguments.unchecked_append({ argv[i], strlen(argv[i]) });
auto result = serenity_main({ auto result = ladybird_main({
.argc = argc, .argc = argc,
.argv = argv, .argv = argv,
.strings = arguments.span(), .strings = arguments.span(),

View file

@ -24,4 +24,4 @@ void set_return_code_for_errors(int);
} }
ErrorOr<int> serenity_main(Main::Arguments); ErrorOr<int> ladybird_main(Main::Arguments);

View file

@ -910,7 +910,7 @@ void build(StringBuilder& builder, Vector<Endpoint> const& endpoints)
} // end anonymous namespace } // end anonymous namespace
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView ipc_file; StringView ipc_file;
StringView output_file = "-"sv; StringView output_file = "-"sv;

View file

@ -17,7 +17,7 @@
#include <LibIDL/IDLParser.h> #include <LibIDL/IDLParser.h>
#include <LibIDL/Types.h> #include <LibIDL/Types.h>
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
Core::ArgsParser args_parser; Core::ArgsParser args_parser;
StringView path; StringView path;

View file

@ -374,7 +374,7 @@ NameFromSource @name@::name_from_source() const
} // end anonymous namespace } // end anonymous namespace
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -20,7 +20,7 @@ static bool is_legacy_alias(JsonObject const& descriptor)
return descriptor.has_string("legacy-alias-for"sv); return descriptor.has_string("legacy-alias-for"sv);
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -13,7 +13,7 @@
ErrorOr<void> generate_header_file(JsonObject& enums_data, Core::File& file); ErrorOr<void> generate_header_file(JsonObject& enums_data, Core::File& file);
ErrorOr<void> generate_implementation_file(JsonObject& enums_data, Core::File& file); ErrorOr<void> generate_implementation_file(JsonObject& enums_data, Core::File& file);
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -14,7 +14,7 @@
ErrorOr<void> generate_header_file(JsonArray& keyword_data, Core::File& file); ErrorOr<void> generate_header_file(JsonArray& keyword_data, Core::File& file);
ErrorOr<void> generate_implementation_file(JsonArray& keyword_data, Core::File& file); ErrorOr<void> generate_implementation_file(JsonArray& keyword_data, Core::File& file);
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -382,7 +382,7 @@ RefPtr<CalculationNode const> Parser::parse_math_function(Function const& functi
} // end anonymous namespace } // end anonymous namespace
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -13,7 +13,7 @@
ErrorOr<void> generate_header_file(JsonObject& media_feature_data, Core::File& file); ErrorOr<void> generate_header_file(JsonObject& media_feature_data, Core::File& file);
ErrorOr<void> generate_implementation_file(JsonObject& media_feature_data, Core::File& file); ErrorOr<void> generate_implementation_file(JsonObject& media_feature_data, Core::File& file);
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -55,7 +55,7 @@ static bool is_legacy_alias(JsonObject const& property)
return property.has_string("legacy-alias-for"sv); return property.has_string("legacy-alias-for"sv);
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -12,7 +12,7 @@
ErrorOr<void> generate_header_file(JsonObject& pseudo_classes_data, Core::File& file); ErrorOr<void> generate_header_file(JsonObject& pseudo_classes_data, Core::File& file);
ErrorOr<void> generate_implementation_file(JsonObject& pseudo_classes_data, Core::File& file); ErrorOr<void> generate_implementation_file(JsonObject& pseudo_classes_data, Core::File& file);
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -12,7 +12,7 @@
ErrorOr<void> generate_header_file(JsonObject& pseudo_elements_data, Core::File& file); ErrorOr<void> generate_header_file(JsonObject& pseudo_elements_data, Core::File& file);
ErrorOr<void> generate_implementation_file(JsonObject& pseudo_elements_data, Core::File& file); ErrorOr<void> generate_implementation_file(JsonObject& pseudo_elements_data, Core::File& file);
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -14,7 +14,7 @@ ErrorOr<void> generate_header_file(JsonObject& properties, Core::File& file);
ErrorOr<void> generate_implementation_file(JsonObject& properties, Core::File& file); ErrorOr<void> generate_implementation_file(JsonObject& properties, Core::File& file);
ErrorOr<void> generate_idl_file(JsonObject& properties, Core::File& file); ErrorOr<void> generate_idl_file(JsonObject& properties, Core::File& file);
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -14,7 +14,7 @@
ErrorOr<void> generate_header_file(JsonObject& transforms_data, Core::File& file); ErrorOr<void> generate_header_file(JsonObject& transforms_data, Core::File& file);
ErrorOr<void> generate_implementation_file(JsonObject& transforms_data, Core::File& file); ErrorOr<void> generate_implementation_file(JsonObject& transforms_data, Core::File& file);
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -15,7 +15,7 @@
ErrorOr<void> generate_header_file(Core::File& file); ErrorOr<void> generate_header_file(Core::File& file);
ErrorOr<void> generate_implementation_file(JsonObject& named_character_reference_data, Core::File& file); ErrorOr<void> generate_implementation_file(JsonObject& named_character_reference_data, Core::File& file);
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView generated_header_path; StringView generated_header_path;
StringView generated_implementation_path; StringView generated_implementation_path;

View file

@ -331,7 +331,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
return {}; return {};
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
Core::ArgsParser args_parser; Core::ArgsParser args_parser;

View file

@ -15,7 +15,7 @@
static constexpr auto EXIT_COLLISION = 0x1; static constexpr auto EXIT_COLLISION = 0x1;
static constexpr auto EXIT_ERROR = 0x2; static constexpr auto EXIT_ERROR = 0x2;
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
if (arguments.argc < 3) { if (arguments.argc < 3) {
warnln("Usage: {} path/to/some.ipc path/to/other.ipc [more ipc files ...]", arguments.strings[0]); warnln("Usage: {} path/to/some.ipc path/to/other.ipc [more ipc files ...]", arguments.strings[0]);

View file

@ -17,7 +17,7 @@
# include <LibCore/Platform/ProcessStatisticsMach.h> # include <LibCore/Platform/ProcessStatisticsMach.h>
#endif #endif
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
AK::set_rich_debug_enabled(true); AK::set_rich_debug_enabled(true);

View file

@ -26,7 +26,7 @@ extern ByteString g_default_certificate_path;
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
AK::set_rich_debug_enabled(true); AK::set_rich_debug_enabled(true);

View file

@ -69,7 +69,7 @@ extern bool g_http_cache_enabled;
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
AK::set_rich_debug_enabled(true); AK::set_rich_debug_enabled(true);

View file

@ -66,7 +66,7 @@ static Vector<ByteString> create_arguments(ByteString const& socket_path, bool h
return arguments; return arguments;
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
AK::set_rich_debug_enabled(true); AK::set_rich_debug_enabled(true);

View file

@ -37,7 +37,7 @@ static ErrorOr<Web::Bindings::AgentType> agent_type_from_string(StringView type)
return Error::from_string_literal("Invalid worker type, must be one of: 'dedicated', 'shared', or 'service'"); return Error::from_string_literal("Invalid worker type, must be one of: 'dedicated', 'shared', or 'service'");
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
AK::set_rich_debug_enabled(true); AK::set_rich_debug_enabled(true);

View file

@ -714,7 +714,7 @@ static ErrorOr<int> run_tests(Core::AnonymousBuffer const& theme, Web::DevicePix
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
#if defined(LADYBIRD_BINARY_PATH) #if defined(LADYBIRD_BINARY_PATH)
auto app = TRY(TestWeb::Application::create(arguments, LADYBIRD_BINARY_PATH)); auto app = TRY(TestWeb::Application::create(arguments, LADYBIRD_BINARY_PATH));

View file

@ -35,7 +35,7 @@ static void open_urls_from_client(Vector<URL::URL> const& urls, WebView::NewWind
} }
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
AK::set_rich_debug_enabled(true); AK::set_rich_debug_enabled(true);

View file

@ -39,7 +39,7 @@ bool is_using_dark_system_theme(QWidget& widget)
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
AK::set_rich_debug_enabled(true); AK::set_rich_debug_enabled(true);

View file

@ -16,7 +16,7 @@
// The Kernel has problems with large anonymous buffers, so let's limit sample reads ourselves. // The Kernel has problems with large anonymous buffers, so let's limit sample reads ourselves.
static constexpr size_t MAX_CHUNK_SIZE = 1 * MiB / 2; static constexpr size_t MAX_CHUNK_SIZE = 1 * MiB / 2;
ErrorOr<int> serenity_main(Main::Arguments args) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView path {}; StringView path {};
int sample_count = -1; int sample_count = -1;
@ -25,7 +25,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
args_parser.set_general_help("Benchmark audio loading"); args_parser.set_general_help("Benchmark audio loading");
args_parser.add_positional_argument(path, "Path to audio file", "path"); args_parser.add_positional_argument(path, "Path to audio file", "path");
args_parser.add_option(sample_count, "How many samples to load at maximum", "sample-count", 's', "samples"); args_parser.add_option(sample_count, "How many samples to load at maximum", "sample-count", 's', "samples");
args_parser.parse(args); args_parser.parse(arguments);
auto maybe_loader = Audio::Loader::create(path); auto maybe_loader = Audio::Loader::create(path);
if (maybe_loader.is_error()) { if (maybe_loader.is_error()) {

View file

@ -32,7 +32,7 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
return options; return options;
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
Options options = TRY(parse_options(arguments)); Options options = TRY(parse_options(arguments));

View file

@ -11,7 +11,7 @@
#include <LibMain/Main.h> #include <LibMain/Main.h>
#include <LibTLS/TLSv12.h> #include <LibTLS/TLSv12.h>
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
struct Request { struct Request {
Vector<Vector<DNS::Messages::ResourceType>> types; Vector<Vector<DNS::Messages::ResourceType>> types;

View file

@ -242,7 +242,7 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
return options; return options;
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
Options options = TRY(parse_options(arguments)); Options options = TRY(parse_options(arguments));

View file

@ -785,7 +785,7 @@ static ErrorOr<int> run_repl(bool gc_on_every_allocation, bool syntax_highlight)
#endif #endif
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
bool gc_on_every_allocation = false; bool gc_on_every_allocation = false;
bool disable_syntax_highlight = false; bool disable_syntax_highlight = false;

View file

@ -515,7 +515,7 @@ static void print_link_error(Wasm::LinkError const& error)
warnln("Missing import '{}'", missing); warnln("Missing import '{}'", missing);
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView filename; StringView filename;
bool print = false; bool print = false;

View file

@ -498,7 +498,7 @@ static void do_run_tests(XML::Document& document)
} }
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> ladybird_main(Main::Arguments arguments)
{ {
StringView filename; StringView filename;
bool run_tests { false }; bool run_tests { false };