mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
Everywhere: Rename serenity_main to ladybird_main
No functional changes.
This commit is contained in:
parent
af671f58ed
commit
ead0a2c78a
Notes:
github-actions[bot]
2025-07-08 13:18:23 +00:00
Author: https://github.com/gmta
Commit: ead0a2c78a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5349
34 changed files with 40 additions and 40 deletions
|
@ -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
|
||||
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
|
||||
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,
|
||||
|
@ -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
|
||||
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:
|
||||
[OS hacking: A better main() for SerenityOS C++ programs](https://www.youtube.com/watch?v=5PciKJW1rUc)
|
||||
|
@ -137,12 +137,12 @@ int main(int argc, char** argv)
|
|||
}
|
||||
```
|
||||
|
||||
Instead, `serenity_main(..)` is defined like this:
|
||||
Instead, `ladybird_main(..)` is defined like this:
|
||||
|
||||
```cpp
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(int argc, char** argv)
|
|||
for (int i = 0; i < argc; ++i)
|
||||
arguments.unchecked_append({ argv[i], strlen(argv[i]) });
|
||||
|
||||
auto result = serenity_main({
|
||||
auto result = ladybird_main({
|
||||
.argc = argc,
|
||||
.argv = argv,
|
||||
.strings = arguments.span(),
|
||||
|
|
|
@ -24,4 +24,4 @@ void set_return_code_for_errors(int);
|
|||
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments);
|
||||
ErrorOr<int> ladybird_main(Main::Arguments);
|
||||
|
|
|
@ -910,7 +910,7 @@ void build(StringBuilder& builder, Vector<Endpoint> const& endpoints)
|
|||
|
||||
} // end anonymous namespace
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView ipc_file;
|
||||
StringView output_file = "-"sv;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <LibIDL/IDLParser.h>
|
||||
#include <LibIDL/Types.h>
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
Core::ArgsParser args_parser;
|
||||
StringView path;
|
||||
|
|
|
@ -374,7 +374,7 @@ NameFromSource @name@::name_from_source() const
|
|||
|
||||
} // end anonymous namespace
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView generated_header_path;
|
||||
StringView generated_implementation_path;
|
||||
|
|
|
@ -20,7 +20,7 @@ static bool is_legacy_alias(JsonObject const& descriptor)
|
|||
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_implementation_path;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
ErrorOr<void> generate_header_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_implementation_path;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
ErrorOr<void> generate_header_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_implementation_path;
|
||||
|
|
|
@ -382,7 +382,7 @@ RefPtr<CalculationNode const> Parser::parse_math_function(Function const& functi
|
|||
|
||||
} // end anonymous namespace
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView generated_header_path;
|
||||
StringView generated_implementation_path;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
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<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView generated_header_path;
|
||||
StringView generated_implementation_path;
|
||||
|
|
|
@ -55,7 +55,7 @@ static bool is_legacy_alias(JsonObject const& property)
|
|||
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_implementation_path;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
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<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView generated_header_path;
|
||||
StringView generated_implementation_path;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
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<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView generated_header_path;
|
||||
StringView generated_implementation_path;
|
||||
|
|
|
@ -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_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_implementation_path;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
ErrorOr<void> generate_header_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_implementation_path;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
ErrorOr<void> generate_header_file(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_implementation_path;
|
||||
|
|
|
@ -331,7 +331,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
Core::ArgsParser args_parser;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
static constexpr auto EXIT_COLLISION = 0x1;
|
||||
static constexpr auto EXIT_ERROR = 0x2;
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
if (arguments.argc < 3) {
|
||||
warnln("Usage: {} path/to/some.ipc path/to/other.ipc [more ipc files ...]", arguments.strings[0]);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# include <LibCore/Platform/ProcessStatisticsMach.h>
|
||||
#endif
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
AK::set_rich_debug_enabled(true);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ static Vector<ByteString> create_arguments(ByteString const& socket_path, bool h
|
|||
return arguments;
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
AK::set_rich_debug_enabled(true);
|
||||
|
||||
|
|
|
@ -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'");
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
AK::set_rich_debug_enabled(true);
|
||||
|
||||
|
|
|
@ -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)
|
||||
auto app = TRY(TestWeb::Application::create(arguments, LADYBIRD_BINARY_PATH));
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// 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;
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments args)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView path {};
|
||||
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.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.parse(args);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto maybe_loader = Audio::Loader::create(path);
|
||||
if (maybe_loader.is_error()) {
|
||||
|
|
|
@ -32,7 +32,7 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
|
|||
return options;
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
Options options = TRY(parse_options(arguments));
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <LibMain/Main.h>
|
||||
#include <LibTLS/TLSv12.h>
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
struct Request {
|
||||
Vector<Vector<DNS::Messages::ResourceType>> types;
|
||||
|
|
|
@ -242,7 +242,7 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
|
|||
return options;
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
Options options = TRY(parse_options(arguments));
|
||||
|
||||
|
|
|
@ -785,7 +785,7 @@ static ErrorOr<int> run_repl(bool gc_on_every_allocation, bool syntax_highlight)
|
|||
|
||||
#endif
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
bool gc_on_every_allocation = false;
|
||||
bool disable_syntax_highlight = false;
|
||||
|
|
|
@ -515,7 +515,7 @@ static void print_link_error(Wasm::LinkError const& error)
|
|||
warnln("Missing import '{}'", missing);
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView filename;
|
||||
bool print = false;
|
||||
|
|
|
@ -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;
|
||||
bool run_tests { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue