diff options
author | Luke Wilde <lukew@serenityos.org> | 2022-06-02 20:30:27 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-06-13 21:45:27 +0100 |
commit | 29b0277a71074a3afad26fd505ee18436e6999d7 (patch) | |
tree | 2425c6b01922bb0d86286ee98feee41e5d46239e /Meta | |
parent | 98f354cec498132a7f725e9bf40c568099f12521 (diff) | |
download | serenity-29b0277a71074a3afad26fd505ee18436e6999d7.zip |
LibWeb/IDL: Respect type of IDL constants
Previously we ignored the type and cast the value to i32 and then put
it into a JS::Value.
Diffstat (limited to 'Meta')
-rw-r--r-- | Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp index e00ba59a00..d4ca97e4f6 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp @@ -2824,10 +2824,11 @@ void @constructor_class@::initialize(JS::GlobalObject& global_object) for (auto& constant : interface.constants) { auto constant_generator = generator.fork(); constant_generator.set("constant.name", constant.name); - constant_generator.set("constant.value", constant.value); + + generate_wrap_statement(constant_generator, constant.value, constant.type, interface, String::formatted("auto constant_{}_value =", constant.name)); constant_generator.append(R"~~~( -define_direct_property("@constant.name@", JS::Value((i32)@constant.value@), JS::Attribute::Enumerable); + define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable); )~~~"); } @@ -3092,10 +3093,11 @@ void @prototype_class@::initialize(JS::GlobalObject& global_object) auto constant_generator = generator.fork(); constant_generator.set("constant.name", constant.name); - constant_generator.set("constant.value", constant.value); + + generate_wrap_statement(constant_generator, constant.value, constant.type, interface, String::formatted("auto constant_{}_value =", constant.name)); constant_generator.append(R"~~~( - define_direct_property("@constant.name@", JS::Value((i32)@constant.value@), JS::Attribute::Enumerable); + define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable); )~~~"); } |