mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibWeb: Support generating IDL float types
The float type is used quite a bit in the SVG spec.
This commit is contained in:
parent
4d49c607f8
commit
3ebc5cc58e
Notes:
sideshowbarker
2024-07-17 16:59:03 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/3ebc5cc58e Pull-request: https://github.com/SerenityOS/serenity/pull/13175
1 changed files with 10 additions and 7 deletions
|
@ -78,6 +78,9 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
|
|||
if (type.name == "double" && !type.nullable)
|
||||
return { .name = "double", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
||||
if (type.name == "float" && !type.nullable)
|
||||
return { .name = "float", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
||||
if (type.name == "boolean" && !type.nullable)
|
||||
return { .name = "bool", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
||||
|
@ -379,19 +382,19 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
}
|
||||
)~~~");
|
||||
}
|
||||
} else if (parameter.type->name == "double") {
|
||||
} else if (parameter.type->name == "double" || parameter.type->name == "float") {
|
||||
if (!optional) {
|
||||
scoped_generator.append(R"~~~(
|
||||
double @cpp_name@ = TRY(@js_name@@js_suffix@.to_double(global_object));
|
||||
@parameter.type.name@ @cpp_name@ = TRY(@js_name@@js_suffix@.to_double(global_object));
|
||||
)~~~");
|
||||
} else {
|
||||
if (optional_default_value.has_value()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
double @cpp_name@;
|
||||
@parameter.type.name@ @cpp_name@;
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
Optional<double> @cpp_name@;
|
||||
Optional<@parameter.type.name@> @cpp_name@;
|
||||
)~~~");
|
||||
}
|
||||
scoped_generator.append(R"~~~(
|
||||
|
@ -1247,7 +1250,7 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va
|
|||
|
||||
@result_expression@ new_array@recursion_depth@;
|
||||
)~~~");
|
||||
} else if (type.name == "boolean" || type.name == "double") {
|
||||
} else if (type.name == "boolean" || type.name == "double" || type.name == "float") {
|
||||
scoped_generator.append(R"~~~(
|
||||
@result_expression@ JS::Value(@value@);
|
||||
)~~~");
|
||||
|
|
Loading…
Reference in a new issue