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(SPEECH_SYNTHESIS)
24
25#include "JSSpeechSynthesisEvent.h"
26
27#include "JSDOMAttribute.h"
28#include "JSDOMBinding.h"
29#include "JSDOMConstructorNotConstructable.h"
30#include "JSDOMConvertNumbers.h"
31#include "JSDOMConvertStrings.h"
32#include "JSDOMExceptionHandling.h"
33#include "JSDOMWrapperCache.h"
34#include "ScriptExecutionContext.h"
35#include <JavaScriptCore/HeapSnapshotBuilder.h>
36#include <JavaScriptCore/JSCInlines.h>
37#include <wtf/GetPtr.h>
38#include <wtf/PointerPreparations.h>
39#include <wtf/URL.h>
40
41
42namespace WebCore {
43using namespace JSC;
44
45// Attributes
46
47JSC::EncodedJSValue jsSpeechSynthesisEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48bool setJSSpeechSynthesisEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
49JSC::EncodedJSValue jsSpeechSynthesisEventCharIndex(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50JSC::EncodedJSValue jsSpeechSynthesisEventElapsedTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51JSC::EncodedJSValue jsSpeechSynthesisEventName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52
53class JSSpeechSynthesisEventPrototype : public JSC::JSNonFinalObject {
54public:
55 using Base = JSC::JSNonFinalObject;
56 static JSSpeechSynthesisEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
57 {
58 JSSpeechSynthesisEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSSpeechSynthesisEventPrototype>(vm.heap)) JSSpeechSynthesisEventPrototype(vm, globalObject, structure);
59 ptr->finishCreation(vm);
60 return ptr;
61 }
62
63 DECLARE_INFO;
64 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
65 {
66 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
67 }
68
69private:
70 JSSpeechSynthesisEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
71 : JSC::JSNonFinalObject(vm, structure)
72 {
73 }
74
75 void finishCreation(JSC::VM&);
76};
77
78using JSSpeechSynthesisEventConstructor = JSDOMConstructorNotConstructable<JSSpeechSynthesisEvent>;
79
80template<> JSValue JSSpeechSynthesisEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
81{
82 return JSEvent::getConstructor(vm, &globalObject);
83}
84
85template<> void JSSpeechSynthesisEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
86{
87 putDirect(vm, vm.propertyNames->prototype, JSSpeechSynthesisEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
88 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SpeechSynthesisEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90}
91
92template<> const ClassInfo JSSpeechSynthesisEventConstructor::s_info = { "SpeechSynthesisEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSpeechSynthesisEventConstructor) };
93
94/* Hash table for prototype */
95
96static const HashTableValue JSSpeechSynthesisEventPrototypeTableValues[] =
97{
98 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisEventConstructor) } },
99 { "charIndex", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisEventCharIndex), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
100 { "elapsedTime", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisEventElapsedTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
101 { "name", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisEventName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
102};
103
104const ClassInfo JSSpeechSynthesisEventPrototype::s_info = { "SpeechSynthesisEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSpeechSynthesisEventPrototype) };
105
106void JSSpeechSynthesisEventPrototype::finishCreation(VM& vm)
107{
108 Base::finishCreation(vm);
109 reifyStaticProperties(vm, JSSpeechSynthesisEvent::info(), JSSpeechSynthesisEventPrototypeTableValues, *this);
110}
111
112const ClassInfo JSSpeechSynthesisEvent::s_info = { "SpeechSynthesisEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSpeechSynthesisEvent) };
113
114JSSpeechSynthesisEvent::JSSpeechSynthesisEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SpeechSynthesisEvent>&& impl)
115 : JSEvent(structure, globalObject, WTFMove(impl))
116{
117}
118
119void JSSpeechSynthesisEvent::finishCreation(VM& vm)
120{
121 Base::finishCreation(vm);
122 ASSERT(inherits(vm, info()));
123
124}
125
126JSObject* JSSpeechSynthesisEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
127{
128 return JSSpeechSynthesisEventPrototype::create(vm, &globalObject, JSSpeechSynthesisEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
129}
130
131JSObject* JSSpeechSynthesisEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
132{
133 return getDOMPrototype<JSSpeechSynthesisEvent>(vm, globalObject);
134}
135
136JSValue JSSpeechSynthesisEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
137{
138 return getDOMConstructor<JSSpeechSynthesisEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
139}
140
141template<> inline JSSpeechSynthesisEvent* IDLAttribute<JSSpeechSynthesisEvent>::cast(ExecState& state, EncodedJSValue thisValue)
142{
143 return jsDynamicCast<JSSpeechSynthesisEvent*>(state.vm(), JSValue::decode(thisValue));
144}
145
146EncodedJSValue jsSpeechSynthesisEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
147{
148 VM& vm = state->vm();
149 auto throwScope = DECLARE_THROW_SCOPE(vm);
150 auto* prototype = jsDynamicCast<JSSpeechSynthesisEventPrototype*>(vm, JSValue::decode(thisValue));
151 if (UNLIKELY(!prototype))
152 return throwVMTypeError(state, throwScope);
153 return JSValue::encode(JSSpeechSynthesisEvent::getConstructor(state->vm(), prototype->globalObject()));
154}
155
156bool setJSSpeechSynthesisEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
157{
158 VM& vm = state->vm();
159 auto throwScope = DECLARE_THROW_SCOPE(vm);
160 auto* prototype = jsDynamicCast<JSSpeechSynthesisEventPrototype*>(vm, JSValue::decode(thisValue));
161 if (UNLIKELY(!prototype)) {
162 throwVMTypeError(state, throwScope);
163 return false;
164 }
165 // Shadowing a built-in constructor
166 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
167}
168
169static inline JSValue jsSpeechSynthesisEventCharIndexGetter(ExecState& state, JSSpeechSynthesisEvent& thisObject, ThrowScope& throwScope)
170{
171 UNUSED_PARAM(throwScope);
172 UNUSED_PARAM(state);
173 auto& impl = thisObject.wrapped();
174 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.charIndex());
175 return result;
176}
177
178EncodedJSValue jsSpeechSynthesisEventCharIndex(ExecState* state, EncodedJSValue thisValue, PropertyName)
179{
180 return IDLAttribute<JSSpeechSynthesisEvent>::get<jsSpeechSynthesisEventCharIndexGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "charIndex");
181}
182
183static inline JSValue jsSpeechSynthesisEventElapsedTimeGetter(ExecState& state, JSSpeechSynthesisEvent& thisObject, ThrowScope& throwScope)
184{
185 UNUSED_PARAM(throwScope);
186 UNUSED_PARAM(state);
187 auto& impl = thisObject.wrapped();
188 JSValue result = toJS<IDLUnrestrictedFloat>(state, throwScope, impl.elapsedTime());
189 return result;
190}
191
192EncodedJSValue jsSpeechSynthesisEventElapsedTime(ExecState* state, EncodedJSValue thisValue, PropertyName)
193{
194 return IDLAttribute<JSSpeechSynthesisEvent>::get<jsSpeechSynthesisEventElapsedTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "elapsedTime");
195}
196
197static inline JSValue jsSpeechSynthesisEventNameGetter(ExecState& state, JSSpeechSynthesisEvent& thisObject, ThrowScope& throwScope)
198{
199 UNUSED_PARAM(throwScope);
200 UNUSED_PARAM(state);
201 auto& impl = thisObject.wrapped();
202 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.name());
203 return result;
204}
205
206EncodedJSValue jsSpeechSynthesisEventName(ExecState* state, EncodedJSValue thisValue, PropertyName)
207{
208 return IDLAttribute<JSSpeechSynthesisEvent>::get<jsSpeechSynthesisEventNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name");
209}
210
211void JSSpeechSynthesisEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
212{
213 auto* thisObject = jsCast<JSSpeechSynthesisEvent*>(cell);
214 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
215 if (thisObject->scriptExecutionContext())
216 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
217 Base::heapSnapshot(cell, builder);
218}
219
220
221}
222
223#endif // ENABLE(SPEECH_SYNTHESIS)
224