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