mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +00:00
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:
parent
9b9b05eabf
commit
ba23d036bd
2 changed files with 4 additions and 1 deletions
|
@ -1475,7 +1475,7 @@ static Optional<String> generate_arguments_match_check_for_count(Vector<IDL::Par
|
||||||
Vector<String> conditions;
|
Vector<String> conditions;
|
||||||
for (auto i = 0u; i < argument_count; ++i) {
|
for (auto i = 0u; i < argument_count; ++i) {
|
||||||
auto const& parameter = parameters[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;
|
continue;
|
||||||
auto argument = String::formatted("arg{}", i);
|
auto argument = String::formatted("arg{}", i);
|
||||||
StringBuilder condition;
|
StringBuilder condition;
|
||||||
|
|
|
@ -61,6 +61,9 @@ struct Type : public RefCounted<Type> {
|
||||||
|
|
||||||
// https://webidl.spec.whatwg.org/#dfn-numeric-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"); }
|
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 {
|
struct Parameter {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue