blob: 4d2ba677849d6a32046daa5d4b0393e1a4440009 [file] [log] [blame]
/*
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 "JSBiquadFilterNode.h"
#include "ExceptionCode.h"
#include "JSAudioParam.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.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();
#if ENABLE(WEB_AUDIO)
JSString* jsStringWithCache(ExecState*, BiquadFilterType);
JSString* jsStringWithCache(ExecState* state, BiquadFilterType enumerationValue)
{
static NeverDestroyed<const String> values[] = {
ASCIILiteral("lowpass"),
ASCIILiteral("highpass"),
ASCIILiteral("bandpass"),
ASCIILiteral("lowshelf"),
ASCIILiteral("highshelf"),
ASCIILiteral("peaking"),
ASCIILiteral("notch"),
ASCIILiteral("allpass"),
};
static_assert(static_cast<size_t>(BiquadFilterType::Lowpass) == 0, "BiquadFilterType::Lowpass is not 0 as expected");
static_assert(static_cast<size_t>(BiquadFilterType::Highpass) == 1, "BiquadFilterType::Highpass is not 1 as expected");
static_assert(static_cast<size_t>(BiquadFilterType::Bandpass) == 2, "BiquadFilterType::Bandpass is not 2 as expected");
static_assert(static_cast<size_t>(BiquadFilterType::Lowshelf) == 3, "BiquadFilterType::Lowshelf is not 3 as expected");
static_assert(static_cast<size_t>(BiquadFilterType::Highshelf) == 4, "BiquadFilterType::Highshelf is not 4 as expected");
static_assert(static_cast<size_t>(BiquadFilterType::Peaking) == 5, "BiquadFilterType::Peaking is not 5 as expected");
static_assert(static_cast<size_t>(BiquadFilterType::Notch) == 6, "BiquadFilterType::Notch is not 6 as expected");
static_assert(static_cast<size_t>(BiquadFilterType::Allpass) == 7, "BiquadFilterType::Allpass is not 7 as expected");
ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
}
template<> struct JSValueTraits<BiquadFilterType> {
static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, BiquadFilterType value) { return jsStringWithCache(state, value); }
};
template<> Optional<BiquadFilterType> parse<BiquadFilterType>(ExecState& state, JSValue value)
{
auto stringValue = value.toWTFString(&state);
if (stringValue == "lowpass")
return BiquadFilterType::Lowpass;
if (stringValue == "highpass")
return BiquadFilterType::Highpass;
if (stringValue == "bandpass")
return BiquadFilterType::Bandpass;
if (stringValue == "lowshelf")
return BiquadFilterType::Lowshelf;
if (stringValue == "highshelf")
return BiquadFilterType::Highshelf;
if (stringValue == "peaking")
return BiquadFilterType::Peaking;
if (stringValue == "notch")
return BiquadFilterType::Notch;
if (stringValue == "allpass")
return BiquadFilterType::Allpass;
return Nullopt;
}
template<> BiquadFilterType convert<BiquadFilterType>(ExecState& state, JSValue value)
{
VM& vm = state.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto result = parse<BiquadFilterType>(state, value);
if (UNLIKELY(!result)) {
throwTypeError(&state, throwScope);
return { };
}
return result.value();
}
template<> inline const char* expectedEnumerationValues<BiquadFilterType>()
{
return "\"lowpass\", \"highpass\", \"bandpass\", \"lowshelf\", \"highshelf\", \"peaking\", \"notch\", \"allpass\"";
}
#endif
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsBiquadFilterNodePrototypeFunctionGetFrequencyResponse(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsBiquadFilterNodeType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSBiquadFilterNodeType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsBiquadFilterNodeFrequency(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsBiquadFilterNodeDetune(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsBiquadFilterNodeQ(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsBiquadFilterNodeGain(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsBiquadFilterNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSBiquadFilterNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSBiquadFilterNodePrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSBiquadFilterNodePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSBiquadFilterNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSBiquadFilterNodePrototype>(vm.heap)) JSBiquadFilterNodePrototype(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:
JSBiquadFilterNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSBiquadFilterNode> JSBiquadFilterNodeConstructor;
template<> JSValue JSBiquadFilterNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSAudioNode::getConstructor(vm, &globalObject);
}
template<> void JSBiquadFilterNodeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSBiquadFilterNode::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("BiquadFilterNode"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSBiquadFilterNodeConstructor::s_info = { "BiquadFilterNode", &Base::s_info, 0, CREATE_METHOD_TABLE(JSBiquadFilterNodeConstructor) };
/* Hash table for prototype */
static const HashTableValue JSBiquadFilterNodePrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBiquadFilterNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBiquadFilterNodeConstructor) } },
{ "type", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBiquadFilterNodeType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBiquadFilterNodeType) } },
{ "frequency", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBiquadFilterNodeFrequency), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "detune", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBiquadFilterNodeDetune), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "Q", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBiquadFilterNodeQ), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "gain", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBiquadFilterNodeGain), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "getFrequencyResponse", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsBiquadFilterNodePrototypeFunctionGetFrequencyResponse), (intptr_t) (3) } },
};
const ClassInfo JSBiquadFilterNodePrototype::s_info = { "BiquadFilterNodePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSBiquadFilterNodePrototype) };
void JSBiquadFilterNodePrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSBiquadFilterNodePrototypeTableValues, *this);
}
const ClassInfo JSBiquadFilterNode::s_info = { "BiquadFilterNode", &Base::s_info, 0, CREATE_METHOD_TABLE(JSBiquadFilterNode) };
JSBiquadFilterNode::JSBiquadFilterNode(Structure* structure, JSDOMGlobalObject& globalObject, Ref<BiquadFilterNode>&& impl)
: JSAudioNode(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSBiquadFilterNode::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSBiquadFilterNodePrototype::create(vm, globalObject, JSBiquadFilterNodePrototype::createStructure(vm, globalObject, JSAudioNode::prototype(vm, globalObject)));
}
JSObject* JSBiquadFilterNode::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSBiquadFilterNode>(vm, globalObject);
}
EncodedJSValue jsBiquadFilterNodeType(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<JSBiquadFilterNode*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BiquadFilterNode", "type");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.type());
return JSValue::encode(result);
}
EncodedJSValue jsBiquadFilterNodeFrequency(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<JSBiquadFilterNode*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BiquadFilterNode", "frequency");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.frequency());
return JSValue::encode(result);
}
EncodedJSValue jsBiquadFilterNodeDetune(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<JSBiquadFilterNode*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BiquadFilterNode", "detune");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.detune());
return JSValue::encode(result);
}
EncodedJSValue jsBiquadFilterNodeQ(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<JSBiquadFilterNode*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BiquadFilterNode", "Q");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.q());
return JSValue::encode(result);
}
EncodedJSValue jsBiquadFilterNodeGain(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<JSBiquadFilterNode*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BiquadFilterNode", "gain");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.gain());
return JSValue::encode(result);
}
EncodedJSValue jsBiquadFilterNodeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSBiquadFilterNodePrototype* domObject = jsDynamicCast<JSBiquadFilterNodePrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSBiquadFilterNode::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSBiquadFilterNodeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSBiquadFilterNodePrototype* domObject = jsDynamicCast<JSBiquadFilterNodePrototype*>(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 setJSBiquadFilterNodeType(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);
JSBiquadFilterNode* castedThis = jsDynamicCast<JSBiquadFilterNode*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "BiquadFilterNode", "type");
}
auto& impl = castedThis->wrapped();
auto nativeValue = parse<BiquadFilterType>(*state, value);
RETURN_IF_EXCEPTION(throwScope, false);
if (UNLIKELY(!nativeValue))
return false;
impl.setType(nativeValue.value());
return true;
}
JSValue JSBiquadFilterNode::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSBiquadFilterNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsBiquadFilterNodePrototypeFunctionGetFrequencyResponse(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSBiquadFilterNode*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "BiquadFilterNode", "getFrequencyResponse");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSBiquadFilterNode::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 3))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto frequencyHz = toFloat32Array(state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto magResponse = toFloat32Array(state->uncheckedArgument(1));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto phaseResponse = toFloat32Array(state->uncheckedArgument(2));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.getFrequencyResponse(WTFMove(frequencyHz), WTFMove(magResponse), WTFMove(phaseResponse));
return JSValue::encode(jsUndefined());
}
void JSBiquadFilterNode::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSBiquadFilterNode*>(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("??_7BiquadFilterNode@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore16BiquadFilterNodeE[]; }
#endif
#endif
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<BiquadFilterNode>&& impl)
{
#if ENABLE(BINDING_INTEGRITY)
void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
#if PLATFORM(WIN)
void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7BiquadFilterNode@WebCore@@6B@"));
#else
void* expectedVTablePointer = &_ZTVN7WebCore16BiquadFilterNodeE[2];
#if COMPILER(CLANG)
// If this fails BiquadFilterNode does not have a vtable, so you need to add the
// ImplementationLacksVTable attribute to the interface definition
static_assert(__is_polymorphic(BiquadFilterNode), "BiquadFilterNode is not polymorphic");
#endif
#endif
// If you hit this assertion you either have a use after free bug, or
// BiquadFilterNode has subclasses. If BiquadFilterNode has subclasses that get passed
// to toJS() we currently require BiquadFilterNode you to opt out of binding hardening
// by adding the SkipVTableValidation attribute to the interface IDL definition
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
return createWrapper<BiquadFilterNode>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, BiquadFilterNode& impl)
{
return wrap(state, globalObject, impl);
}
}
#endif // ENABLE(WEB_AUDIO)