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