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 "JSRTCDataChannelEvent.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructor.h" |
30 | #include "JSDOMConvertBoolean.h" |
31 | #include "JSDOMConvertInterface.h" |
32 | #include "JSDOMExceptionHandling.h" |
33 | #include "JSDOMGlobalObject.h" |
34 | #include "JSDOMWrapperCache.h" |
35 | #include "JSRTCDataChannel.h" |
36 | #include "ScriptExecutionContext.h" |
37 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
38 | #include <JavaScriptCore/JSCInlines.h> |
39 | #include <wtf/GetPtr.h> |
40 | #include <wtf/PointerPreparations.h> |
41 | #include <wtf/URL.h> |
42 | |
43 | #if ENABLE(WEB_RTC) |
44 | #include "JSDOMConvertStrings.h" |
45 | #endif |
46 | |
47 | |
48 | namespace WebCore { |
49 | using namespace JSC; |
50 | |
51 | template<> RTCDataChannelEvent::Init convertDictionary<RTCDataChannelEvent::Init>(ExecState& state, JSValue value) |
52 | { |
53 | VM& vm = state.vm(); |
54 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
55 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
56 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
57 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
58 | throwTypeError(&state, throwScope); |
59 | return { }; |
60 | } |
61 | RTCDataChannelEvent::Init result; |
62 | JSValue bubblesValue; |
63 | if (isNullOrUndefined) |
64 | bubblesValue = jsUndefined(); |
65 | else { |
66 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles" )); |
67 | RETURN_IF_EXCEPTION(throwScope, { }); |
68 | } |
69 | if (!bubblesValue.isUndefined()) { |
70 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
71 | RETURN_IF_EXCEPTION(throwScope, { }); |
72 | } else |
73 | result.bubbles = false; |
74 | JSValue cancelableValue; |
75 | if (isNullOrUndefined) |
76 | cancelableValue = jsUndefined(); |
77 | else { |
78 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable" )); |
79 | RETURN_IF_EXCEPTION(throwScope, { }); |
80 | } |
81 | if (!cancelableValue.isUndefined()) { |
82 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
83 | RETURN_IF_EXCEPTION(throwScope, { }); |
84 | } else |
85 | result.cancelable = false; |
86 | JSValue composedValue; |
87 | if (isNullOrUndefined) |
88 | composedValue = jsUndefined(); |
89 | else { |
90 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
91 | RETURN_IF_EXCEPTION(throwScope, { }); |
92 | } |
93 | if (!composedValue.isUndefined()) { |
94 | result.composed = convert<IDLBoolean>(state, composedValue); |
95 | RETURN_IF_EXCEPTION(throwScope, { }); |
96 | } else |
97 | result.composed = false; |
98 | JSValue channelValue; |
99 | if (isNullOrUndefined) |
100 | channelValue = jsUndefined(); |
101 | else { |
102 | channelValue = object->get(&state, Identifier::fromString(&state, "channel" )); |
103 | RETURN_IF_EXCEPTION(throwScope, { }); |
104 | } |
105 | if (!channelValue.isUndefined()) { |
106 | result.channel = convert<IDLInterface<RTCDataChannel>>(state, channelValue); |
107 | RETURN_IF_EXCEPTION(throwScope, { }); |
108 | } else { |
109 | throwRequiredMemberTypeError(state, throwScope, "channel" , "RTCDataChannelEventInit" , "RTCDataChannel" ); |
110 | return { }; |
111 | } |
112 | return result; |
113 | } |
114 | |
115 | // Attributes |
116 | |
117 | JSC::EncodedJSValue jsRTCDataChannelEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
118 | bool setJSRTCDataChannelEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
119 | JSC::EncodedJSValue jsRTCDataChannelEventChannel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
120 | |
121 | class JSRTCDataChannelEventPrototype : public JSC::JSNonFinalObject { |
122 | public: |
123 | using Base = JSC::JSNonFinalObject; |
124 | static JSRTCDataChannelEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
125 | { |
126 | JSRTCDataChannelEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCDataChannelEventPrototype>(vm.heap)) JSRTCDataChannelEventPrototype(vm, globalObject, structure); |
127 | ptr->finishCreation(vm); |
128 | return ptr; |
129 | } |
130 | |
131 | DECLARE_INFO; |
132 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
133 | { |
134 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
135 | } |
136 | |
137 | private: |
138 | JSRTCDataChannelEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
139 | : JSC::JSNonFinalObject(vm, structure) |
140 | { |
141 | } |
142 | |
143 | void finishCreation(JSC::VM&); |
144 | }; |
145 | |
146 | using JSRTCDataChannelEventConstructor = JSDOMConstructor<JSRTCDataChannelEvent>; |
147 | |
148 | template<> EncodedJSValue JSC_HOST_CALL JSRTCDataChannelEventConstructor::construct(ExecState* state) |
149 | { |
150 | VM& vm = state->vm(); |
151 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
152 | UNUSED_PARAM(throwScope); |
153 | auto* castedThis = jsCast<JSRTCDataChannelEventConstructor*>(state->jsCallee()); |
154 | ASSERT(castedThis); |
155 | if (UNLIKELY(state->argumentCount() < 2)) |
156 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
157 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
158 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
159 | auto eventInitDict = convert<IDLDictionary<RTCDataChannelEvent::Init>>(*state, state->uncheckedArgument(1)); |
160 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
161 | auto object = RTCDataChannelEvent::create(WTFMove(type), WTFMove(eventInitDict)); |
162 | return JSValue::encode(toJSNewlyCreated<IDLInterface<RTCDataChannelEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
163 | } |
164 | |
165 | template<> JSValue JSRTCDataChannelEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
166 | { |
167 | return JSEvent::getConstructor(vm, &globalObject); |
168 | } |
169 | |
170 | template<> void JSRTCDataChannelEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
171 | { |
172 | putDirect(vm, vm.propertyNames->prototype, JSRTCDataChannelEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
173 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RTCDataChannelEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
174 | putDirect(vm, vm.propertyNames->length, jsNumber(2), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
175 | } |
176 | |
177 | template<> const ClassInfo JSRTCDataChannelEventConstructor::s_info = { "RTCDataChannelEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCDataChannelEventConstructor) }; |
178 | |
179 | /* Hash table for prototype */ |
180 | |
181 | static const HashTableValue JSRTCDataChannelEventPrototypeTableValues[] = |
182 | { |
183 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelEventConstructor) } }, |
184 | { "channel" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelEventChannel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
185 | }; |
186 | |
187 | const ClassInfo JSRTCDataChannelEventPrototype::s_info = { "RTCDataChannelEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCDataChannelEventPrototype) }; |
188 | |
189 | void JSRTCDataChannelEventPrototype::finishCreation(VM& vm) |
190 | { |
191 | Base::finishCreation(vm); |
192 | reifyStaticProperties(vm, JSRTCDataChannelEvent::info(), JSRTCDataChannelEventPrototypeTableValues, *this); |
193 | } |
194 | |
195 | const ClassInfo JSRTCDataChannelEvent::s_info = { "RTCDataChannelEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCDataChannelEvent) }; |
196 | |
197 | JSRTCDataChannelEvent::JSRTCDataChannelEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCDataChannelEvent>&& impl) |
198 | : JSEvent(structure, globalObject, WTFMove(impl)) |
199 | { |
200 | } |
201 | |
202 | void JSRTCDataChannelEvent::finishCreation(VM& vm) |
203 | { |
204 | Base::finishCreation(vm); |
205 | ASSERT(inherits(vm, info())); |
206 | |
207 | } |
208 | |
209 | JSObject* JSRTCDataChannelEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
210 | { |
211 | return JSRTCDataChannelEventPrototype::create(vm, &globalObject, JSRTCDataChannelEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
212 | } |
213 | |
214 | JSObject* JSRTCDataChannelEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
215 | { |
216 | return getDOMPrototype<JSRTCDataChannelEvent>(vm, globalObject); |
217 | } |
218 | |
219 | JSValue JSRTCDataChannelEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
220 | { |
221 | return getDOMConstructor<JSRTCDataChannelEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
222 | } |
223 | |
224 | template<> inline JSRTCDataChannelEvent* IDLAttribute<JSRTCDataChannelEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
225 | { |
226 | return jsDynamicCast<JSRTCDataChannelEvent*>(state.vm(), JSValue::decode(thisValue)); |
227 | } |
228 | |
229 | EncodedJSValue jsRTCDataChannelEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
230 | { |
231 | VM& vm = state->vm(); |
232 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
233 | auto* prototype = jsDynamicCast<JSRTCDataChannelEventPrototype*>(vm, JSValue::decode(thisValue)); |
234 | if (UNLIKELY(!prototype)) |
235 | return throwVMTypeError(state, throwScope); |
236 | return JSValue::encode(JSRTCDataChannelEvent::getConstructor(state->vm(), prototype->globalObject())); |
237 | } |
238 | |
239 | bool setJSRTCDataChannelEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
240 | { |
241 | VM& vm = state->vm(); |
242 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
243 | auto* prototype = jsDynamicCast<JSRTCDataChannelEventPrototype*>(vm, JSValue::decode(thisValue)); |
244 | if (UNLIKELY(!prototype)) { |
245 | throwVMTypeError(state, throwScope); |
246 | return false; |
247 | } |
248 | // Shadowing a built-in constructor |
249 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
250 | } |
251 | |
252 | static inline JSValue jsRTCDataChannelEventChannelGetter(ExecState& state, JSRTCDataChannelEvent& thisObject, ThrowScope& throwScope) |
253 | { |
254 | UNUSED_PARAM(throwScope); |
255 | UNUSED_PARAM(state); |
256 | auto& impl = thisObject.wrapped(); |
257 | JSValue result = toJS<IDLInterface<RTCDataChannel>>(state, *thisObject.globalObject(), throwScope, impl.channel()); |
258 | return result; |
259 | } |
260 | |
261 | EncodedJSValue jsRTCDataChannelEventChannel(ExecState* state, EncodedJSValue thisValue, PropertyName) |
262 | { |
263 | return IDLAttribute<JSRTCDataChannelEvent>::get<jsRTCDataChannelEventChannelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "channel" ); |
264 | } |
265 | |
266 | void JSRTCDataChannelEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
267 | { |
268 | auto* thisObject = jsCast<JSRTCDataChannelEvent*>(cell); |
269 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
270 | if (thisObject->scriptExecutionContext()) |
271 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
272 | Base::heapSnapshot(cell, builder); |
273 | } |
274 | |
275 | #if ENABLE(BINDING_INTEGRITY) |
276 | #if PLATFORM(WIN) |
277 | #pragma warning(disable: 4483) |
278 | extern "C" { extern void (*const __identifier("??_7RTCDataChannelEvent@WebCore@@6B@" )[])(); } |
279 | #else |
280 | extern "C" { extern void* _ZTVN7WebCore19RTCDataChannelEventE[]; } |
281 | #endif |
282 | #endif |
283 | |
284 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCDataChannelEvent>&& impl) |
285 | { |
286 | |
287 | #if ENABLE(BINDING_INTEGRITY) |
288 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
289 | #if PLATFORM(WIN) |
290 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7RTCDataChannelEvent@WebCore@@6B@" )); |
291 | #else |
292 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore19RTCDataChannelEventE[2]); |
293 | #endif |
294 | |
295 | // If this fails RTCDataChannelEvent does not have a vtable, so you need to add the |
296 | // ImplementationLacksVTable attribute to the interface definition |
297 | static_assert(std::is_polymorphic<RTCDataChannelEvent>::value, "RTCDataChannelEvent is not polymorphic" ); |
298 | |
299 | // If you hit this assertion you either have a use after free bug, or |
300 | // RTCDataChannelEvent has subclasses. If RTCDataChannelEvent has subclasses that get passed |
301 | // to toJS() we currently require RTCDataChannelEvent you to opt out of binding hardening |
302 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
303 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
304 | #endif |
305 | return createWrapper<RTCDataChannelEvent>(globalObject, WTFMove(impl)); |
306 | } |
307 | |
308 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCDataChannelEvent& impl) |
309 | { |
310 | return wrap(state, globalObject, impl); |
311 | } |
312 | |
313 | |
314 | } |
315 | |
316 | #endif // ENABLE(WEB_RTC) |
317 | |