Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/IDBMutableFileBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM IDBMutableFile.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "EventHandlerBinding.h"
4
#include "EventTargetBinding.h"
5
#include "IDBMutableFileBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/UseCounter.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/DOMRequest.h"
12
#include "mozilla/dom/IDBDatabase.h"
13
#include "mozilla/dom/IDBFileHandle.h"
14
#include "mozilla/dom/IDBMutableFile.h"
15
#include "mozilla/dom/NonRefcountedDOMObject.h"
16
#include "mozilla/dom/Nullable.h"
17
#include "mozilla/dom/XrayExpandoClass.h"
18
19
namespace mozilla {
20
namespace dom {
21
22
namespace binding_detail {}; // Just to make sure it's known as a namespace
23
using namespace mozilla::dom::binding_detail;
24
25
26
namespace IDBMutableFile_Binding {
27
28
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
29
              "Can't inherit from an interface with a different ownership model.");
30
31
MOZ_CAN_RUN_SCRIPT static bool
32
get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
33
0
{
34
0
  AUTO_PROFILER_LABEL_FAST("get IDBMutableFile.name", DOM, cx);
35
0
36
0
  DOMString result;
37
0
  self->GetName(result);
38
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
39
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
40
0
    return false;
41
0
  }
42
0
  return true;
43
0
}
44
45
static const JSJitInfo name_getterinfo = {
46
  { (JSJitGetterOp)get_name },
47
  { prototypes::id::IDBMutableFile },
48
  { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
49
  JSJitInfo::Getter,
50
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
51
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
52
  false,  /* isInfallible. False in setters. */
53
  false,  /* isMovable.  Not relevant for setters. */
54
  false, /* isEliminatable.  Not relevant for setters. */
55
  false, /* isAlwaysInSlot.  Only relevant for getters. */
56
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
57
  false,  /* isTypedMethod.  Only relevant for methods. */
58
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
59
};
60
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
61
static_assert(0 < 1, "There is no slot for us");
62
63
MOZ_CAN_RUN_SCRIPT static bool
64
get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
65
0
{
66
0
  AUTO_PROFILER_LABEL_FAST("get IDBMutableFile.type", DOM, cx);
67
0
68
0
  DOMString result;
69
0
  self->GetType(result);
70
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
71
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
72
0
    return false;
73
0
  }
74
0
  return true;
75
0
}
76
77
static const JSJitInfo type_getterinfo = {
78
  { (JSJitGetterOp)get_type },
79
  { prototypes::id::IDBMutableFile },
80
  { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
81
  JSJitInfo::Getter,
82
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
83
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
84
  false,  /* isInfallible. False in setters. */
85
  false,  /* isMovable.  Not relevant for setters. */
86
  false, /* isEliminatable.  Not relevant for setters. */
87
  false, /* isAlwaysInSlot.  Only relevant for getters. */
88
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
89
  false,  /* isTypedMethod.  Only relevant for methods. */
90
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
91
};
92
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
93
static_assert(0 < 1, "There is no slot for us");
94
95
MOZ_CAN_RUN_SCRIPT static bool
96
get_database(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
97
0
{
98
0
  AUTO_PROFILER_LABEL_FAST("get IDBMutableFile.database", DOM, cx);
99
0
100
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBDatabase>(self->Database()));
101
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
102
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
103
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
104
0
    return false;
105
0
  }
106
0
  return true;
107
0
}
108
109
static const JSJitInfo database_getterinfo = {
110
  { (JSJitGetterOp)get_database },
111
  { prototypes::id::IDBMutableFile },
112
  { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
113
  JSJitInfo::Getter,
114
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
115
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
116
  false,  /* isInfallible. False in setters. */
117
  false,  /* isMovable.  Not relevant for setters. */
118
  false, /* isEliminatable.  Not relevant for setters. */
119
  false, /* isAlwaysInSlot.  Only relevant for getters. */
120
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
121
  false,  /* isTypedMethod.  Only relevant for methods. */
122
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
123
};
124
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
125
static_assert(0 < 1, "There is no slot for us");
126
127
MOZ_CAN_RUN_SCRIPT static bool
128
open(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, const JSJitMethodCallArgs& args)
129
0
{
130
0
  AUTO_PROFILER_LABEL_FAST("IDBMutableFile.open", DOM, cx);
131
0
132
0
  FileMode arg0;
133
0
  if (args.hasDefined(0)) {
134
0
    {
135
0
      int index;
136
0
      if (!FindEnumStringIndex<true>(cx, args[0], FileModeValues::strings, "FileMode", "Argument 1 of IDBMutableFile.open", &index)) {
137
0
        return false;
138
0
      }
139
0
      MOZ_ASSERT(index >= 0);
140
0
      arg0 = static_cast<FileMode>(index);
141
0
    }
142
0
  } else {
143
0
    arg0 = FileMode::Readonly;
144
0
  }
145
0
  FastErrorResult rv;
146
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBFileHandle>(self->Open(arg0, rv)));
147
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
148
0
    return false;
149
0
  }
150
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
151
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_IDBMutableFile_open);
152
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
153
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
154
0
    return false;
