mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
BindingsGenerator: Support nullable integral attributes
Previously we were assuming that the attribute return value was never nullable and going to be returned in an Optional<IntegralType>, causing complile errors for something such as: `attribute unsigned long?`.
This commit is contained in:
parent
d6243abec3
commit
ad32227c83
Notes:
github-actions[bot]
2024-08-01 10:18:08 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/ad32227c833 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/876
1 changed files with 7 additions and 1 deletions
|
@ -412,9 +412,15 @@ static void generate_from_integral(SourceGenerator& scoped_generator, IDL::Type
|
|||
VERIFY(it != idl_type_map.end());
|
||||
scoped_generator.set("cpp_type"sv, it->cpp_type);
|
||||
|
||||
scoped_generator.append(R"~~~(
|
||||
if (type.is_nullable()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
@result_expression@ JS::Value(static_cast<@cpp_type@>(@value@.release_value()));
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
@result_expression@ JS::Value(static_cast<@cpp_type@>(@value@));
|
||||
)~~~");
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ParameterType>
|
||||
|
|
Loading…
Add table
Reference in a new issue