1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00
serenity/Userland/Libraries/LibJS/Runtime/JobCallback.h
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

34 lines
854 B
C++

/*
* Copyright (c) 2021, Linus Groh <mail@linusgroh.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Runtime/Function.h>
#include <LibJS/Runtime/VM.h>
namespace JS {
// 9.4.1 JobCallback Records, https://tc39.es/ecma262/#sec-jobcallback-records
struct JobCallback {
Function* callback;
};
// 9.4.2 HostMakeJobCallback, https://tc39.es/ecma262/#sec-hostmakejobcallback
inline JobCallback make_job_callback(Function& callback)
{
return { &callback };
}
// 9.4.3 HostCallJobCallback, https://tc39.es/ecma262/#sec-hostcalljobcallback
template<typename... Args>
[[nodiscard]] inline Value call_job_callback(VM& vm, JobCallback& job_callback, Value this_value, Args... args)
{
VERIFY(job_callback.callback);
auto& callback = *job_callback.callback;
return vm.call(callback, this_value, args...);
}
}