mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-27 14:22:08 +00:00 
			
		
		
		
	 4c1c6ef91c
			
		
	
	
		4c1c6ef91c
		
	
	
	
	
		
			
			This allows the host of LibJS (notably LibWeb in this case) to override certain functions such as HostEnqueuePromiseJob, so it can do it's own thing in certain situations. Notably, LibWeb will override HostEnqueuePromiseJob to put promise jobs on the microtask queue. This also makes promise jobs use AK::Function instead of JS::NativeFunction. This removes the need to go through a JavaScript function and it more closely matches the spec's idea of "abstract closures"
		
			
				
	
	
		
			26 lines
		
	
	
	
		
			730 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
	
		
			730 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
 | |
|  * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibJS/Runtime/GlobalObject.h>
 | |
| #include <LibJS/Runtime/JobCallback.h>
 | |
| #include <LibJS/Runtime/NativeFunction.h>
 | |
| #include <LibJS/Runtime/Promise.h>
 | |
| 
 | |
| namespace JS {
 | |
| 
 | |
| struct PromiseJob {
 | |
|     Function<ThrowCompletionOr<Value>()> job;
 | |
|     Realm* realm { nullptr };
 | |
| };
 | |
| 
 | |
| // NOTE: These return a PromiseJob to prevent awkward casting at call sites.
 | |
| PromiseJob create_promise_reaction_job(GlobalObject&, PromiseReaction&, Value argument);
 | |
| PromiseJob create_promise_resolve_thenable_job(GlobalObject&, Promise&, Value thenable, JobCallback then);
 | |
| 
 | |
| }
 |