LibWeb: Add IDLGenerators::is_primitive()

This adds the is_primitive() method as described in the Web IDL
specification. is_primitive() returns true if the type is a bigint,
boolean or numeric type.
This commit is contained in:
Kenneth Myhra 2022-04-03 18:21:29 +02:00 committed by Andreas Kling
parent 9b9b05eabf
commit ba23d036bd
Notes: sideshowbarker 2024-07-17 18:46:57 +09:00
2 changed files with 4 additions and 1 deletions

View file

@ -1475,7 +1475,7 @@ static Optional<String> generate_arguments_match_check_for_count(Vector<IDL::Par
Vector<String> conditions;
for (auto i = 0u; i < argument_count; ++i) {
auto const& parameter = parameters[i];
if (parameter.type->is_string() || parameter.type->is_numeric())
if (parameter.type->is_string() || parameter.type->is_primitive())
continue;
auto argument = String::formatted("arg{}", i);
StringBuilder condition;

View file

@ -61,6 +61,9 @@ struct Type : public RefCounted<Type> {
// https://webidl.spec.whatwg.org/#dfn-numeric-type
bool is_numeric() const { return is_integer() || name.is_one_of("float", "unrestricted float", "double", "unrestricted double"); }
// https://webidl.spec.whatwg.org/#dfn-primitive-type
bool is_primitive() const { return is_numeric() || name.is_one_of("bigint", "boolean"); }
};
struct Parameter {