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_AUDIO)
24
25#include "JSAudioProcessingEvent.h"
26
27#include "JSAudioBuffer.h"
28#include "JSDOMAttribute.h"
29#include "JSDOMBinding.h"
30#include "JSDOMConstructorNotConstructable.h"
31#include "JSDOMConvertInterface.h"
32#include "JSDOMConvertNumbers.h"
33#include "JSDOMExceptionHandling.h"
34#include "JSDOMGlobalObject.h"
35#include "JSDOMWrapperCache.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
44namespace WebCore {
45using namespace JSC;
46
47// Attributes
48
49JSC::EncodedJSValue jsAudioProcessingEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSAudioProcessingEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51JSC::EncodedJSValue jsAudioProcessingEventPlaybackTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52JSC::EncodedJSValue jsAudioProcessingEventInputBuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53JSC::EncodedJSValue jsAudioProcessingEventOutputBuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54
55class JSAudioProcessingEventPrototype : public JSC::JSNonFinalObject {
56public:
57 using Base = JSC::JSNonFinalObject;
58 static JSAudioProcessingEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
59 {
60 JSAudioProcessingEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSAudioProcessingEventPrototype>(vm.heap)) JSAudioProcessingEventPrototype(vm, globalObject, structure);
61 ptr->finishCreation(vm);
62 return ptr;
63 }
64
65 DECLARE_INFO;
66 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
67 {
68 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
69 }
70
71private:
72 JSAudioProcessingEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
73 : JSC::JSNonFinalObject(vm, structure)
74 {
75 }
76
77 void finishCreation(JSC::VM&);
78};
79
80using JSAudioProcessingEventConstructor = JSDOMConstructorNotConstructable<JSAudioProcessingEvent>;
81
82template<> JSValue JSAudioProcessingEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
83{
84 return JSEvent::getConstructor(vm, &globalObject);
85}
86
87template<> void JSAudioProcessingEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
88{
89 putDirect(vm, vm.propertyNames->prototype, JSAudioProcessingEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("AudioProcessingEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
91 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
92}
93
94template<> const ClassInfo JSAudioProcessingEventConstructor::s_info = { "AudioProcessingEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAudioProcessingEventConstructor) };
95
96/* Hash table for prototype */
97
98static const HashTableValue JSAudioProcessingEventPrototypeTableValues[] =
99{
100 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioProcessingEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAudioProcessingEventConstructor) } },
101 { "playbackTime", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioProcessingEventPlaybackTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
102 { "inputBuffer", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioProcessingEventInputBuffer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
103 { "outputBuffer", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioProcessingEventOutputBuffer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
104};
105
106const ClassInfo JSAudioProcessingEventPrototype::s_info = { "AudioProcessingEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAudioProcessingEventPrototype) };
107
108void JSAudioProcessingEventPrototype::finishCreation(VM& vm)
109{
110 Base::finishCreation(vm);
111 reifyStaticProperties(vm, JSAudioProcessingEvent::info(), JSAudioProcessingEventPrototypeTableValues, *this);
112}
113
114const ClassInfo JSAudioProcessingEvent::s_info = { "AudioProcessingEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAudioProcessingEvent) };
115
116JSAudioProcessingEvent::JSAudioProcessingEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<AudioProcessingEvent>&& impl)
117 : JSEvent(structure, globalObject, WTFMove(impl))
118{
119}
120
121void JSAudioProcessingEvent::finishCreation(VM& vm)
122{
123 Base::finishCreation(vm);
124 ASSERT(inherits(vm, info()));
125
126}
127
128JSObject* JSAudioProcessingEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
129{
130 return JSAudioProcessingEventPrototype::create(vm, &globalObject, JSAudioProcessingEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
131}
132
133JSObject* JSAudioProcessingEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
134{
135 return getDOMPrototype<JSAudioProcessingEvent>(vm, globalObject);
136}
137
138JSValue JSAudioProcessingEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
139{
140 return getDOMConstructor<JSAudioProcessingEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
141}
142
143template<> inline JSAudioProcessingEvent* IDLAttribute<JSAudioProcessingEvent>::cast(ExecState& state, EncodedJSValue thisValue)
144{
145 return jsDynamicCast<JSAudioProcessingEvent*>(state.vm(), JSValue::decode(thisValue));
146}
147
148EncodedJSValue jsAudioProcessingEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
149{
150 VM& vm = state->vm();
151 auto throwScope = DECLARE_THROW_SCOPE(vm);
152 auto* prototype = jsDynamicCast<JSAudioProcessingEventPrototype*>(vm, JSValue::decode(thisValue));
153 if (UNLIKELY(!prototype))
154 return throwVMTypeError(state, throwScope);
155 return JSValue::encode(JSAudioProcessingEvent::getConstructor(state->vm(), prototype->globalObject()));
156}
157
158bool setJSAudioProcessingEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
159{
160 VM& vm = state->vm();
161 auto throwScope = DECLARE_THROW_SCOPE(vm);
162 auto* prototype = jsDynamicCast<JSAudioProcessingEventPrototype*>(vm, JSValue::decode(thisValue));
163 if (UNLIKELY(!prototype)) {
164 throwVMTypeError(state, throwScope);
165 return false;
166 }
167 // Shadowing a built-in constructor
168 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
169}
170
171static inline JSValue jsAudioProcessingEventPlaybackTimeGetter(ExecState& state, JSAudioProcessingEvent& thisObject, ThrowScope& throwScope)
172{
173 UNUSED_PARAM(throwScope);
174 UNUSED_PARAM(state);
175 auto& impl = thisObject.wrapped();
176 JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.playbackTime());
177 return result;
178}
179
180EncodedJSValue jsAudioProcessingEventPlaybackTime(ExecState* state, EncodedJSValue thisValue, PropertyName)
181{
182 return IDLAttribute<JSAudioProcessingEvent>::get<jsAudioProcessingEventPlaybackTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "playbackTime");
183}
184
185static inline JSValue jsAudioProcessingEventInputBufferGetter(ExecState& state, JSAudioProcessingEvent& thisObject, ThrowScope& throwScope)
186{
187 UNUSED_PARAM(throwScope);
188 UNUSED_PARAM(state);
189 auto& impl = thisObject.wrapped();
190 JSValue result = toJS<IDLInterface<AudioBuffer>>(state, *thisObject.globalObject(), throwScope, impl.inputBuffer());
191 return result;
192}
193
194EncodedJSValue jsAudioProcessingEventInputBuffer(ExecState* state, EncodedJSValue thisValue, PropertyName)
195{
196 return IDLAttribute<JSAudioProcessingEvent>::get<jsAudioProcessingEventInputBufferGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "inputBuffer");
197}
198
199static inline JSValue jsAudioProcessingEventOutputBufferGetter(ExecState& state, JSAudioProcessingEvent& thisObject, ThrowScope& throwScope)
200{
201 UNUSED_PARAM(throwScope);
202 UNUSED_PARAM(state);
203 auto& impl = thisObject.wrapped();
204 JSValue result = toJS<IDLInterface<AudioBuffer>>(state, *thisObject.globalObject(), throwScope, impl.outputBuffer());
205 return result;
206}
207
208EncodedJSValue jsAudioProcessingEventOutputBuffer(ExecState* state, EncodedJSValue thisValue, PropertyName)
209{
210 return IDLAttribute<JSAudioProcessingEvent>::get<jsAudioProcessingEventOutputBufferGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "outputBuffer");
211}
212
213void JSAudioProcessingEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
214{
215 auto* thisObject = jsCast<JSAudioProcessingEvent*>(cell);
216 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
217 if (thisObject->scriptExecutionContext())
218 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
219 Base::heapSnapshot(cell, builder);
220}
221
222#if ENABLE(BINDING_INTEGRITY)
223#if PLATFORM(WIN)
224#pragma warning(disable: 4483)
225extern "C" { extern void (*const __identifier("??_7AudioProcessingEvent@WebCore@@6B@")[])(); }
226#else
227extern "C" { extern void* _ZTVN7WebCore20AudioProcessingEventE[]; }
228#endif
229#endif
230
231JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<AudioProcessingEvent>&& impl)
232{
233
234#if ENABLE(BINDING_INTEGRITY)
235 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
236#if PLATFORM(WIN)
237 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7AudioProcessingEvent@WebCore@@6B@"));
238#else
239 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore20AudioProcessingEventE[2]);
240#endif
241
242 // If this fails AudioProcessingEvent does not have a vtable, so you need to add the
243 // ImplementationLacksVTable attribute to the interface definition
244 static_assert(std::is_polymorphic<AudioProcessingEvent>::value, "AudioProcessingEvent is not polymorphic");
245
246 // If you hit this assertion you either have a use after free bug, or
247 // AudioProcessingEvent has subclasses. If AudioProcessingEvent has subclasses that get passed
248 // to toJS() we currently require AudioProcessingEvent you to opt out of binding hardening
249 // by adding the SkipVTableValidation attribute to the interface IDL definition
250 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
251#endif
252 return createWrapper<AudioProcessingEvent>(globalObject, WTFMove(impl));
253}
254
255JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, AudioProcessingEvent& impl)
256{
257 return wrap(state, globalObject, impl);
258}
259
260
261}
262
263#endif // ENABLE(WEB_AUDIO)
264