1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00

LibIDL+LibWeb: Begin support for async iterator in IDL

This adds support for async iterators of the form:

    async iterable<value_type>;
    async iterable<value_type>(/* arguments... */);

It does not yet support the value pairs of the form:

    async iterable<key_type, value_type>;
    async iterable<key_type, value_type>(/* arguments... */);

Async iterators have an optional `return` data property. There's not a
particularly good way to know what interfaces implement this property.
So this adds a new extended attribute, DefinesAsyncIteratorReturn, which
interfaces can use to declare their support.
This commit is contained in:
Timothy Flynn 2025-04-12 13:18:02 -04:00 committed by Tim Flynn
parent 398f1ce2a0
commit c0ead1b01a
Notes: github-actions[bot] 2025-04-14 21:44:24 +00:00
10 changed files with 593 additions and 7 deletions

View file

@ -530,6 +530,8 @@ void Parser::parse_iterable(Interface& interface)
interface.value_iterator_type = move(first_type);
}
if (interface.async_value_iterator_type.has_value())
report_parsing_error("Interfaces with an async iterable declaration must not have an iterable declaration."sv, filename, input, lexer.tell());
if (interface.set_entry_type.has_value())
report_parsing_error("Interfaces with an iterable declaration must not have a setlike declaration."sv, filename, input, lexer.tell());
@ -537,6 +539,44 @@ void Parser::parse_iterable(Interface& interface)
assert_specific(';');
}
// https://webidl.spec.whatwg.org/#idl-async-iterable-declaration
void Parser::parse_async_iterable(Interface& interface)
{
if (interface.async_value_iterator_type.has_value())
report_parsing_error("Interfaces must not have more than one async iterable declaration."sv, filename, input, lexer.tell());
if (interface.set_entry_type.has_value())
report_parsing_error("Interfaces with an async iterable declaration must not have a setlike declaration."sv, filename, input, lexer.tell());
if (interface.value_iterator_type.has_value())
report_parsing_error("Interfaces with an async iterable declaration must not have an iterable declaration."sv, filename, input, lexer.tell());
if (interface.supports_indexed_properties())
report_parsing_error("Interfaces with an async iterable declaration must not support indexed properties."sv, filename, input, lexer.tell());
// FIXME: Reject interfaces that have a maplike declaration when we support that type.
assert_string("async"sv);
consume_whitespace();
assert_string("iterable"sv);
assert_specific('<');
auto first_type = parse_type();
if (lexer.next_is(',')) {
// https://webidl.spec.whatwg.org/#pair-asynchronously-iterable-declaration
report_parsing_error("FIXME: Support paired async iterable declarations."sv, filename, input, lexer.tell());
} else {
interface.async_value_iterator_type = move(first_type);
}
assert_specific('>');
if (lexer.next_is('(')) {
assert_specific('(');
interface.async_value_iterator_parameters = parse_parameters();
assert_specific(')');
}
assert_specific(';');
}
void Parser::parse_setlike(Interface& interface, bool is_readonly)
{
if (interface.supports_indexed_properties())
@ -690,6 +730,11 @@ void Parser::parse_interface(Interface& interface)
interface.has_unscopable_member = true;
}
if (lexer.next_is("async")) {
parse_async_iterable(interface);
continue;
}
if (lexer.next_is("constructor")) {
parse_constructor(extended_attributes, interface);
continue;