Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/SVGAnimatedBooleanBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM SVGAnimatedBoolean.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "SVGAnimatedBooleanBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/DOMJSClass.h"
8
#include "mozilla/dom/NonRefcountedDOMObject.h"
9
#include "mozilla/dom/PrimitiveConversions.h"
10
#include "mozilla/dom/SVGAnimatedBoolean.h"
11
#include "mozilla/dom/XrayExpandoClass.h"
12
13
namespace mozilla {
14
namespace dom {
15
16
namespace binding_detail {}; // Just to make sure it's known as a namespace
17
using namespace mozilla::dom::binding_detail;
18
19
20
namespace SVGAnimatedBoolean_Binding {
21
22
MOZ_CAN_RUN_SCRIPT static bool
23
get_baseVal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGAnimatedBoolean* self, JSJitGetterCallArgs args)
24
0
{
25
0
  AUTO_PROFILER_LABEL_FAST("get SVGAnimatedBoolean.baseVal", DOM, cx);
26
0
27
0
  bool result(self->BaseVal());
28
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
29
0
  args.rval().setBoolean(result);
30
0
  return true;
31
0
}
32
33
MOZ_CAN_RUN_SCRIPT static bool
34
set_baseVal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGAnimatedBoolean* self, JSJitSetterCallArgs args)
35
0
{
36
0
  AUTO_PROFILER_LABEL_FAST("set SVGAnimatedBoolean.baseVal", DOM, cx);
37
0
38
0
  bool arg0;
39
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
40
0
    return false;
41
0
  }
42
0
  self->SetBaseVal(arg0);
43
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
44
0
45
0
  return true;
46
0
}
47
48
static const JSJitInfo baseVal_getterinfo = {
49
  { (JSJitGetterOp)get_baseVal },
50
  { prototypes::id::SVGAnimatedBoolean },
51
  { PrototypeTraits<prototypes::id::SVGAnimatedBoolean>::Depth },
52
  JSJitInfo::Getter,
53
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
54
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
55
  true,  /* isInfallible. False in setters. */
56
  false,  /* isMovable.  Not relevant for setters. */
57
  false, /* isEliminatable.  Not relevant for setters. */
58
  false, /* isAlwaysInSlot.  Only relevant for getters. */
59
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
60
  false,  /* isTypedMethod.  Only relevant for methods. */
61
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
62
};
63
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
64
static_assert(0 < 1, "There is no slot for us");
65
static const JSJitInfo baseVal_setterinfo = {
66
  { (JSJitGetterOp)set_baseVal },
67
  { prototypes::id::SVGAnimatedBoolean },
68
  { PrototypeTraits<prototypes::id::SVGAnimatedBoolean>::Depth },
69
  JSJitInfo::Setter,
70
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
71
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
72
  false,  /* isInfallible. False in setters. */
73
  false,  /* isMovable.  Not relevant for setters. */
74
  false, /* isEliminatable.  Not relevant for setters. */
75
  false, /* isAlwaysInSlot.  Only relevant for getters. */
76
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
77
  false,  /* isTypedMethod.  Only relevant for methods. */
78
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
79
};
80
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
81
static_assert(0 < 1, "There is no slot for us");
82
83
MOZ_CAN_RUN_SCRIPT static bool
84
get_animVal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGAnimatedBoolean* self, JSJitGetterCallArgs args)
85
0
{
86
0
  AUTO_PROFILER_LABEL_FAST("get SVGAnimatedBoolean.animVal", DOM, cx);
87
0
88
0
  bool result(self->AnimVal());
89
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
90
0
  args.rval().setBoolean(result);
91
0
  return true;
92
0
}
93
94
static const JSJitInfo animVal_getterinfo = {
95
  { (JSJitGetterOp)get_animVal },
96
  { prototypes::id::SVGAnimatedBoolean },
97
  { PrototypeTraits<prototypes::id::SVGAnimatedBoolean>::Depth },
98
  JSJitInfo::Getter,
99
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
100
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
101
  true,  /* isInfallible. False in setters. */
102
  false,  /* isMovable.  Not relevant for setters. */
103
  false, /* isEliminatable.  Not relevant for setters. */
104
  false, /* isAlwaysInSlot.  Only relevant for getters. */
105
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
106
  false,  /* isTypedMethod.  Only relevant for methods. */
107
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
108
};
109
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
110
static_assert(0 < 1, "There is no slot for us");
111
112
static bool
113
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
114
0
{
115
0
  mozilla::dom::SVGAnimatedBoolean* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGAnimatedBoolean>(obj);
116
0
  // We don't want to preserve if we don't have a wrapper, and we
117
0
  // obviously can't preserve if we're not initialized.
118
0
  if (self && self->GetWrapperPreserveColor()) {
119
0
    PreserveWrapper(self);
120
0
  }
121
0
  return true;
122
0
}
123
124
static void
125
_finalize(js::FreeOp* fop, JSObject* obj)
126
0
{
127
0
  mozilla::dom::SVGAnimatedBoolean* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGAnimatedBoolean>(obj);
128
0
  if (self) {
129
0
    ClearWrapper(self, self, obj);
130
0
    AddForDeferredFinalization<mozilla::dom::SVGAnimatedBoolean>(self);
131
0
  }
132
0
}
133
134
static size_t
135
_objectMoved(JSObject* obj, JSObject* old)
136
0
{
137
0
  mozilla::dom::SVGAnimatedBoolean* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGAnimatedBoolean>(obj);
138
0
  if (self) {
139
0
    UpdateWrapper(self, self, obj, old);
140
0
  }
141
0
142
0
  return 0;
143
0
}
144
145
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
146
#if defined(__clang__)
147
#pragma clang diagnostic push
148
#pragma clang diagnostic ignored "-Wmissing-braces"
149
#endif
150
static const JSPropertySpec sAttributes_specs[] = {
151
  { "baseVal", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &baseVal_getterinfo, GenericSetter<NormalThisPolicy>, &baseVal_setterinfo },
152
  { "animVal", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &animVal_getterinfo, nullptr, nullptr },
153
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
154
};
155
#if defined(__clang__)
156
#pragma clang diagnostic pop
157
#endif
158
159
160
static const Prefable<const JSPropertySpec> sAttributes[] = {
161
  { nullptr, &sAttributes_specs[0] },
162
  { nullptr, nullptr }
163
};
164
165
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
166
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
167
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
168
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
169
170
171
static uint16_t sNativeProperties_sortedPropertyIndices[2];
172
static PropertyInfo sNativeProperties_propertyInfos[2];
173
174
static const NativePropertiesN<1> sNativeProperties = {
175
  false, 0,
176
  false, 0,
177
  false, 0,
178
  true,  0 /* sAttributes */,
179
  false, 0,
180
  false, 0,
181
  false, 0,
182
  -1,
183
  2,
184
  sNativeProperties_sortedPropertyIndices,
185
  {
186
    { sAttributes, &sNativeProperties_propertyInfos[0] }
187
  }
188
};
189
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
190
    "We have a property info count that is oversized");
