forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Meta: Port Generate_CSS_PropertyID_cpp to LibMain/Core::Stream
- Loading branch information
Showing
2 changed files
with
8 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,23 @@ | ||
/* | ||
* Copyright (c) 2018-2020, Andreas Kling <[email protected]> | ||
* Copyright (c) 2021, Sam Atkins <[email protected]> | ||
* Copyright (c) 2021-2022, Sam Atkins <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include "GeneratorUtil.h" | ||
#include <AK/ByteBuffer.h> | ||
#include <AK/JsonObject.h> | ||
#include <AK/SourceGenerator.h> | ||
#include <AK/StringBuilder.h> | ||
#include <LibCore/File.h> | ||
#include <LibMain/Main.h> | ||
|
||
int main(int argc, char** argv) | ||
ErrorOr<int> serenity_main(Main::Arguments arguments) | ||
{ | ||
if (argc != 2) { | ||
warnln("usage: {} <path/to/CSS/Properties.json>", argv[0]); | ||
if (arguments.argc != 2) { | ||
warnln("usage: {} <path/to/CSS/Properties.json>", arguments.strings[0]); | ||
return 1; | ||
} | ||
auto file = Core::File::construct(argv[1]); | ||
if (!file->open(Core::OpenMode::ReadOnly)) | ||
return 1; | ||
|
||
auto json = JsonValue::from_string(file->read_all()).release_value_but_fixme_should_propagate_errors(); | ||
auto json = TRY(read_entire_file_as_json(arguments.strings[1])); | ||
VERIFY(json.is_object()); | ||
|
||
auto& properties = json.as_object(); | ||
|
@@ -416,4 +411,5 @@ size_t property_maximum_value_count(PropertyID property_id) | |
)~~~"); | ||
|
||
outln("{}", generator.as_string_view()); | ||
return 0; | ||
} |