mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:57:35 +00:00
LibWeb: Convert all generated bindings to ThrowCompletionOr
This also required converting URLSearchParams::for_each and the callback function it invokes to ThrowCompletionOr. With this, the ReturnType enum used by WrapperGenerator is removed as all callers would be using ReturnType::Completion.
This commit is contained in:
parent
19ac19eae1
commit
c19c306744
3 changed files with 120 additions and 220 deletions
|
@ -207,13 +207,14 @@ String URLSearchParams::to_string()
|
|||
return url_encode(m_list, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded);
|
||||
}
|
||||
|
||||
void URLSearchParams::for_each(Function<IterationDecision(String const&, String const&)> callback)
|
||||
JS::ThrowCompletionOr<void> URLSearchParams::for_each(ForEachCallback callback)
|
||||
{
|
||||
for (auto i = 0u; i < m_list.size(); ++i) {
|
||||
auto& query_param = m_list[i]; // We are explicitly iterating over the indices here as the callback might delete items from the list
|
||||
if (callback(query_param.name, query_param.value) == IterationDecision::Break)
|
||||
break;
|
||||
TRY(callback(query_param.name, query_param.value));
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,8 @@ public:
|
|||
|
||||
String to_string();
|
||||
|
||||
void for_each(Function<IterationDecision(String const&, String const&)>);
|
||||
using ForEachCallback = Function<JS::ThrowCompletionOr<void>(String const&, String const&)>;
|
||||
JS::ThrowCompletionOr<void> for_each(ForEachCallback);
|
||||
|
||||
private:
|
||||
friend class URL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue