mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 05:35:52 +03:00
LibWeb: Add short type to IDL generator
This commit is contained in:
parent
02d5ed44cb
commit
ba8704243e
Notes:
sideshowbarker
2024-07-17 18:46:57 +09:00
Author: https://github.com/bplaat Commit: https://github.com/SerenityOS/serenity/commit/ba8704243e Pull-request: https://github.com/SerenityOS/serenity/pull/22867
@ -161,6 +161,9 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
|
||||
if (type.name() == "unsigned long" && !type.is_nullable())
|
||||
return { .name = "WebIDL::UnsignedLong", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
||||
if (type.name() == "short" && !type.is_nullable())
|
||||
return { .name = "WebIDL::Short", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
||||
if (type.name() == "unsigned short" && !type.is_nullable())
|
||||
return { .name = "WebIDL::UnsignedShort", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
||||
@ -515,6 +518,31 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
||||
scoped_generator.append(R"~~~(
|
||||
else
|
||||
@cpp_name@ = @parameter.optional_default_value@UL;
|
||||
)~~~");
|
||||
}
|
||||
} else if (parameter.type->name() == "short") {
|
||||
if (!optional || optional_default_value.has_value()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
WebIDL::Short @cpp_name@;
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
Optional<WebIDL::Short> @cpp_name@;
|
||||
)~~~");
|
||||
}
|
||||
if (optional) {
|
||||
scoped_generator.append(R"~~~(
|
||||
if (!@js_name@@js_suffix@.is_undefined())
|
||||
)~~~");
|
||||
}
|
||||
// FIXME: pass through [EnforceRange] and [Clamp] extended attributes
|
||||
scoped_generator.append(R"~~~(
|
||||
@cpp_name@ = TRY(WebIDL::convert_to_int<WebIDL::Short>(vm, @js_name@@js_suffix@));
|
||||
)~~~");
|
||||
if (optional_default_value.has_value()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
else
|
||||
@cpp_name@ = @parameter.optional_default_value@;
|
||||
)~~~");
|
||||
}
|
||||
} else if (parameter.type->name() == "unsigned short") {
|
||||
|
Loading…
Reference in New Issue
Block a user