mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:27:35 +00:00
LibJS+LibWeb: Move IteratorOperations.h AOs to Iterator.h
Rather than splitting the Iterator type and its AOs into two files, let's combine them into one file to match every other JS runtime object that we have.
This commit is contained in:
parent
7d0f70bfa0
commit
9d7215c636
46 changed files with 307 additions and 340 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -7,6 +8,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
@ -35,12 +38,30 @@ private:
|
|||
IteratorRecord m_iterated; // [[Iterated]]
|
||||
};
|
||||
|
||||
enum class IteratorHint {
|
||||
Sync,
|
||||
Async,
|
||||
};
|
||||
|
||||
enum class StringHandling {
|
||||
IterateStrings,
|
||||
RejectStrings,
|
||||
};
|
||||
|
||||
ThrowCompletionOr<IteratorRecord> get_iterator_from_method(VM&, Value, NonnullGCPtr<FunctionObject>);
|
||||
ThrowCompletionOr<IteratorRecord> get_iterator(VM&, Value, IteratorHint);
|
||||
ThrowCompletionOr<IteratorRecord> get_iterator_direct(VM&, Object&);
|
||||
ThrowCompletionOr<IteratorRecord> get_iterator_flattenable(VM&, Value, StringHandling);
|
||||
ThrowCompletionOr<NonnullGCPtr<Object>> iterator_next(VM&, IteratorRecord const&, Optional<Value> = {});
|
||||
ThrowCompletionOr<GCPtr<Object>> iterator_step(VM&, IteratorRecord const&);
|
||||
ThrowCompletionOr<bool> iterator_complete(VM&, Object& iterator_result);
|
||||
ThrowCompletionOr<Value> iterator_value(VM&, Object& iterator_result);
|
||||
Completion iterator_close(VM&, IteratorRecord const&, Completion);
|
||||
Completion async_iterator_close(VM&, IteratorRecord const&, Completion);
|
||||
NonnullGCPtr<Object> create_iterator_result_object(VM&, Value, bool done);
|
||||
ThrowCompletionOr<MarkedVector<Value>> iterator_to_list(VM&, IteratorRecord const&);
|
||||
|
||||
using IteratorValueCallback = Function<Optional<Completion>(Value)>;
|
||||
Completion get_iterator_values(VM&, Value iterable, IteratorValueCallback callback);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue