/work/obj-fuzz/dom/bindings/XPathNSResolverBinding.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
14 | | using namespace mozilla::dom::binding_detail; |
15 | | |
16 | | |
17 | | void |
18 | | XPathNSResolver::LookupNamespaceURI(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& prefix, nsString& aRetVal, ErrorResult& aRv) |
19 | 0 | { |
20 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
21 | 0 | JS::AutoValueVector argv(cx); |
22 | 0 | if (!argv.resize(1)) { |
23 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
24 | 0 | return; |
25 | 0 | } |
26 | 0 | unsigned argc = 1; |
27 | 0 |
|
28 | 0 | do { |
29 | 0 | nsString mutableStr(prefix); |
30 | 0 | if (!xpc::StringToJsval(cx, mutableStr, argv[0])) { |
31 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
32 | 0 | return; |
33 | 0 | } |
34 | 0 | break; |
35 | 0 | } while (false); |
36 | 0 |
|
37 | 0 | bool isCallable = JS::IsCallable(mCallback); |
38 | 0 | JS::Rooted<JS::Value> callable(cx); |
39 | 0 | if (isCallable) { |
40 | 0 | callable = JS::ObjectValue(*mCallback); |
41 | 0 | } else { |
42 | 0 | XPathNSResolverAtoms* atomsCache = GetAtomCache<XPathNSResolverAtoms>(cx); |
43 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
44 | 0 | !GetCallableProperty(cx, atomsCache->lookupNamespaceURI_id, &callable)) { |
45 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
46 | 0 | return; |
47 | 0 | } |
48 | 0 | } |
49 | 0 | JS::Rooted<JS::Value> thisValue(cx, isCallable ? aThisVal.get() |
50 | 0 | : JS::ObjectValue(*mCallback)); |
51 | 0 | if (!JS::Call(cx, thisValue, callable, |
52 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
53 | 0 | aRv.NoteJSContextException(cx); |
54 | 0 | return; |
55 | 0 | } |
56 | 0 | binding_detail::FakeString rvalDecl; |
57 | 0 | if (!ConvertJSValueToString(cx, rval, eNull, eNull, rvalDecl)) { |
58 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
59 | 0 | return; |
60 | 0 | } |
61 | 0 | aRetVal = rvalDecl; |
62 | 0 | } |
63 | | |
64 | | bool |
65 | | XPathNSResolver::InitIds(JSContext* cx, XPathNSResolverAtoms* atomsCache) |
66 | 0 | { |
67 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
68 | 0 |
|
69 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
70 | 0 | // uninitialized. |
71 | 0 | if (!atomsCache->lookupNamespaceURI_id.init(cx, "lookupNamespaceURI")) { |
72 | 0 | return false; |
73 | 0 | } |
74 | 0 | return true; |
75 | 0 | } |
76 | | |
77 | | |
78 | | |
79 | | namespace binding_detail { |
80 | | } // namespace binding_detail |
81 | | |
82 | | |
83 | | } // namespace dom |
84 | | } // namespace mozilla |