Line data Source code
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/PrimitiveConversions.h"
10 : #include "mozilla/dom/XrayExpandoClass.h"
11 : #include "nsGeolocation.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 :
16 : namespace PositionErrorBinding {
17 :
18 : static bool
19 0 : get_code(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PositionError* self, JSJitGetterCallArgs args)
20 : {
21 0 : uint16_t result(self->Code());
22 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
23 0 : args.rval().setInt32(int32_t(result));
24 0 : return true;
25 : }
26 :
27 : static const JSJitInfo code_getterinfo = {
28 : { (JSJitGetterOp)get_code },
29 : { prototypes::id::PositionError },
30 : { PrototypeTraits<prototypes::id::PositionError>::Depth },
31 : JSJitInfo::Getter,
32 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
33 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
34 : true, /* isInfallible. False in setters. */
35 : false, /* isMovable. Not relevant for setters. */
36 : false, /* isEliminatable. Not relevant for setters. */
37 : false, /* isAlwaysInSlot. Only relevant for getters. */
38 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
39 : false, /* isTypedMethod. Only relevant for methods. */
40 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
41 : };
42 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
43 : static_assert(0 < 1, "There is no slot for us");
44 :
45 : static bool
46 0 : get_message(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PositionError* self, JSJitGetterCallArgs args)
47 : {
48 0 : DOMString result;
49 0 : self->GetMessage(result);
50 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
51 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
52 0 : return false;
53 : }
54 0 : return true;
55 : }
56 :
57 : static const JSJitInfo message_getterinfo = {
58 : { (JSJitGetterOp)get_message },
59 : { prototypes::id::PositionError },
60 : { PrototypeTraits<prototypes::id::PositionError>::Depth },
61 : JSJitInfo::Getter,
62 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
63 : JSVAL_TYPE_STRING, /* 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 :
75 : static bool
76 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
77 : {
78 0 : mozilla::dom::PositionError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PositionError>(obj);
79 : // We don't want to preserve if we don't have a wrapper, and we
80 : // obviously can't preserve if we're not initialized.
81 0 : if (self && self->GetWrapperPreserveColor()) {
82 0 : PreserveWrapper(self);
83 : }
84 0 : return true;
85 : }
86 :
87 : static void
88 0 : _finalize(js::FreeOp* fop, JSObject* obj)
89 : {
90 0 : mozilla::dom::PositionError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PositionError>(obj);
91 0 : if (self) {
92 0 : ClearWrapper(self, self, obj);
93 0 : AddForDeferredFinalization<mozilla::dom::PositionError>(self);
94 : }
95 0 : }
96 :
97 : static void
98 0 : _objectMoved(JSObject* obj, const JSObject* old)
99 : {
100 0 : mozilla::dom::PositionError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PositionError>(obj);
101 0 : if (self) {
102 0 : UpdateWrapper(self, self, obj, old);
103 : }
104 0 : }
105 :
106 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
107 : #if defined(__clang__)
108 : #pragma clang diagnostic push
109 : #pragma clang diagnostic ignored "-Wmissing-braces"
110 : #endif
111 : static const JSPropertySpec sAttributes_specs[] = {
112 : { "code", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &code_getterinfo, nullptr, nullptr },
113 : { "message", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &message_getterinfo, nullptr, nullptr },
114 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
115 : };
116 : #if defined(__clang__)
117 : #pragma clang diagnostic pop
118 : #endif
119 :
120 :
121 : // Can't be const because the pref-enabled boolean needs to be writable
122 : static Prefable<const JSPropertySpec> sAttributes[] = {
123 : { nullptr, &sAttributes_specs[0] },
124 : { nullptr, nullptr }
125 : };
126 :
127 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
128 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
129 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
130 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
131 :
132 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
133 : #if defined(__clang__)
134 : #pragma clang diagnostic push
135 : #pragma clang diagnostic ignored "-Wmissing-braces"
136 : #endif
137 : static const ConstantSpec sConstants_specs[] = {
138 : { "PERMISSION_DENIED", JS::Int32Value(1) },
139 : { "POSITION_UNAVAILABLE", JS::Int32Value(2) },
140 : { "TIMEOUT", JS::Int32Value(3) },
141 : { 0, JS::UndefinedValue() }
142 : };
143 : #if defined(__clang__)
144 : #pragma clang diagnostic pop
145 : #endif
146 :
147 :
148 : // Can't be const because the pref-enabled boolean needs to be writable
149 : static Prefable<const ConstantSpec> sConstants[] = {
150 : { nullptr, &sConstants_specs[0] },
151 : { nullptr, nullptr }
152 : };
153 :
154 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
155 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
156 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
157 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
158 :
159 :
160 : static uint16_t sNativeProperties_sortedPropertyIndices[5];
161 : static PropertyInfo sNativeProperties_propertyInfos[5];
162 :
163 : static const NativePropertiesN<2> sNativeProperties = {
164 : false, 0,
165 : false, 0,
166 : false, 0,
167 : true, 0 /* sAttributes */,
168 : false, 0,
169 : false, 0,
170 : true, 1 /* sConstants */,
171 : -1,
172 : 5,
173 : sNativeProperties_sortedPropertyIndices,
174 : {
175 : { sAttributes, &sNativeProperties_propertyInfos[0] },
176 : { sConstants, &sNativeProperties_propertyInfos[2] }
177 : }
178 : };
179 : static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
180 : "We have a property info count that is oversized");
181 :
182 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
183 : {
184 : "PositionErrorPrototype",
185 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
186 : JS_NULL_CLASS_OPS,
187 : JS_NULL_CLASS_SPEC,
188 : JS_NULL_CLASS_EXT,
189 : JS_NULL_OBJECT_OPS
190 : },
191 : eInterfacePrototype,
192 : false,
193 : prototypes::id::PositionError,
194 : PrototypeTraits<prototypes::id::PositionError>::Depth,
195 : sNativePropertyHooks,
196 : "[object PositionErrorPrototype]",
197 : JS::GetRealmObjectPrototype
198 : };
199 :
200 : static const js::ClassOps sClassOps = {
201 : _addProperty, /* addProperty */
202 : nullptr, /* delProperty */
203 : nullptr, /* getProperty */
204 : nullptr, /* setProperty */
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 : { "PositionError",
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::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 },
230 : IsBaseOf<nsISupports, mozilla::dom::PositionError >::value,
231 : sNativePropertyHooks,
232 : FindAssociatedGlobalForNative<mozilla::dom::PositionError>::Get,
233 : GetProtoObjectHandle,
234 : GetCCParticipant<mozilla::dom::PositionError>::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 0 : GetJSClass()
243 : {
244 0 : return sClass.ToJSClass();
245 : }
246 :
247 : bool
248 0 : Wrap(JSContext* aCx, mozilla::dom::PositionError* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
249 : {
250 : MOZ_ASSERT(static_cast<mozilla::dom::PositionError*>(aObject) ==
251 : reinterpret_cast<mozilla::dom::PositionError*>(aObject),
252 : "Multiple inheritance for mozilla::dom::PositionError is broken.");
253 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
254 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
255 0 : MOZ_ASSERT(!aCache->GetWrapper(),
256 : "You should probably not be using Wrap() directly; use "
257 : "GetOrCreateDOMReflector instead");
258 :
259 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
260 : "nsISupports must be on our primary inheritance chain");
261 :
262 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
263 0 : if (!global) {
264 0 : return false;
265 : }
266 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
267 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
268 :
269 : // That might have ended up wrapping us already, due to the wonders
270 : // of XBL. Check for that, and bail out as needed.
271 0 : aReflector.set(aCache->GetWrapper());
272 0 : if (aReflector) {
273 : #ifdef DEBUG
274 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
275 : #endif // DEBUG
276 0 : return true;
277 : }
278 :
279 0 : JSAutoCompartment ac(aCx, global);
280 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
281 0 : if (!canonicalProto) {
282 0 : return false;
283 : }
284 0 : JS::Rooted<JSObject*> proto(aCx);
285 0 : if (aGivenProto) {
286 0 : proto = aGivenProto;
287 : // Unfortunately, while aGivenProto was in the compartment of aCx
288 : // coming in, we changed compartments to that of "parent" so may need
289 : // to wrap the proto here.
290 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
291 0 : if (!JS_WrapObject(aCx, &proto)) {
292 0 : return false;
293 : }
294 : }
295 : } else {
296 0 : proto = canonicalProto;
297 : }
298 :
299 0 : BindingJSObjectCreator<mozilla::dom::PositionError> creator(aCx);
300 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
301 0 : if (!aReflector) {
302 0 : return false;
303 : }
304 :
305 0 : aCache->SetWrapper(aReflector);
306 0 : creator.InitializationSucceeded();
307 :
308 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
309 : aCache->GetWrapperPreserveColor() == aReflector);
310 : // If proto != canonicalProto, we have to preserve our wrapper;
311 : // otherwise we won't be able to properly recreate it later, since
312 : // we won't know what proto to use. Note that we don't check
313 : // aGivenProto here, since it's entirely possible (and even
314 : // somewhat common) to have a non-null aGivenProto which is the
315 : // same as canonicalProto.
316 0 : if (proto != canonicalProto) {
317 0 : PreserveWrapper(aObject);
318 : }
319 :
320 0 : return true;
321 : }
322 :
323 : const NativePropertyHooks sNativePropertyHooks[] = { {
324 : nullptr,
325 : nullptr,
326 : nullptr,
327 : { sNativeProperties.Upcast(), nullptr },
328 : prototypes::id::PositionError,
329 : constructors::id::_ID_Count,
330 : nullptr,
331 : &DefaultXrayExpandoObjectClass
332 : } };
333 :
334 : void
335 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
336 : {
337 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
338 0 : if (!parentProto) {
339 0 : return;
340 : }
341 :
342 : static bool sIdsInited = false;
343 0 : if (!sIdsInited && NS_IsMainThread()) {
344 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
345 0 : return;
346 : }
347 0 : sIdsInited = true;
348 : }
349 :
350 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PositionError);
351 0 : JS::Heap<JSObject*>* interfaceCache = nullptr;
352 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
353 : &sPrototypeClass.mBase, protoCache,
354 : nullptr, nullptr, 0, nullptr,
355 : interfaceCache,
356 : sNativeProperties.Upcast(),
357 : nullptr,
358 : nullptr, aDefineOnGlobal,
359 : nullptr,
360 0 : false);
361 : }
362 :
363 : JS::Handle<JSObject*>
364 0 : GetProtoObjectHandle(JSContext* aCx)
365 : {
366 : /* Get the interface prototype object for this class. This will create the
367 : object as needed. */
368 0 : bool aDefineOnGlobal = true;
369 :
370 : /* Make sure our global is sane. Hopefully we can remove this sometime */
371 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
372 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
373 0 : return nullptr;
374 : }
375 :
376 : /* Check to see whether the interface objects are already installed */
377 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
378 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::PositionError)) {
379 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
380 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
381 : }
382 :
383 : /*
384 : * The object might _still_ be null, but that's OK.
385 : *
386 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
387 : * traced by TraceProtoAndIfaceCache() and its contents are never
388 : * changed after they have been set.
389 : *
390 : * Calling address() avoids the read read barrier that does gray
391 : * unmarking, but it's not possible for the object to be gray here.
392 : */
393 :
394 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::PositionError);
395 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
396 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
397 : }
398 :
399 : } // namespace PositionErrorBinding
400 :
401 :
402 :
403 : } // namespace dom
404 : } // namespace mozilla
|