Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM PerformanceMark.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "PerformanceEntryBinding.h"
4 : #include "PerformanceMarkBinding.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/NonRefcountedDOMObject.h"
10 : #include "mozilla/dom/PerformanceMark.h"
11 : #include "mozilla/dom/XrayExpandoClass.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 :
16 : namespace PerformanceMarkBinding {
17 :
18 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<PerformanceEntryBinding::NativeType>::value,
19 : "Can't inherit from an interface with a different ownership model.");
20 :
21 : static bool
22 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
23 : {
24 0 : mozilla::dom::PerformanceMark* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceMark>(obj);
25 : // We don't want to preserve if we don't have a wrapper, and we
26 : // obviously can't preserve if we're not initialized.
27 0 : if (self && self->GetWrapperPreserveColor()) {
28 0 : PreserveWrapper(self);
29 : }
30 0 : return true;
31 : }
32 :
33 : static void
34 0 : _finalize(js::FreeOp* fop, JSObject* obj)
35 : {
36 0 : mozilla::dom::PerformanceMark* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceMark>(obj);
37 0 : if (self) {
38 0 : ClearWrapper(self, self, obj);
39 0 : AddForDeferredFinalization<mozilla::dom::PerformanceMark>(self);
40 : }
41 0 : }
42 :
43 : static void
44 0 : _objectMoved(JSObject* obj, const JSObject* old)
45 : {
46 0 : mozilla::dom::PerformanceMark* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceMark>(obj);
47 0 : if (self) {
48 0 : UpdateWrapper(self, self, obj, old);
49 : }
50 0 : }
51 :
52 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
53 : {
54 : "Function",
55 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
56 : &sBoringInterfaceObjectClassClassOps,
57 : JS_NULL_CLASS_SPEC,
58 : JS_NULL_CLASS_EXT,
59 : &sInterfaceObjectClassObjectOps
60 : },
61 : eInterface,
62 : true,
63 : prototypes::id::PerformanceMark,
64 : PrototypeTraits<prototypes::id::PerformanceMark>::Depth,
65 : sNativePropertyHooks,
66 : "function PerformanceMark() {\n [native code]\n}",
67 : PerformanceEntryBinding::GetConstructorObject
68 : };
69 :
70 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
71 : {
72 : "PerformanceMarkPrototype",
73 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
74 : JS_NULL_CLASS_OPS,
75 : JS_NULL_CLASS_SPEC,
76 : JS_NULL_CLASS_EXT,
77 : JS_NULL_OBJECT_OPS
78 : },
79 : eInterfacePrototype,
80 : false,
81 : prototypes::id::PerformanceMark,
82 : PrototypeTraits<prototypes::id::PerformanceMark>::Depth,
83 : sNativePropertyHooks,
84 : "[object PerformanceMarkPrototype]",
85 : PerformanceEntryBinding::GetProtoObject
86 : };
87 :
88 : JSObject*
89 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
90 : {
91 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
92 : }
93 :
94 : static const js::ClassOps sClassOps = {
95 : _addProperty, /* addProperty */
96 : nullptr, /* delProperty */
97 : nullptr, /* getProperty */
98 : nullptr, /* setProperty */
99 : nullptr, /* enumerate */
100 : nullptr, /* newEnumerate */
101 : nullptr, /* resolve */
102 : nullptr, /* mayResolve */
103 : _finalize, /* finalize */
104 : nullptr, /* call */
105 : nullptr, /* hasInstance */
106 : nullptr, /* construct */
107 : nullptr, /* trace */
108 : };
109 :
110 : static const js::ClassExtension sClassExtension = {
111 : nullptr, /* weakmapKeyDelegateOp */
112 : _objectMoved /* objectMovedOp */
113 : };
114 :
115 : static const DOMJSClass sClass = {
116 : { "PerformanceMark",
117 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
118 : &sClassOps,
119 : JS_NULL_CLASS_SPEC,
120 : &sClassExtension,
121 : JS_NULL_OBJECT_OPS
122 : },
123 : { prototypes::id::PerformanceEntry, prototypes::id::PerformanceMark, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
124 : IsBaseOf<nsISupports, mozilla::dom::PerformanceMark >::value,
125 : sNativePropertyHooks,
126 : FindAssociatedGlobalForNative<mozilla::dom::PerformanceMark>::Get,
127 : GetProtoObjectHandle,
128 : GetCCParticipant<mozilla::dom::PerformanceMark>::Get()
129 : };
130 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
131 : "Must have the right minimal number of reserved slots.");
132 : static_assert(1 >= 1,
133 : "Must have enough reserved slots.");
134 :
135 : const JSClass*
136 0 : GetJSClass()
137 : {
138 0 : return sClass.ToJSClass();
139 : }
140 :
141 : bool
142 0 : Wrap(JSContext* aCx, mozilla::dom::PerformanceMark* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
143 : {
144 : MOZ_ASSERT(static_cast<mozilla::dom::PerformanceMark*>(aObject) ==
145 : reinterpret_cast<mozilla::dom::PerformanceMark*>(aObject),
146 : "Multiple inheritance for mozilla::dom::PerformanceMark is broken.");
147 : MOZ_ASSERT(static_cast<mozilla::dom::PerformanceEntry*>(aObject) ==
148 : reinterpret_cast<mozilla::dom::PerformanceEntry*>(aObject),
149 : "Multiple inheritance for mozilla::dom::PerformanceEntry is broken.");
150 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
151 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
152 0 : MOZ_ASSERT(!aCache->GetWrapper(),
153 : "You should probably not be using Wrap() directly; use "
154 : "GetOrCreateDOMReflector instead");
155 :
156 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
157 : "nsISupports must be on our primary inheritance chain");
158 :
159 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
160 0 : if (!global) {
161 0 : return false;
162 : }
163 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
164 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
165 :
166 : // That might have ended up wrapping us already, due to the wonders
167 : // of XBL. Check for that, and bail out as needed.
168 0 : aReflector.set(aCache->GetWrapper());
169 0 : if (aReflector) {
170 : #ifdef DEBUG
171 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
172 : #endif // DEBUG
173 0 : return true;
174 : }
175 :
176 0 : JSAutoCompartment ac(aCx, global);
177 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
178 0 : if (!canonicalProto) {
179 0 : return false;
180 : }
181 0 : JS::Rooted<JSObject*> proto(aCx);
182 0 : if (aGivenProto) {
183 0 : proto = aGivenProto;
184 : // Unfortunately, while aGivenProto was in the compartment of aCx
185 : // coming in, we changed compartments to that of "parent" so may need
186 : // to wrap the proto here.
187 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
188 0 : if (!JS_WrapObject(aCx, &proto)) {
189 0 : return false;
190 : }
191 : }
192 : } else {
193 0 : proto = canonicalProto;
194 : }
195 :
196 0 : BindingJSObjectCreator<mozilla::dom::PerformanceMark> creator(aCx);
197 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
198 0 : if (!aReflector) {
199 0 : return false;
200 : }
201 :
202 0 : aCache->SetWrapper(aReflector);
203 0 : creator.InitializationSucceeded();
204 :
205 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
206 : aCache->GetWrapperPreserveColor() == aReflector);
207 : // If proto != canonicalProto, we have to preserve our wrapper;
208 : // otherwise we won't be able to properly recreate it later, since
209 : // we won't know what proto to use. Note that we don't check
210 : // aGivenProto here, since it's entirely possible (and even
211 : // somewhat common) to have a non-null aGivenProto which is the
212 : // same as canonicalProto.
213 0 : if (proto != canonicalProto) {
214 0 : PreserveWrapper(aObject);
215 : }
216 :
217 0 : return true;
218 : }
219 :
220 : const NativePropertyHooks sNativePropertyHooks[] = { {
221 : nullptr,
222 : nullptr,
223 : nullptr,
224 : { nullptr, nullptr },
225 : prototypes::id::PerformanceMark,
226 : constructors::id::PerformanceMark,
227 : PerformanceEntryBinding::sNativePropertyHooks,
228 : &DefaultXrayExpandoObjectClass
229 : } };
230 :
231 : void
232 1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
233 : {
234 1 : JS::Handle<JSObject*> parentProto(PerformanceEntryBinding::GetProtoObjectHandle(aCx));
235 1 : if (!parentProto) {
236 0 : return;
237 : }
238 :
239 1 : JS::Handle<JSObject*> constructorProto(PerformanceEntryBinding::GetConstructorObjectHandle(aCx));
240 1 : if (!constructorProto) {
241 0 : return;
242 : }
243 :
244 1 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PerformanceMark);
245 1 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PerformanceMark);
246 1 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
247 : &sPrototypeClass.mBase, protoCache,
248 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
249 : interfaceCache,
250 : nullptr,
251 : nullptr,
252 : "PerformanceMark", aDefineOnGlobal,
253 : nullptr,
254 1 : false);
255 : }
256 :
257 : JS::Handle<JSObject*>
258 0 : GetProtoObjectHandle(JSContext* aCx)
259 : {
260 : /* Get the interface prototype object for this class. This will create the
261 : object as needed. */
262 0 : bool aDefineOnGlobal = true;
263 :
264 : /* Make sure our global is sane. Hopefully we can remove this sometime */
265 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
266 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
267 0 : return nullptr;
268 : }
269 :
270 : /* Check to see whether the interface objects are already installed */
271 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
272 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::PerformanceMark)) {
273 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
274 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
275 : }
276 :
277 : /*
278 : * The object might _still_ be null, but that's OK.
279 : *
280 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
281 : * traced by TraceProtoAndIfaceCache() and its contents are never
282 : * changed after they have been set.
283 : *
284 : * Calling address() avoids the read read barrier that does gray
285 : * unmarking, but it's not possible for the object to be gray here.
286 : */
287 :
288 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::PerformanceMark);
289 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
290 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
291 : }
292 :
293 : JS::Handle<JSObject*>
294 1 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
295 : {
296 : /* Get the interface object for this class. This will create the object as
297 : needed. */
298 :
299 : /* Make sure our global is sane. Hopefully we can remove this sometime */
300 1 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
301 1 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
302 0 : return nullptr;
303 : }
304 :
305 : /* Check to see whether the interface objects are already installed */
306 1 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
307 1 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::PerformanceMark)) {
308 2 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
309 1 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
310 : }
311 :
312 : /*
313 : * The object might _still_ be null, but that's OK.
314 : *
315 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
316 : * traced by TraceProtoAndIfaceCache() and its contents are never
317 : * changed after they have been set.
318 : *
319 : * Calling address() avoids the read read barrier that does gray
320 : * unmarking, but it's not possible for the object to be gray here.
321 : */
322 :
323 1 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::PerformanceMark);
324 1 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
325 1 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
326 : }
327 :
328 : JSObject*
329 1 : GetConstructorObject(JSContext* aCx)
330 : {
331 1 : return GetConstructorObjectHandle(aCx);
332 : }
333 :
334 : } // namespace PerformanceMarkBinding
335 :
336 :
337 :
338 : } // namespace dom
339 : } // namespace mozilla
|