191
192
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
193
  {
194
    "Function",
195
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
196
    &sBoringInterfaceObjectClassClassOps,
197
    JS_NULL_CLASS_SPEC,
198
    JS_NULL_CLASS_EXT,
199
    &sInterfaceObjectClassObjectOps
200
  },
201
  eInterface,
202
  true,
203
  prototypes::id::SVGAnimatedBoolean,
204
  PrototypeTraits<prototypes::id::SVGAnimatedBoolean>::Depth,
205
  sNativePropertyHooks,
206
  "function SVGAnimatedBoolean() {\n    [native code]\n}",
207
  JS::GetRealmFunctionPrototype
208
};
209
210
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
211
  {
212
    "SVGAnimatedBooleanPrototype",
213
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
214
    JS_NULL_CLASS_OPS,
215
    JS_NULL_CLASS_SPEC,
216
    JS_NULL_CLASS_EXT,
217
    JS_NULL_OBJECT_OPS
218
  },
219
  eInterfacePrototype,
220
  false,
221
  prototypes::id::SVGAnimatedBoolean,
222
  PrototypeTraits<prototypes::id::SVGAnimatedBoolean>::Depth,
223
  sNativePropertyHooks,
224
  "[object SVGAnimatedBooleanPrototype]",
225
  JS::GetRealmObjectPrototype
226
};
227
228
static const js::ClassOps sClassOps = {
229
  _addProperty, /* addProperty */
230
  nullptr,               /* delProperty */
231
  nullptr,               /* enumerate */
232
  nullptr, /* newEnumerate */
233
  nullptr, /* resolve */
234
  nullptr, /* mayResolve */
235
  _finalize, /* finalize */
236
  nullptr, /* call */
237
  nullptr,               /* hasInstance */
238
  nullptr,               /* construct */
239
  nullptr, /* trace */
240
};
241
242
static const js::ClassExtension sClassExtension = {
243
  nullptr, /* weakmapKeyDelegateOp */
244
  _objectMoved /* objectMovedOp */
245
};
246
247
static const DOMJSClass sClass = {
248
  { "SVGAnimatedBoolean",
249
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
250
    &sClassOps,
251
    JS_NULL_CLASS_SPEC,
252
    &sClassExtension,
253
    JS_NULL_OBJECT_OPS
254
  },
255
  { prototypes::id::SVGAnimatedBoolean, 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 },
256
  IsBaseOf<nsISupports, mozilla::dom::SVGAnimatedBoolean >::value,
257
  sNativePropertyHooks,
258
  FindAssociatedGlobalForNative<mozilla::dom::SVGAnimatedBoolean>::Get,
259
  GetProtoObjectHandle,
260
  GetCCParticipant<mozilla::dom::SVGAnimatedBoolean>::Get()
261
};
262
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
263
              "Must have the right minimal number of reserved slots.");
