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 "JSSpeechSynthesisVoice.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConvertBoolean.h" |
30 | #include "JSDOMConvertStrings.h" |
31 | #include "JSDOMExceptionHandling.h" |
32 | #include "JSDOMWrapperCache.h" |
33 | #include "ScriptExecutionContext.h" |
34 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
35 | #include <JavaScriptCore/JSCInlines.h> |
36 | #include <wtf/GetPtr.h> |
37 | #include <wtf/PointerPreparations.h> |
38 | #include <wtf/URL.h> |
39 | |
40 | |
41 | namespace WebCore { |
42 | using namespace JSC; |
43 | |
44 | // Attributes |
45 | |
46 | JSC::EncodedJSValue jsSpeechSynthesisVoiceVoiceURI(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
47 | JSC::EncodedJSValue jsSpeechSynthesisVoiceName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
48 | JSC::EncodedJSValue jsSpeechSynthesisVoiceLang(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
49 | JSC::EncodedJSValue jsSpeechSynthesisVoiceLocalService(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
50 | JSC::EncodedJSValue jsSpeechSynthesisVoiceDefault(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
51 | |
52 | class JSSpeechSynthesisVoicePrototype : public JSC::JSNonFinalObject { |
53 | public: |
54 | using Base = JSC::JSNonFinalObject; |
55 | static JSSpeechSynthesisVoicePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
56 | { |
57 | JSSpeechSynthesisVoicePrototype* ptr = new (NotNull, JSC::allocateCell<JSSpeechSynthesisVoicePrototype>(vm.heap)) JSSpeechSynthesisVoicePrototype(vm, globalObject, structure); |
58 | ptr->finishCreation(vm); |
59 | return ptr; |
60 | } |
61 | |
62 | DECLARE_INFO; |
63 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
64 | { |
65 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
66 | } |
67 | |
68 | private: |
69 | JSSpeechSynthesisVoicePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
70 | : JSC::JSNonFinalObject(vm, structure) |
71 | { |
72 | } |
73 | |
74 | void finishCreation(JSC::VM&); |
75 | }; |
76 | |
77 | /* Hash table for prototype */ |
78 | |
79 | static const HashTableValue JSSpeechSynthesisVoicePrototypeTableValues[] = |
80 | { |
81 | { "voiceURI" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceVoiceURI), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
82 | { "name" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
83 | { "lang" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceLang), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
84 | { "localService" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceLocalService), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
85 | { "default" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceDefault), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
86 | }; |
87 | |
88 | const ClassInfo JSSpeechSynthesisVoicePrototype::s_info = { "SpeechSynthesisVoicePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSpeechSynthesisVoicePrototype) }; |
89 | |
90 | void JSSpeechSynthesisVoicePrototype::finishCreation(VM& vm) |
91 | { |
92 | Base::finishCreation(vm); |
93 | reifyStaticProperties(vm, JSSpeechSynthesisVoice::info(), JSSpeechSynthesisVoicePrototypeTableValues, *this); |
94 | } |
95 | |
96 | const ClassInfo JSSpeechSynthesisVoice::s_info = { "SpeechSynthesisVoice" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSpeechSynthesisVoice) }; |
97 | |
98 | JSSpeechSynthesisVoice::JSSpeechSynthesisVoice(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SpeechSynthesisVoice>&& impl) |
99 | : JSDOMWrapper<SpeechSynthesisVoice>(structure, globalObject, WTFMove(impl)) |
100 | { |
101 | } |
102 | |
103 | void JSSpeechSynthesisVoice::finishCreation(VM& vm) |
104 | { |
105 | Base::finishCreation(vm); |
106 | ASSERT(inherits(vm, info())); |
107 | |
108 | } |
109 | |
110 | JSObject* JSSpeechSynthesisVoice::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
111 | { |
112 | return JSSpeechSynthesisVoicePrototype::create(vm, &globalObject, JSSpeechSynthesisVoicePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
113 | } |
114 | |
115 | JSObject* JSSpeechSynthesisVoice::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
116 | { |
117 | return getDOMPrototype<JSSpeechSynthesisVoice>(vm, globalObject); |
118 | } |
119 | |
120 | void JSSpeechSynthesisVoice::destroy(JSC::JSCell* cell) |
121 | { |
122 | JSSpeechSynthesisVoice* thisObject = static_cast<JSSpeechSynthesisVoice*>(cell); |
123 | thisObject->JSSpeechSynthesisVoice::~JSSpeechSynthesisVoice(); |
124 | } |
125 | |
126 | template<> inline JSSpeechSynthesisVoice* IDLAttribute<JSSpeechSynthesisVoice>::cast(ExecState& state, EncodedJSValue thisValue) |
127 | { |
128 | return jsDynamicCast<JSSpeechSynthesisVoice*>(state.vm(), JSValue::decode(thisValue)); |
129 | } |
130 | |
131 | static inline JSValue jsSpeechSynthesisVoiceVoiceURIGetter(ExecState& state, JSSpeechSynthesisVoice& thisObject, ThrowScope& throwScope) |
132 | { |
133 | UNUSED_PARAM(throwScope); |
134 | UNUSED_PARAM(state); |
135 | auto& impl = thisObject.wrapped(); |
136 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.voiceURI()); |
137 | return result; |
138 | } |
139 | |
140 | EncodedJSValue jsSpeechSynthesisVoiceVoiceURI(ExecState* state, EncodedJSValue thisValue, PropertyName) |
141 | { |
142 | return IDLAttribute<JSSpeechSynthesisVoice>::get<jsSpeechSynthesisVoiceVoiceURIGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "voiceURI" ); |
143 | } |
144 | |
145 | static inline JSValue jsSpeechSynthesisVoiceNameGetter(ExecState& state, JSSpeechSynthesisVoice& thisObject, ThrowScope& throwScope) |
146 | { |
147 | UNUSED_PARAM(throwScope); |
148 | UNUSED_PARAM(state); |
149 | auto& impl = thisObject.wrapped(); |
150 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.name()); |
151 | return result; |
152 | } |
153 | |
154 | EncodedJSValue jsSpeechSynthesisVoiceName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
155 | { |
156 | return IDLAttribute<JSSpeechSynthesisVoice>::get<jsSpeechSynthesisVoiceNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name" ); |
157 | } |
158 | |
159 | static inline JSValue jsSpeechSynthesisVoiceLangGetter(ExecState& state, JSSpeechSynthesisVoice& thisObject, ThrowScope& throwScope) |
160 | { |
161 | UNUSED_PARAM(throwScope); |
162 | UNUSED_PARAM(state); |
163 | auto& impl = thisObject.wrapped(); |
164 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.lang()); |
165 | return result; |
166 | } |
167 | |
168 | EncodedJSValue jsSpeechSynthesisVoiceLang(ExecState* state, EncodedJSValue thisValue, PropertyName) |
169 | { |
170 | return IDLAttribute<JSSpeechSynthesisVoice>::get<jsSpeechSynthesisVoiceLangGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "lang" ); |
171 | } |
172 | |
173 | static inline JSValue jsSpeechSynthesisVoiceLocalServiceGetter(ExecState& state, JSSpeechSynthesisVoice& thisObject, ThrowScope& throwScope) |
174 | { |
175 | UNUSED_PARAM(throwScope); |
176 | UNUSED_PARAM(state); |
177 | auto& impl = thisObject.wrapped(); |
178 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.localService()); |
179 | return result; |
180 | } |
181 | |
182 | EncodedJSValue jsSpeechSynthesisVoiceLocalService(ExecState* state, EncodedJSValue thisValue, PropertyName) |
183 | { |
184 | return IDLAttribute<JSSpeechSynthesisVoice>::get<jsSpeechSynthesisVoiceLocalServiceGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "localService" ); |
185 | } |
186 | |
187 | static inline JSValue jsSpeechSynthesisVoiceDefaultGetter(ExecState& state, JSSpeechSynthesisVoice& thisObject, ThrowScope& throwScope) |
188 | { |
189 | UNUSED_PARAM(throwScope); |
190 | UNUSED_PARAM(state); |
191 | auto& impl = thisObject.wrapped(); |
192 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isDefault()); |
193 | return result; |
194 | } |
195 | |
196 | EncodedJSValue jsSpeechSynthesisVoiceDefault(ExecState* state, EncodedJSValue thisValue, PropertyName) |
197 | { |
198 | return IDLAttribute<JSSpeechSynthesisVoice>::get<jsSpeechSynthesisVoiceDefaultGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "default" ); |
199 | } |
200 | |
201 | void JSSpeechSynthesisVoice::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
202 | { |
203 | auto* thisObject = jsCast<JSSpeechSynthesisVoice*>(cell); |
204 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
205 | if (thisObject->scriptExecutionContext()) |
206 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
207 | Base::heapSnapshot(cell, builder); |
208 | } |
209 | |
210 | bool JSSpeechSynthesisVoiceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
211 | { |
212 | UNUSED_PARAM(handle); |
213 | UNUSED_PARAM(visitor); |
214 | UNUSED_PARAM(reason); |
215 | return false; |
216 | } |
217 | |
218 | void JSSpeechSynthesisVoiceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
219 | { |
220 | auto* jsSpeechSynthesisVoice = static_cast<JSSpeechSynthesisVoice*>(handle.slot()->asCell()); |
221 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
222 | uncacheWrapper(world, &jsSpeechSynthesisVoice->wrapped(), jsSpeechSynthesisVoice); |
223 | } |
224 | |
225 | #if ENABLE(BINDING_INTEGRITY) |
226 | #if PLATFORM(WIN) |
227 | #pragma warning(disable: 4483) |
228 | extern "C" { extern void (*const __identifier("??_7SpeechSynthesisVoice@WebCore@@6B@" )[])(); } |
229 | #else |
230 | extern "C" { extern void* _ZTVN7WebCore20SpeechSynthesisVoiceE[]; } |
231 | #endif |
232 | #endif |
233 | |
234 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SpeechSynthesisVoice>&& impl) |
235 | { |
236 | |
237 | #if ENABLE(BINDING_INTEGRITY) |
238 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
239 | #if PLATFORM(WIN) |
240 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7SpeechSynthesisVoice@WebCore@@6B@" )); |
241 | #else |
242 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore20SpeechSynthesisVoiceE[2]); |
243 | #endif |
244 | |
245 | // If this fails SpeechSynthesisVoice does not have a vtable, so you need to add the |
246 | // ImplementationLacksVTable attribute to the interface definition |
247 | static_assert(std::is_polymorphic<SpeechSynthesisVoice>::value, "SpeechSynthesisVoice is not polymorphic" ); |
248 | |
249 | // If you hit this assertion you either have a use after free bug, or |
250 | // SpeechSynthesisVoice has subclasses. If SpeechSynthesisVoice has subclasses that get passed |
251 | // to toJS() we currently require SpeechSynthesisVoice you to opt out of binding hardening |
252 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
253 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
254 | #endif |
255 | return createWrapper<SpeechSynthesisVoice>(globalObject, WTFMove(impl)); |
256 | } |
257 | |
258 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SpeechSynthesisVoice& impl) |
259 | { |
260 | return wrap(state, globalObject, impl); |
261 | } |
262 | |
263 | SpeechSynthesisVoice* JSSpeechSynthesisVoice::toWrapped(JSC::VM& vm, JSC::JSValue value) |
264 | { |
265 | if (auto* wrapper = jsDynamicCast<JSSpeechSynthesisVoice*>(vm, value)) |
266 | return &wrapper->wrapped(); |
267 | return nullptr; |
268 | } |
269 | |
270 | } |
271 | |
272 | #endif // ENABLE(SPEECH_SYNTHESIS) |
273 | |