155
0
  }
156
0
  return true;
157
0
}
158
159
static const JSJitInfo open_methodinfo = {
160
  { (JSJitGetterOp)open },
161
  { prototypes::id::IDBMutableFile },
162
  { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
163
  JSJitInfo::Method,
164
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
165
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
166
  false,  /* isInfallible. False in setters. */
167
  false,  /* isMovable.  Not relevant for setters. */
168
  false, /* isEliminatable.  Not relevant for setters. */
169
  false, /* isAlwaysInSlot.  Only relevant for getters. */
170
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
171
  false,  /* isTypedMethod.  Only relevant for methods. */
172
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
173
};
174
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
175
static_assert(0 < 1, "There is no slot for us");
176
177
MOZ_CAN_RUN_SCRIPT static bool
178
getFile(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, const JSJitMethodCallArgs& args)
179
0
{
180
0
  AUTO_PROFILER_LABEL_FAST("IDBMutableFile.getFile", DOM, cx);
181
0
182
0
  FastErrorResult rv;
183
0
  auto result(StrongOrRawPtr<mozilla::dom::DOMRequest>(self->GetFile(rv)));
184
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
185
0
    return false;
186
0
  }
187
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
188
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_IDBMutableFile_getFile);
189
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
190
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
191
0
    return false;
192
0
  }
193
0
  return true;