264
static_assert(1 >= 1,
265
              "Must have enough reserved slots.");
266
267
const JSClass*
268
GetJSClass()
269
0
{
270
0
  return sClass.ToJSClass();
271
0
}
272
273
bool
274
Wrap(JSContext* aCx, mozilla::dom::SVGAnimatedBoolean* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
275
0
{
276
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SVGAnimatedBoolean>::value,
277
0
                "Shouldn't have wrappercached things that are not refcounted.");
278
0
  MOZ_ASSERT(static_cast<mozilla::dom::SVGAnimatedBoolean*>(aObject) ==
279
0
             reinterpret_cast<mozilla::dom::SVGAnimatedBoolean*>(aObject),
280
0
             "Multiple inheritance for mozilla::dom::SVGAnimatedBoolean is broken.");
281
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
282
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
283
0
  MOZ_ASSERT(!aCache->GetWrapper(),
284
0
             "You should probably not be using Wrap() directly; use "
285
0
             "GetOrCreateDOMReflector instead");
286
0
287
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
288
0
             "nsISupports must be on our primary inheritance chain");
289
0
290
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
291
0
  if (!global) {
292
0
    return false;
293
0
  }
294
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
295
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
296
0
297
0
  // That might have ended up wrapping us already, due to the wonders
298
0
  // of XBL.  Check for that, and bail out as needed.
299
0
  aReflector.set(aCache->GetWrapper());
300
0
  if (aReflector) {
301
#ifdef DEBUG
302
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
303
#endif // DEBUG
304
    return true;
305
0
  }
306
0
307
0
  JSAutoRealm ar(aCx, global);
308
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
309
0
  if (!canonicalProto) {
310
0
    return false;
311
0
  }
312
0
  JS::Rooted<JSObject*> proto(aCx);
313
0
  if (aGivenProto) {
314
0
    proto = aGivenProto;
315
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
316
0
    // coming in, we changed compartments to that of "parent" so may need
317
0
    // to wrap the proto here.
318
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
319
0
      if (!JS_WrapObject(aCx, &proto)) {
320
0
        return false;
321
0
      }
322
0
    }
323
0
  } else {
324
0
    proto = canonicalProto;
325
0
  }
326
0
327
0
  BindingJSObjectCreator<mozilla::dom::SVGAnimatedBoolean> creator(aCx);
328
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
329
0
  if (!aReflector) {
330
0
    return false;
331
0
  }
332
0
333
0
  aCache->SetWrapper(aReflector);
334
0
  creator.InitializationSucceeded();
335
0
336
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
337
0
             aCache->GetWrapperPreserveColor() == aReflector);
338
0
  // If proto != canonicalProto, we have to preserve our wrapper;
339
0
  // otherwise we won't be able to properly recreate it later, since
340
0
  // we won't know what proto to use.  Note that we don't check
341
0
  // aGivenProto here, since it's entirely possible (and even
342
0
  // somewhat common) to have a non-null aGivenProto which is the
343
0
  // same as canonicalProto.
344
0
  if (proto != canonicalProto) {
345
0
    PreserveWrapper(aObject);
346
0
  }
347
0
348
0
  return true;
349
0
}
350
351
const NativePropertyHooks sNativePropertyHooks[] = { {
352
  nullptr,
353
  nullptr,
354
  nullptr,
355
  { sNativeProperties.Upcast(), nullptr },
356
  prototypes::id::SVGAnimatedBoolean,
357
  constructors::id::SVGAnimatedBoolean,
358
  nullptr,
359
  &DefaultXrayExpandoObjectClass
360
} };
361
362
void
363
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
364
0
{
365
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
366
0
  if (!parentProto) {
367
0
    return;
368
0
  }
369
0
370
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
371
0
  if (!constructorProto) {
372
0
    return;
373
0
  }
374
0
375
0
  static bool sIdsInited = false;
376
0
  if (!sIdsInited && NS_IsMainThread()) {
377
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
378
0
      return;
379
0
    }
380
0
    sIdsInited = true;
381
0
  }
382
0
383
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGAnimatedBoolean);
384
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGAnimatedBoolean);
385
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
386
0
                              &sPrototypeClass.mBase, protoCache,
387
0
                              nullptr,
388
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
389
0
                              interfaceCache,
390
0
                              sNativeProperties.Upcast(),
391
0
                              nullptr,
392
0
                              "SVGAnimatedBoolean", aDefineOnGlobal,
393
0
                              nullptr,
394
0
                              false);
395
0
}
396
397
JSObject*
398
GetConstructorObject(JSContext* aCx)
399
0
{
400
0
  return GetConstructorObjectHandle(aCx);
401
0
}
402
403
} // namespace SVGAnimatedBoolean_Binding
404
405
406
407
} // namespace dom
408
} // namespace mozilla