| 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(WEB_AUDIO) |
| 24 | |
| 25 | #include "JSConvolverNode.h" |
| 26 | |
| 27 | #include "JSAudioBuffer.h" |
| 28 | #include "JSDOMAttribute.h" |
| 29 | #include "JSDOMBinding.h" |
| 30 | #include "JSDOMConstructorNotConstructable.h" |
| 31 | #include "JSDOMConvertBoolean.h" |
| 32 | #include "JSDOMConvertInterface.h" |
| 33 | #include "JSDOMConvertNullable.h" |
| 34 | #include "JSDOMExceptionHandling.h" |
| 35 | #include "JSDOMGlobalObject.h" |
| 36 | #include "JSDOMWrapperCache.h" |
| 37 | #include "ScriptExecutionContext.h" |
| 38 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 39 | #include <JavaScriptCore/JSCInlines.h> |
| 40 | #include <wtf/GetPtr.h> |
| 41 | #include <wtf/PointerPreparations.h> |
| 42 | #include <wtf/URL.h> |
| 43 | |
| 44 | |
| 45 | namespace WebCore { |
| 46 | using namespace JSC; |
| 47 | |
| 48 | // Attributes |
| 49 | |
| 50 | JSC::EncodedJSValue jsConvolverNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 51 | bool setJSConvolverNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 52 | JSC::EncodedJSValue jsConvolverNodeBuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 53 | bool setJSConvolverNodeBuffer(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 54 | JSC::EncodedJSValue jsConvolverNodeNormalize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 55 | bool setJSConvolverNodeNormalize(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 56 | |
| 57 | class JSConvolverNodePrototype : public JSC::JSNonFinalObject { |
| 58 | public: |
| 59 | using Base = JSC::JSNonFinalObject; |
| 60 | static JSConvolverNodePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 61 | { |
| 62 | JSConvolverNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSConvolverNodePrototype>(vm.heap)) JSConvolverNodePrototype(vm, globalObject, structure); |
| 63 | ptr->finishCreation(vm); |
| 64 | return ptr; |
| 65 | } |
| 66 | |
| 67 | DECLARE_INFO; |
| 68 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 69 | { |
| 70 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 71 | } |
| 72 | |
| 73 | private: |
| 74 | JSConvolverNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 75 | : JSC::JSNonFinalObject(vm, structure) |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | void finishCreation(JSC::VM&); |
| 80 | }; |
| 81 | |
| 82 | using JSConvolverNodeConstructor = JSDOMConstructorNotConstructable<JSConvolverNode>; |
| 83 | |
| 84 | template<> JSValue JSConvolverNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 85 | { |
| 86 | return JSAudioNode::getConstructor(vm, &globalObject); |
| 87 | } |
| 88 | |
| 89 | template<> void JSConvolverNodeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 90 | { |
| 91 | putDirect(vm, vm.propertyNames->prototype, JSConvolverNode::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 92 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("ConvolverNode"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 93 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 94 | } |
| 95 | |
| 96 | template<> const ClassInfo JSConvolverNodeConstructor::s_info = { "ConvolverNode" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSConvolverNodeConstructor) }; |
| 97 | |
| 98 | /* Hash table for prototype */ |
| 99 | |
| 100 | static const HashTableValue JSConvolverNodePrototypeTableValues[] = |
| 101 | { |
| 102 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsConvolverNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSConvolverNodeConstructor) } }, |
| 103 | { "buffer" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsConvolverNodeBuffer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSConvolverNodeBuffer) } }, |
| 104 | { "normalize" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsConvolverNodeNormalize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSConvolverNodeNormalize) } }, |
| 105 | }; |
| 106 | |
| 107 | const ClassInfo JSConvolverNodePrototype::s_info = { "ConvolverNodePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSConvolverNodePrototype) }; |
| 108 | |
| 109 | void JSConvolverNodePrototype::finishCreation(VM& vm) |
| 110 | { |
| 111 | Base::finishCreation(vm); |
| 112 | reifyStaticProperties(vm, JSConvolverNode::info(), JSConvolverNodePrototypeTableValues, *this); |
| 113 | } |
| 114 | |
| 115 | const ClassInfo JSConvolverNode::s_info = { "ConvolverNode" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSConvolverNode) }; |
| 116 | |
| 117 | JSConvolverNode::JSConvolverNode(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ConvolverNode>&& impl) |
| 118 | : JSAudioNode(structure, globalObject, WTFMove(impl)) |
| 119 | { |
| 120 | } |
| 121 | |
| 122 | void JSConvolverNode::finishCreation(VM& vm) |
| 123 | { |
| 124 | Base::finishCreation(vm); |
| 125 | ASSERT(inherits(vm, info())); |
| 126 | |
| 127 | } |
| 128 | |
| 129 | JSObject* JSConvolverNode::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 130 | { |
| 131 | return JSConvolverNodePrototype::create(vm, &globalObject, JSConvolverNodePrototype::createStructure(vm, &globalObject, JSAudioNode::prototype(vm, globalObject))); |
| 132 | } |
| 133 | |
| 134 | JSObject* JSConvolverNode::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 135 | { |
| 136 | return getDOMPrototype<JSConvolverNode>(vm, globalObject); |
| 137 | } |
| 138 | |
| 139 | JSValue JSConvolverNode::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 140 | { |
| 141 | return getDOMConstructor<JSConvolverNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 142 | } |
| 143 | |
| 144 | template<> inline JSConvolverNode* IDLAttribute<JSConvolverNode>::cast(ExecState& state, EncodedJSValue thisValue) |
| 145 | { |
| 146 | return jsDynamicCast<JSConvolverNode*>(state.vm(), JSValue::decode(thisValue)); |
| 147 | } |
| 148 | |
| 149 | EncodedJSValue jsConvolverNodeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 150 | { |
| 151 | VM& vm = state->vm(); |
| 152 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 153 | auto* prototype = jsDynamicCast<JSConvolverNodePrototype*>(vm, JSValue::decode(thisValue)); |
| 154 | if (UNLIKELY(!prototype)) |
| 155 | return throwVMTypeError(state, throwScope); |
| 156 | return JSValue::encode(JSConvolverNode::getConstructor(state->vm(), prototype->globalObject())); |
| 157 | } |
| 158 | |
| 159 | bool setJSConvolverNodeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 160 | { |
| 161 | VM& vm = state->vm(); |
| 162 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 163 | auto* prototype = jsDynamicCast<JSConvolverNodePrototype*>(vm, JSValue::decode(thisValue)); |
| 164 | if (UNLIKELY(!prototype)) { |
| 165 | throwVMTypeError(state, throwScope); |
| 166 | return false; |
| 167 | } |
| 168 | // Shadowing a built-in constructor |
| 169 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 170 | } |
| 171 | |
| 172 | static inline JSValue jsConvolverNodeBufferGetter(ExecState& state, JSConvolverNode& thisObject, ThrowScope& throwScope) |
| 173 | { |
| 174 | UNUSED_PARAM(throwScope); |
| 175 | UNUSED_PARAM(state); |
| 176 | auto& impl = thisObject.wrapped(); |
| 177 | JSValue result = toJS<IDLNullable<IDLInterface<AudioBuffer>>>(state, *thisObject.globalObject(), throwScope, impl.buffer()); |
| 178 | return result; |
| 179 | } |
| 180 | |
| 181 | EncodedJSValue jsConvolverNodeBuffer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 182 | { |
| 183 | return IDLAttribute<JSConvolverNode>::get<jsConvolverNodeBufferGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "buffer" ); |
| 184 | } |
| 185 | |
| 186 | static inline bool setJSConvolverNodeBufferSetter(ExecState& state, JSConvolverNode& thisObject, JSValue value, ThrowScope& throwScope) |
| 187 | { |
| 188 | UNUSED_PARAM(throwScope); |
| 189 | auto& impl = thisObject.wrapped(); |
| 190 | auto nativeValue = convert<IDLNullable<IDLInterface<AudioBuffer>>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "ConvolverNode" , "buffer" , "AudioBuffer" ); }); |
| 191 | RETURN_IF_EXCEPTION(throwScope, false); |
| 192 | AttributeSetter::call(state, throwScope, [&] { |
| 193 | return impl.setBuffer(WTFMove(nativeValue)); |
| 194 | }); |
| 195 | return true; |
| 196 | } |
| 197 | |
| 198 | bool setJSConvolverNodeBuffer(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 199 | { |
| 200 | return IDLAttribute<JSConvolverNode>::set<setJSConvolverNodeBufferSetter>(*state, thisValue, encodedValue, "buffer" ); |
| 201 | } |
| 202 | |
| 203 | static inline JSValue jsConvolverNodeNormalizeGetter(ExecState& state, JSConvolverNode& thisObject, ThrowScope& throwScope) |
| 204 | { |
| 205 | UNUSED_PARAM(throwScope); |
| 206 | UNUSED_PARAM(state); |
| 207 | auto& impl = thisObject.wrapped(); |
| 208 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.normalize()); |
| 209 | return result; |
| 210 | } |
| 211 | |
| 212 | EncodedJSValue jsConvolverNodeNormalize(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 213 | { |
| 214 | return IDLAttribute<JSConvolverNode>::get<jsConvolverNodeNormalizeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "normalize" ); |
| 215 | } |
| 216 | |
| 217 | static inline bool setJSConvolverNodeNormalizeSetter(ExecState& state, JSConvolverNode& thisObject, JSValue value, ThrowScope& throwScope) |
| 218 | { |
| 219 | UNUSED_PARAM(throwScope); |
| 220 | auto& impl = thisObject.wrapped(); |
| 221 | auto nativeValue = convert<IDLBoolean>(state, value); |
| 222 | RETURN_IF_EXCEPTION(throwScope, false); |
| 223 | AttributeSetter::call(state, throwScope, [&] { |
| 224 | return impl.setNormalize(WTFMove(nativeValue)); |
| 225 | }); |
| 226 | return true; |
| 227 | } |
| 228 | |
| 229 | bool setJSConvolverNodeNormalize(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 230 | { |
| 231 | return IDLAttribute<JSConvolverNode>::set<setJSConvolverNodeNormalizeSetter>(*state, thisValue, encodedValue, "normalize" ); |
| 232 | } |
| 233 | |
| 234 | void JSConvolverNode::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 235 | { |
| 236 | auto* thisObject = jsCast<JSConvolverNode*>(cell); |
| 237 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 238 | if (thisObject->scriptExecutionContext()) |
| 239 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 240 | Base::heapSnapshot(cell, builder); |
| 241 | } |
| 242 | |
| 243 | #if ENABLE(BINDING_INTEGRITY) |
| 244 | #if PLATFORM(WIN) |
| 245 | #pragma warning(disable: 4483) |
| 246 | extern "C" { extern void (*const __identifier("??_7ConvolverNode@WebCore@@6B@" )[])(); } |
| 247 | #else |
| 248 | extern "C" { extern void* _ZTVN7WebCore13ConvolverNodeE[]; } |
| 249 | #endif |
| 250 | #endif |
| 251 | |
| 252 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ConvolverNode>&& impl) |
| 253 | { |
| 254 | |
| 255 | #if ENABLE(BINDING_INTEGRITY) |
| 256 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 257 | #if PLATFORM(WIN) |
| 258 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7ConvolverNode@WebCore@@6B@" )); |
| 259 | #else |
| 260 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore13ConvolverNodeE[2]); |
| 261 | #endif |
| 262 | |
| 263 | // If this fails ConvolverNode does not have a vtable, so you need to add the |
| 264 | // ImplementationLacksVTable attribute to the interface definition |
| 265 | static_assert(std::is_polymorphic<ConvolverNode>::value, "ConvolverNode is not polymorphic" ); |
| 266 | |
| 267 | // If you hit this assertion you either have a use after free bug, or |
| 268 | // ConvolverNode has subclasses. If ConvolverNode has subclasses that get passed |
| 269 | // to toJS() we currently require ConvolverNode you to opt out of binding hardening |
| 270 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 271 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 272 | #endif |
| 273 | return createWrapper<ConvolverNode>(globalObject, WTFMove(impl)); |
| 274 | } |
| 275 | |
| 276 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ConvolverNode& impl) |
| 277 | { |
| 278 | return wrap(state, globalObject, impl); |
| 279 | } |
| 280 | |
| 281 | |
| 282 | } |
| 283 | |
| 284 | #endif // ENABLE(WEB_AUDIO) |
| 285 | |