/work/obj-fuzz/dom/bindings/TransceiverImplBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM TransceiverImpl.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "RTCRtpTransceiverBinding.h" |
4 | | #include "TransceiverImpl.h" |
5 | | #include "TransceiverImplBinding.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/MediaStreamTrack.h" |
11 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
12 | | #include "mozilla/dom/XrayExpandoClass.h" |
13 | | #include "nsContentUtils.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 TransceiverImpl_Binding { |
23 | | |
24 | | MOZ_CAN_RUN_SCRIPT static bool |
25 | | getReceiveTrack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::TransceiverImpl* self, const JSJitMethodCallArgs& args) |
26 | 0 | { |
27 | 0 | AUTO_PROFILER_LABEL_FAST("TransceiverImpl.getReceiveTrack", DOM, cx); |
28 | 0 |
|
29 | 0 | auto result(StrongOrRawPtr<mozilla::dom::MediaStreamTrack>(self->GetReceiveTrack())); |
30 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
31 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
32 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
33 | 0 | return false; |
34 | 0 | } |
35 | 0 | return true; |
36 | 0 | } |
37 | | |
38 | | static const JSJitInfo getReceiveTrack_methodinfo = { |
39 | | { (JSJitGetterOp)getReceiveTrack }, |
40 | | { prototypes::id::TransceiverImpl }, |
41 | | { PrototypeTraits<prototypes::id::TransceiverImpl>::Depth }, |
42 | | JSJitInfo::Method, |
43 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
44 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
45 | | false, /* isInfallible. False in setters. */ |
46 | | false, /* isMovable. Not relevant for setters. */ |
47 | | false, /* isEliminatable. Not relevant for setters. */ |
48 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
49 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
50 | | false, /* isTypedMethod. Only relevant for methods. */ |
51 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
52 | | }; |
53 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
54 | | static_assert(0 < 1, "There is no slot for us"); |
55 | | |
56 | | MOZ_CAN_RUN_SCRIPT static bool |
57 | | syncWithJS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::TransceiverImpl* self, const JSJitMethodCallArgs& args) |
58 | 0 | { |
59 | 0 | AUTO_PROFILER_LABEL_FAST("TransceiverImpl.syncWithJS", DOM, cx); |
60 | 0 |
|
61 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
62 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TransceiverImpl.syncWithJS"); |
63 | 0 | } |
64 | 0 | NonNull<mozilla::dom::RTCRtpTransceiver> arg0; |
65 | 0 | if (args[0].isObject()) { |
66 | 0 | { |
67 | 0 | nsresult rv = UnwrapObject<prototypes::id::RTCRtpTransceiver, mozilla::dom::RTCRtpTransceiver>(args[0], arg0); |
68 | 0 | if (NS_FAILED(rv)) { |
69 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of TransceiverImpl.syncWithJS", "RTCRtpTransceiver"); |
70 | 0 | return false; |
71 | 0 | } |
72 | 0 | } |
73 | 0 | } else { |
74 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of TransceiverImpl.syncWithJS"); |
75 | 0 | return false; |
76 | 0 | } |
77 | 0 | FastErrorResult rv; |
78 | 0 | self->SyncWithJS(MOZ_KnownLive(NonNullHelper(arg0)), rv); |
79 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
80 | 0 | return false; |
81 | 0 | } |
82 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
83 | 0 | args.rval().setUndefined(); |
84 | 0 | return true; |
85 | 0 | } |
86 | | |
87 | | static const JSJitInfo syncWithJS_methodinfo = { |
88 | | { (JSJitGetterOp)syncWithJS }, |
89 | | { prototypes::id::TransceiverImpl }, |
90 | | { PrototypeTraits<prototypes::id::TransceiverImpl>::Depth }, |
91 | | JSJitInfo::Method, |
92 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
93 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
94 | | false, /* isInfallible. False in setters. */ |
95 | | false, /* isMovable. Not relevant for setters. */ |
96 | | false, /* isEliminatable. Not relevant for setters. */ |
97 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
98 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
99 | | false, /* isTypedMethod. Only relevant for methods. */ |
100 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
101 | | }; |
102 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
103 | | static_assert(0 < 1, "There is no slot for us"); |
104 | | |
105 | | static void |
106 | | _finalize(js::FreeOp* fop, JSObject* obj) |
107 | 0 | { |
108 | 0 | mozilla::TransceiverImpl* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::TransceiverImpl>(obj); |
109 | 0 | if (self) { |
110 | 0 | AddForDeferredFinalization<mozilla::TransceiverImpl>(self); |
111 | 0 | } |
112 | 0 | } |
113 | | |
114 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
115 | | #if defined(__clang__) |
116 | | #pragma clang diagnostic push |
117 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
118 | | #endif |
119 | | static const JSFunctionSpec sMethods_specs[] = { |
120 | | JS_FNSPEC("getReceiveTrack", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getReceiveTrack_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
121 | | JS_FNSPEC("syncWithJS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&syncWithJS_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
122 | | JS_FS_END |
123 | | }; |
124 | | #if defined(__clang__) |
125 | | #pragma clang diagnostic pop |
126 | | #endif |
127 | | |
128 | | |
129 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
130 | | { nullptr, &sMethods_specs[0] }, |
131 | | { nullptr, nullptr } |
132 | | }; |
133 | | |
134 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
135 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
136 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
137 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
138 | | |
139 | | |
140 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
141 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
142 | | |
143 | | static const NativePropertiesN<1> sNativeProperties = { |
144 | | false, 0, |
145 | | false, 0, |
146 | | true, 0 /* sMethods */, |
147 | | false, 0, |
148 | | false, 0, |
149 | | false, 0, |
150 | | false, 0, |
151 | | -1, |
152 | | 2, |
153 | | sNativeProperties_sortedPropertyIndices, |
154 | | { |
155 | | { sMethods, &sNativeProperties_propertyInfos[0] } |
156 | | } |
157 | | }; |
158 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
159 | | "We have a property info count that is oversized"); |
160 | | |
161 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
162 | | { |
163 | | "Function", |
164 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
165 | | &sBoringInterfaceObjectClassClassOps, |
166 | | JS_NULL_CLASS_SPEC, |
167 | | JS_NULL_CLASS_EXT, |
168 | | &sInterfaceObjectClassObjectOps |
169 | | }, |
170 | | eInterface, |
171 | | true, |
172 | | prototypes::id::TransceiverImpl, |
173 | | PrototypeTraits<prototypes::id::TransceiverImpl>::Depth, |
174 | | sNativePropertyHooks, |
175 | | "function TransceiverImpl() {\n [native code]\n}", |
176 | | JS::GetRealmFunctionPrototype |
177 | | }; |
178 | | |
179 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
180 | | { |
181 | | "TransceiverImplPrototype", |
182 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
183 | | JS_NULL_CLASS_OPS, |
184 | | JS_NULL_CLASS_SPEC, |
185 | | JS_NULL_CLASS_EXT, |
186 | | JS_NULL_OBJECT_OPS |
187 | | }, |
188 | | eInterfacePrototype, |
189 | | false, |
190 | | prototypes::id::TransceiverImpl, |
191 | | PrototypeTraits<prototypes::id::TransceiverImpl>::Depth, |
192 | | sNativePropertyHooks, |
193 | | "[object TransceiverImplPrototype]", |
194 | | JS::GetRealmObjectPrototype |
195 | | }; |
196 | | |
197 | | bool |
198 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
199 | 0 | { |
200 | 0 | return nsContentUtils::ThreadsafeIsSystemCaller(aCx); |
201 | 0 | } |
202 | | |
203 | | static const js::ClassOps sClassOps = { |
204 | | nullptr, /* addProperty */ |
205 | | nullptr, /* delProperty */ |
206 | | nullptr, /* enumerate */ |
207 | | nullptr, /* newEnumerate */ |
208 | | nullptr, /* resolve */ |
209 | | nullptr, /* mayResolve */ |
210 | | _finalize, /* finalize */ |
211 | | nullptr, /* call */ |
212 | | nullptr, /* hasInstance */ |
213 | | nullptr, /* construct */ |
214 | | nullptr, /* trace */ |
215 | | }; |
216 | | |
217 | | static const js::ClassExtension sClassExtension = { |
218 | | nullptr, /* weakmapKeyDelegateOp */ |
219 | | nullptr /* objectMovedOp */ |
220 | | }; |
221 | | |
222 | | static const DOMJSClass sClass = { |
223 | | { "TransceiverImpl", |
224 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
225 | | &sClassOps, |
226 | | JS_NULL_CLASS_SPEC, |
227 | | &sClassExtension, |
228 | | JS_NULL_OBJECT_OPS |
229 | | }, |
230 | | { prototypes::id::TransceiverImpl, 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 }, |
231 | | IsBaseOf<nsISupports, mozilla::TransceiverImpl >::value, |
232 | | sNativePropertyHooks, |
233 | | FindAssociatedGlobalForNative<mozilla::TransceiverImpl>::Get, |
234 | | GetProtoObjectHandle, |
235 | | GetCCParticipant<mozilla::TransceiverImpl>::Get() |
236 | | }; |
237 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
238 | | "Must have the right minimal number of reserved slots."); |
239 | | static_assert(1 >= 1, |
240 | | "Must have enough reserved slots."); |
241 | | |
242 | | const JSClass* |
243 | | GetJSClass() |
244 | 0 | { |
245 | 0 | return sClass.ToJSClass(); |
246 | 0 | } |
247 | | |
248 | | bool |
249 | | Wrap(JSContext* aCx, mozilla::TransceiverImpl* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
250 | 0 | { |
251 | 0 | MOZ_ASSERT(static_cast<mozilla::TransceiverImpl*>(aObject) == |
252 | 0 | reinterpret_cast<mozilla::TransceiverImpl*>(aObject), |
253 | 0 | "Multiple inheritance for mozilla::TransceiverImpl is broken."); |
254 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
255 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
256 | 0 |
|
257 | 0 | JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx)); |
258 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
259 | 0 | if (!canonicalProto) { |
260 | 0 | return false; |
261 | 0 | } |
262 | 0 | JS::Rooted<JSObject*> proto(aCx); |
263 | 0 | if (aGivenProto) { |
264 | 0 | proto = aGivenProto; |
265 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
266 | 0 | // coming in, we changed compartments to that of "parent" so may need |
267 | 0 | // to wrap the proto here. |
268 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
269 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
270 | 0 | return false; |
271 | 0 | } |
272 | 0 | } |
273 | 0 | } else { |
274 | 0 | proto = canonicalProto; |
275 | 0 | } |
276 | 0 |
|
277 | 0 | BindingJSObjectCreator<mozilla::TransceiverImpl> creator(aCx); |
278 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
279 | 0 | if (!aReflector) { |
280 | 0 | return false; |
281 | 0 | } |
282 | 0 | |
283 | 0 | |
284 | 0 | |
285 | 0 | creator.InitializationSucceeded(); |
286 | 0 | return true; |
287 | 0 | } |
288 | | |
289 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
290 | | nullptr, |
291 | | nullptr, |
292 | | nullptr, |
293 | | { sNativeProperties.Upcast(), nullptr }, |
294 | | prototypes::id::TransceiverImpl, |
295 | | constructors::id::TransceiverImpl, |
296 | | nullptr, |
297 | | &DefaultXrayExpandoObjectClass |
298 | | } }; |
299 | | |
300 | | void |
301 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
302 | 0 | { |
303 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
304 | 0 | if (!parentProto) { |
305 | 0 | return; |
306 | 0 | } |
307 | 0 | |
308 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
309 | 0 | if (!constructorProto) { |
310 | 0 | return; |
311 | 0 | } |
312 | 0 | |
313 | 0 | static bool sIdsInited = false; |
314 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
315 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
316 | 0 | return; |
317 | 0 | } |
318 | 0 | sIdsInited = true; |
319 | 0 | } |
320 | 0 |
|
321 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TransceiverImpl); |
322 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TransceiverImpl); |
323 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
324 | 0 | &sPrototypeClass.mBase, protoCache, |
325 | 0 | nullptr, |
326 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
327 | 0 | interfaceCache, |
328 | 0 | sNativeProperties.Upcast(), |
329 | 0 | nullptr, |
330 | 0 | "TransceiverImpl", aDefineOnGlobal, |
331 | 0 | nullptr, |
332 | 0 | false); |
333 | 0 | } |
334 | | |
335 | | JSObject* |
336 | | GetConstructorObject(JSContext* aCx) |
337 | 0 | { |
338 | 0 | return GetConstructorObjectHandle(aCx); |
339 | 0 | } |
340 | | |
341 | | } // namespace TransceiverImpl_Binding |
342 | | |
343 | | |
344 | | |
345 | | } // namespace dom |
346 | | } // namespace mozilla |