diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2023-02-25 10:24:54 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-26 00:27:22 +0100 |
commit | 2facb0e8ed4679c5bf006b456eba2737a7767266 (patch) | |
tree | afae9af67e2e338d4f81e6837634f1ac16dde3d2 | |
parent | 99f094905e91276e3ee85b334505b3888d0f27fd (diff) | |
download | serenity-2facb0e8ed4679c5bf006b456eba2737a7767266.zip |
BindingsGenerator: Use JS::Value::to_string() when new String
Make sure to use JS::Value::to_string() when the IDL interface is marked
with the extended attribute UseNewAKString.
-rw-r--r-- | Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 13a6866edd..e8639cfe39 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -1226,9 +1226,15 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter if (includes_string) { // 14. If types includes a string type, then return the result of converting V to that type. // NOTE: Currently all string types are converted to String. - union_generator.append(R"~~~( + if (interface.extended_attributes.contains("UseNewAKString")) { + union_generator.append(R"~~~( + return TRY(@js_name@@js_suffix@.to_string(vm)); +)~~~"); + } else { + union_generator.append(R"~~~( return TRY(@js_name@@js_suffix@.to_deprecated_string(vm)); )~~~"); + } } else if (numeric_type && includes_bigint) { // 15. If types includes a numeric type and bigint, then return the result of converting V to either that numeric type or bigint. // https://webidl.spec.whatwg.org/#converted-to-a-numeric-type-or-bigint |