mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-27 14:22:08 +00:00 
			
		
		
		
	 40a70461a0
			
		
	
	
		40a70461a0
		
	
	
	
	
		
			
			Similar to create() in LibJS, wrap() et al. are on a low enough level to warrant passing a Realm directly instead of relying on the current realm from the VM, as a wrapper may need to be allocated while no JS is being executed.
		
			
				
	
	
		
			47 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibWeb/Bindings/Wrappable.h>
 | |
| #include <LibWeb/Fetch/Headers.h>
 | |
| 
 | |
| namespace Web::Fetch {
 | |
| 
 | |
| class HeadersIterator
 | |
|     : public Bindings::Wrappable
 | |
|     , public RefCounted<HeadersIterator> {
 | |
| public:
 | |
|     using WrapperType = Bindings::HeadersIteratorWrapper;
 | |
| 
 | |
|     static NonnullRefPtr<HeadersIterator> create(Headers const& headers, JS::Object::PropertyKind iteration_kind)
 | |
|     {
 | |
|         return adopt_ref(*new HeadersIterator(headers, iteration_kind));
 | |
|     }
 | |
| 
 | |
|     JS::ThrowCompletionOr<JS::Object*> next();
 | |
| 
 | |
|     void visit_edges(JS::Cell::Visitor&);
 | |
| 
 | |
| private:
 | |
|     HeadersIterator(Headers const& headers, JS::Object::PropertyKind iteration_kind)
 | |
|         : m_headers(headers)
 | |
|         , m_iteration_kind(iteration_kind)
 | |
|     {
 | |
|     }
 | |
| 
 | |
|     Headers const& m_headers;
 | |
|     JS::Object::PropertyKind m_iteration_kind;
 | |
|     size_t m_index { 0 };
 | |
| };
 | |
| 
 | |
| }
 | |
| 
 | |
| namespace Web::Bindings {
 | |
| 
 | |
| HeadersIteratorWrapper* wrap(JS::Realm&, Fetch::HeadersIterator&);
 | |
| 
 | |
| }
 |