summaryrefslogtreecommitdiff
path: root/Meta/Lagom
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2022-04-03 18:21:29 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-05 22:33:44 +0200
commitba23d036bdea49034bb46707c69d2982ac363d7d (patch)
tree6effbd2e535cffacf50789ee2fab13311442b00c /Meta/Lagom
parent9b9b05eabf047942edb8a3c8846fc76b6592d310 (diff)
downloadserenity-ba23d036bdea49034bb46707c69d2982ac363d7d.zip
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.
Diffstat (limited to 'Meta/Lagom')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp2
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h3
2 files changed, 4 insertions, 1 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
index 0dc6fb103b..61b9ec8b4b 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
@@ -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;
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h
index ad8424948e..6874d0190c 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h
@@ -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 {