Coverage Report

Created: 2018-09-25 14:53

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