dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / web_idl / async_iterator.lucb
#==============================================================================================
#
# async_iterator - WebIDL::AsyncIterator: the default asynchronous iterator objects
#
# DESCRIPTION:
# Port of Libraries/LibWeb/WebIDL/AsyncIterator.cpp (lines 1-217) and AsyncIterator.h
# (lines 1-118). The iterator is a platform object whose next() and return() run on JS
# promises: its construction and edges are here, the iteration steps come with luce-js
# (phase 3).
#
# Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/WebIDL/AsyncIterator.h:29 Web::WebIDL::AsyncIterator::next.
## https://webidl.spec.whatwg.org/#ref-for-dfn-asynchronous-iterator-prototype-object%E2%91%A2
pub func idl_async_iterator_next[TAsyncIteratorInterface](realm: Realm*, interface_name: ak.StringView) -> JsObject*?!:
trap("unported (P3): Web::WebIDL::AsyncIterator::next (the JS this value and promises)")
## Ported from Libraries/LibWeb/WebIDL/AsyncIterator.h:44 Web::WebIDL::AsyncIterator::return_.
## https://webidl.spec.whatwg.org/#ref-for-asynchronous-iterator-return
pub func idl_async_iterator_return[TAsyncIteratorInterface](realm: Realm*, interface_name: ak.StringView, value: JsValue) -> JsObject*?!:
trap("unported (P3): Web::WebIDL::AsyncIterator::return_ (the JS this value and promises)")
## Ported from Libraries/LibWeb/WebIDL/AsyncIterator.cpp:15 Web::WebIDL::AsyncIterator::AsyncIterator.
pub func idl_async_iterator_construct(this: IdlAsyncIterator*, realm: Realm*, iteration_kind: JsObjectPropertyKind):
idl_async_iterator_init_fields(this)
bind_platform_object_construct_realm(this.bind_platform_object(), realm)
this.m_kind = iteration_kind
## Ported from Libraries/LibWeb/WebIDL/AsyncIterator.cpp:23 Web::WebIDL::AsyncIterator::visit_edges (override).
pub func idl_async_iterator_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
let this = (IdlAsyncIterator*)base
bind_platform_object_visit_edges_impl(base, visitor)
gc.cell_visitor_visit_cell(visitor, (gc.Cell*?)this.m_ongoing_promise)
## Ported from Libraries/LibWeb/WebIDL/AsyncIterator.h:63 Web::WebIDL::AsyncIterator::next_iteration_result (virtual).
pub func idl_async_iterator_next_iteration_result_impl(this: IdlAsyncIterator*, arg0: Realm*) -> JsPromiseCapability*:
trap("pure virtual: Web::WebIDL::AsyncIterator::next_iteration_result")
## Ported from Libraries/LibWeb/WebIDL/AsyncIterator.cpp:211 Web::WebIDL::AsyncIterator::iterator_return (virtual).
pub func idl_async_iterator_iterator_return_impl(this: IdlAsyncIterator*, arg0: Realm*, arg1: JsValue) -> JsPromiseCapability*:
# If this is reached, a `return` data property was generated for your async iterator, but you neglected to override this method.
trap("VERIFY_NOT_REACHED")
## Ported from Libraries/LibWeb/WebIDL/AsyncIterator.h:68 Web::WebIDL::AsyncIterator::validate_this:
## the steps to validate `this` that are common between "next" and "return" (ToObject of the JS
## this value, rejecting a promise on failure: phase 3).
pub func idl_async_iterator_validate_this[TAsyncIteratorInterface](realm: Realm*, interface_name: ak.StringView, this_validation_promise_capability: JsPromiseCapability*? = none) -> void*?:
trap("unported (P3): Web::WebIDL::AsyncIterator::validate_this (the JS this value)")
## Ported from Libraries/LibWeb/WebIDL/AsyncIterator.cpp:30 Web::WebIDL::AsyncIterator::iterator_next_impl.
## https://webidl.spec.whatwg.org/#ref-for-dfn-asynchronous-iterator-prototype-object%E2%91%A2
pub func idl_async_iterator_iterator_next_impl(this: IdlAsyncIterator*) -> JsObject*?!:
trap("unported (P3): Web::WebIDL::AsyncIterator::iterator_next_impl (JS promises)")
## Ported from Libraries/LibWeb/WebIDL/AsyncIterator.cpp:143 Web::WebIDL::AsyncIterator::iterator_return_impl.
## https://webidl.spec.whatwg.org/#ref-for-asynchronous-iterator-return
pub func idl_async_iterator_iterator_return_impl_2(this: IdlAsyncIterator*, return_promise_capability: JsPromiseCapability*, value: JsValue) -> JsObject*?!:
trap("unported (P3): Web::WebIDL::AsyncIterator::iterator_return_impl (JS promises)")