Skip to content

Commit

Permalink
LibWeb: Map all the IDL string types to AK::String for now
Browse files Browse the repository at this point in the history
DOMString, CSSOMString and USVString can all map to AK::String for now,
until we figure something better out.
  • Loading branch information
awesomekling committed Mar 8, 2021
1 parent bc116f3 commit 2cff070
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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@@[email protected]_string(global_object, @legacy_null_to_empty_string@);
Expand Down Expand Up @@ -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();
Expand All @@ -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);
)~~~");
Expand Down

0 comments on commit 2cff070

Please sign in to comment.