From 29b0277a71074a3afad26fd505ee18436e6999d7 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Thu, 2 Jun 2022 20:30:27 +0100 Subject: [PATCH] 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. --- .../LibWeb/WrapperGenerator/IDLGenerators.cpp | 10 ++++++---- 1 file 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); )~~~"); }