/work/obj-fuzz/dom/bindings/AudioStreamTrackBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM AudioStreamTrack.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AudioStreamTrackBinding.h" |
4 | | #include "MediaStreamTrackBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/AudioStreamTrack.h" |
8 | | #include "mozilla/dom/BindingUtils.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/XrayExpandoClass.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
17 | | using namespace mozilla::dom::binding_detail; |
18 | | |
19 | | |
20 | | namespace AudioStreamTrack_Binding { |
21 | | |
22 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<MediaStreamTrack_Binding::NativeType>::value, |
23 | | "Can't inherit from an interface with a different ownership model."); |
24 | | |
25 | | static bool |
26 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
27 | 0 | { |
28 | 0 | mozilla::dom::AudioStreamTrack* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioStreamTrack>(obj); |
29 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
30 | 0 | // obviously can't preserve if we're not initialized. |
31 | 0 | if (self && self->GetWrapperPreserveColor()) { |
32 | 0 | PreserveWrapper(self); |
33 | 0 | } |
34 | 0 | return true; |
35 | 0 | } |
36 | | |
37 | | static void |
38 | | _finalize(js::FreeOp* fop, JSObject* obj) |
39 | 0 | { |
40 | 0 | mozilla::dom::AudioStreamTrack* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioStreamTrack>(obj); |
41 | 0 | if (self) { |
42 | 0 | ClearWrapper(self, self, obj); |
43 | 0 | AddForDeferredFinalization<mozilla::dom::AudioStreamTrack>(self); |
44 | 0 | } |
45 | 0 | } |
46 | | |
47 | | static size_t |
48 | | _objectMoved(JSObject* obj, JSObject* old) |
49 | 0 | { |
50 | 0 | mozilla::dom::AudioStreamTrack* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioStreamTrack>(obj); |
51 | 0 | if (self) { |
52 | 0 | UpdateWrapper(self, self, obj, old); |
53 | 0 | } |
54 | 0 |
|
55 | 0 | return 0; |
56 | 0 | } |
57 | | |
58 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
59 | | { |
60 | | "Function", |
61 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
62 | | &sBoringInterfaceObjectClassClassOps, |
63 | | JS_NULL_CLASS_SPEC, |
64 | | JS_NULL_CLASS_EXT, |
65 | | &sInterfaceObjectClassObjectOps |
66 | | }, |
67 | | eInterface, |
68 | | true, |
69 | | prototypes::id::AudioStreamTrack, |
70 | | PrototypeTraits<prototypes::id::AudioStreamTrack>::Depth, |
71 | | sNativePropertyHooks, |
72 | | "function AudioStreamTrack() {\n [native code]\n}", |
73 | | MediaStreamTrack_Binding::GetConstructorObject |
74 | | }; |
75 | | |
76 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
77 | | { |
78 | | "AudioStreamTrackPrototype", |
79 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
80 | | JS_NULL_CLASS_OPS, |
81 | | JS_NULL_CLASS_SPEC, |
82 | | JS_NULL_CLASS_EXT, |
83 | | JS_NULL_OBJECT_OPS |
84 | | }, |
85 | | eInterfacePrototype, |
86 | | false, |
87 | | prototypes::id::AudioStreamTrack, |
88 | | PrototypeTraits<prototypes::id::AudioStreamTrack>::Depth, |
89 | | sNativePropertyHooks, |
90 | | "[object AudioStreamTrackPrototype]", |
91 | | MediaStreamTrack_Binding::GetProtoObject |
92 | | }; |
93 | | |
94 | | static const js::ClassOps sClassOps = { |
95 | | _addProperty, /* addProperty */ |
96 | | nullptr, /* delProperty */ |
97 | | nullptr, /* enumerate */ |
98 | | nullptr, /* newEnumerate */ |
99 | | nullptr, /* resolve */ |
100 | | nullptr, /* mayResolve */ |
101 | | _finalize, /* finalize */ |
102 | | nullptr, /* call */ |
103 | | nullptr, /* hasInstance */ |
104 | | nullptr, /* construct */ |
105 | | nullptr, /* trace */ |
106 | | }; |
107 | | |
108 | | static const js::ClassExtension sClassExtension = { |
109 | | nullptr, /* weakmapKeyDelegateOp */ |
110 | | _objectMoved /* objectMovedOp */ |
111 | | }; |
112 | | |
113 | | static const DOMJSClass sClass = { |
114 | | { "AudioStreamTrack", |
115 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
116 | | &sClassOps, |
117 | | JS_NULL_CLASS_SPEC, |
118 | | &sClassExtension, |
119 | | JS_NULL_OBJECT_OPS |
120 | | }, |
121 | | { prototypes::id::EventTarget, prototypes::id::MediaStreamTrack, prototypes::id::AudioStreamTrack, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
122 | | IsBaseOf<nsISupports, mozilla::dom::AudioStreamTrack >::value, |
123 | | sNativePropertyHooks, |
124 | | FindAssociatedGlobalForNative<mozilla::dom::AudioStreamTrack>::Get, |
125 | | GetProtoObjectHandle, |
126 | | GetCCParticipant<mozilla::dom::AudioStreamTrack>::Get() |
127 | | }; |
128 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
129 | | "Must have the right minimal number of reserved slots."); |
130 | | static_assert(1 >= 1, |
131 | | "Must have enough reserved slots."); |
132 | | |
133 | | const JSClass* |
134 | | GetJSClass() |
135 | 0 | { |
136 | 0 | return sClass.ToJSClass(); |
137 | 0 | } |
138 | | |
139 | | bool |
140 | | Wrap(JSContext* aCx, mozilla::dom::AudioStreamTrack* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
141 | 0 | { |
142 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::AudioStreamTrack>::value, |
143 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
144 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::AudioStreamTrack*>(aObject) == |
145 | 0 | reinterpret_cast<mozilla::dom::AudioStreamTrack*>(aObject), |
146 | 0 | "Multiple inheritance for mozilla::dom::AudioStreamTrack is broken."); |
147 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::MediaStreamTrack*>(aObject) == |
148 | 0 | reinterpret_cast<mozilla::dom::MediaStreamTrack*>(aObject), |
149 | 0 | "Multiple inheritance for mozilla::dom::MediaStreamTrack is broken."); |
150 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
151 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
152 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
153 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
154 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
155 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
156 | 0 | "You should probably not be using Wrap() directly; use " |
157 | 0 | "GetOrCreateDOMReflector instead"); |
158 | 0 |
|
159 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
160 | 0 | "nsISupports must be on our primary inheritance chain"); |
161 | 0 |
|
162 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
163 | 0 | if (!global) { |
164 | 0 | return false; |
165 | 0 | } |
166 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
167 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
168 | 0 |
|
169 | 0 | // That might have ended up wrapping us already, due to the wonders |
170 | 0 | // of XBL. Check for that, and bail out as needed. |
171 | 0 | aReflector.set(aCache->GetWrapper()); |
172 | 0 | if (aReflector) { |
173 | | #ifdef DEBUG |
174 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
175 | | #endif // DEBUG |
176 | | return true; |
177 | 0 | } |
178 | 0 |
|
179 | 0 | JSAutoRealm ar(aCx, global); |
180 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
181 | 0 | if (!canonicalProto) { |
182 | 0 | return false; |
183 | 0 | } |
184 | 0 | JS::Rooted<JSObject*> proto(aCx); |
185 | 0 | if (aGivenProto) { |
186 | 0 | proto = aGivenProto; |
187 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
188 | 0 | // coming in, we changed compartments to that of "parent" so may need |
189 | 0 | // to wrap the proto here. |
190 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
191 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
192 | 0 | return false; |
193 | 0 | } |
194 | 0 | } |
195 | 0 | } else { |
196 | 0 | proto = canonicalProto; |
197 | 0 | } |
198 | 0 |
|
199 | 0 | BindingJSObjectCreator<mozilla::dom::AudioStreamTrack> creator(aCx); |
200 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
201 | 0 | if (!aReflector) { |
202 | 0 | return false; |
203 | 0 | } |
204 | 0 | |
205 | 0 | aCache->SetWrapper(aReflector); |
206 | 0 | creator.InitializationSucceeded(); |
207 | 0 |
|
208 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
209 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
210 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
211 | 0 | // otherwise we won't be able to properly recreate it later, since |
212 | 0 | // we won't know what proto to use. Note that we don't check |
213 | 0 | // aGivenProto here, since it's entirely possible (and even |
214 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
215 | 0 | // same as canonicalProto. |
216 | 0 | if (proto != canonicalProto) { |
217 | 0 | PreserveWrapper(aObject); |
218 | 0 | } |
219 | 0 |
|
220 | 0 | return true; |
221 | 0 | } |
222 | | |
223 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
224 | | nullptr, |
225 | | nullptr, |
226 | | nullptr, |
227 | | { nullptr, nullptr }, |
228 | | prototypes::id::AudioStreamTrack, |
229 | | constructors::id::AudioStreamTrack, |
230 | | MediaStreamTrack_Binding::sNativePropertyHooks, |
231 | | &DefaultXrayExpandoObjectClass |
232 | | } }; |
233 | | |
234 | | void |
235 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
236 | 0 | { |
237 | 0 | JS::Handle<JSObject*> parentProto(MediaStreamTrack_Binding::GetProtoObjectHandle(aCx)); |
238 | 0 | if (!parentProto) { |
239 | 0 | return; |
240 | 0 | } |
241 | 0 | |
242 | 0 | JS::Handle<JSObject*> constructorProto(MediaStreamTrack_Binding::GetConstructorObjectHandle(aCx)); |
243 | 0 | if (!constructorProto) { |
244 | 0 | return; |
245 | 0 | } |
246 | 0 | |
247 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioStreamTrack); |
248 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AudioStreamTrack); |
249 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
250 | 0 | &sPrototypeClass.mBase, protoCache, |
251 | 0 | nullptr, |
252 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
253 | 0 | interfaceCache, |
254 | 0 | nullptr, |
255 | 0 | nullptr, |
256 | 0 | "AudioStreamTrack", aDefineOnGlobal, |
257 | 0 | nullptr, |
258 | 0 | false); |
259 | 0 | } |
260 | | |
261 | | JSObject* |
262 | | GetConstructorObject(JSContext* aCx) |
263 | 0 | { |
264 | 0 | return GetConstructorObjectHandle(aCx); |
265 | 0 | } |
266 | | |
267 | | } // namespace AudioStreamTrack_Binding |
268 | | |
269 | | |
270 | | |
271 | | } // namespace dom |
272 | | } // namespace mozilla |