| /* |
| This file is part of the WebKit open source project. |
| This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| |
| This library is free software; you can redistribute it and/or |
| modify it under the terms of the GNU Library General Public |
| License as published by the Free Software Foundation; either |
| version 2 of the License, or (at your option) any later version. |
| |
| This library is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| Library General Public License for more details. |
| |
| You should have received a copy of the GNU Library General Public License |
| along with this library; see the file COPYING.LIB. If not, write to |
| the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| Boston, MA 02110-1301, USA. |
| */ |
| |
| #include "config.h" |
| |
| #if ENABLE(SPEECH_SYNTHESIS) |
| |
| #include "JSSpeechSynthesisVoice.h" |
| |
| #include "JSDOMBinding.h" |
| #include "URL.h" |
| #include <runtime/JSString.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsSpeechSynthesisVoiceVoiceURI(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsSpeechSynthesisVoiceName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsSpeechSynthesisVoiceLang(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsSpeechSynthesisVoiceLocalService(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsSpeechSynthesisVoiceDefault(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisVoiceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSSpeechSynthesisVoicePrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSSpeechSynthesisVoicePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSSpeechSynthesisVoicePrototype* ptr = new (NotNull, JSC::allocateCell<JSSpeechSynthesisVoicePrototype>(vm.heap)) JSSpeechSynthesisVoicePrototype(vm, globalObject, structure); |
| ptr->finishCreation(vm); |
| return ptr; |
| } |
| |
| DECLARE_INFO; |
| static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| { |
| return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| } |
| |
| private: |
| JSSpeechSynthesisVoicePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSSpeechSynthesisVoicePrototypeTableValues[] = |
| { |
| { "voiceURI", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceVoiceURI), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "name", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "lang", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceLang), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "localService", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceLocalService), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "default", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisVoiceDefault), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| }; |
| |
| const ClassInfo JSSpeechSynthesisVoicePrototype::s_info = { "SpeechSynthesisVoicePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSpeechSynthesisVoicePrototype) }; |
| |
| void JSSpeechSynthesisVoicePrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSSpeechSynthesisVoicePrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSSpeechSynthesisVoice::s_info = { "SpeechSynthesisVoice", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSpeechSynthesisVoice) }; |
| |
| JSSpeechSynthesisVoice::JSSpeechSynthesisVoice(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SpeechSynthesisVoice>&& impl) |
| : JSDOMWrapper<SpeechSynthesisVoice>(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSSpeechSynthesisVoice::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSSpeechSynthesisVoicePrototype::create(vm, globalObject, JSSpeechSynthesisVoicePrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); |
| } |
| |
| JSObject* JSSpeechSynthesisVoice::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSSpeechSynthesisVoice>(vm, globalObject); |
| } |
| |
| void JSSpeechSynthesisVoice::destroy(JSC::JSCell* cell) |
| { |
| JSSpeechSynthesisVoice* thisObject = static_cast<JSSpeechSynthesisVoice*>(cell); |
| thisObject->JSSpeechSynthesisVoice::~JSSpeechSynthesisVoice(); |
| } |
| |
| EncodedJSValue jsSpeechSynthesisVoiceVoiceURI(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSSpeechSynthesisVoice*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisVoice", "voiceURI"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.voiceURI()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisVoiceName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSSpeechSynthesisVoice*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisVoice", "name"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.name()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisVoiceLang(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSSpeechSynthesisVoice*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisVoice", "lang"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.lang()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisVoiceLocalService(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSSpeechSynthesisVoice*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisVoice", "localService"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsBoolean(impl.localService()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisVoiceDefault(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSSpeechSynthesisVoice*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisVoice", "default"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsBoolean(impl.isDefault()); |
| return JSValue::encode(result); |
| } |
| |
| |
| bool setJSSpeechSynthesisVoiceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSSpeechSynthesisVoicePrototype* domObject = jsDynamicCast<JSSpeechSynthesisVoicePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) { |
| throwVMTypeError(state, throwScope); |
| return false; |
| } |
| // Shadowing a built-in constructor |
| return domObject->putDirect(state->vm(), state->propertyNames().constructor, value); |
| } |
| |
| bool JSSpeechSynthesisVoiceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) |
| { |
| UNUSED_PARAM(handle); |
| UNUSED_PARAM(visitor); |
| return false; |
| } |
| |
| void JSSpeechSynthesisVoiceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| { |
| auto* jsSpeechSynthesisVoice = jsCast<JSSpeechSynthesisVoice*>(handle.slot()->asCell()); |
| auto& world = *static_cast<DOMWrapperWorld*>(context); |
| uncacheWrapper(world, &jsSpeechSynthesisVoice->wrapped(), jsSpeechSynthesisVoice); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7SpeechSynthesisVoice@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore20SpeechSynthesisVoiceE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SpeechSynthesisVoice>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7SpeechSynthesisVoice@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore20SpeechSynthesisVoiceE[2]; |
| #if COMPILER(CLANG) |
| // If this fails SpeechSynthesisVoice does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(SpeechSynthesisVoice), "SpeechSynthesisVoice is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // SpeechSynthesisVoice has subclasses. If SpeechSynthesisVoice has subclasses that get passed |
| // to toJS() we currently require SpeechSynthesisVoice you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<SpeechSynthesisVoice>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SpeechSynthesisVoice& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| SpeechSynthesisVoice* JSSpeechSynthesisVoice::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSSpeechSynthesisVoice*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |
| |
| #endif // ENABLE(SPEECH_SYNTHESIS) |