1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

LibJS: Move JobCallback functions out-of-line

This allows JobCallback.h to not include Runtime/AbstractOperations.h
and FunctionObject.h.
This commit is contained in:
Andreas Kling 2022-11-23 11:32:45 +01:00 committed by Linus Groh
parent 20e51025bb
commit 96cbf368bd
4 changed files with 36 additions and 18 deletions

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/FunctionObject.h>
#include <LibJS/Runtime/JobCallback.h>
namespace JS {
// 9.5.2 HostMakeJobCallback ( callback ), https://tc39.es/ecma262/#sec-hostmakejobcallback
JobCallback make_job_callback(FunctionObject& callback)
{
// 1. Return the JobCallback Record { [[Callback]]: callback, [[HostDefined]]: empty }.
return { make_handle(&callback) };
}
// 9.5.3 HostCallJobCallback ( jobCallback, V, argumentsList ), https://tc39.es/ecma262/#sec-hostcalljobcallback
ThrowCompletionOr<Value> call_job_callback(VM& vm, JobCallback& job_callback, Value this_value, MarkedVector<Value> arguments_list)
{
// 1. Assert: IsCallable(jobCallback.[[Callback]]) is true.
VERIFY(!job_callback.callback.is_null());
// 2. Return ? Call(jobCallback.[[Callback]], V, argumentsList).
return call(vm, job_callback.callback.cell(), this_value, move(arguments_list));
}
}