Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM TestFunctions.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_TestFunctionsBinding_h
4 : #define mozilla_dom_TestFunctionsBinding_h
5 :
6 : #include "js/RootingAPI.h"
7 : #include "jspubtd.h"
8 : #include "mozilla/ErrorResult.h"
9 : #include "mozilla/dom/BindingDeclarations.h"
10 : #include "mozilla/dom/CallbackFunction.h"
11 : #include "mozilla/dom/Nullable.h"
12 : #include "mozilla/dom/ToJSValue.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : struct NativePropertyHooks;
18 : class Promise;
19 : class PromiseReturner;
20 : class ProtoAndIfaceCache;
21 : class TestFunctions;
22 : struct TestFunctionsAtoms;
23 :
24 : } // namespace dom
25 : } // namespace mozilla
26 :
27 : namespace mozilla {
28 : namespace dom {
29 :
30 0 : class PromiseReturner : public CallbackFunction
31 : {
32 : public:
33 : explicit inline PromiseReturner(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
34 : : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
35 : {
36 : MOZ_ASSERT(JS::IsCallable(mCallback));
37 : }
38 :
39 0 : explicit inline PromiseReturner(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
40 0 : : CallbackFunction(aCallback, FastCallbackConstructor())
41 : {
42 0 : MOZ_ASSERT(JS::IsCallable(mCallback));
43 0 : }
44 :
45 : explicit inline PromiseReturner(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
46 : : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
47 : {
48 : MOZ_ASSERT(JS::IsCallable(mCallback));
49 : }
50 :
51 : explicit inline PromiseReturner(CallbackFunction* aOther)
52 : : CallbackFunction(aOther)
53 : {
54 : }
55 :
56 : template <typename T>
57 : inline already_AddRefed<Promise>
58 : Call(const T& thisVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
59 : {
60 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
61 : if (!aExecutionReason) {
62 : aExecutionReason = "PromiseReturner";
63 : }
64 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
65 : if (!s.GetContext()) {
66 : MOZ_ASSERT(aRv.Failed());
67 : return nullptr;
68 : }
69 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
70 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
71 : aRv.Throw(NS_ERROR_FAILURE);
72 : return nullptr;
73 : }
74 : return Call(s.GetContext(), thisValJS, aRv);
75 : }
76 :
77 : inline already_AddRefed<Promise>
78 0 : Call(ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
79 : {
80 0 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
81 0 : if (!aExecutionReason) {
82 0 : aExecutionReason = "PromiseReturner";
83 : }
84 0 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
85 0 : if (!s.GetContext()) {
86 0 : MOZ_ASSERT(aRv.Failed());
87 0 : return nullptr;
88 : }
89 0 : return Call(s.GetContext(), JS::UndefinedHandleValue, aRv);
90 : }
91 :
92 : template <typename T>
93 : inline already_AddRefed<Promise>
94 : Call(const T& thisVal, const char* aExecutionReason = nullptr)
95 : {
96 : IgnoredErrorResult rv;
97 : return Call(thisVal, rv, aExecutionReason);
98 : }
99 :
100 : inline already_AddRefed<Promise>
101 : Call(const char* aExecutionReason = nullptr)
102 : {
103 : IgnoredErrorResult rv;
104 : return Call(rv, aExecutionReason, eReportExceptions, nullptr);
105 : }
106 :
107 : inline bool
108 : operator==(const PromiseReturner& aOther) const
109 : {
110 : return CallbackFunction::operator==(aOther);
111 : }
112 :
113 : private:
114 : already_AddRefed<Promise> Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv);
115 : };
116 :
117 :
118 : namespace binding_detail {
119 0 : class FastPromiseReturner : public PromiseReturner
120 : {
121 : public:
122 0 : explicit inline FastPromiseReturner(JS::Handle<JSObject*> aCallback)
123 0 : : PromiseReturner(aCallback, FastCallbackConstructor())
124 : {
125 0 : }
126 :
127 : inline void
128 0 : Trace(JSTracer* aTracer)
129 : {
130 0 : PromiseReturner::Trace(aTracer);
131 0 : }
132 :
133 : inline void
134 0 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
135 : {
136 0 : PromiseReturner::FinishSlowJSInitIfMoreThanOneOwner(aCx);
137 0 : }
138 : };
139 : } // namespace binding_detail
140 :
141 :
142 : namespace TestFunctionsBinding {
143 :
144 : typedef mozilla::dom::TestFunctions NativeType;
145 :
146 : bool
147 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
148 :
149 : JSObject*
150 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
151 :
152 : const JSClass*
153 : GetJSClass();
154 :
155 : bool
156 : Wrap(JSContext* aCx, mozilla::dom::TestFunctions* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
157 :
158 : // We declare this as an array so that retrieving a pointer to this
159 : // binding's property hooks only requires compile/link-time resolvable
160 : // address arithmetic. Declaring it as a pointer instead would require
161 : // doing a run-time load to fetch a pointer to this binding's property
162 : // hooks. And then structures which embedded a pointer to this structure
163 : // would require a run-time load for proper initialization, which would
164 : // then induce static constructors. Lots of static constructors.
165 : extern const NativePropertyHooks sNativePropertyHooks[];
166 :
167 : void
168 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
169 :
170 : JS::Handle<JSObject*>
171 : GetProtoObjectHandle(JSContext* aCx);
172 :
173 : JS::Handle<JSObject*>
174 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
175 :
176 : JSObject*
177 : GetConstructorObject(JSContext* aCx);
178 :
179 : } // namespace TestFunctionsBinding
180 :
181 :
182 :
183 : } // namespace dom
184 : } // namespace mozilla
185 :
186 : #endif // mozilla_dom_TestFunctionsBinding_h
|