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