Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM PaymentResponse.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "PaymentResponseBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "jsapi.h"
6 : #include "mozilla/OwningNonNull.h"
7 : #include "mozilla/dom/BindingUtils.h"
8 : #include "mozilla/dom/DOMJSClass.h"
9 : #include "mozilla/dom/NonRefcountedDOMObject.h"
10 : #include "mozilla/dom/Nullable.h"
11 : #include "mozilla/dom/PaymentAddress.h"
12 : #include "mozilla/dom/PaymentRequest.h"
13 : #include "mozilla/dom/PaymentResponse.h"
14 : #include "mozilla/dom/Promise.h"
15 : #include "mozilla/dom/ToJSValue.h"
16 : #include "mozilla/dom/XrayExpandoClass.h"
17 :
18 : namespace mozilla {
19 : namespace dom {
20 :
21 : namespace PaymentCompleteValues {
22 : extern const EnumEntry strings[4] = {
23 : {"success", 7},
24 : {"fail", 4},
25 : {"unknown", 7},
26 : { nullptr, 0 }
27 : };
28 : } // namespace PaymentCompleteValues
29 :
30 : bool
31 0 : ToJSValue(JSContext* aCx, PaymentComplete aArgument, JS::MutableHandle<JS::Value> aValue)
32 : {
33 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(PaymentCompleteValues::strings));
34 : JSString* resultStr =
35 0 : JS_NewStringCopyN(aCx, PaymentCompleteValues::strings[uint32_t(aArgument)].value,
36 0 : PaymentCompleteValues::strings[uint32_t(aArgument)].length);
37 0 : if (!resultStr) {
38 0 : return false;
39 : }
40 0 : aValue.setString(resultStr);
41 0 : return true;
42 : }
43 :
44 :
45 : namespace PaymentResponseBinding {
46 :
47 : static bool
48 0 : get_requestId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args)
49 : {
50 0 : DOMString result;
51 0 : self->GetRequestId(result);
52 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
53 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
54 0 : return false;
55 : }
56 0 : return true;
57 : }
58 :
59 : static const JSJitInfo requestId_getterinfo = {
60 : { (JSJitGetterOp)get_requestId },
61 : { prototypes::id::PaymentResponse },
62 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
63 : JSJitInfo::Getter,
64 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
65 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
66 : false, /* isInfallible. False in setters. */
67 : false, /* isMovable. Not relevant for setters. */
68 : false, /* isEliminatable. Not relevant for setters. */
69 : false, /* isAlwaysInSlot. Only relevant for getters. */
70 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
71 : false, /* isTypedMethod. Only relevant for methods. */
72 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
73 : };
74 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
75 : static_assert(0 < 1, "There is no slot for us");
76 :
77 : static bool
78 0 : get_methodName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args)
79 : {
80 0 : DOMString result;
81 0 : self->GetMethodName(result);
82 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
83 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
84 0 : return false;
85 : }
86 0 : return true;
87 : }
88 :
89 : static const JSJitInfo methodName_getterinfo = {
90 : { (JSJitGetterOp)get_methodName },
91 : { prototypes::id::PaymentResponse },
92 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
93 : JSJitInfo::Getter,
94 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
95 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
96 : false, /* isInfallible. False in setters. */
97 : false, /* isMovable. Not relevant for setters. */
98 : false, /* isEliminatable. Not relevant for setters. */
99 : false, /* isAlwaysInSlot. Only relevant for getters. */
100 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
101 : false, /* isTypedMethod. Only relevant for methods. */
102 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
103 : };
104 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
105 : static_assert(0 < 1, "There is no slot for us");
106 :
107 : static bool
108 0 : get_details(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args)
109 : {
110 0 : JS::Rooted<JSObject*> result(cx);
111 0 : self->GetDetails(cx, &result);
112 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
113 0 : JS::ExposeObjectToActiveJS(result);
114 0 : args.rval().setObject(*result);
115 0 : if (!MaybeWrapObjectValue(cx, args.rval())) {
116 0 : return false;
117 : }
118 0 : return true;
119 : }
120 :
121 : static const JSJitInfo details_getterinfo = {
122 : { (JSJitGetterOp)get_details },
123 : { prototypes::id::PaymentResponse },
124 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
125 : JSJitInfo::Getter,
126 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
127 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
128 : false, /* isInfallible. False in setters. */
129 : false, /* isMovable. Not relevant for setters. */
130 : false, /* isEliminatable. Not relevant for setters. */
131 : false, /* isAlwaysInSlot. Only relevant for getters. */
132 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
133 : false, /* isTypedMethod. Only relevant for methods. */
134 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
135 : };
136 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
137 : static_assert(0 < 1, "There is no slot for us");
138 :
139 : static bool
140 0 : get_shippingAddress(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args)
141 : {
142 0 : auto result(StrongOrRawPtr<mozilla::dom::PaymentAddress>(self->GetShippingAddress()));
143 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
144 0 : if (!result) {
145 0 : args.rval().setNull();
146 0 : return true;
147 : }
148 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
149 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
150 0 : return false;
151 : }
152 0 : return true;
153 : }
154 :
155 : static const JSJitInfo shippingAddress_getterinfo = {
156 : { (JSJitGetterOp)get_shippingAddress },
157 : { prototypes::id::PaymentResponse },
158 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
159 : JSJitInfo::Getter,
160 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
161 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
162 : false, /* isInfallible. False in setters. */
163 : false, /* isMovable. Not relevant for setters. */
164 : false, /* isEliminatable. Not relevant for setters. */
165 : false, /* isAlwaysInSlot. Only relevant for getters. */
166 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
167 : false, /* isTypedMethod. Only relevant for methods. */
168 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
169 : };
170 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
171 : static_assert(0 < 1, "There is no slot for us");
172 :
173 : static bool
174 0 : get_shippingOption(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args)
175 : {
176 0 : DOMString result;
177 0 : self->GetShippingOption(result);
178 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
179 0 : if (!xpc::StringToJsval(cx, result, args.rval())) {
180 0 : return false;
181 : }
182 0 : return true;
183 : }
184 :
185 : static const JSJitInfo shippingOption_getterinfo = {
186 : { (JSJitGetterOp)get_shippingOption },
187 : { prototypes::id::PaymentResponse },
188 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
189 : JSJitInfo::Getter,
190 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
191 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
192 : false, /* isInfallible. False in setters. */
193 : false, /* isMovable. Not relevant for setters. */
194 : false, /* isEliminatable. Not relevant for setters. */
195 : false, /* isAlwaysInSlot. Only relevant for getters. */
196 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
197 : false, /* isTypedMethod. Only relevant for methods. */
198 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
199 : };
200 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
201 : static_assert(0 < 1, "There is no slot for us");
202 :
203 : static bool
204 0 : get_payerName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args)
205 : {
206 0 : DOMString result;
207 0 : self->GetPayerName(result);
208 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
209 0 : if (!xpc::StringToJsval(cx, result, args.rval())) {
210 0 : return false;
211 : }
212 0 : return true;
213 : }
214 :
215 : static const JSJitInfo payerName_getterinfo = {
216 : { (JSJitGetterOp)get_payerName },
217 : { prototypes::id::PaymentResponse },
218 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
219 : JSJitInfo::Getter,
220 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
221 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
222 : false, /* isInfallible. False in setters. */
223 : false, /* isMovable. Not relevant for setters. */
224 : false, /* isEliminatable. Not relevant for setters. */
225 : false, /* isAlwaysInSlot. Only relevant for getters. */
226 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
227 : false, /* isTypedMethod. Only relevant for methods. */
228 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
229 : };
230 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
231 : static_assert(0 < 1, "There is no slot for us");
232 :
233 : static bool
234 0 : get_payerEmail(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args)
235 : {
236 0 : DOMString result;
237 0 : self->GetPayerEmail(result);
238 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
239 0 : if (!xpc::StringToJsval(cx, result, args.rval())) {
240 0 : return false;
241 : }
242 0 : return true;
243 : }
244 :
245 : static const JSJitInfo payerEmail_getterinfo = {
246 : { (JSJitGetterOp)get_payerEmail },
247 : { prototypes::id::PaymentResponse },
248 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
249 : JSJitInfo::Getter,
250 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
251 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
252 : false, /* isInfallible. False in setters. */
253 : false, /* isMovable. Not relevant for setters. */
254 : false, /* isEliminatable. Not relevant for setters. */
255 : false, /* isAlwaysInSlot. Only relevant for getters. */
256 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
257 : false, /* isTypedMethod. Only relevant for methods. */
258 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
259 : };
260 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
261 : static_assert(0 < 1, "There is no slot for us");
262 :
263 : static bool
264 0 : get_payerPhone(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JSJitGetterCallArgs args)
265 : {
266 0 : DOMString result;
267 0 : self->GetPayerPhone(result);
268 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
269 0 : if (!xpc::StringToJsval(cx, result, args.rval())) {
270 0 : return false;
271 : }
272 0 : return true;
273 : }
274 :
275 : static const JSJitInfo payerPhone_getterinfo = {
276 : { (JSJitGetterOp)get_payerPhone },
277 : { prototypes::id::PaymentResponse },
278 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
279 : JSJitInfo::Getter,
280 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
281 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
282 : false, /* isInfallible. False in setters. */
283 : false, /* isMovable. Not relevant for setters. */
284 : false, /* isEliminatable. Not relevant for setters. */
285 : false, /* isAlwaysInSlot. Only relevant for getters. */
286 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
287 : false, /* isTypedMethod. Only relevant for methods. */
288 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
289 : };
290 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
291 : static_assert(0 < 1, "There is no slot for us");
292 :
293 : static bool
294 0 : complete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, const JSJitMethodCallArgs& args)
295 : {
296 : PaymentComplete arg0;
297 0 : if (args.hasDefined(0)) {
298 : {
299 : int index;
300 0 : if (!FindEnumStringIndex<true>(cx, args[0], PaymentCompleteValues::strings, "PaymentComplete", "Argument 1 of PaymentResponse.complete", &index)) {
301 0 : return false;
302 : }
303 0 : MOZ_ASSERT(index >= 0);
304 0 : arg0 = static_cast<PaymentComplete>(index);
305 : }
306 : } else {
307 0 : arg0 = PaymentComplete::Unknown;
308 : }
309 0 : binding_detail::FastErrorResult rv;
310 0 : auto result(StrongOrRawPtr<Promise>(self->Complete(arg0, rv)));
311 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
312 0 : return false;
313 : }
314 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
315 : static_assert(!IsPointer<decltype(result)>::value,
316 : "NewObject implies that we need to keep the object alive with a strong reference.");
317 0 : if (!ToJSValue(cx, result, args.rval())) {
318 0 : return false;
319 : }
320 0 : return true;
321 : }
322 :
323 : static bool
324 0 : complete_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, const JSJitMethodCallArgs& args)
325 : {
326 : // Make sure to save the callee before someone maybe messes
327 : // with rval().
328 0 : JS::Rooted<JSObject*> callee(cx, &args.callee());
329 0 : bool ok = complete(cx, obj, self, args);
330 0 : if (ok) {
331 0 : return true;
332 : }
333 0 : return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
334 0 : args.rval());
335 : }
336 :
337 : static const JSJitInfo complete_methodinfo = {
338 : { (JSJitGetterOp)complete_promiseWrapper },
339 : { prototypes::id::PaymentResponse },
340 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
341 : JSJitInfo::Method,
342 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
343 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
344 : false, /* isInfallible. False in setters. */
345 : false, /* isMovable. Not relevant for setters. */
346 : false, /* isEliminatable. Not relevant for setters. */
347 : false, /* isAlwaysInSlot. Only relevant for getters. */
348 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
349 : false, /* isTypedMethod. Only relevant for methods. */
350 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
351 : };
352 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
353 : static_assert(0 < 1, "There is no slot for us");
354 :
355 : bool
356 0 : JsonifyAttributes(JSContext* aCx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, JS::Rooted<JSObject*>& aResult)
357 : {
358 : { // scope for "temp"
359 0 : JS::Rooted<JS::Value> temp(aCx);
360 0 : if (!get_requestId(aCx, obj, self, JSJitGetterCallArgs(&temp))) {
361 0 : return false;
362 : }
363 0 : if (!JS_DefineProperty(aCx, aResult, "requestId", temp, JSPROP_ENUMERATE)) {
364 0 : return false;
365 : }
366 : }
367 : { // scope for "temp"
368 0 : JS::Rooted<JS::Value> temp(aCx);
369 0 : if (!get_methodName(aCx, obj, self, JSJitGetterCallArgs(&temp))) {
370 0 : return false;
371 : }
372 0 : if (!JS_DefineProperty(aCx, aResult, "methodName", temp, JSPROP_ENUMERATE)) {
373 0 : return false;
374 : }
375 : }
376 : { // scope for "temp"
377 0 : JS::Rooted<JS::Value> temp(aCx);
378 0 : if (!get_shippingAddress(aCx, obj, self, JSJitGetterCallArgs(&temp))) {
379 0 : return false;
380 : }
381 0 : if (!JS_DefineProperty(aCx, aResult, "shippingAddress", temp, JSPROP_ENUMERATE)) {
382 0 : return false;
383 : }
384 : }
385 : { // scope for "temp"
386 0 : JS::Rooted<JS::Value> temp(aCx);
387 0 : if (!get_shippingOption(aCx, obj, self, JSJitGetterCallArgs(&temp))) {
388 0 : return false;
389 : }
390 0 : if (!JS_DefineProperty(aCx, aResult, "shippingOption", temp, JSPROP_ENUMERATE)) {
391 0 : return false;
392 : }
393 : }
394 : { // scope for "temp"
395 0 : JS::Rooted<JS::Value> temp(aCx);
396 0 : if (!get_payerName(aCx, obj, self, JSJitGetterCallArgs(&temp))) {
397 0 : return false;
398 : }
399 0 : if (!JS_DefineProperty(aCx, aResult, "payerName", temp, JSPROP_ENUMERATE)) {
400 0 : return false;
401 : }
402 : }
403 : { // scope for "temp"
404 0 : JS::Rooted<JS::Value> temp(aCx);
405 0 : if (!get_payerEmail(aCx, obj, self, JSJitGetterCallArgs(&temp))) {
406 0 : return false;
407 : }
408 0 : if (!JS_DefineProperty(aCx, aResult, "payerEmail", temp, JSPROP_ENUMERATE)) {
409 0 : return false;
410 : }
411 : }
412 : { // scope for "temp"
413 0 : JS::Rooted<JS::Value> temp(aCx);
414 0 : if (!get_payerPhone(aCx, obj, self, JSJitGetterCallArgs(&temp))) {
415 0 : return false;
416 : }
417 0 : if (!JS_DefineProperty(aCx, aResult, "payerPhone", temp, JSPROP_ENUMERATE)) {
418 0 : return false;
419 : }
420 : }
421 0 : return true;
422 : }
423 :
424 : static bool
425 0 : __jsonifier(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaymentResponse* self, const JSJitMethodCallArgs& args)
426 : {
427 0 : JS::Rooted<JSObject*> result(cx, JS_NewPlainObject(cx));
428 0 : if (!result) {
429 0 : return false;
430 : }
431 0 : if (!PaymentResponseBinding::JsonifyAttributes(cx, obj, self, result)) {
432 0 : return false;
433 : }
434 0 : args.rval().setObject(*result);
435 0 : return true;
436 : }
437 :
438 : static const JSJitInfo __jsonifier_methodinfo = {
439 : { (JSJitGetterOp)__jsonifier },
440 : { prototypes::id::PaymentResponse },
441 : { PrototypeTraits<prototypes::id::PaymentResponse>::Depth },
442 : JSJitInfo::Method,
443 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
444 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
445 : false, /* isInfallible. False in setters. */
446 : false, /* isMovable. Not relevant for setters. */
447 : false, /* isEliminatable. Not relevant for setters. */
448 : false, /* isAlwaysInSlot. Only relevant for getters. */
449 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
450 : false, /* isTypedMethod. Only relevant for methods. */
451 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
452 : };
453 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
454 : static_assert(0 < 1, "There is no slot for us");
455 :
456 : static bool
457 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
458 : {
459 0 : mozilla::dom::PaymentResponse* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaymentResponse>(obj);
460 : // We don't want to preserve if we don't have a wrapper, and we
461 : // obviously can't preserve if we're not initialized.
462 0 : if (self && self->GetWrapperPreserveColor()) {
463 0 : PreserveWrapper(self);
464 : }
465 0 : return true;
466 : }
467 :
468 : static void
469 0 : _finalize(js::FreeOp* fop, JSObject* obj)
470 : {
471 0 : mozilla::dom::PaymentResponse* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaymentResponse>(obj);
472 0 : if (self) {
473 0 : ClearWrapper(self, self, obj);
474 0 : AddForDeferredFinalization<mozilla::dom::PaymentResponse>(self);
475 : }
476 0 : }
477 :
478 : static void
479 0 : _objectMoved(JSObject* obj, const JSObject* old)
480 : {
481 0 : mozilla::dom::PaymentResponse* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaymentResponse>(obj);
482 0 : if (self) {
483 0 : UpdateWrapper(self, self, obj, old);
484 : }
485 0 : }
486 :
487 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
488 : #if defined(__clang__)
489 : #pragma clang diagnostic push
490 : #pragma clang diagnostic ignored "-Wmissing-braces"
491 : #endif
492 : static const JSFunctionSpec sMethods_specs[] = {
493 : JS_FNSPEC("complete", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&complete_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
494 : JS_FNSPEC("toJSON", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&__jsonifier_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
495 : JS_FS_END
496 : };
497 : #if defined(__clang__)
498 : #pragma clang diagnostic pop
499 : #endif
500 :
501 : static PrefableDisablers sMethods_disablers0 = {
502 : true, true, 0, nullptr
503 : };
504 :
505 : // Can't be const because the pref-enabled boolean needs to be writable
506 : static Prefable<const JSFunctionSpec> sMethods[] = {
507 : { &sMethods_disablers0, &sMethods_specs[0] },
508 : { nullptr, nullptr }
509 : };
510 :
511 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
512 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
513 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
514 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
515 :
516 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
517 : #if defined(__clang__)
518 : #pragma clang diagnostic push
519 : #pragma clang diagnostic ignored "-Wmissing-braces"
520 : #endif
521 : static const JSPropertySpec sAttributes_specs[] = {
522 : { "requestId", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &requestId_getterinfo, nullptr, nullptr },
523 : { "methodName", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &methodName_getterinfo, nullptr, nullptr },
524 : { "details", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &details_getterinfo, nullptr, nullptr },
525 : { "shippingAddress", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &shippingAddress_getterinfo, nullptr, nullptr },
526 : { "shippingOption", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &shippingOption_getterinfo, nullptr, nullptr },
527 : { "payerName", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &payerName_getterinfo, nullptr, nullptr },
528 : { "payerEmail", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &payerEmail_getterinfo, nullptr, nullptr },
529 : { "payerPhone", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &payerPhone_getterinfo, nullptr, nullptr },
530 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
531 : };
532 : #if defined(__clang__)
533 : #pragma clang diagnostic pop
534 : #endif
535 :
536 : static PrefableDisablers sAttributes_disablers0 = {
537 : true, true, 0, nullptr
538 : };
539 :
540 : // Can't be const because the pref-enabled boolean needs to be writable
541 : static Prefable<const JSPropertySpec> sAttributes[] = {
542 : { &sAttributes_disablers0, &sAttributes_specs[0] },
543 : { nullptr, nullptr }
544 : };
545 :
546 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
547 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
548 : static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
549 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
550 :
551 :
552 : static uint16_t sNativeProperties_sortedPropertyIndices[10];
553 : static PropertyInfo sNativeProperties_propertyInfos[10];
554 :
555 : static const NativePropertiesN<2> sNativeProperties = {
556 : false, 0,
557 : false, 0,
558 : true, 0 /* sMethods */,
559 : true, 1 /* sAttributes */,
560 : false, 0,
561 : false, 0,
562 : false, 0,
563 : -1,
564 : 10,
565 : sNativeProperties_sortedPropertyIndices,
566 : {
567 : { sMethods, &sNativeProperties_propertyInfos[0] },
568 : { sAttributes, &sNativeProperties_propertyInfos[2] }
569 : }
570 : };
571 : static_assert(10 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
572 : "We have a property info count that is oversized");
573 :
574 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
575 : {
576 : "Function",
577 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
578 : &sBoringInterfaceObjectClassClassOps,
579 : JS_NULL_CLASS_SPEC,
580 : JS_NULL_CLASS_EXT,
581 : &sInterfaceObjectClassObjectOps
582 : },
583 : eInterface,
584 : true,
585 : prototypes::id::PaymentResponse,
586 : PrototypeTraits<prototypes::id::PaymentResponse>::Depth,
587 : sNativePropertyHooks,
588 : "function PaymentResponse() {\n [native code]\n}",
589 : JS::GetRealmFunctionPrototype
590 : };
591 :
592 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
593 : {
594 : "PaymentResponsePrototype",
595 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
596 : JS_NULL_CLASS_OPS,
597 : JS_NULL_CLASS_SPEC,
598 : JS_NULL_CLASS_EXT,
599 : JS_NULL_OBJECT_OPS
600 : },
601 : eInterfacePrototype,
602 : false,
603 : prototypes::id::PaymentResponse,
604 : PrototypeTraits<prototypes::id::PaymentResponse>::Depth,
605 : sNativePropertyHooks,
606 : "[object PaymentResponsePrototype]",
607 : JS::GetRealmObjectPrototype
608 : };
609 :
610 : bool
611 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
612 : {
613 0 : return mozilla::dom::PaymentRequest::PrefEnabled(aCx, aObj) &&
614 0 : mozilla::dom::IsSecureContextOrObjectIsFromSecureContext(aCx, aObj);
615 : }
616 :
617 : JSObject*
618 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
619 : {
620 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
621 : }
622 :
623 : static const js::ClassOps sClassOps = {
624 : _addProperty, /* addProperty */
625 : nullptr, /* delProperty */
626 : nullptr, /* getProperty */
627 : nullptr, /* setProperty */
628 : nullptr, /* enumerate */
629 : nullptr, /* newEnumerate */
630 : nullptr, /* resolve */
631 : nullptr, /* mayResolve */
632 : _finalize, /* finalize */
633 : nullptr, /* call */
634 : nullptr, /* hasInstance */
635 : nullptr, /* construct */
636 : nullptr, /* trace */
637 : };
638 :
639 : static const js::ClassExtension sClassExtension = {
640 : nullptr, /* weakmapKeyDelegateOp */
641 : _objectMoved /* objectMovedOp */
642 : };
643 :
644 : static const DOMJSClass sClass = {
645 : { "PaymentResponse",
646 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
647 : &sClassOps,
648 : JS_NULL_CLASS_SPEC,
649 : &sClassExtension,
650 : JS_NULL_OBJECT_OPS
651 : },
652 : { prototypes::id::PaymentResponse, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
653 : IsBaseOf<nsISupports, mozilla::dom::PaymentResponse >::value,
654 : sNativePropertyHooks,
655 : FindAssociatedGlobalForNative<mozilla::dom::PaymentResponse>::Get,
656 : GetProtoObjectHandle,
657 : GetCCParticipant<mozilla::dom::PaymentResponse>::Get()
658 : };
659 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
660 : "Must have the right minimal number of reserved slots.");
661 : static_assert(1 >= 1,
662 : "Must have enough reserved slots.");
663 :
664 : const JSClass*
665 0 : GetJSClass()
666 : {
667 0 : return sClass.ToJSClass();
668 : }
669 :
670 : bool
671 0 : Wrap(JSContext* aCx, mozilla::dom::PaymentResponse* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
672 : {
673 : MOZ_ASSERT(static_cast<mozilla::dom::PaymentResponse*>(aObject) ==
674 : reinterpret_cast<mozilla::dom::PaymentResponse*>(aObject),
675 : "Multiple inheritance for mozilla::dom::PaymentResponse is broken.");
676 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
677 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
678 0 : MOZ_ASSERT(!aCache->GetWrapper(),
679 : "You should probably not be using Wrap() directly; use "
680 : "GetOrCreateDOMReflector instead");
681 :
682 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
683 : "nsISupports must be on our primary inheritance chain");
684 :
685 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
686 0 : if (!global) {
687 0 : return false;
688 : }
689 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
690 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
691 :
692 : // That might have ended up wrapping us already, due to the wonders
693 : // of XBL. Check for that, and bail out as needed.
694 0 : aReflector.set(aCache->GetWrapper());
695 0 : if (aReflector) {
696 : #ifdef DEBUG
697 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
698 : #endif // DEBUG
699 0 : return true;
700 : }
701 :
702 0 : JSAutoCompartment ac(aCx, global);
703 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
704 0 : if (!canonicalProto) {
705 0 : return false;
706 : }
707 0 : JS::Rooted<JSObject*> proto(aCx);
708 0 : if (aGivenProto) {
709 0 : proto = aGivenProto;
710 : // Unfortunately, while aGivenProto was in the compartment of aCx
711 : // coming in, we changed compartments to that of "parent" so may need
712 : // to wrap the proto here.
713 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
714 0 : if (!JS_WrapObject(aCx, &proto)) {
715 0 : return false;
716 : }
717 : }
718 : } else {
719 0 : proto = canonicalProto;
720 : }
721 :
722 0 : BindingJSObjectCreator<mozilla::dom::PaymentResponse> creator(aCx);
723 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
724 0 : if (!aReflector) {
725 0 : return false;
726 : }
727 :
728 0 : aCache->SetWrapper(aReflector);
729 0 : creator.InitializationSucceeded();
730 :
731 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
732 : aCache->GetWrapperPreserveColor() == aReflector);
733 : // If proto != canonicalProto, we have to preserve our wrapper;
734 : // otherwise we won't be able to properly recreate it later, since
735 : // we won't know what proto to use. Note that we don't check
736 : // aGivenProto here, since it's entirely possible (and even
737 : // somewhat common) to have a non-null aGivenProto which is the
738 : // same as canonicalProto.
739 0 : if (proto != canonicalProto) {
740 0 : PreserveWrapper(aObject);
741 : }
742 :
743 0 : return true;
744 : }
745 :
746 : const NativePropertyHooks sNativePropertyHooks[] = { {
747 : nullptr,
748 : nullptr,
749 : nullptr,
750 : { sNativeProperties.Upcast(), nullptr },
751 : prototypes::id::PaymentResponse,
752 : constructors::id::PaymentResponse,
753 : nullptr,
754 : &DefaultXrayExpandoObjectClass
755 : } };
756 :
757 : void
758 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
759 : {
760 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
761 0 : if (!parentProto) {
762 0 : return;
763 : }
764 :
765 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
766 0 : if (!constructorProto) {
767 0 : return;
768 : }
769 :
770 : static bool sIdsInited = false;
771 0 : if (!sIdsInited && NS_IsMainThread()) {
772 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
773 0 : return;
774 : }
775 0 : sIdsInited = true;
776 : }
777 :
778 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PaymentResponse);
779 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PaymentResponse);
780 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
781 : &sPrototypeClass.mBase, protoCache,
782 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
783 : interfaceCache,
784 : sNativeProperties.Upcast(),
785 : nullptr,
786 : "PaymentResponse", aDefineOnGlobal,
787 : nullptr,
788 0 : false);
789 : }
790 :
791 : JS::Handle<JSObject*>
792 0 : GetProtoObjectHandle(JSContext* aCx)
793 : {
794 : /* Get the interface prototype object for this class. This will create the
795 : object as needed. */
796 0 : bool aDefineOnGlobal = true;
797 :
798 : /* Make sure our global is sane. Hopefully we can remove this sometime */
799 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
800 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
801 0 : return nullptr;
802 : }
803 :
804 : /* Check to see whether the interface objects are already installed */
805 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
806 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::PaymentResponse)) {
807 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
808 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
809 : }
810 :
811 : /*
812 : * The object might _still_ be null, but that's OK.
813 : *
814 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
815 : * traced by TraceProtoAndIfaceCache() and its contents are never
816 : * changed after they have been set.
817 : *
818 : * Calling address() avoids the read read barrier that does gray
819 : * unmarking, but it's not possible for the object to be gray here.
820 : */
821 :
822 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::PaymentResponse);
823 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
824 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
825 : }
826 :
827 : JS::Handle<JSObject*>
828 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
829 : {
830 : /* Get the interface object for this class. This will create the object as
831 : needed. */
832 :
833 : /* Make sure our global is sane. Hopefully we can remove this sometime */
834 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
835 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
836 0 : return nullptr;
837 : }
838 :
839 : /* Check to see whether the interface objects are already installed */
840 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
841 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::PaymentResponse)) {
842 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
843 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
844 : }
845 :
846 : /*
847 : * The object might _still_ be null, but that's OK.
848 : *
849 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
850 : * traced by TraceProtoAndIfaceCache() and its contents are never
851 : * changed after they have been set.
852 : *
853 : * Calling address() avoids the read read barrier that does gray
854 : * unmarking, but it's not possible for the object to be gray here.
855 : */
856 :
857 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::PaymentResponse);
858 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
859 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
860 : }
861 :
862 : JSObject*
863 0 : GetConstructorObject(JSContext* aCx)
864 : {
865 0 : return GetConstructorObjectHandle(aCx);
866 : }
867 :
868 : } // namespace PaymentResponseBinding
869 :
870 :
871 :
872 : } // namespace dom
873 : } // namespace mozilla
|