Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/PromiseBinding.h
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM Promise.webidl BY Codegen.py - DO NOT EDIT */
2
3
#ifndef mozilla_dom_PromiseBinding_h
4
#define mozilla_dom_PromiseBinding_h
5
6
#include "GeckoProfiler.h"
7
#include "js/RootingAPI.h"
8
#include "jspubtd.h"
9
#include "mozilla/ErrorResult.h"
10
#include "mozilla/dom/BindingDeclarations.h"
11
#include "mozilla/dom/CallbackFunction.h"
12
#include "mozilla/dom/Nullable.h"
13
#include "mozilla/dom/PrototypeList.h"
14
#include "mozilla/dom/ToJSValue.h"
15
16
namespace mozilla {
17
namespace dom {
18
19
class AnyCallback;
20
struct NativePropertyHooks;
21
class PromiseJobCallback;
22
class PromiseNativeHandler;
23
struct PromiseNativeHandlerAtoms;
24
class ProtoAndIfaceCache;
25
26
} // namespace dom
27
} // namespace mozilla
28
29
namespace mozilla {
30
namespace dom {
31
32
class PromiseJobCallback : public CallbackFunction
33
{
34
public:
35
  explicit inline PromiseJobCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
36
    : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
37
0
  {
38
0
    MOZ_ASSERT(JS::IsCallable(mCallback));
39
0
  }
40
41
  explicit inline PromiseJobCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
42
    : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
43
0
  {
44
0
    MOZ_ASSERT(JS::IsCallable(mCallback));
45
0
  }
46
47
  explicit inline PromiseJobCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
48
    : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
49
0
  {
50
0
    MOZ_ASSERT(JS::IsCallable(mCallback));
51
0
  }
52
53
  explicit inline PromiseJobCallback(CallbackFunction* aOther)
54
    : CallbackFunction(aOther)
55
0
  {
56
0
  }
57
58
  template <typename T>
59
  inline void
60
  Call(const T& thisVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
61
  {
62
    MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
63
    if (!aExecutionReason) {
64
      aExecutionReason = "PromiseJobCallback";
65
    }
66
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
67
    if (!s.GetContext()) {
68
      MOZ_ASSERT(aRv.Failed());
69
      return;
70
    }
71
    JS::Rooted<JS::Value> thisValJS(s.GetContext());
72
    if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
73
      aRv.Throw(NS_ERROR_FAILURE);
74
      return;
75
    }
76
    return Call(s.GetContext(), thisValJS, aRv);
77
  }
78
79
  inline void
80
  Call(ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
81
0
  {
82
0
    MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
83
0
    if (!aExecutionReason) {
84
0
      aExecutionReason = "PromiseJobCallback";
85
0
    }
86
0
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
87
0
    if (!s.GetContext()) {
88
0
      MOZ_ASSERT(aRv.Failed());
89
0
      return;
90
0
    }
91
0
    return Call(s.GetContext(), JS::UndefinedHandleValue, aRv);
92
0
  }
93
94
  template <typename T>
95
  inline void
96
  Call(const T& thisVal, const char* aExecutionReason = nullptr)
97
  {
98
    return Call(thisVal, IgnoreErrors(), aExecutionReason);
99
  }
100
101
  inline void
102
  Call(const char* aExecutionReason = nullptr)
103
0
  {
104
0
    return Call(IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
105
0
  }
106
107
  inline bool
108
  operator==(const PromiseJobCallback& aOther) const
109
0
  {
110
0
    return CallbackFunction::operator==(aOther);
111
0
  }
112
113
private:
114
  void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv);
115
};
116
117
118
class AnyCallback : public CallbackFunction
119
{
120
public:
121
  explicit inline AnyCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
122
    : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
123
0
  {
124
0
    MOZ_ASSERT(JS::IsCallable(mCallback));
125
0
  }
126
127
  explicit inline AnyCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
128
    : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
129
0
  {
130
0
    MOZ_ASSERT(JS::IsCallable(mCallback));
131
0
  }
132
133
  explicit inline AnyCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
134
    : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
135
0
  {
136
0
    MOZ_ASSERT(JS::IsCallable(mCallback));
137
0
  }
138
139
  explicit inline AnyCallback(CallbackFunction* aOther)
140
    : CallbackFunction(aOther)
141
0
  {
142
0
  }
143
144
  template <typename T>
145
  inline void
146
  Call(const T& thisVal, JS::Handle<JS::Value> value, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
147
  {
148
    MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
149
    if (!aExecutionReason) {
150
      aExecutionReason = "AnyCallback";
151
    }
152
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
153
    if (!s.GetContext()) {
154
      MOZ_ASSERT(aRv.Failed());
155
      return;
156
    }
157
    JS::Rooted<JS::Value> thisValJS(s.GetContext());
158
    if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
159
      aRv.Throw(NS_ERROR_FAILURE);
160
      return;
161
    }
162
    return Call(s.GetContext(), thisValJS, value, aRetVal, aRv);
163
  }
164
165
  inline void
166
  Call(JS::Handle<JS::Value> value, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
167
0
  {
168
0
    MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
169
0
    if (!aExecutionReason) {
170
0
      aExecutionReason = "AnyCallback";
171
0
    }
172
0
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
173
0
    if (!s.GetContext()) {
174
0
      MOZ_ASSERT(aRv.Failed());
175
0
      return;
176
0
    }
177
0
    return Call(s.GetContext(), JS::UndefinedHandleValue, value, aRetVal, aRv);
178
0
  }
179
180
  template <typename T>
181
  inline void
182
  Call(const T& thisVal, JS::Handle<JS::Value> value, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr)
183
  {
184
    return Call(thisVal, value, aRetVal, IgnoreErrors(), aExecutionReason);
185
  }
186
187
  inline void
188
  Call(JS::Handle<JS::Value> value, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr)
189
0
  {
190
0
    return Call(value, aRetVal, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
191
0
  }
192
193
  inline bool
194
  operator==(const AnyCallback& aOther) const
195
0
  {
196
0
    return CallbackFunction::operator==(aOther);
197
0
  }
198
199
private:
200
  void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, JS::Handle<JS::Value> value, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv);
201
};
202
203
204
namespace binding_detail {
205
class FastPromiseJobCallback : public PromiseJobCallback
206
{
207
public:
208
  explicit inline FastPromiseJobCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
209
    : PromiseJobCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
210
0
  {
211
0
  }
212
213
  inline void
214
  Trace(JSTracer* aTracer)
215
0
  {
216
0
    PromiseJobCallback::Trace(aTracer);
217
0
  }
218
219
  inline void
220
  FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
221
0
  {
222
0
    PromiseJobCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
223
0
  }
224
};
225
} // namespace binding_detail
226
227
228
namespace binding_detail {
229
class FastAnyCallback : public AnyCallback
230
{
231
public:
232
  explicit inline FastAnyCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
233
    : AnyCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
234
0
  {
235
0
  }
236
237
  inline void
238
  Trace(JSTracer* aTracer)
239
0
  {
240
0
    AnyCallback::Trace(aTracer);
241
0
  }
242
243
  inline void
244
  FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
245
0
  {
246
0
    AnyCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
247
0
  }
248
};
249
} // namespace binding_detail
250
251
252
namespace PromiseNativeHandler_Binding {
253
254
  typedef mozilla::dom::PromiseNativeHandler NativeType;
255
256
  const JSClass*
257
  GetJSClass();
258
259
  bool
260
  Wrap(JSContext* aCx, mozilla::dom::PromiseNativeHandler* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
261
262
  // We declare this as an array so that retrieving a pointer to this
263
  // binding's property hooks only requires compile/link-time resolvable
264
  // address arithmetic.  Declaring it as a pointer instead would require
265
  // doing a run-time load to fetch a pointer to this binding's property
266
  // hooks.  And then structures which embedded a pointer to this structure
267
  // would require a run-time load for proper initialization, which would
268
  // then induce static constructors.  Lots of static constructors.
269
  extern const NativePropertyHooks sNativePropertyHooks[];
270
271
  void
272
  CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
273
274
  inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
275
0
  {
276
0
    /* Get the interface prototype object for this class.  This will create the
277
0
       object as needed. */
278
0
    return GetPerInterfaceObjectHandle(aCx, prototypes::id::PromiseNativeHandler,
279
0
                                       &CreateInterfaceObjects,
280
0
                                       /* aDefineOnGlobal = */ true);
281
0
282
0
  }
283
284
} // namespace PromiseNativeHandler_Binding
285
286
287
288
} // namespace dom
289
} // namespace mozilla
290
291
#endif // mozilla_dom_PromiseBinding_h