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