1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | |
23 | #if ENABLE(WEB_RTC) |
24 | |
25 | #include "JSRTCPeerConnectionIceEvent.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructor.h" |
30 | #include "JSDOMConvertBoolean.h" |
31 | #include "JSDOMConvertInterface.h" |
32 | #include "JSDOMConvertNullable.h" |
33 | #include "JSDOMConvertStrings.h" |
34 | #include "JSDOMExceptionHandling.h" |
35 | #include "JSDOMGlobalObject.h" |
36 | #include "JSDOMWrapperCache.h" |
37 | #include "JSRTCIceCandidate.h" |
38 | #include "ScriptExecutionContext.h" |
39 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
40 | #include <JavaScriptCore/JSCInlines.h> |
41 | #include <wtf/GetPtr.h> |
42 | #include <wtf/PointerPreparations.h> |
43 | #include <wtf/URL.h> |
44 | |
45 | |
46 | namespace WebCore { |
47 | using namespace JSC; |
48 | |
49 | template<> RTCPeerConnectionIceEvent::Init convertDictionary<RTCPeerConnectionIceEvent::Init>(ExecState& state, JSValue value) |
50 | { |
51 | VM& vm = state.vm(); |
52 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
53 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
54 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
55 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
56 | throwTypeError(&state, throwScope); |
57 | return { }; |
58 | } |
59 | RTCPeerConnectionIceEvent::Init result; |
60 | JSValue bubblesValue; |
61 | if (isNullOrUndefined) |
62 | bubblesValue = jsUndefined(); |
63 | else { |
64 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles" )); |
65 | RETURN_IF_EXCEPTION(throwScope, { }); |
66 | } |
67 | if (!bubblesValue.isUndefined()) { |
68 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
69 | RETURN_IF_EXCEPTION(throwScope, { }); |
70 | } else |
71 | result.bubbles = false; |
72 | JSValue cancelableValue; |
73 | if (isNullOrUndefined) |
74 | cancelableValue = jsUndefined(); |
75 | else { |
76 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable" )); |
77 | RETURN_IF_EXCEPTION(throwScope, { }); |
78 | } |
79 | if (!cancelableValue.isUndefined()) { |
80 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
81 | RETURN_IF_EXCEPTION(throwScope, { }); |
82 | } else |
83 | result.cancelable = false; |
84 | JSValue composedValue; |
85 | if (isNullOrUndefined) |
86 | composedValue = jsUndefined(); |
87 | else { |
88 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
89 | RETURN_IF_EXCEPTION(throwScope, { }); |
90 | } |
91 | if (!composedValue.isUndefined()) { |
92 | result.composed = convert<IDLBoolean>(state, composedValue); |
93 | RETURN_IF_EXCEPTION(throwScope, { }); |
94 | } else |
95 | result.composed = false; |
96 | JSValue candidateValue; |
97 | if (isNullOrUndefined) |
98 | candidateValue = jsUndefined(); |
99 | else { |
100 | candidateValue = object->get(&state, Identifier::fromString(&state, "candidate" )); |
101 | RETURN_IF_EXCEPTION(throwScope, { }); |
102 | } |
103 | if (!candidateValue.isUndefined()) { |
104 | result.candidate = convert<IDLNullable<IDLInterface<RTCIceCandidate>>>(state, candidateValue); |
105 | RETURN_IF_EXCEPTION(throwScope, { }); |
106 | } |
107 | JSValue urlValue; |
108 | if (isNullOrUndefined) |
109 | urlValue = jsUndefined(); |
110 | else { |
111 | urlValue = object->get(&state, Identifier::fromString(&state, "url" )); |
112 | RETURN_IF_EXCEPTION(throwScope, { }); |
113 | } |
114 | if (!urlValue.isUndefined()) { |
115 | result.url = convert<IDLNullable<IDLDOMString>>(state, urlValue); |
116 | RETURN_IF_EXCEPTION(throwScope, { }); |
117 | } |
118 | return result; |
119 | } |
120 | |
121 | // Attributes |
122 | |
123 | JSC::EncodedJSValue jsRTCPeerConnectionIceEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
124 | bool setJSRTCPeerConnectionIceEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
125 | JSC::EncodedJSValue jsRTCPeerConnectionIceEventCandidate(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
126 | JSC::EncodedJSValue jsRTCPeerConnectionIceEventUrl(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
127 | |
128 | class JSRTCPeerConnectionIceEventPrototype : public JSC::JSNonFinalObject { |
129 | public: |
130 | using Base = JSC::JSNonFinalObject; |
131 | static JSRTCPeerConnectionIceEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
132 | { |
133 | JSRTCPeerConnectionIceEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCPeerConnectionIceEventPrototype>(vm.heap)) JSRTCPeerConnectionIceEventPrototype(vm, globalObject, structure); |
134 | ptr->finishCreation(vm); |
135 | return ptr; |
136 | } |
137 | |
138 | DECLARE_INFO; |
139 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
140 | { |
141 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
142 | } |
143 | |
144 | private: |
145 | JSRTCPeerConnectionIceEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
146 | : JSC::JSNonFinalObject(vm, structure) |
147 | { |
148 | } |
149 | |
150 | void finishCreation(JSC::VM&); |
151 | }; |
152 | |
153 | using JSRTCPeerConnectionIceEventConstructor = JSDOMConstructor<JSRTCPeerConnectionIceEvent>; |
154 | |
155 | template<> EncodedJSValue JSC_HOST_CALL JSRTCPeerConnectionIceEventConstructor::construct(ExecState* state) |
156 | { |
157 | VM& vm = state->vm(); |
158 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
159 | UNUSED_PARAM(throwScope); |
160 | auto* castedThis = jsCast<JSRTCPeerConnectionIceEventConstructor*>(state->jsCallee()); |
161 | ASSERT(castedThis); |
162 | if (UNLIKELY(state->argumentCount() < 1)) |
163 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
164 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
165 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
166 | auto eventInitDict = convert<IDLDictionary<RTCPeerConnectionIceEvent::Init>>(*state, state->argument(1)); |
167 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
168 | auto object = RTCPeerConnectionIceEvent::create(WTFMove(type), WTFMove(eventInitDict)); |
169 | return JSValue::encode(toJSNewlyCreated<IDLInterface<RTCPeerConnectionIceEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
170 | } |
171 | |
172 | template<> JSValue JSRTCPeerConnectionIceEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
173 | { |
174 | return JSEvent::getConstructor(vm, &globalObject); |
175 | } |
176 | |
177 | template<> void JSRTCPeerConnectionIceEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
178 | { |
179 | putDirect(vm, vm.propertyNames->prototype, JSRTCPeerConnectionIceEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
180 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RTCPeerConnectionIceEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
181 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
182 | } |
183 | |
184 | template<> const ClassInfo JSRTCPeerConnectionIceEventConstructor::s_info = { "RTCPeerConnectionIceEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCPeerConnectionIceEventConstructor) }; |
185 | |
186 | /* Hash table for prototype */ |
187 | |
188 | static const HashTableValue JSRTCPeerConnectionIceEventPrototypeTableValues[] = |
189 | { |
190 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionIceEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCPeerConnectionIceEventConstructor) } }, |
191 | { "candidate" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionIceEventCandidate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
192 | { "url" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCPeerConnectionIceEventUrl), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
193 | }; |
194 | |
195 | const ClassInfo JSRTCPeerConnectionIceEventPrototype::s_info = { "RTCPeerConnectionIceEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCPeerConnectionIceEventPrototype) }; |
196 | |
197 | void JSRTCPeerConnectionIceEventPrototype::finishCreation(VM& vm) |
198 | { |
199 | Base::finishCreation(vm); |
200 | reifyStaticProperties(vm, JSRTCPeerConnectionIceEvent::info(), JSRTCPeerConnectionIceEventPrototypeTableValues, *this); |
201 | } |
202 | |
203 | const ClassInfo JSRTCPeerConnectionIceEvent::s_info = { "RTCPeerConnectionIceEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCPeerConnectionIceEvent) }; |
204 | |
205 | JSRTCPeerConnectionIceEvent::JSRTCPeerConnectionIceEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCPeerConnectionIceEvent>&& impl) |
206 | : JSEvent(structure, globalObject, WTFMove(impl)) |
207 | { |
208 | } |
209 | |
210 | void JSRTCPeerConnectionIceEvent::finishCreation(VM& vm) |
211 | { |
212 | Base::finishCreation(vm); |
213 | ASSERT(inherits(vm, info())); |
214 | |
215 | } |
216 | |
217 | JSObject* JSRTCPeerConnectionIceEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
218 | { |
219 | return JSRTCPeerConnectionIceEventPrototype::create(vm, &globalObject, JSRTCPeerConnectionIceEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
220 | } |
221 | |
222 | JSObject* JSRTCPeerConnectionIceEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
223 | { |
224 | return getDOMPrototype<JSRTCPeerConnectionIceEvent>(vm, globalObject); |
225 | } |
226 | |
227 | JSValue JSRTCPeerConnectionIceEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
228 | { |
229 | return getDOMConstructor<JSRTCPeerConnectionIceEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
230 | } |
231 | |
232 | template<> inline JSRTCPeerConnectionIceEvent* IDLAttribute<JSRTCPeerConnectionIceEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
233 | { |
234 | return jsDynamicCast<JSRTCPeerConnectionIceEvent*>(state.vm(), JSValue::decode(thisValue)); |
235 | } |
236 | |
237 | EncodedJSValue jsRTCPeerConnectionIceEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
238 | { |
239 | VM& vm = state->vm(); |
240 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
241 | auto* prototype = jsDynamicCast<JSRTCPeerConnectionIceEventPrototype*>(vm, JSValue::decode(thisValue)); |
242 | if (UNLIKELY(!prototype)) |
243 | return throwVMTypeError(state, throwScope); |
244 | return JSValue::encode(JSRTCPeerConnectionIceEvent::getConstructor(state->vm(), prototype->globalObject())); |
245 | } |
246 | |
247 | bool setJSRTCPeerConnectionIceEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
248 | { |
249 | VM& vm = state->vm(); |
250 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
251 | auto* prototype = jsDynamicCast<JSRTCPeerConnectionIceEventPrototype*>(vm, JSValue::decode(thisValue)); |
252 | if (UNLIKELY(!prototype)) { |
253 | throwVMTypeError(state, throwScope); |
254 | return false; |
255 | } |
256 | // Shadowing a built-in constructor |
257 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
258 | } |
259 | |
260 | static inline JSValue jsRTCPeerConnectionIceEventCandidateGetter(ExecState& state, JSRTCPeerConnectionIceEvent& thisObject, ThrowScope& throwScope) |
261 | { |
262 | UNUSED_PARAM(throwScope); |
263 | UNUSED_PARAM(state); |
264 | auto& impl = thisObject.wrapped(); |
265 | JSValue result = toJS<IDLNullable<IDLInterface<RTCIceCandidate>>>(state, *thisObject.globalObject(), throwScope, impl.candidate()); |
266 | return result; |
267 | } |
268 | |
269 | EncodedJSValue jsRTCPeerConnectionIceEventCandidate(ExecState* state, EncodedJSValue thisValue, PropertyName) |
270 | { |
271 | return IDLAttribute<JSRTCPeerConnectionIceEvent>::get<jsRTCPeerConnectionIceEventCandidateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "candidate" ); |
272 | } |
273 | |
274 | static inline JSValue jsRTCPeerConnectionIceEventUrlGetter(ExecState& state, JSRTCPeerConnectionIceEvent& thisObject, ThrowScope& throwScope) |
275 | { |
276 | UNUSED_PARAM(throwScope); |
277 | UNUSED_PARAM(state); |
278 | auto& impl = thisObject.wrapped(); |
279 | JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.url()); |
280 | return result; |
281 | } |
282 | |
283 | EncodedJSValue jsRTCPeerConnectionIceEventUrl(ExecState* state, EncodedJSValue thisValue, PropertyName) |
284 | { |
285 | return IDLAttribute<JSRTCPeerConnectionIceEvent>::get<jsRTCPeerConnectionIceEventUrlGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "url" ); |
286 | } |
287 | |
288 | void JSRTCPeerConnectionIceEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
289 | { |
290 | auto* thisObject = jsCast<JSRTCPeerConnectionIceEvent*>(cell); |
291 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
292 | if (thisObject->scriptExecutionContext()) |
293 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
294 | Base::heapSnapshot(cell, builder); |
295 | } |
296 | |
297 | #if ENABLE(BINDING_INTEGRITY) |
298 | #if PLATFORM(WIN) |
299 | #pragma warning(disable: 4483) |
300 | extern "C" { extern void (*const __identifier("??_7RTCPeerConnectionIceEvent@WebCore@@6B@" )[])(); } |
301 | #else |
302 | extern "C" { extern void* _ZTVN7WebCore25RTCPeerConnectionIceEventE[]; } |
303 | #endif |
304 | #endif |
305 | |
306 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCPeerConnectionIceEvent>&& impl) |
307 | { |
308 | |
309 | #if ENABLE(BINDING_INTEGRITY) |
310 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
311 | #if PLATFORM(WIN) |
312 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7RTCPeerConnectionIceEvent@WebCore@@6B@" )); |
313 | #else |
314 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore25RTCPeerConnectionIceEventE[2]); |
315 | #endif |
316 | |
317 | // If this fails RTCPeerConnectionIceEvent does not have a vtable, so you need to add the |
318 | // ImplementationLacksVTable attribute to the interface definition |
319 | static_assert(std::is_polymorphic<RTCPeerConnectionIceEvent>::value, "RTCPeerConnectionIceEvent is not polymorphic" ); |
320 | |
321 | // If you hit this assertion you either have a use after free bug, or |
322 | // RTCPeerConnectionIceEvent has subclasses. If RTCPeerConnectionIceEvent has subclasses that get passed |
323 | // to toJS() we currently require RTCPeerConnectionIceEvent you to opt out of binding hardening |
324 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
325 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
326 | #endif |
327 | return createWrapper<RTCPeerConnectionIceEvent>(globalObject, WTFMove(impl)); |
328 | } |
329 | |
330 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCPeerConnectionIceEvent& impl) |
331 | { |
332 | return wrap(state, globalObject, impl); |
333 | } |
334 | |
335 | |
336 | } |
337 | |
338 | #endif // ENABLE(WEB_RTC) |
339 | |