194
0
}
195
196
static const JSJitInfo getFile_methodinfo = {
197
  { (JSJitGetterOp)getFile },
198
  { prototypes::id::IDBMutableFile },
199
  { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
200
  JSJitInfo::Method,
201
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
202
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
203
  false,  /* isInfallible. False in setters. */
204
  false,  /* isMovable.  Not relevant for setters. */
205
  false, /* isEliminatable.  Not relevant for setters. */
206
  false, /* isAlwaysInSlot.  Only relevant for getters. */
207
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
208
  false,  /* isTypedMethod.  Only relevant for methods. */
209
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
210
};
211
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
212
static_assert(0 < 1, "There is no slot for us");
213
214
MOZ_CAN_RUN_SCRIPT static bool
215
get_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
216
0
{
217
0
  AUTO_PROFILER_LABEL_FAST("get IDBMutableFile.onabort", DOM, cx);
218
0
219
0
  RefPtr<EventHandlerNonNull> result(self->GetOnabort());
220
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
221
0
  if (result) {
222
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
223
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
224
0
      return false;
225
0
    }
226
0
    return true;
227
0
  } else {
228
0
    args.rval().setNull();
229
0
    return true;
230
0
  }
231
0
}
232
233
MOZ_CAN_RUN_SCRIPT static bool
234
set_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitSetterCallArgs args)
235
0
{
236
0
  AUTO_PROFILER_LABEL_FAST("set IDBMutableFile.onabort", DOM, cx);
237
0
238
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
239
0
  if (args[0].isObject()) {
240
0
    { // scope for tempRoot and tempGlobalRoot if needed
241
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
242
0
    }
243
0
  } else {
244
0
    arg0 = nullptr;
245
0
  }
246
0
  self->SetOnabort(Constify(arg0));
247
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
248
0
249
0
  return true;
250
0
}
251
252
static const JSJitInfo onabort_getterinfo = {
253
  { (JSJitGetterOp)get_onabort },
254
  { prototypes::id::IDBMutableFile },
255
  { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
256
  JSJitInfo::Getter,
257
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
258
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
259
  false,  /* isInfallible. False in setters. */
260
  false,  /* isMovable.  Not relevant for setters. */
261
  false, /* isEliminatable.  Not relevant for setters. */
262
  false, /* isAlwaysInSlot.  Only relevant for getters. */
263
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
264
  false,  /* isTypedMethod.  Only relevant for methods. */
265
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
266
};
267
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
268
static_assert(0 < 1, "There is no slot for us");
269
static const JSJitInfo onabort_setterinfo = {
270
  { (JSJitGetterOp)set_onabort },
271
  { prototypes::id::IDBMutableFile },
272
  { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
273
  JSJitInfo::Setter,
274
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
275
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
276
  false,  /* isInfallible. False in setters. */
277
  false,  /* isMovable.  Not relevant for setters. */
278
  false, /* isEliminatable.  Not relevant for setters. */
279
  false, /* isAlwaysInSlot.  Only relevant for getters. */
280
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
281
  false,  /* isTypedMethod.  Only relevant for methods. */
282
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
283
};
284
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
285
static_assert(0 < 1, "There is no slot for us");
286
287
MOZ_CAN_RUN_SCRIPT static bool
288
get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
289
0
{
290
0
  AUTO_PROFILER_LABEL_FAST("get IDBMutableFile.onerror", DOM, cx);
291
0
292
0
  RefPtr<EventHandlerNonNull> result(self->GetOnerror());
293
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
294
0
  if (result) {
295
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
296
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
297
0
      return false;
298
0
    }
299
0
    return true;
300
0
  } else {
301
0
    args.rval().setNull();
302
0
    return true;
303
0
  }
304
0
}
305
306
MOZ_CAN_RUN_SCRIPT static bool
307
set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitSetterCallArgs args)
308
0
{
309
0
  AUTO_PROFILER_LABEL_FAST("set IDBMutableFile.onerror", DOM, cx);
310
0
311
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
312
0
  if (args[0].isObject()) {
313
0
    { // scope for tempRoot and tempGlobalRoot if needed
314
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
315
0
    }
316
0
  } else {
317
0
    arg0 = nullptr;
318
0
  }
319
0
  self->SetOnerror(Constify(arg0));
320
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
321
0
322
0
  return true;
323
0
}
324
325
static const JSJitInfo onerror_getterinfo = {
326
  { (JSJitGetterOp)get_onerror },
327
  { prototypes::id::IDBMutableFile },
328
  { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
329
  JSJitInfo::Getter,
330
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
331
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
332
  false,  /* isInfallible. False in setters. */
333
  false,  /* isMovable.  Not relevant for setters. */
334
  false, /* isEliminatable.  Not relevant for setters. */
335
  false, /* isAlwaysInSlot.  Only relevant for getters. */
336
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
337
  false,  /* isTypedMethod.  Only relevant for methods. */
338
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
339
};
340
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
341
static_assert(0 < 1, "There is no slot for us");
342
static const JSJitInfo onerror_setterinfo = {
343
  { (JSJitGetterOp)set_onerror },
344
  { prototypes::id::IDBMutableFile },
345
  { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
346
  JSJitInfo::Setter,
347
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
348
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
349
  false,  /* isInfallible. False in setters. */
350
  false,  /* isMovable.  Not relevant for setters. */
351
  false, /* isEliminatable.  Not relevant for setters. */
352
  false, /* isAlwaysInSlot.  Only relevant for getters. */
353
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
354
  false,  /* isTypedMethod.  Only relevant for methods. */
355
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
356
};
357
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
358
static_assert(0 < 1, "There is no slot for us");
359
360
static bool
361
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
362
0
{
363
0
  mozilla::dom::IDBMutableFile* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBMutableFile>(obj);
364
0
  // We don't want to preserve if we don't have a wrapper, and we
365
0
  // obviously can't preserve if we're not initialized.
366
0
  if (self && self->GetWrapperPreserveColor()) {
367
0
    PreserveWrapper(self);
368
0
  }
369
0
  return true;
370
0
}
371
372
static void
373
_finalize(js::FreeOp* fop, JSObject* obj)
374
0
{
375
0
  mozilla::dom::IDBMutableFile* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBMutableFile>(obj);
376
0
  if (self) {
377
0
    ClearWrapper(self, self, obj);
378
0
    AddForDeferredFinalization<mozilla::dom::IDBMutableFile>(self);
379
0
  }
380
0
}
381
382
static size_t
383
_objectMoved(JSObject* obj, JSObject* old)
384
0
{
385
0
  mozilla::dom::IDBMutableFile* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBMutableFile>(obj);
386
0
  if (self) {
387
0
    UpdateWrapper(self, self, obj, old);
388
0
  }
389
0
390
0
  return 0;
391
0
}
392
393
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
394
#if defined(__clang__)
395
#pragma clang diagnostic push
396
#pragma clang diagnostic ignored "-Wmissing-braces"
397
#endif
398
static const JSFunctionSpec sMethods_specs[] = {
399
  JS_FNSPEC("open", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&open_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
400
  JS_FNSPEC("getFile", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getFile_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
401
  JS_FS_END
402
};
403
#if defined(__clang__)
404
#pragma clang diagnostic pop
405
#endif
406
407
408
static const Prefable<const JSFunctionSpec> sMethods[] = {
409
  { nullptr, &sMethods_specs[0] },
410
  { nullptr, nullptr }
411
};
412
413
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
414
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
415
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
416
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
417
418
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
419
#if defined(__clang__)
420
#pragma clang diagnostic push
421
#pragma clang diagnostic ignored "-Wmissing-braces"
422
#endif
423
static const JSPropertySpec sAttributes_specs[] = {
424
  { "name", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &name_getterinfo, nullptr, nullptr },
425
  { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr },
426
  { "database", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &database_getterinfo, nullptr, nullptr },
427
  { "onabort", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onabort_getterinfo, GenericSetter<NormalThisPolicy>, &onabort_setterinfo },
428
  { "onerror", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onerror_getterinfo, GenericSetter<NormalThisPolicy>, &onerror_setterinfo },
429
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
430
};
431
#if defined(__clang__)
432
#pragma clang diagnostic pop
433
#endif
434
435
436
static const Prefable<const JSPropertySpec> sAttributes[] = {
437
  { nullptr, &sAttributes_specs[0] },
438
  { nullptr, nullptr }
439
};
440
441
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
442
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
443
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
444
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
445
446
447
static uint16_t sNativeProperties_sortedPropertyIndices[7];
448
static PropertyInfo sNativeProperties_propertyInfos[7];
449
450
static const NativePropertiesN<2> sNativeProperties = {
451
  false, 0,
452
  false, 0,
453
  true,  0 /* sMethods */,
454
  true,  1 /* sAttributes */,
455
  false, 0,
456
  false, 0,
457
  false, 0,
458
  -1,
459
  7,
460
  sNativeProperties_sortedPropertyIndices,
461
  {
462
    { sMethods, &sNativeProperties_propertyInfos[0] },
463
    { sAttributes, &sNativeProperties_propertyInfos[2] }
464
  }
465
};
466
static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
467
    "We have a property info count that is oversized");
468
469
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
470
  {
471
    "Function",
472
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
473
    &sBoringInterfaceObjectClassClassOps,
474
    JS_NULL_CLASS_SPEC,
475
    JS_NULL_CLASS_EXT,
476
    &sInterfaceObjectClassObjectOps
477
  },
478
  eInterface,
479
  true,
480
  prototypes::id::IDBMutableFile,
481
  PrototypeTraits<prototypes::id::IDBMutableFile>::Depth,
482
  sNativePropertyHooks,
483
  "function IDBMutableFile() {\n    [native code]\n}",
484
  EventTarget_Binding::GetConstructorObject
485
};
486
487
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
488
  {
489
    "IDBMutableFilePrototype",
490
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
491
    JS_NULL_CLASS_OPS,
492
    JS_NULL_CLASS_SPEC,
493
    JS_NULL_CLASS_EXT,
494
    JS_NULL_OBJECT_OPS
495
  },
496
  eInterfacePrototype,
497
  false,
498
  prototypes::id::IDBMutableFile,
499
  PrototypeTraits<prototypes::id::IDBMutableFile>::Depth,
500
  sNativePropertyHooks,
501
  "[object IDBMutableFilePrototype]",
502
  EventTarget_Binding::GetProtoObject
503
};
504
505
static const js::ClassOps sClassOps = {
506
  _addProperty, /* addProperty */
507
  nullptr,               /* delProperty */
508
  nullptr,               /* enumerate */
509
  nullptr, /* newEnumerate */
510
  nullptr, /* resolve */
511
  nullptr, /* mayResolve */
512
  _finalize, /* finalize */
513
  nullptr, /* call */
514
  nullptr,               /* hasInstance */
515
  nullptr,               /* construct */
516
  nullptr, /* trace */
517
};
518
519
static const js::ClassExtension sClassExtension = {
520
  nullptr, /* weakmapKeyDelegateOp */
521
  _objectMoved /* objectMovedOp */
522
};
523
524
static const DOMJSClass sClass = {
525
  { "IDBMutableFile",
526
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
527
    &sClassOps,
528
    JS_NULL_CLASS_SPEC,
529
    &sClassExtension,
530
    JS_NULL_OBJECT_OPS
531
  },
532
  { prototypes::id::EventTarget, prototypes::id::IDBMutableFile, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
533
  IsBaseOf<nsISupports, mozilla::dom::IDBMutableFile >::value,
534
  sNativePropertyHooks,
535
  FindAssociatedGlobalForNative<mozilla::dom::IDBMutableFile>::Get,
536
  GetProtoObjectHandle,
537
  GetCCParticipant<mozilla::dom::IDBMutableFile>::Get()
538
};
539
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
540
              "Must have the right minimal number of reserved slots.");
541
static_assert(1 >= 1,
542
              "Must have enough reserved slots.");
543
544
const JSClass*
545
GetJSClass()
546
0
{
547
0
  return sClass.ToJSClass();
548
0
}
549
550
bool
551
Wrap(JSContext* aCx, mozilla::dom::IDBMutableFile* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
552
0
{
553
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::IDBMutableFile>::value,
554
0
                "Shouldn't have wrappercached things that are not refcounted.");
555
0
  MOZ_ASSERT(static_cast<mozilla::dom::IDBMutableFile*>(aObject) ==
556
0
             reinterpret_cast<mozilla::dom::IDBMutableFile*>(aObject),
557
0
             "Multiple inheritance for mozilla::dom::IDBMutableFile is broken.");
558
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
559
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
560
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
561
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
562
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
563
0
  MOZ_ASSERT(!aCache->GetWrapper(),
564
0
             "You should probably not be using Wrap() directly; use "
565
0
             "GetOrCreateDOMReflector instead");
566
0
567
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
568
0
             "nsISupports must be on our primary inheritance chain");
569
0
570
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
571
0
  if (!global) {
572
0
    return false;
573
0
  }
574
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
575
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
576
0
577
0
  // That might have ended up wrapping us already, due to the wonders
578
0
  // of XBL.  Check for that, and bail out as needed.
579
0
  aReflector.set(aCache->GetWrapper());
580
0
  if (aReflector) {
581
#ifdef DEBUG
582
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
583
#endif // DEBUG
584
    return true;
585
0
  }
586
0
587
0
  JSAutoRealm ar(aCx, global);
588
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
589
0
  if (!canonicalProto) {
590
0
    return false;
591
0
  }
592
0
  JS::Rooted<JSObject*> proto(aCx);
593
0
  if (aGivenProto) {
594
0
    proto = aGivenProto;
595
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
596
0
    // coming in, we changed compartments to that of "parent" so may need
597
0
    // to wrap the proto here.
598
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
599
0
      if (!JS_WrapObject(aCx, &proto)) {
600
0
        return false;
601
0
      }
602
0
    }
603
0
  } else {
604
0
    proto = canonicalProto;
605
0
  }
