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