diff options
author | Linus Groh <mail@linusgroh.de> | 2021-07-04 20:51:23 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-07-04 22:07:36 +0100 |
commit | 8ade0df4c3c3c900bed4c4c5b4a0907ecf5172da (patch) | |
tree | 61ff06fded737e28ef25e678b0f2f29273159b1d /Userland/Libraries/LibWeb | |
parent | 09bd5f8772156f0031a3fa914bed2371429d09a0 (diff) | |
download | serenity-8ade0df4c3c3c900bed4c4c5b4a0907ecf5172da.zip |
LibWeb: Change WrapperGenerator to emit acessor properties
This is how the Web IDL spec defines it. We might eventually not need
native properties anymore, but that's another change for another day.
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 381c369007..bfe1182aff 100644 --- a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -1157,12 +1157,12 @@ private: auto attribute_generator = generator.fork(); attribute_generator.set("attribute.name:snakecase", attribute.name.to_snakecase()); attribute_generator.append(R"~~~( - JS_DECLARE_NATIVE_GETTER(@attribute.name:snakecase@_getter); + JS_DECLARE_NATIVE_FUNCTION(@attribute.name:snakecase@_getter); )~~~"); if (!attribute.readonly) { attribute_generator.append(R"~~~( - JS_DECLARE_NATIVE_SETTER(@attribute.name:snakecase@_setter); + JS_DECLARE_NATIVE_FUNCTION(@attribute.name:snakecase@_setter); )~~~"); } } @@ -1308,7 +1308,7 @@ void @prototype_class@::initialize(JS::GlobalObject& global_object) attribute_generator.set("attribute.setter_callback", attribute.setter_callback_name); attribute_generator.append(R"~~~( - define_native_property("@attribute.name@", @attribute.getter_callback@, @attribute.setter_callback@, default_attributes); + define_native_accessor("@attribute.name@", @attribute.getter_callback@, @attribute.setter_callback@, default_attributes); )~~~"); } @@ -1453,7 +1453,7 @@ static @fully_qualified_name@* impl_from(JS::VM& vm, JS::GlobalObject& global_ob } attribute_generator.append(R"~~~( -JS_DEFINE_NATIVE_GETTER(@prototype_class@::@attribute.getter_callback@) +JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::@attribute.getter_callback@) { auto* impl = impl_from(vm, global_object); if (!impl) @@ -1491,14 +1491,16 @@ JS_DEFINE_NATIVE_GETTER(@prototype_class@::@attribute.getter_callback@) if (!attribute.readonly) { attribute_generator.append(R"~~~( -JS_DEFINE_NATIVE_SETTER(@prototype_class@::@attribute.setter_callback@) +JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::@attribute.setter_callback@) { auto* impl = impl_from(vm, global_object); if (!impl) - return; + return {}; + + auto value = vm.argument(0); )~~~"); - generate_to_cpp(generator, attribute, "value", "", "cpp_value", true, attribute.extended_attributes.contains("LegacyNullToEmptyString")); + generate_to_cpp(generator, attribute, "value", "", "cpp_value", false, attribute.extended_attributes.contains("LegacyNullToEmptyString")); if (attribute.extended_attributes.contains("Reflect")) { if (attribute.type.name != "boolean") { @@ -1520,6 +1522,7 @@ JS_DEFINE_NATIVE_SETTER(@prototype_class@::@attribute.setter_callback@) } attribute_generator.append(R"~~~( + return {}; } )~~~"); } |