summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-08 16:14:56 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-08 16:14:56 +0100
commit2cff070108caf94061a33b4c8ccdfd8f0b8dbcf2 (patch)
tree780ca9b3137e976e904c5f105543110f7b8caa22 /Userland/Libraries
parentbc116f3b13c1fc1a199eee9dc401b1ee0bbbe098 (diff)
downloadserenity-2cff070108caf94061a33b4c8ccdfd8f0b8dbcf2.zip
LibWeb: Map all the IDL string types to AK::String for now
DOMString, CSSOMString and USVString can all map to AK::String for now, until we figure something better out.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
index b9a6da33f6..21d96beb50 100644
--- a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
+++ b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
@@ -102,6 +102,7 @@ static size_t get_function_length(FunctionType& function)
struct Type {
String name;
bool nullable { false };
+ bool is_string() const { return name.is_one_of("DOMString", "USVString", "CSSOMString"); }
};
struct Parameter {
@@ -517,7 +518,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
scoped_generator.set("return_statement", "return {};");
// FIXME: Add support for optional to all types
- if (parameter.type.name == "DOMString") {
+ if (parameter.type.is_string()) {
if (!optional) {
scoped_generator.append(R"~~~(
auto @cpp_name@ = @js_name@@js_suffix@.to_string(global_object, @legacy_null_to_empty_string@);
@@ -1255,7 +1256,7 @@ static @fully_qualified_name@* impl_from(JS::VM& vm, JS::GlobalObject& global_ob
}
if (return_type.nullable) {
- if (return_type.name == "DOMString") {
+ if (return_type.is_string()) {
scoped_generator.append(R"~~~(
if (retval.is_null())
return JS::js_null();
@@ -1268,7 +1269,7 @@ static @fully_qualified_name@* impl_from(JS::VM& vm, JS::GlobalObject& global_ob
}
}
- if (return_type.name == "DOMString") {
+ if (return_type.is_string()) {
scoped_generator.append(R"~~~(
return JS::js_string(vm, retval);
)~~~");