| /* |
| 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(WEB_AUDIO) |
| |
| #include "JSOscillatorNode.h" |
| |
| #include "EventNames.h" |
| #include "ExceptionCode.h" |
| #include "JSAudioParam.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDOMConvert.h" |
| #include "JSEventListener.h" |
| #include "JSPeriodicWave.h" |
| #include <runtime/Error.h> |
| #include <runtime/JSString.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| template<typename T> Optional<T> parse(ExecState&, JSValue); |
| template<typename T> const char* expectedEnumerationValues(); |
| |
| JSString* jsStringWithCache(ExecState*, OscillatorNode::Type); |
| |
| JSString* jsStringWithCache(ExecState* state, OscillatorNode::Type enumerationValue) |
| { |
| static NeverDestroyed<const String> values[] = { |
| ASCIILiteral("sine"), |
| ASCIILiteral("square"), |
| ASCIILiteral("sawtooth"), |
| ASCIILiteral("triangle"), |
| ASCIILiteral("custom"), |
| }; |
| static_assert(static_cast<size_t>(OscillatorNode::Type::Sine) == 0, "OscillatorNode::Type::Sine is not 0 as expected"); |
| static_assert(static_cast<size_t>(OscillatorNode::Type::Square) == 1, "OscillatorNode::Type::Square is not 1 as expected"); |
| static_assert(static_cast<size_t>(OscillatorNode::Type::Sawtooth) == 2, "OscillatorNode::Type::Sawtooth is not 2 as expected"); |
| static_assert(static_cast<size_t>(OscillatorNode::Type::Triangle) == 3, "OscillatorNode::Type::Triangle is not 3 as expected"); |
| static_assert(static_cast<size_t>(OscillatorNode::Type::Custom) == 4, "OscillatorNode::Type::Custom is not 4 as expected"); |
| ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]); |
| } |
| |
| template<> struct JSValueTraits<OscillatorNode::Type> { |
| static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, OscillatorNode::Type value) { return jsStringWithCache(state, value); } |
| }; |
| |
| template<> Optional<OscillatorNode::Type> parse<OscillatorNode::Type>(ExecState& state, JSValue value) |
| { |
| auto stringValue = value.toWTFString(&state); |
| if (stringValue == "sine") |
| return OscillatorNode::Type::Sine; |
| if (stringValue == "square") |
| return OscillatorNode::Type::Square; |
| if (stringValue == "sawtooth") |
| return OscillatorNode::Type::Sawtooth; |
| if (stringValue == "triangle") |
| return OscillatorNode::Type::Triangle; |
| if (stringValue == "custom") |
| return OscillatorNode::Type::Custom; |
| return Nullopt; |
| } |
| |
| template<> OscillatorNode::Type convert<OscillatorNode::Type>(ExecState& state, JSValue value) |
| { |
| VM& vm = state.vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| auto result = parse<OscillatorNode::Type>(state, value); |
| if (UNLIKELY(!result)) { |
| throwTypeError(&state, throwScope); |
| return { }; |
| } |
| return result.value(); |
| } |
| |
| template<> inline const char* expectedEnumerationValues<OscillatorNode::Type>() |
| { |
| return "\"sine\", \"square\", \"sawtooth\", \"triangle\", \"custom\""; |
| } |
| |
| // Functions |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionStart(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionStop(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionSetPeriodicWave(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsOscillatorNodeType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSOscillatorNodeType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsOscillatorNodePlaybackState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsOscillatorNodeFrequency(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsOscillatorNodeDetune(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsOscillatorNodeOnended(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSOscillatorNodeOnended(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsOscillatorNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSOscillatorNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSOscillatorNodePrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSOscillatorNodePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSOscillatorNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSOscillatorNodePrototype>(vm.heap)) JSOscillatorNodePrototype(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: |
| JSOscillatorNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructorNotConstructable<JSOscillatorNode> JSOscillatorNodeConstructor; |
| |
| /* Hash table for constructor */ |
| |
| static const HashTableValue JSOscillatorNodeConstructorTableValues[] = |
| { |
| { "UNSCHEDULED_STATE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
| { "SCHEDULED_STATE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| { "PLAYING_STATE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| { "FINISHED_STATE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| }; |
| |
| static_assert(OscillatorNode::UNSCHEDULED_STATE == 0, "UNSCHEDULED_STATE in OscillatorNode does not match value from IDL"); |
| static_assert(OscillatorNode::SCHEDULED_STATE == 1, "SCHEDULED_STATE in OscillatorNode does not match value from IDL"); |
| static_assert(OscillatorNode::PLAYING_STATE == 2, "PLAYING_STATE in OscillatorNode does not match value from IDL"); |
| static_assert(OscillatorNode::FINISHED_STATE == 3, "FINISHED_STATE in OscillatorNode does not match value from IDL"); |
| |
| template<> JSValue JSOscillatorNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSAudioNode::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSOscillatorNodeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSOscillatorNode::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("OscillatorNode"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum); |
| reifyStaticProperties(vm, JSOscillatorNodeConstructorTableValues, *this); |
| } |
| |
| template<> const ClassInfo JSOscillatorNodeConstructor::s_info = { "OscillatorNode", &Base::s_info, 0, CREATE_METHOD_TABLE(JSOscillatorNodeConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSOscillatorNodePrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOscillatorNodeConstructor) } }, |
| { "type", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOscillatorNodeType) } }, |
| { "playbackState", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodePlaybackState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "frequency", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeFrequency), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "detune", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeDetune), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "onended", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeOnended), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOscillatorNodeOnended) } }, |
| { "start", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsOscillatorNodePrototypeFunctionStart), (intptr_t) (0) } }, |
| { "stop", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsOscillatorNodePrototypeFunctionStop), (intptr_t) (0) } }, |
| { "setPeriodicWave", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsOscillatorNodePrototypeFunctionSetPeriodicWave), (intptr_t) (1) } }, |
| { "UNSCHEDULED_STATE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
| { "SCHEDULED_STATE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| { "PLAYING_STATE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| { "FINISHED_STATE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| }; |
| |
| const ClassInfo JSOscillatorNodePrototype::s_info = { "OscillatorNodePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSOscillatorNodePrototype) }; |
| |
| void JSOscillatorNodePrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSOscillatorNodePrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSOscillatorNode::s_info = { "OscillatorNode", &Base::s_info, 0, CREATE_METHOD_TABLE(JSOscillatorNode) }; |
| |
| JSOscillatorNode::JSOscillatorNode(Structure* structure, JSDOMGlobalObject& globalObject, Ref<OscillatorNode>&& impl) |
| : JSAudioNode(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSOscillatorNode::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSOscillatorNodePrototype::create(vm, globalObject, JSOscillatorNodePrototype::createStructure(vm, globalObject, JSAudioNode::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSOscillatorNode::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSOscillatorNode>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsOscillatorNodeType(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<JSOscillatorNode*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "OscillatorNode", "type"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.type()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsOscillatorNodePlaybackState(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<JSOscillatorNode*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "OscillatorNode", "playbackState"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.playbackState()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsOscillatorNodeFrequency(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<JSOscillatorNode*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "OscillatorNode", "frequency"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.frequency()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsOscillatorNodeDetune(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<JSOscillatorNode*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "OscillatorNode", "detune"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.detune()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsOscillatorNodeOnended(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<JSOscillatorNode*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "OscillatorNode", "onended"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().endedEvent)); |
| } |
| |
| |
| EncodedJSValue jsOscillatorNodeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSOscillatorNodePrototype* domObject = jsDynamicCast<JSOscillatorNodePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSOscillatorNode::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSOscillatorNodeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSOscillatorNodePrototype* domObject = jsDynamicCast<JSOscillatorNodePrototype*>(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 setJSOscillatorNodeType(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue value = JSValue::decode(encodedValue); |
| UNUSED_PARAM(thisValue); |
| JSOscillatorNode* castedThis = jsDynamicCast<JSOscillatorNode*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "OscillatorNode", "type"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = parse<OscillatorNode::Type>(*state, value); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| if (UNLIKELY(!nativeValue)) |
| return false; |
| impl.setType(nativeValue.value(), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| bool setJSOscillatorNodeOnended(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue value = JSValue::decode(encodedValue); |
| UNUSED_PARAM(thisValue); |
| JSOscillatorNode* castedThis = jsDynamicCast<JSOscillatorNode*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "OscillatorNode", "onended"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().endedEvent, value); |
| return true; |
| } |
| |
| |
| JSValue JSOscillatorNode::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSOscillatorNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionStart(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSOscillatorNode*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "OscillatorNode", "start"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSOscillatorNode::info()); |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto when = state->argument(0).isUndefined() ? 0 : convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.start(WTFMove(when), ec); |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionStop(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSOscillatorNode*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "OscillatorNode", "stop"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSOscillatorNode::info()); |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto when = state->argument(0).isUndefined() ? 0 : convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.stop(WTFMove(when), ec); |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionSetPeriodicWave(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSOscillatorNode*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "OscillatorNode", "setPeriodicWave"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSOscillatorNode::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| PeriodicWave* wave = nullptr; |
| if (!state->uncheckedArgument(0).isUndefinedOrNull()) { |
| wave = JSPeriodicWave::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!wave)) |
| return throwArgumentTypeError(*state, throwScope, 0, "wave", "OscillatorNode", "setPeriodicWave", "PeriodicWave"); |
| } |
| impl.setPeriodicWave(WTFMove(wave)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| void JSOscillatorNode::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| { |
| auto* thisObject = jsCast<JSOscillatorNode*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| Base::visitChildren(thisObject, visitor); |
| thisObject->wrapped().visitJSEventListeners(visitor); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7OscillatorNode@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore14OscillatorNodeE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<OscillatorNode>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7OscillatorNode@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore14OscillatorNodeE[2]; |
| #if COMPILER(CLANG) |
| // If this fails OscillatorNode does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(OscillatorNode), "OscillatorNode is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // OscillatorNode has subclasses. If OscillatorNode has subclasses that get passed |
| // to toJS() we currently require OscillatorNode you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<OscillatorNode>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, OscillatorNode& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| |
| } |
| |
| #endif // ENABLE(WEB_AUDIO) |