Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM XPathNSResolver.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "XPathNSResolverBinding.h"
5 : #include "mozilla/OwningNonNull.h"
6 : #include "mozilla/dom/BindingUtils.h"
7 : #include "mozilla/dom/NonRefcountedDOMObject.h"
8 : #include "mozilla/dom/Nullable.h"
9 :
10 : namespace mozilla {
11 : namespace dom {
12 :
13 : void
14 0 : XPathNSResolver::LookupNamespaceURI(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& prefix, nsString& aRetVal, ErrorResult& aRv)
15 : {
16 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
17 0 : JS::AutoValueVector argv(cx);
18 0 : if (!argv.resize(1)) {
19 0 : aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
20 0 : return;
21 : }
22 0 : unsigned argc = 1;
23 :
24 : do {
25 0 : nsString mutableStr(prefix);
26 0 : if (!xpc::StringToJsval(cx, mutableStr, argv[0])) {
27 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
28 0 : return;
29 : }
30 0 : break;
31 : } while (0);
32 :
33 0 : bool isCallable = JS::IsCallable(mCallback);
34 0 : JS::Rooted<JS::Value> callable(cx);
35 0 : if (isCallable) {
36 0 : callable = JS::ObjectValue(*mCallback);
37 : } else {
38 0 : XPathNSResolverAtoms* atomsCache = GetAtomCache<XPathNSResolverAtoms>(cx);
39 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
40 0 : !GetCallableProperty(cx, atomsCache->lookupNamespaceURI_id, &callable)) {
41 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
42 0 : return;
43 : }
44 : }
45 0 : JS::Rooted<JS::Value> thisValue(cx, isCallable ? aThisVal.get()
46 0 : : JS::ObjectValue(*mCallback));
47 0 : if (!JS::Call(cx, thisValue, callable,
48 0 : JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
49 0 : aRv.NoteJSContextException(cx);
50 0 : return;
51 : }
52 0 : binding_detail::FakeString rvalDecl;
53 0 : if (!ConvertJSValueToString(cx, rval, eNull, eNull, rvalDecl)) {
54 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
55 0 : return;
56 : }
57 0 : aRetVal = rvalDecl;
58 : }
59 :
60 : bool
61 0 : XPathNSResolver::InitIds(JSContext* cx, XPathNSResolverAtoms* atomsCache)
62 : {
63 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
64 :
65 : // Initialize these in reverse order so that any failure leaves the first one
66 : // uninitialized.
67 0 : if (!atomsCache->lookupNamespaceURI_id.init(cx, "lookupNamespaceURI")) {
68 0 : return false;
69 : }
70 0 : return true;
71 : }
72 :
73 :
74 :
75 : namespace binding_detail {
76 : } // namespace binding_detail
77 :
78 :
79 : } // namespace dom
80 9 : } // namespace mozilla
|