mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
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.
This commit is contained in:
parent
bc116f3b13
commit
2cff070108
Notes:
sideshowbarker
2024-07-18 21:37:01 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2cff070108c
1 changed files with 4 additions and 3 deletions
|
@ -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);
|
||||
)~~~");
|
||||
|
|
Loading…
Reference in a new issue