Coverage Report

Created: 2018-09-25 14:53

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