LibWeb: Generate Optional<NonnullGCPtr<T>> as GCPtr<T>

This is the general pattern which has been adopted in LibWeb, so let's
generate our IDL like this too.
This commit is contained in:
Shannon Booth 2024-04-07 15:10:36 +02:00 committed by Andreas Kling
commit 80658743d3
Notes: sideshowbarker 2024-07-17 10:54:57 +09:00
7 changed files with 11 additions and 11 deletions

View file

@ -513,7 +513,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
)~~~");
} else {
scoped_generator.append(R"~~~(
Optional<JS::NonnullGCPtr<@parameter.type.name@>> @cpp_name@;
JS::GCPtr<@parameter.type.name@> @cpp_name@;
if (!@js_name@@js_suffix@.is_undefined()) {
if (!@js_name@@js_suffix@.is_object() || !is<@parameter.type.name@>(@js_name@@js_suffix@.as_object()))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");