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