Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM SpeechGrammar.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "SpeechGrammarBinding.h"
4 : #include "SpeechRecognition.h"
5 : #include "WrapperFactory.h"
6 : #include "mozilla/FloatingPoint.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/Preferences.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 : #include "mozilla/dom/PrimitiveConversions.h"
13 : #include "mozilla/dom/SpeechGrammar.h"
14 : #include "mozilla/dom/XrayExpandoClass.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : namespace SpeechGrammarBinding {
20 :
21 : static bool
22 0 : get_src(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechGrammar* self, JSJitGetterCallArgs args)
23 : {
24 0 : binding_detail::FastErrorResult rv;
25 0 : DOMString result;
26 0 : self->GetSrc(result, rv);
27 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
28 0 : return false;
29 : }
30 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
31 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
32 0 : return false;
33 : }
34 0 : return true;
35 : }
36 :
37 : static bool
38 0 : set_src(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechGrammar* self, JSJitSetterCallArgs args)
39 : {
40 0 : binding_detail::FakeString arg0;
41 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
42 0 : return false;
43 : }
44 0 : binding_detail::FastErrorResult rv;
45 0 : self->SetSrc(NonNullHelper(Constify(arg0)), rv);
46 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
47 0 : return false;
48 : }
49 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
50 :
51 0 : return true;
52 : }
53 :
54 : static const JSJitInfo src_getterinfo = {
55 : { (JSJitGetterOp)get_src },
56 : { prototypes::id::SpeechGrammar },
57 : { PrototypeTraits<prototypes::id::SpeechGrammar>::Depth },
58 : JSJitInfo::Getter,
59 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
60 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
61 : false, /* isInfallible. False in setters. */
62 : false, /* isMovable. Not relevant for setters. */
63 : false, /* isEliminatable. Not relevant for setters. */
64 : false, /* isAlwaysInSlot. Only relevant for getters. */
65 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
66 : false, /* isTypedMethod. Only relevant for methods. */
67 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
68 : };
69 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
70 : static_assert(0 < 1, "There is no slot for us");
71 : static const JSJitInfo src_setterinfo = {
72 : { (JSJitGetterOp)set_src },
73 : { prototypes::id::SpeechGrammar },
74 : { PrototypeTraits<prototypes::id::SpeechGrammar>::Depth },
75 : JSJitInfo::Setter,
76 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
77 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
78 : false, /* isInfallible. False in setters. */
79 : false, /* isMovable. Not relevant for setters. */
80 : false, /* isEliminatable. Not relevant for setters. */
81 : false, /* isAlwaysInSlot. Only relevant for getters. */
82 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
83 : false, /* isTypedMethod. Only relevant for methods. */
84 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
85 : };
86 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
87 : static_assert(0 < 1, "There is no slot for us");
88 :
89 : static bool
90 0 : get_weight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechGrammar* self, JSJitGetterCallArgs args)
91 : {
92 0 : binding_detail::FastErrorResult rv;
93 0 : float result(self->GetWeight(rv));
94 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
95 0 : return false;
96 : }
97 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
98 0 : args.rval().set(JS_NumberValue(double(result)));
99 0 : return true;
100 : }
101 :
102 : static bool
103 0 : set_weight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechGrammar* self, JSJitSetterCallArgs args)
104 : {
105 : float arg0;
106 0 : if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
107 0 : return false;
108 0 : } else if (!mozilla::IsFinite(arg0)) {
109 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SpeechGrammar.weight");
110 0 : return false;
111 : }
112 0 : binding_detail::FastErrorResult rv;
113 0 : self->SetWeight(arg0, rv);
114 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
115 0 : return false;
116 : }
117 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
118 :
119 0 : return true;
120 : }
121 :
122 : static const JSJitInfo weight_getterinfo = {
123 : { (JSJitGetterOp)get_weight },
124 : { prototypes::id::SpeechGrammar },
125 : { PrototypeTraits<prototypes::id::SpeechGrammar>::Depth },
126 : JSJitInfo::Getter,
127 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
128 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
129 : false, /* isInfallible. False in setters. */
130 : false, /* isMovable. Not relevant for setters. */
131 : false, /* isEliminatable. Not relevant for setters. */
132 : false, /* isAlwaysInSlot. Only relevant for getters. */
133 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
134 : false, /* isTypedMethod. Only relevant for methods. */
135 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
136 : };
137 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
138 : static_assert(0 < 1, "There is no slot for us");
139 : static const JSJitInfo weight_setterinfo = {
140 : { (JSJitGetterOp)set_weight },
141 : { prototypes::id::SpeechGrammar },
142 : { PrototypeTraits<prototypes::id::SpeechGrammar>::Depth },
143 : JSJitInfo::Setter,
144 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
145 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
146 : false, /* isInfallible. False in setters. */
147 : false, /* isMovable. Not relevant for setters. */
148 : false, /* isEliminatable. Not relevant for setters. */
149 : false, /* isAlwaysInSlot. Only relevant for getters. */
150 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
151 : false, /* isTypedMethod. Only relevant for methods. */
152 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
153 : };
154 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
155 : static_assert(0 < 1, "There is no slot for us");
156 :
157 : static bool
158 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
159 : {
160 0 : mozilla::dom::SpeechGrammar* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechGrammar>(obj);
161 : // We don't want to preserve if we don't have a wrapper, and we
162 : // obviously can't preserve if we're not initialized.
163 0 : if (self && self->GetWrapperPreserveColor()) {
164 0 : PreserveWrapper(self);
165 : }
166 0 : return true;
167 : }
168 :
169 : static void
170 0 : _finalize(js::FreeOp* fop, JSObject* obj)
171 : {
172 0 : mozilla::dom::SpeechGrammar* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechGrammar>(obj);
173 0 : if (self) {
174 0 : ClearWrapper(self, self, obj);
175 0 : AddForDeferredFinalization<mozilla::dom::SpeechGrammar>(self);
176 : }
177 0 : }
178 :
179 : static void
180 0 : _objectMoved(JSObject* obj, const JSObject* old)
181 : {
182 0 : mozilla::dom::SpeechGrammar* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechGrammar>(obj);
183 0 : if (self) {
184 0 : UpdateWrapper(self, self, obj, old);
185 : }
186 0 : }
187 :
188 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
189 : #if defined(__clang__)
190 : #pragma clang diagnostic push
191 : #pragma clang diagnostic ignored "-Wmissing-braces"
192 : #endif
193 : static const JSPropertySpec sAttributes_specs[] = {
194 : { "src", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &src_getterinfo, GenericBindingSetter, &src_setterinfo },
195 : { "weight", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &weight_getterinfo, GenericBindingSetter, &weight_setterinfo },
196 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
197 : };
198 : #if defined(__clang__)
199 : #pragma clang diagnostic pop
200 : #endif
201 :
202 :
203 : // Can't be const because the pref-enabled boolean needs to be writable
204 : static Prefable<const JSPropertySpec> sAttributes[] = {
205 : { nullptr, &sAttributes_specs[0] },
206 : { nullptr, nullptr }
207 : };
208 :
209 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
210 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
211 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
212 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
213 :
214 :
215 : static uint16_t sNativeProperties_sortedPropertyIndices[2];
216 : static PropertyInfo sNativeProperties_propertyInfos[2];
217 :
218 : static const NativePropertiesN<1> sNativeProperties = {
219 : false, 0,
220 : false, 0,
221 : false, 0,
222 : true, 0 /* sAttributes */,
223 : false, 0,
224 : false, 0,
225 : false, 0,
226 : -1,
227 : 2,
228 : sNativeProperties_sortedPropertyIndices,
229 : {
230 : { sAttributes, &sNativeProperties_propertyInfos[0] }
231 : }
232 : };
233 : static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
234 : "We have a property info count that is oversized");
235 :
236 : static bool
237 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
238 : {
239 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
240 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
241 0 : if (!args.isConstructing()) {
242 : // XXXbz wish I could get the name from the callee instead of
243 : // Adding more relocations
244 0 : return ThrowConstructorWithoutNew(cx, "SpeechGrammar");
245 : }
246 :
247 0 : GlobalObject global(cx, obj);
248 0 : if (global.Failed()) {
249 0 : return false;
250 : }
251 :
252 0 : JS::Rooted<JSObject*> desiredProto(cx);
253 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
254 0 : return false;
255 : }
256 :
257 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
258 0 : Maybe<JSAutoCompartment> ac;
259 0 : if (objIsXray) {
260 0 : obj = js::CheckedUnwrap(obj);
261 0 : if (!obj) {
262 0 : return false;
263 : }
264 0 : ac.emplace(cx, obj);
265 0 : if (!JS_WrapObject(cx, &desiredProto)) {
266 0 : return false;
267 : }
268 : }
269 0 : binding_detail::FastErrorResult rv;
270 0 : auto result(StrongOrRawPtr<mozilla::dom::SpeechGrammar>(mozilla::dom::SpeechGrammar::Constructor(global, rv)));
271 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
272 0 : return false;
273 : }
274 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
275 : static_assert(!IsPointer<decltype(result)>::value,
276 : "NewObject implies that we need to keep the object alive with a strong reference.");
277 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
278 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
279 0 : return false;
280 : }
281 0 : return true;
282 : }
283 :
284 : static const js::ClassOps sInterfaceObjectClassOps = {
285 : nullptr, /* addProperty */
286 : nullptr, /* delProperty */
287 : nullptr, /* getProperty */
288 : nullptr, /* setProperty */
289 : nullptr, /* enumerate */
290 : nullptr, /* newEnumerate */
291 : nullptr, /* resolve */
292 : nullptr, /* mayResolve */
293 : nullptr, /* finalize */
294 : _constructor, /* call */
295 : nullptr, /* hasInstance */
296 : _constructor, /* construct */
297 : nullptr, /* trace */
298 : };
299 :
300 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
301 : {
302 : "Function",
303 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
304 : &sInterfaceObjectClassOps,
305 : JS_NULL_CLASS_SPEC,
306 : JS_NULL_CLASS_EXT,
307 : &sInterfaceObjectClassObjectOps
308 : },
309 : eInterface,
310 : true,
311 : prototypes::id::SpeechGrammar,
312 : PrototypeTraits<prototypes::id::SpeechGrammar>::Depth,
313 : sNativePropertyHooks,
314 : "function SpeechGrammar() {\n [native code]\n}",
315 : JS::GetRealmFunctionPrototype
316 : };
317 :
318 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
319 : {
320 : "SpeechGrammarPrototype",
321 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
322 : JS_NULL_CLASS_OPS,
323 : JS_NULL_CLASS_SPEC,
324 : JS_NULL_CLASS_EXT,
325 : JS_NULL_OBJECT_OPS
326 : },
327 : eInterfacePrototype,
328 : false,
329 : prototypes::id::SpeechGrammar,
330 : PrototypeTraits<prototypes::id::SpeechGrammar>::Depth,
331 : sNativePropertyHooks,
332 : "[object SpeechGrammarPrototype]",
333 : JS::GetRealmObjectPrototype
334 : };
335 :
336 : bool
337 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
338 : {
339 : static bool sPrefValue;
340 : static bool sPrefCacheSetUp = false;
341 0 : if (!sPrefCacheSetUp) {
342 0 : sPrefCacheSetUp = true;
343 0 : Preferences::AddBoolVarCache(&sPrefValue, "media.webspeech.recognition.enable");
344 : }
345 :
346 0 : return sPrefValue &&
347 0 : SpeechRecognition::IsAuthorized(aCx, aObj);
348 : }
349 :
350 : JSObject*
351 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
352 : {
353 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
354 : }
355 :
356 : static const js::ClassOps sClassOps = {
357 : _addProperty, /* addProperty */
358 : nullptr, /* delProperty */
359 : nullptr, /* getProperty */
360 : nullptr, /* setProperty */
361 : nullptr, /* enumerate */
362 : nullptr, /* newEnumerate */
363 : nullptr, /* resolve */
364 : nullptr, /* mayResolve */
365 : _finalize, /* finalize */
366 : nullptr, /* call */
367 : nullptr, /* hasInstance */
368 : nullptr, /* construct */
369 : nullptr, /* trace */
370 : };
371 :
372 : static const js::ClassExtension sClassExtension = {
373 : nullptr, /* weakmapKeyDelegateOp */
374 : _objectMoved /* objectMovedOp */
375 : };
376 :
377 : static const DOMJSClass sClass = {
378 : { "SpeechGrammar",
379 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
380 : &sClassOps,
381 : JS_NULL_CLASS_SPEC,
382 : &sClassExtension,
383 : JS_NULL_OBJECT_OPS
384 : },
385 : { prototypes::id::SpeechGrammar, 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 },
386 : IsBaseOf<nsISupports, mozilla::dom::SpeechGrammar >::value,
387 : sNativePropertyHooks,
388 : FindAssociatedGlobalForNative<mozilla::dom::SpeechGrammar>::Get,
389 : GetProtoObjectHandle,
390 : GetCCParticipant<mozilla::dom::SpeechGrammar>::Get()
391 : };
392 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
393 : "Must have the right minimal number of reserved slots.");
394 : static_assert(1 >= 1,
395 : "Must have enough reserved slots.");
396 :
397 : const JSClass*
398 0 : GetJSClass()
399 : {
400 0 : return sClass.ToJSClass();
401 : }
402 :
403 : bool
404 0 : Wrap(JSContext* aCx, mozilla::dom::SpeechGrammar* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
405 : {
406 : MOZ_ASSERT(static_cast<mozilla::dom::SpeechGrammar*>(aObject) ==
407 : reinterpret_cast<mozilla::dom::SpeechGrammar*>(aObject),
408 : "Multiple inheritance for mozilla::dom::SpeechGrammar is broken.");
409 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
410 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
411 0 : MOZ_ASSERT(!aCache->GetWrapper(),
412 : "You should probably not be using Wrap() directly; use "
413 : "GetOrCreateDOMReflector instead");
414 :
415 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
416 : "nsISupports must be on our primary inheritance chain");
417 :
418 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
419 0 : if (!global) {
420 0 : return false;
421 : }
422 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
423 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
424 :
425 : // That might have ended up wrapping us already, due to the wonders
426 : // of XBL. Check for that, and bail out as needed.
427 0 : aReflector.set(aCache->GetWrapper());
428 0 : if (aReflector) {
429 : #ifdef DEBUG
430 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
431 : #endif // DEBUG
432 0 : return true;
433 : }
434 :
435 0 : JSAutoCompartment ac(aCx, global);
436 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
437 0 : if (!canonicalProto) {
438 0 : return false;
439 : }
440 0 : JS::Rooted<JSObject*> proto(aCx);
441 0 : if (aGivenProto) {
442 0 : proto = aGivenProto;
443 : // Unfortunately, while aGivenProto was in the compartment of aCx
444 : // coming in, we changed compartments to that of "parent" so may need
445 : // to wrap the proto here.
446 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
447 0 : if (!JS_WrapObject(aCx, &proto)) {
448 0 : return false;
449 : }
450 : }
451 : } else {
452 0 : proto = canonicalProto;
453 : }
454 :
455 0 : BindingJSObjectCreator<mozilla::dom::SpeechGrammar> creator(aCx);
456 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
457 0 : if (!aReflector) {
458 0 : return false;
459 : }
460 :
461 0 : aCache->SetWrapper(aReflector);
462 0 : creator.InitializationSucceeded();
463 :
464 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
465 : aCache->GetWrapperPreserveColor() == aReflector);
466 : // If proto != canonicalProto, we have to preserve our wrapper;
467 : // otherwise we won't be able to properly recreate it later, since
468 : // we won't know what proto to use. Note that we don't check
469 : // aGivenProto here, since it's entirely possible (and even
470 : // somewhat common) to have a non-null aGivenProto which is the
471 : // same as canonicalProto.
472 0 : if (proto != canonicalProto) {
473 0 : PreserveWrapper(aObject);
474 : }
475 :
476 0 : return true;
477 : }
478 :
479 : const NativePropertyHooks sNativePropertyHooks[] = { {
480 : nullptr,
481 : nullptr,
482 : nullptr,
483 : { sNativeProperties.Upcast(), nullptr },
484 : prototypes::id::SpeechGrammar,
485 : constructors::id::SpeechGrammar,
486 : nullptr,
487 : &DefaultXrayExpandoObjectClass
488 : } };
489 :
490 : void
491 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
492 : {
493 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
494 0 : if (!parentProto) {
495 0 : return;
496 : }
497 :
498 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
499 0 : if (!constructorProto) {
500 0 : return;
501 : }
502 :
503 : static bool sIdsInited = false;
504 0 : if (!sIdsInited && NS_IsMainThread()) {
505 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
506 0 : return;
507 : }
508 0 : sIdsInited = true;
509 : }
510 :
511 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SpeechGrammar);
512 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SpeechGrammar);
513 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
514 : &sPrototypeClass.mBase, protoCache,
515 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
516 : interfaceCache,
517 : sNativeProperties.Upcast(),
518 : nullptr,
519 : "SpeechGrammar", aDefineOnGlobal,
520 : nullptr,
521 0 : false);
522 : }
523 :
524 : JS::Handle<JSObject*>
525 0 : GetProtoObjectHandle(JSContext* aCx)
526 : {
527 : /* Get the interface prototype object for this class. This will create the
528 : object as needed. */
529 0 : bool aDefineOnGlobal = true;
530 :
531 : /* Make sure our global is sane. Hopefully we can remove this sometime */
532 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
533 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
534 0 : return nullptr;
535 : }
536 :
537 : /* Check to see whether the interface objects are already installed */
538 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
539 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::SpeechGrammar)) {
540 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
541 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
542 : }
543 :
544 : /*
545 : * The object might _still_ be null, but that's OK.
546 : *
547 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
548 : * traced by TraceProtoAndIfaceCache() and its contents are never
549 : * changed after they have been set.
550 : *
551 : * Calling address() avoids the read read barrier that does gray
552 : * unmarking, but it's not possible for the object to be gray here.
553 : */
554 :
555 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::SpeechGrammar);
556 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
557 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
558 : }
559 :
560 : JS::Handle<JSObject*>
561 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
562 : {
563 : /* Get the interface object for this class. This will create the object as
564 : needed. */
565 :
566 : /* Make sure our global is sane. Hopefully we can remove this sometime */
567 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
568 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
569 0 : return nullptr;
570 : }
571 :
572 : /* Check to see whether the interface objects are already installed */
573 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
574 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::SpeechGrammar)) {
575 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
576 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
577 : }
578 :
579 : /*
580 : * The object might _still_ be null, but that's OK.
581 : *
582 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
583 : * traced by TraceProtoAndIfaceCache() and its contents are never
584 : * changed after they have been set.
585 : *
586 : * Calling address() avoids the read read barrier that does gray
587 : * unmarking, but it's not possible for the object to be gray here.
588 : */
589 :
590 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::SpeechGrammar);
591 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
592 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
593 : }
594 :
595 : JSObject*
596 0 : GetConstructorObject(JSContext* aCx)
597 : {
598 0 : return GetConstructorObjectHandle(aCx);
599 : }
600 :
601 : } // namespace SpeechGrammarBinding
602 :
603 :
604 :
605 : } // namespace dom
606 : } // namespace mozilla
|