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