Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM Function.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "FunctionBinding.h"
#include "MainThreadUtils.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
MOZ_CAN_RUN_SCRIPT void
Function::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv)
{
JS::Rooted<JS::Value> rval(cx);
JS::RootedVector<JS::Value> argv(cx);
if (!argv.resize((1 - 1) + arguments.Length())) {
// That threw an exception on the JSContext, and our CallSetup will do
// the right thing with that.
return;
}
unsigned argc = (1 - 1) + arguments.Length();
do {
for (uint32_t idx = 0; idx < arguments.Length(); ++idx) {
JS::ExposeValueToActiveJS(arguments[idx]);
argv[0 + idx].set(arguments[idx]);
if (!MaybeWrapValue(cx, argv[0 + idx])) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
continue;
}
break;
} while (false);
JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
if (!JS::Call(cx, aThisVal, callable,
JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
aRv.NoteJSContextException(cx);
return;
}
JS::Rooted<JS::Value> rvalDecl(cx);
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
#pragma clang diagnostic ignored "-Wunreachable-code-return"
#endif // __clang__
if ((false) && !CallerSubsumes(rval)) {
cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("return value of Function");
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif // __clang__
rvalDecl = rval;
aRetVal.set(rvalDecl);
}
MOZ_CAN_RUN_SCRIPT void
VoidFunction::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
{
JS::Rooted<JS::Value> rval(cx);
JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
if (!JS::Call(cx, aThisVal, callable,
JS::HandleValueArray::empty(), &rval)) {
aRv.NoteJSContextException(cx);
return;
}
}
} // namespace mozilla::dom