Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM XPathNSResolver.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "XPathNSResolverBinding.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/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/Nullable.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
void
XPathNSResolver::LookupNamespaceURI(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const nsAString& prefix, nsString& aRetVal, ErrorResult& aRv)
{
JS::Rooted<JS::Value> rval(cx);
JS::RootedVector<JS::Value> argv(cx);
if (!argv.resize(1)) {
// That threw an exception on the JSContext, and our CallSetup will do
// the right thing with that.
return;
}
unsigned argc = 1;
do {
if (!xpc::StringToJsval(cx, prefix, argv[0])) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
break;
} while (false);
bool isCallable = JS::IsCallable(mCallback);
JS::Rooted<JS::Value> callable(cx);
if (isCallable) {
callable = JS::ObjectValue(*mCallback);
} else {
XPathNSResolverAtoms* atomsCache = GetAtomCache<XPathNSResolverAtoms>(cx);
if ((reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) ||
!GetCallableProperty(cx, atomsCache->lookupNamespaceURI_id, &callable)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
}
JS::Rooted<JS::Value> thisValue(cx, isCallable ? aThisVal.get()
: JS::ObjectValue(*mCallback));
if (!JS::Call(cx, thisValue, callable,
JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
aRv.NoteJSContextException(cx);
return;
}
binding_detail::FakeString<char16_t> rvalDecl;
if (!ConvertJSValueToString(cx, rval, eNull, eNull, rvalDecl)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
aRetVal = rvalDecl;
}
bool
XPathNSResolver::InitIds(JSContext* cx, XPathNSResolverAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->lookupNamespaceURI_id.init(cx, "lookupNamespaceURI")) {
return false;
}
return true;
}
} // namespace mozilla::dom