606
0
607
0
  BindingJSObjectCreator<mozilla::dom::IDBMutableFile> creator(aCx);
608
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
609
0
  if (!aReflector) {
610
0
    return false;
611
0
  }
612
0
613
0
  aCache->SetWrapper(aReflector);
614
0
  creator.InitializationSucceeded();
615
0
616
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
617
0
             aCache->GetWrapperPreserveColor() == aReflector);
618
0
  // If proto != canonicalProto, we have to preserve our wrapper;
619
0
  // otherwise we won't be able to properly recreate it later, since
620
0
  // we won't know what proto to use.  Note that we don't check
621
0
  // aGivenProto here, since it's entirely possible (and even
622
0
  // somewhat common) to have a non-null aGivenProto which is the
623
0
  // same as canonicalProto.
624
0
  if (proto != canonicalProto) {
625
0
    PreserveWrapper(aObject);
626
0
  }
627
0
628
0
  return true;
629
0
}
630
631
const NativePropertyHooks sNativePropertyHooks[] = { {
632
  nullptr,
633
  nullptr,
634
  nullptr,
635
  { sNativeProperties.Upcast(), nullptr },
636
  prototypes::id::IDBMutableFile,
637
  constructors::id::IDBMutableFile,
638
  EventTarget_Binding::sNativePropertyHooks,
639
  &DefaultXrayExpandoObjectClass
640
} };
641
642
void
643
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
644
0
{
645
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
646
0
  if (!parentProto) {
647
0
    return;
648
0
  }
649
0
650
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
651
0
  if (!constructorProto) {
652
0
    return;
653
0
  }
654
0
655
0
  static bool sIdsInited = false;
656
0
  if (!sIdsInited && NS_IsMainThread()) {
657
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
658
0
      return;
659
0
    }
660
0
    sIdsInited = true;
661
0
  }
662
0
663
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBMutableFile);
664
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBMutableFile);
665
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
666
0
                              &sPrototypeClass.mBase, protoCache,
667
0
                              nullptr,
668
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
669
0
                              interfaceCache,
670
0
                              sNativeProperties.Upcast(),
671
0
                              nullptr,
672
0
                              "IDBMutableFile", aDefineOnGlobal,
673
0
                              nullptr,
674
0
                              false);
675
0
}
676
677
JSObject*
678
GetConstructorObject(JSContext* aCx)
679
0
{
680
0
  return GetConstructorObjectHandle(aCx);
681
0
}
682
683
} // namespace IDBMutableFile_Binding
684
685
686
687
} // namespace dom
688
} // namespace mozilla