1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:48:10 +00:00

LibJS: Convert to_double() to ThrowCompletionOr

This commit is contained in:
Idan Horowitz 2021-10-16 22:11:08 +03:00 committed by Linus Groh
parent 51c33b3b35
commit 1639ed7e0a
10 changed files with 23 additions and 40 deletions

View file

@ -1057,9 +1057,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
} else if (parameter.type->name == "double") {
if (!optional) {
scoped_generator.append(R"~~~(
double @cpp_name@ = @js_name@@js_suffix@.to_double(global_object);
if (vm.exception())
@return_statement@
double @cpp_name@ = TRY_OR_DISCARD(@js_name@@js_suffix@.to_double(global_object));
)~~~");
} else {
if (optional_default_value.has_value()) {
@ -1072,11 +1070,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
)~~~");
}
scoped_generator.append(R"~~~(
if (!@js_name@@js_suffix@.is_undefined()) {
@cpp_name@ = @js_name@@js_suffix@.to_double(global_object);
if (vm.exception())
@return_statement@
}
if (!@js_name@@js_suffix@.is_undefined())
@cpp_name@ = TRY_OR_DISCARD(@js_name@@js_suffix@.to_double(global_object));
)~~~");
if (optional_default_value.has_value()) {
scoped_generator.append(R"~~~(