
    8Sj              
          S SK Jr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SKJ
r
  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S\S\4S jrS\S\4S jrS\S\SS4S jrS\S\SS4S jrS\S\S\SS4S jrS\S\SS4S jrS\S\S\SS4S jr S\S\S\SS4S jr!S\S\S\S\SS4
S jr"S\S\S\SS4S jr#S\S\S\S\SS4
S  jr$S\S\S\SS4S! jr%S\S\S\S\SS4
S" jr&S\S\S\S\SS4
S# jr'g)$    )TextIO)%write_operation_parameter_conversions)GenerationContext) add_header_includes_for_idl_type)"fully_qualified_name_for_interfaceidl_identifier_cpp_name)libweb_include_path)GeneratedIncludes)operation_callback_names)parameter_list_length)type_check_idl_value)to_javascript_value)make_name_acceptable_cpp)title_case_to_snake_case)	Interface	interfacereturnc                 d    [        U R                  R                  U R                   S35      5      $ )Nz
Iterator.hr
   path	with_nameimplemented_namer   s    W/mnt/mint/home/seanl/public/Repos/ladybird/Meta/Generators/libweb_bindings/iterables.py,iterator_implementation_header_for_interfacer      s+    y~~779;U;U:VV`8abcc    c                 d    [        U R                  R                  U R                   S35      5      $ )NzAsyncIterator.hr   r   s    r   2async_iterator_implementation_header_for_interfacer      s+    y~~779;U;U:VVe8fghhr   outNc                     UR                   b  UR                   R                  c  g U R                  SUR                   SUR                   SUR                   SUR                   SUR                   S35        g )Nclass z6IteratorPrototype : public JS::Object {
    JS_OBJECT(z9IteratorPrototype, JS::Object);
    GC_DECLARE_ALLOCATOR(z*IteratorPrototype);

public:
    explicit z^IteratorPrototype(JS::Realm&);
    virtual void initialize(JS::Realm&) override;
    virtual ~zRIteratorPrototype() override;

private:
    JS_DECLARE_NATIVE_FUNCTION(next);
};

)iterablekey_typewritenamer    r   s     r   $write_iterator_prototype_declarationr(       s    !Y%7%7%@%@%HII9>>" #~~ #..) * nn nn 	r   c                     UR                   c  g U R                  SUR                   SUR                   SUR                   SUR                   SUR                   SSUR                  ;   a  SOS	 S
35        g )Nr"   z;AsyncIteratorPrototype : public JS::Object {
    JS_OBJECT(z>AsyncIteratorPrototype, JS::Object);
    GC_DECLARE_ALLOCATOR(z/AsyncIteratorPrototype);

public:
    explicit zcAsyncIteratorPrototype(JS::Realm&);
    virtual void initialize(JS::Realm&) override;
    virtual ~zWAsyncIteratorPrototype() override;

private:
    JS_DECLARE_NATIVE_FUNCTION(next);
    DefinesAsyncIteratorReturnz$JS_DECLARE_NATIVE_FUNCTION(return_); z
};

)async_iterabler%   r&   extended_attributesr'   s     r   *write_async_iterator_prototype_declarationr.   6   s    'II9>>" #~~ #..) * nn nn  0LyOlOl/l+rtu v	r   includesc                     UR                   b  UR                   R                  c  g UR                  S5        U R                  S5        g )NzLibJS/Runtime/ArrayPrototype.ha      object.define_native_function(realm, vm.names.entries, entries, 0, default_attributes);
    object.define_native_function(realm, vm.names.forEach, for_each, 1, default_attributes);
    object.define_native_function(realm, vm.names.keys, keys, 0, default_attributes);
    object.define_native_function(realm, vm.names.values, values, 0, default_attributes);

    object.define_direct_property(vm.well_known_symbol_iterator(), object.get_without_side_effects(vm.names.entries), JS::Attribute::Configurable | JS::Attribute::Writable);

)r#   r$   addr%   r    r/   r   s      r   $define_the_pair_iterable_declarationr3   M   sB    
 !Y%7%7%@%@%HLL12II		r   c                     UR                   c  g U R                  S[        UR                   R                  5       S35        g )NzB    object.define_native_function(realm, vm.names.values, values, z, default_attributes);
    object.define_direct_property(vm.well_known_symbol_async_iterator(), object.get_without_side_effects(vm.names.values), JS::Attribute::Configurable | JS::Attribute::Writable);

)r,   r%   r   
parametersr'   s     r   %define_the_async_iterable_declarationr6   b   sU     'IINOdene}e}  fI  fI  PJ  OK K 	r   c                     UR                   c  g UR                  S5        U R                  S5        UR                   R                  (       d  U R                  S5        U R                  S5        g )NLibJS/Runtime/Map.haD      object.define_native_accessor(realm, vm.names.size, get_size, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
    object.define_native_function(realm, vm.names.entries, entries, 0, default_attributes);
    object.define_direct_property(vm.well_known_symbol_iterator(), object.get_without_side_effects(vm.names.entries), JS::Attribute::Configurable | JS::Attribute::Writable);
    object.define_native_function(realm, vm.names.keys, keys, 0, default_attributes);
    object.define_native_function(realm, vm.names.values, values, 0, default_attributes);
    object.define_native_function(realm, vm.names.forEach, for_each, 1, default_attributes);
    object.define_native_function(realm, vm.names.get, get, 1, default_attributes);
    object.define_native_function(realm, vm.names.has, has, 1, default_attributes);
z    object.define_native_function(realm, vm.names.delete_, delete_, 1, default_attributes);
    object.define_native_function(realm, vm.names.clear, clear, 0, default_attributes);

)mapliker1   r%   readonlyr2   s      r   define_the_maplike_declarationr<   q   s`    
  LL&'II	
 %%			

 IIdOr   c                 \   UR                   c  g UR                  S5        [        U5      nU R                  S5        UR                   R                  (       dE  SU;  a  U R                  S5        SU;  a  U R                  S5        SU;  a  U R                  S5        U R                  S	5        g )
NLibJS/Runtime/Set.ha      object.define_native_accessor(realm, vm.names.size, get_size, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
    object.define_native_function(realm, vm.names.entries, entries, 0, default_attributes);
    object.define_native_function(realm, vm.names.keys, values, 0, default_attributes);
    object.define_native_function(realm, vm.names.values, values, 0, default_attributes);
    object.define_direct_property(vm.well_known_symbol_iterator(), object.get_without_side_effects(vm.names.values), JS::Attribute::Configurable | JS::Attribute::Writable);
    object.define_native_function(realm, vm.names.forEach, for_each, 1, default_attributes);
    object.define_native_function(realm, vm.names.has, has, 1, default_attributes);
r1   zT    object.define_native_function(realm, vm.names.add, add, 1, default_attributes);
delete_z\    object.define_native_function(realm, vm.names.delete_, delete_, 1, default_attributes);
clearzX    object.define_native_function(realm, vm.names.clear, clear, 0, default_attributes);
r9   )setliker1   r   r%   r;   )r    r/   r   operation_callbackss       r   define_the_setlike_declarationrC      s    
  LL&'29=II		 %%++IImn//IIuv--IIqrIIdOr   contextc           !      N   UR                   b  UR                   R                  c  g UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  [        U5      5        [	        UR                   R                  X!5        [	        UR                   R
                  X!5        U R                  SUR                   SUR                   S[        U5       SUR                   S	UR                   S
[        U5       SUR                   SUR                   S[        U5       SUR                   SUR                   S[        UR                   R                  SX!5       S[        UR                   R
                  SX!5       S35        g )N"LibJS/Runtime/AbstractOperations.hLibJS/Runtime/Error.hLibJS/Runtime/ValueInlines.h"LibWeb/Bindings/ExceptionOrUtils.hJS_DEFINE_NATIVE_FUNCTION((::entries)
{
    WebIDL::log_trace(vm, "a  ::entries");

    // 1. Let jsValue be ? ToObject(this value).
    // 2. If jsValue is a platform object, then perform a security check, passing jsValue, "%Symbol.iterator%", and "method".
    // 3. If jsValue does not implement definition, then throw a TypeError.
    auto* this_impl = TRY(impl_from(vm));

    // 4. Return a newly created default iterator object for definition, with jsValue as its target, "key+value" as its kind, and index set to 0.
    return TRY(throw_dom_exception_if_needed(vm, [&] { return zgIterator::create(*this_impl, JS::Object::PropertyKind::KeyAndValue); }));
}

JS_DEFINE_NATIVE_FUNCTION(%::keys)
{
    WebIDL::log_trace(vm, "a  ::keys");

    // 1. Let jsValue be ? ToObject(this value).
    // 2. If jsValue is a platform object, then perform a security check, passing jsValue, "keys", and "method".
    // 3. If jsValue does not implement definition, then throw a TypeError.
    auto* this_impl = TRY(impl_from(vm));

    // 4. Return a newly created default iterator object for definition, with jsValue as its target, "key" as its kind, and index set to 0.
    return TRY(throw_dom_exception_if_needed(vm, [&] { return z_Iterator::create(*this_impl, JS::Object::PropertyKind::Key); }));
}

JS_DEFINE_NATIVE_FUNCTION('::values)
{
    WebIDL::log_trace(vm, "a  ::values");

    // 1. Let jsValue be ? ToObject(this value).
    // 2. If jsValue is a platform object, then perform a security check, passing jsValue, "values", and "method".
    // 3. If jsValue does not implement definition, then throw a TypeError.
    auto* this_impl = TRY(impl_from(vm));

    // 4. Return a newly created default iterator object for definition, with jsValue as its target, "value" as its kind, and index set to 0.
    return TRY(throw_dom_exception_if_needed(vm, [&] { return zaIterator::create(*this_impl, JS::Object::PropertyKind::Value); }));
}

JS_DEFINE_NATIVE_FUNCTION()::for_each)
{
    WebIDL::log_trace(vm, "aw  ::for_each");
    auto* this_impl = TRY(impl_from(vm));

    auto callback = vm.argument(0);
    if (!callback.is_function())
        return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAFunction, callback);

    auto this_value = vm.this_value();
    TRY(this_impl->for_each([&](auto key, auto value) -> JS::ThrowCompletionOr<void> {
        JS::Value wrapped_key = keyz$;
        JS::Value wrapped_value = valuez;
        TRY(JS::call(vm, callback.as_function(), vm.argument(1), wrapped_value, wrapped_key, this_value));
        return {};
    }));

    return JS::js_undefined();
}

)
r#   r$   r1   r   r   
value_typer%   prototype_classr   r   r    rD   r/   r   s       r   )write_pair_iterable_declaration_functionsrT      s    !Y%7%7%@%@%HLL56LL()LL/0LL56LL=iHI$Y%7%7%@%@(T$Y%7%7%B%BHVII,Y-F-F,G H%556 7@ Accl@m?n o %445 6%556 7@ Accl@m?n o %445 6%556 7@ Accl@m?n o %445 6%556 	7! "5Y5G5G5P5PRWYa!k l m##6y7I7I7T7TV]_g#q"r sg; ;r   c           
      x   UR                   b  UR                   R                  c  g UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  [        U5      5        UR                   S3nU R                  SR                  / S	PUR                   PS
PUR                   PSPUR                   PSPUR                   PSPUR                   PSPUR                   PSPUR                   PSP[        U5       PSP[        [        U5      5       PSP[        U5       PSPU PSP[        U5       PSPUR                   PSPUR                   PSP[        [        U5      5       PSP5      5        g )NzAK/TypeCasts.hrG   z!LibJS/Runtime/IteratorPrototype.hLibJS/Runtime/PrimitiveString.hrH   rI   Iteratorr+   GC_DEFINE_ALLOCATOR(zIteratorPrototype);

zIteratorPrototype::zIteratorPrototype(JS::Realm& realm)
    : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().iterator_prototype())
{
}

zIteratorPrototype::~zIteratorPrototype()
{
}

void aZ  IteratorPrototype::initialize(JS::Realm& realm)
{
    auto& vm = this->vm();
    Base::initialize(realm);
    define_native_function(realm, vm.names.next, next, 0, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable);
    define_direct_property(vm.well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm, "zQ Iterator"_utf16), JS::Attribute::Configurable);
}

static JS::ThrowCompletionOr<zIterator*> z`_impl_from(JS::VM& vm)
{
    auto this_object = TRY(vm.this_value().to_object(vm));
    if (!is<znIterator>(*this_object))
        return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "z");
    return static_cast<z<Iterator*>(this_object.ptr());
}

JS_DEFINE_NATIVE_FUNCTION(z6IteratorPrototype::next)
{
    WebIDL::log_trace(vm, "z0IteratorPrototype::next");
    auto* impl = TRY(ze_impl_from(vm));
    return TRY(throw_dom_exception_if_needed(vm, [&] { return impl->next(); }));
}

)
r#   r$   r1   r   r&   r%   joinr   r   r   )r    r/   r   iterator_interface_names       r   'write_iterator_prototype_implementationr[      su   
 !Y%7%7%@%@%HLL!"LL()LL45LL23LL/0LL56LL=iHI!* 09II " "& "y~~&6 " 7 "
 "#"$-NN#3"4"  " %" &/^^$4"5" nn"c"  dmcqcqbr!" s!"& AKL'"& MX'"& Yq  rJ  Kb  rc  Yd  Xe'"&e'", 0	:;-",<V-". WnUn/".o/"0 ;9EF1"0G1"6 %>>*7"6+7": &NN+;":,;"< //GH_/`ab="<c=" "r   c                 `   UR                   c  g UR                   R                  b  [        SUR                   S35      eUR	                  S5        UR	                  [        U5      5        [        UR                   R                  X!5        U R                  SUR                   SUR                   S35        [        XR                   R                  X!5        SR                  S UR                   R                   5       5      nU(       a  SU 3nU R                  S	[        U5       S
U S35        g )Nz0Unsupported pair async iterable declaration on ''rI   rJ   rM   zY::values");
    auto& realm = *vm.current_realm();
    auto* impl = TRY(impl_from(vm));

z, c              3   8   #    U  H  n[        U5      v   M     g 7f)Nr   ).0	parameters     r   	<genexpr>=write_async_iterable_declaration_functions.<locals>.<genexpr>M  s     rNq1)<<Nqs   z>    return TRY(throw_dom_exception_if_needed(vm, [&] { return zCAsyncIterator::create(realm, JS::Object::PropertyKind::Value, *implz); }));
}

)r,   r$   RuntimeErrorr&   r1   r   r   rQ   r%   rR   r   r5   rY   r   )r    rD   r/   r   	argumentss        r   *write_async_iterable_declaration_functionsre   2  s.    '((4MinnM]]^_``LL56LLCINO$Y%=%=%H%H(\II&y'@'@&A B%556 7	 *#/G/G/R/RT\f		riNfNfNqNqrrI$	IIKLnoxLyKz  {~  H  ~I I 	r   c                    UR                   c  g UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  [        U5      5        U R                  SUR                   SUR                   SUR                   S	UR                   S
UR                   SUR                   SUR                   SSUR
                  ;   a  SOS SUR                   SUR                   S[        U5       SUR                   S35        SUR
                  ;   aF  U R                  SUR                   SUR                   S[        U5       SUR                   S3	5        g g )NzAK/StringView.hz&LibJS/Runtime/AsyncIteratorPrototype.hrV   rI   zLibWeb/WebIDL/AsyncIterator.hrX   zAsyncIteratorPrototype);

zAsyncIteratorPrototype::zAsyncIteratorPrototype(JS::Realm& realm)
    : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().async_iterator_prototype())
{
}

zAsyncIteratorPrototype::~z#AsyncIteratorPrototype()
{
}

void zAsyncIteratorPrototype::initialize(JS::Realm& realm)
{
    auto& vm = this->vm();
    Base::initialize(realm);
    define_direct_property(vm.well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm, "z AsyncIterator"_utf16), JS::Attribute::Configurable);

    define_native_function(realm, vm.names.next, next, 0, JS::default_attributes);
    r*   zTdefine_native_function(realm, vm.names.return_, return_, 1, JS::default_attributes);r+   z
}

JS_DEFINE_NATIVE_FUNCTION(z;AsyncIteratorPrototype::next)
{
    WebIDL::log_trace(vm, "zAsyncIteratorPrototype::next");
    auto& realm = *vm.current_realm();

    return TRY(throw_dom_exception_if_needed(vm, [&] {
        return WebIDL::AsyncIterator::next<zAsyncIterator>(realm, "zAsyncIterator"sv);
    }));
}
z
JS_DEFINE_NATIVE_FUNCTION(z>AsyncIteratorPrototype::return_)
{
    WebIDL::log_trace(vm, "zAsyncIteratorPrototype::return");
    auto& realm = *vm.current_realm();

    auto value = vm.argument(0);

    return TRY(throw_dom_exception_if_needed(vm, [&] {
        return WebIDL::AsyncIterator::return_<z%AsyncIterator"sv, value);
    }));
}
)r,   r1   r   r%   r&   r-   r   r2   s      r   -write_async_iterator_prototype_implementationrg   Y  s   
 'LL"#LL9:LL23LL56LL01LLCINOII  0 1
 ((8 9
  ))..)9 : nn c dmcqcqbr s `|  @I  @]  @]  `][  ce  f f %>>* +%NN+ ,, -Oy,Y+ZZqr{  sA  sA  rB B7	 D $y'D'DD		 $>>* +%NN+ ,/ 0RR[/\.]]tu~  vD  vD  uE E 	 Er   c                    UR                   c  g UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        U R                  SR                  / SPUR                   PS	PUR                   PS
PUR                   PSPUR                   PSPUR                   PSPUR                   PSPUR                   PSPUR                   PSPUR                   PSPUR                   PSPUR                   PSPUR                   PSP[        UR                   R                  SX!UR                  5       PSPUR                   PSPUR                   PSP[        UR                   R                  SX!UR                  5       PSP5      5        S[        U5      ;  a  UR                   R                  (       d  U R                  SUR                   SUR                   S[        UR                   R                  SX!UR                  5       S[        UR                   R                  SX!UR                  5       S 3	5        S![        U5      ;  at  UR                   R                  (       dY  U R                  S"UR                   S#UR                   S$[        UR                   R                  SX!UR                  5       S%35        S&[        U5      ;  aI  UR                   R                  (       d-  U R                  S"UR                   S'UR                   S(35        g g g ))NrF   rG   r8   zLibJS/Runtime/MapIterator.hrH   rI   r+   zI// https://webidl.spec.whatwg.org/#js-map-size
JS_DEFINE_NATIVE_FUNCTION()::get_size)
{
    WebIDL::log_trace(vm, "u  ::get_size");

    // 1. Let O be the this value, implementation-checked against A with identifier "size" and type "getter".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Return map’s size, converted to a JavaScript value.
    return map->map_size();
}

// https://webidl.spec.whatwg.org/#js-map-entries
JS_DEFINE_NATIVE_FUNCTION(rK   aN  ::entries");
    auto& realm = *vm.current_realm();

    // 1. Let O be the this value, implementation-checked against A with identifier "entries" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Return the result of creating a map iterator from map with kind "key+value".
    return JS::MapIterator::create(realm, *map, PropertyKind::KeyAndValue);
}

// https://webidl.spec.whatwg.org/#js-map-keys
JS_DEFINE_NATIVE_FUNCTION(rL   a<  ::keys");
    auto& realm = *vm.current_realm();

    // 1. Let O be the this value, implementation-checked against A with identifier "keys" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Return the result of creating a map iterator from map with kind "key".
    return JS::MapIterator::create(realm, *map, PropertyKind::Key);
}

// https://webidl.spec.whatwg.org/#js-map-values
JS_DEFINE_NATIVE_FUNCTION(rM   aE  ::values");
    auto& realm = *vm.current_realm();

    // 1. Let O be the this value, implementation-checked against A with identifier "values" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Return the result of creating a map iterator from map with kind "value".
    return JS::MapIterator::create(realm, *map, PropertyKind::Value);
}

// https://webidl.spec.whatwg.org/#js-map-forEach
JS_DEFINE_NATIVE_FUNCTION(rN   u  ::for_each");

    // 1. Let O be the this value, implementation-checked against A with identifier "forEach" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Let callbackFn be the first argument passed to the function, or undefined if not supplied.
    auto callback = vm.argument(0);

    // 4. If IsCallable(callbackFn) is false, throw a TypeError.
    if (!callback.is_function())
        return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAFunction, callback);

    // 5. Let thisArg be the second argument passed to the function, or undefined if not supplied.
    auto this_arg = vm.argument(1);

    // 6. For each key → value of map:
    for (auto [key, value] : *map) {
        // 1. Let jsKey and jsValue be key and value converted to a JavaScript value.
        // 2. Perform ? Call(callbackFn, thisArg, « jsValue, jsKey, O »).
        TRY(JS::call(vm, callback.as_function(), this_arg, value, key, this_impl));
    }

    // 7. Return undefined.
    return JS::js_undefined();
}

// https://webidl.spec.whatwg.org/#js-map-get
JS_DEFINE_NATIVE_FUNCTION(z$::get)
{
    WebIDL::log_trace(vm, "aH  ::get");

    // 1. Let O be the this value, implementation-checked against A with identifier "get" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Let keyType be the key type specified in the maplike declaration.
    // 4. Let keyArg be the first argument passed to this function, or undefined if not supplied.
    // 5. Let key be keyArg converted to an IDL value of type keyType.
    auto key = vm.argument(0);
    rO   a&  

    // FIXME: 6. If key is -0, set key to +0.

    // 7. If map[key] exists, then return map[key], converted to a JavaScript value.
    auto result = map->map_get(key);
    return result.value_or(JS::js_undefined());
}

// https://webidl.spec.whatwg.org/#js-map-has
JS_DEFINE_NATIVE_FUNCTION($::has)
{
    WebIDL::log_trace(vm, "aH  ::has");

    // 1. Let O be the this value, implementation-checked against A with identifier "has" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Let keyType be the key type specified in the maplike declaration.
    // 4. Let keyArg be the first argument passed to this function, or undefined if not supplied.
    // 5. Let key be keyArg converted to an IDL value of type keyType.
    auto key = vm.argument(0);
    z

    // FIXME: 6. If key is -0, set key to +0.

    // 7. If map[key] exists, then return true; otherwise return false.
    return map->map_has(key);
}
setzH// https://webidl.spec.whatwg.org/#js-map-set
JS_DEFINE_NATIVE_FUNCTION(z$::set)
{
    WebIDL::log_trace(vm, "ai  ::set");

    // 1. Let O be the this value, implementation-checked against A with identifier "set" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Let keyType be the key type specified in the maplike declaration, and valueType be the value type.
    // 4. Let keyArg be the first argument passed to this function, or undefined if not supplied.
    // 5. Let key be keyArg converted to an IDL value of type keyType.
    auto key = vm.argument(0);
    a  

    // FIXME: 6. If key is -0, set key to +0.

    // 7. Let valueArg be the second argument passed to this function, or undefined if not supplied.
    // 8. Let value be valueArg converted to an IDL value of type valueType.
    auto value = vm.argument(1);
    rP   z

    // 9. Set map[key] to value.
    map->map_set(key, value);
    this_impl->on_map_modified_from_js({});

    // 10. Return O.
    return this_impl;
}

r?   zK// https://webidl.spec.whatwg.org/#js-map-delete
JS_DEFINE_NATIVE_FUNCTION((::delete_)
{
    WebIDL::log_trace(vm, "aO  ::delete_");

    // 1. Let O be the this value, implementation-checked against A with identifier "delete" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Let keyType be the key type specified in the maplike declaration.
    // 4. Let keyArg be the first argument passed to this function, or undefined if not supplied.
    // 5. Let key be keyArg converted to an IDL value of type keyType.
    auto key = vm.argument(0);
    a  

    // FIXME: 6. If key is -0, set key to +0.

    // 7. Let retVal be true if map[key] exists, or else false.
    // 8. Remove map[key].
    auto result = map->map_remove(key);
    this_impl->on_map_modified_from_js({});

    // 9. Return retVal.
    return result;
}

r@   &::clear)
{
    WebIDL::log_trace(vm, "a>  ::clear");

    // 1. Let O be the this value, implementation-checked against A with identifier "delete" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let map be the map entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Map> map = this_impl->map_entries();

    // 3. Clear map.
    // NOTE: The map is preserved because there may be existing iterators, currently suspended, iterating over it.
    map->map_clear();
    this_impl->on_map_modified_from_js({});

    // 4. Return undefined.
    return JS::js_undefined();
}

)r:   r1   r%   rY   rR   r   r$   r&   r   r;   rQ   rS   s       r   #write_maplike_declaration_functionsrn     sh     LL56LL()LL&'LL./LL/0LL56II M M  M$445M6M &556M7M  %445!M 6!M$ &556%M$7%M@ %445AM@6AMD &556EMD7EM` %445aM`6aMd &556eMd7eM@ %445AM@6AMD &556EMD7EM@ %445AM@6AMD &556EMD7EM\ )++44eXPYP^P^_`]M\
a]Mp %445qMp6qMt &556uMt7uML )++44eXPYP^P^_`MMLaMM Mb ,Y77	@Q@Q@Z@Z		 $445 6%556 7 )++44eXPYP^P^_` a )++66T]TbTbcd 
e-   	H 0;;IDUDUD^D^		 $445 6%556 7 )++44eXPYP^P^_` a 	@ .y99)BSBSB\B\		 $445 6%556 7 	 C]9r   c                 *   UR                   c  g UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        U R                  SUR                   SUR                   S	UR                   S
UR                   SUR                   SUR                   SUR                   SUR                   SUR                   SUR                   S[	        UR                   R
                  SX!UR                  5       S35        S[        U5      ;  at  UR                   R                  (       dY  U R                  SUR                   SUR                   S[	        UR                   R
                  SX!UR                  5       S35        S[        U5      ;  at  UR                   R                  (       dY  U R                  SUR                   SUR                   S[	        UR                   R
                  SX!UR                  5       S35        S[        U5      ;  aI  UR                   R                  (       d-  U R                  SUR                   S UR                   S!35        g g g )"NrF   rG   r>   zLibJS/Runtime/SetIterator.hrH   rI   zI// https://webidl.spec.whatwg.org/#js-set-size
JS_DEFINE_NATIVE_FUNCTION(ri   u  ::size");

    // 1. Let O be the this value, implementation-checked against A with identifier "size" and type "getter".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let set be the set entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Set> set = this_impl->set_entries();

    // 3. Return set’s size, converted to a JavaScript value.
    return set->set_size();
}

// https://webidl.spec.whatwg.org/#js-set-entries
JS_DEFINE_NATIVE_FUNCTION(rK   aO  ::values");
    auto& realm = *vm.current_realm();

    // 1. Let O be the this value, implementation-checked against A with identifier "entries" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let set be the set entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Set> set = this_impl->set_entries();

    // 3. Return the result of creating a set iterator from set with kind "key+value".
    return JS::SetIterator::create(realm, *set, PropertyKind::KeyAndValue);
}

// https://webidl.spec.whatwg.org/#js-set-values
JS_DEFINE_NATIVE_FUNCTION(rM   aE  ::values");
    auto& realm = *vm.current_realm();

    // 1. Let O be the this value, implementation-checked against A with identifier "values" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let set be the set entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Set> set = this_impl->set_entries();

    // 3. Return the result of creating a set iterator from set with kind "value".
    return JS::SetIterator::create(realm, *set, PropertyKind::Value);
}

// https://webidl.spec.whatwg.org/#js-set-forEach
JS_DEFINE_NATIVE_FUNCTION(rN   u  ::for_each");

    // 1. Let O be the this value, implementation-checked against A with identifier "forEach" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let set be the set entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Set> set = this_impl->set_entries();

    // 3. Let callbackFn be the first argument passed to the function, or undefined if not supplied.
    // 4. If IsCallable(callbackFn) is false, throw a TypeError.
    auto callback = vm.argument(0);
    if (!callback.is_function())
        return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAFunction, callback);

    // 5. Let thisArg be the second argument passed to the function, or undefined if not supplied.
    auto this_arg = vm.argument(1);

    // 6. For each value of set:
    for (auto value : *set) {
        // 1. Let jsValue be value converted to a JavaScript value.

        // 2. Perform ? Call(callbackFn, thisArg, « jsValue, jsValue, O»).
        TRY(JS::call(vm, callback.as_function(), this_arg, value, value, this_impl));
    }

    // 7. Return undefined.
    return JS::js_undefined();
}

// https://webidl.spec.whatwg.org/#js-set-has
JS_DEFINE_NATIVE_FUNCTION(rj   a  ::has");

    // 1. Let O be the this value, implementation-checked against A with identifier "has" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let set be the set entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Set> set = this_impl->set_entries();

    // 3. Let valueType be the value type specified in the setlike declaration.
    // 4. Let valueArg be the first argument passed to this function, or undefined if not supplied.
    // 5. Let value be valueArg converted to an IDL value of type valueType.
    // FIXME: 6. If value is -0, set value to +0.
    auto value = vm.argument(0);
    rP   zp

    // 7. If set contains value, then return true, otherwise return false.
    return set->set_has(value);
}

r1   zH// https://webidl.spec.whatwg.org/#js-set-add
JS_DEFINE_NATIVE_FUNCTION(z$::add)
{
    WebIDL::log_trace(vm, "a  ::add");

    // 1. Let O be the this value, implementation-checked against A with identifier "add" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let set be the set entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Set> set = this_impl->set_entries();

    // 3. Let valueType be the value type specified in the setlike declaration.
    // 4. Let valueArg be the first argument passed to this function, or undefined if not supplied.
    // 5. Let value be valueArg converted to an IDL value of type valueType.
    // FIXME: 6. If value is -0, set value to +0.
    auto value = vm.argument(0);
    z

    // 6. Append value to set.
    set->set_add(value);
    this_impl->on_set_modified_from_js({});

    return this_impl;
}

r?   zK// https://webidl.spec.whatwg.org/#js-set-delete
JS_DEFINE_NATIVE_FUNCTION(rl   u_  ::delete_");

    // 1. Let O be the this value, implementation-checked against A with identifier "delete" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let set be O’s set entries.
    GC::Ref<JS::Set> set = this_impl->set_entries();

    // 3. Let valueType be the value type specified in the setlike declaration.
    // 4. Let valueArg be the first argument passed to this function, or undefined if not supplied.
    // 5. Let value be valueArg converted to an IDL value of type valueType.
    // 6. FIXME: If value is -0, set value to +0.
    auto value = vm.argument(0);
    z

    // 7. Let retVal be true if set contains value, or else false.
    // 8. Remove value from set.
    auto result = set->set_remove(value);
    this_impl->on_set_modified_from_js({});

    // 9. Return retVal.
    return result;
}

r@   zJ// https://webidl.spec.whatwg.org/#js-set-clear
JS_DEFINE_NATIVE_FUNCTION(rm   aC  ::clear");

    // 1. Let O be the this value, implementation-checked against A with identifier "clear" and type "method".
    auto* this_impl = TRY(impl_from(vm));

    // 2. Let set be the set entries of the IDL value that represents a reference to O.
    GC::Ref<JS::Set> set = this_impl->set_entries();

    // 3. Empty set.
    // NOTE: Note: The set is preserved because there may be existing iterators, currently suspended, iterating over it.
    set->set_clear();
    this_impl->on_set_modified_from_js({});

    // 4. Return undefined.
    return JS::js_undefined();
}

)	rA   r1   r%   rR   r   rQ   r&   r   r;   rS   s       r   #write_setlike_declaration_functionsrp     s     LL56LL()LL&'LL./LL/0LL56II $445 6%556 7 %445 6%556 7 %445 6%556 7 %445 6%556 7< %445 6%556 7 )++66T]TbTbcd ee eR ,Y77	@Q@Q@Z@Z		 $445 6%556 7 )++66T]TbTbcd 	e! 	: 0;;IDUDUD^D^		 $445 6%556 7 )++66T]TbTbcd e! 	> .y99)BSBSB\B\		 $445 6%556 7 	 C]9r   )(typingr   $Generators.libweb_bindings.argumentsr   "Generators.libweb_bindings.contextr   $Generators.libweb_bindings.cpp_typesr   r   r	   r
   #Generators.libweb_bindings.includesr   .Generators.libweb_bindings.overload_resolutionr   r   'Generators.libweb_bindings.to_idl_valuer   &Generators.libweb_bindings.to_js_valuer   Utils.utilsr   r   Utils.webidl_parserr   strr   r   r(   r.   r3   r6   r<   rC   rT   r[   re   rg   rn   rp    r   r   <module>r}      se    V @ Q S H D A S P H F 0 0 )dI d# di) iPS if  t ,F y UY .	  
	*	 
	  
	:	  
	>L	LL  L 	L
 
L^3	33 3 
	3l$	$$  $ 	$
 
$N>	>> > 
	>B|	||  | 	|
 
|~L	LL  L 	L
 
Lr   