Source code

Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM TestCallback.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "MainThreadUtils.h"
#include "TestCallbackBinding.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"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/UnionTypes.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
TestUnionArguments::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const StringOrLong& arg1, const Nullable<StringOrLong>& arg2, const Optional<StringOrLong>& arg3, const Optional<Nullable<StringOrLong>>& arg4, ErrorResult& aRv)
{
JS::Rooted<JS::Value> rval(cx);
JS::RootedVector<JS::Value> argv(cx);
if (!argv.resize(4)) {
// That threw an exception on the JSContext, and our CallSetup will do
// the right thing with that.
return;
}
unsigned argc = 4;
do {
if (arg4.WasPassed()) {
JS::Rooted<JSObject*> callbackObj(cx, CallbackKnownNotGray());
if (arg4.Value().IsNull()) {
argv[3].setNull();
break;
}
if (!arg4.Value().Value().ToJSVal(cx, callbackObj, argv[3])) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
break;
} else if (argc == 4) {
// This is our current trailing argument; reduce argc
--argc;
} else {
argv[3].setUndefined();
}
} while (false);
do {
if (arg3.WasPassed()) {
JS::Rooted<JSObject*> callbackObj(cx, CallbackKnownNotGray());
if (!arg3.Value().ToJSVal(cx, callbackObj, argv[2])) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
break;
} else if (argc == 3) {
// This is our current trailing argument; reduce argc
--argc;
} else {
argv[2].setUndefined();
}
} while (false);
do {
JS::Rooted<JSObject*> callbackObj(cx, CallbackKnownNotGray());
if (arg2.IsNull()) {
argv[1].setNull();
break;
}
if (!arg2.Value().ToJSVal(cx, callbackObj, argv[1])) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
break;
} while (false);
do {
JS::Rooted<JSObject*> callbackObj(cx, CallbackKnownNotGray());
if (!arg1.ToJSVal(cx, callbackObj, argv[0])) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
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;
}
}
} // namespace mozilla::dom