| 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(VIDEO_TRACK) |
| 24 | |
| 25 | #include "JSDataCue.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructor.h" |
| 30 | #include "JSDOMConvertAny.h" |
| 31 | #include "JSDOMConvertBufferSource.h" |
| 32 | #include "JSDOMConvertInterface.h" |
| 33 | #include "JSDOMConvertStrings.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 | #if ENABLE(VIDEO_TRACK) |
| 45 | #include "JSDOMConvertNumbers.h" |
| 46 | #endif |
| 47 | |
| 48 | |
| 49 | namespace WebCore { |
| 50 | using namespace JSC; |
| 51 | |
| 52 | // Attributes |
| 53 | |
| 54 | JSC::EncodedJSValue jsDataCueConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 55 | bool setJSDataCueConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 56 | JSC::EncodedJSValue jsDataCueData(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 57 | bool setJSDataCueData(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 58 | JSC::EncodedJSValue jsDataCueValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 59 | bool setJSDataCueValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 60 | JSC::EncodedJSValue jsDataCueType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 61 | |
| 62 | class JSDataCuePrototype : public JSC::JSNonFinalObject { |
| 63 | public: |
| 64 | using Base = JSC::JSNonFinalObject; |
| 65 | static JSDataCuePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 66 | { |
| 67 | JSDataCuePrototype* ptr = new (NotNull, JSC::allocateCell<JSDataCuePrototype>(vm.heap)) JSDataCuePrototype(vm, globalObject, structure); |
| 68 | ptr->finishCreation(vm); |
| 69 | return ptr; |
| 70 | } |
| 71 | |
| 72 | DECLARE_INFO; |
| 73 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 74 | { |
| 75 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 76 | } |
| 77 | |
| 78 | private: |
| 79 | JSDataCuePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 80 | : JSC::JSNonFinalObject(vm, structure) |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | void finishCreation(JSC::VM&); |
| 85 | }; |
| 86 | |
| 87 | using JSDataCueConstructor = JSDOMConstructor<JSDataCue>; |
| 88 | |
| 89 | static inline EncodedJSValue constructJSDataCue1(ExecState* state) |
| 90 | { |
| 91 | VM& vm = state->vm(); |
| 92 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 93 | UNUSED_PARAM(throwScope); |
| 94 | auto* castedThis = jsCast<JSDataCueConstructor*>(state->jsCallee()); |
| 95 | ASSERT(castedThis); |
| 96 | auto* context = castedThis->scriptExecutionContext(); |
| 97 | if (UNLIKELY(!context)) |
| 98 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "DataCue" ); |
| 99 | auto startTime = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 100 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 101 | auto endTime = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 102 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 103 | auto data = convert<IDLArrayBuffer>(*state, state->uncheckedArgument(2), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 2, "data" , "DataCue" , nullptr, "ArrayBuffer" ); }); |
| 104 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 105 | auto object = DataCue::create(*context, WTFMove(startTime), WTFMove(endTime), *data); |
| 106 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DataCue>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 107 | } |
| 108 | |
| 109 | static inline EncodedJSValue constructJSDataCue2(ExecState* state) |
| 110 | { |
| 111 | VM& vm = state->vm(); |
| 112 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 113 | UNUSED_PARAM(throwScope); |
| 114 | auto* castedThis = jsCast<JSDataCueConstructor*>(state->jsCallee()); |
| 115 | ASSERT(castedThis); |
| 116 | auto* context = castedThis->scriptExecutionContext(); |
| 117 | if (UNLIKELY(!context)) |
| 118 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "DataCue" ); |
| 119 | auto startTime = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 120 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 121 | auto endTime = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 122 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 123 | auto value = convert<IDLAny>(*state, state->uncheckedArgument(2)); |
| 124 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 125 | auto type = state->argument(3).isUndefined() ? String() : convert<IDLDOMString>(*state, state->uncheckedArgument(3)); |
| 126 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 127 | auto object = DataCue::create(*context, WTFMove(startTime), WTFMove(endTime), WTFMove(value), WTFMove(type)); |
| 128 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DataCue>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 129 | } |
| 130 | |
| 131 | template<> EncodedJSValue JSC_HOST_CALL JSDataCueConstructor::construct(ExecState* state) |
| 132 | { |
| 133 | VM& vm = state->vm(); |
| 134 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 135 | UNUSED_PARAM(throwScope); |
| 136 | size_t argsCount = std::min<size_t>(4, state->argumentCount()); |
| 137 | if (argsCount == 3) { |
| 138 | JSValue distinguishingArg = state->uncheckedArgument(2); |
| 139 | #if ENABLE(VIDEO_TRACK) |
| 140 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSArrayBuffer>(vm)) |
| 141 | return constructJSDataCue1(state); |
| 142 | #endif |
| 143 | #if ENABLE(VIDEO_TRACK) |
| 144 | return constructJSDataCue2(state); |
| 145 | #endif |
| 146 | } |
| 147 | if (argsCount == 4) { |
| 148 | #if ENABLE(VIDEO_TRACK) |
| 149 | return constructJSDataCue2(state); |
| 150 | #endif |
| 151 | } |
| 152 | return argsCount < 3 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
| 153 | } |
| 154 | |
| 155 | template<> JSValue JSDataCueConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 156 | { |
| 157 | return JSTextTrackCue::getConstructor(vm, &globalObject); |
| 158 | } |
| 159 | |
| 160 | template<> void JSDataCueConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 161 | { |
| 162 | putDirect(vm, vm.propertyNames->prototype, JSDataCue::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 163 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("DataCue"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 164 | putDirect(vm, vm.propertyNames->length, jsNumber(3), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 165 | } |
| 166 | |
| 167 | template<> const ClassInfo JSDataCueConstructor::s_info = { "DataCue" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDataCueConstructor) }; |
| 168 | |
| 169 | /* Hash table for prototype */ |
| 170 | |
| 171 | static const HashTableValue JSDataCuePrototypeTableValues[] = |
| 172 | { |
| 173 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataCueConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDataCueConstructor) } }, |
| 174 | { "data" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataCueData), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDataCueData) } }, |
| 175 | { "value" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataCueValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDataCueValue) } }, |
| 176 | { "type" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataCueType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 177 | }; |
| 178 | |
| 179 | const ClassInfo JSDataCuePrototype::s_info = { "DataCuePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDataCuePrototype) }; |
| 180 | |
| 181 | void JSDataCuePrototype::finishCreation(VM& vm) |
| 182 | { |
| 183 | Base::finishCreation(vm); |
| 184 | reifyStaticProperties(vm, JSDataCue::info(), JSDataCuePrototypeTableValues, *this); |
| 185 | } |
| 186 | |
| 187 | const ClassInfo JSDataCue::s_info = { "DataCue" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDataCue) }; |
| 188 | |
| 189 | JSDataCue::JSDataCue(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DataCue>&& impl) |
| 190 | : JSTextTrackCue(structure, globalObject, WTFMove(impl)) |
| 191 | { |
| 192 | } |
| 193 | |
| 194 | void JSDataCue::finishCreation(VM& vm) |
| 195 | { |
| 196 | Base::finishCreation(vm); |
| 197 | ASSERT(inherits(vm, info())); |
| 198 | |
| 199 | } |
| 200 | |
| 201 | JSObject* JSDataCue::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 202 | { |
| 203 | return JSDataCuePrototype::create(vm, &globalObject, JSDataCuePrototype::createStructure(vm, &globalObject, JSTextTrackCue::prototype(vm, globalObject))); |
| 204 | } |
| 205 | |
| 206 | JSObject* JSDataCue::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 207 | { |
| 208 | return getDOMPrototype<JSDataCue>(vm, globalObject); |
| 209 | } |
| 210 | |
| 211 | JSValue JSDataCue::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 212 | { |
| 213 | return getDOMConstructor<JSDataCueConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 214 | } |
| 215 | |
| 216 | template<> inline JSDataCue* IDLAttribute<JSDataCue>::cast(ExecState& state, EncodedJSValue thisValue) |
| 217 | { |
| 218 | return jsDynamicCast<JSDataCue*>(state.vm(), JSValue::decode(thisValue)); |
| 219 | } |
| 220 | |
| 221 | EncodedJSValue jsDataCueConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 222 | { |
| 223 | VM& vm = state->vm(); |
| 224 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 225 | auto* prototype = jsDynamicCast<JSDataCuePrototype*>(vm, JSValue::decode(thisValue)); |
| 226 | if (UNLIKELY(!prototype)) |
| 227 | return throwVMTypeError(state, throwScope); |
| 228 | return JSValue::encode(JSDataCue::getConstructor(state->vm(), prototype->globalObject())); |
| 229 | } |
| 230 | |
| 231 | bool setJSDataCueConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 232 | { |
| 233 | VM& vm = state->vm(); |
| 234 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 235 | auto* prototype = jsDynamicCast<JSDataCuePrototype*>(vm, JSValue::decode(thisValue)); |
| 236 | if (UNLIKELY(!prototype)) { |
| 237 | throwVMTypeError(state, throwScope); |
| 238 | return false; |
| 239 | } |
| 240 | // Shadowing a built-in constructor |
| 241 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 242 | } |
| 243 | |
| 244 | static inline JSValue jsDataCueDataGetter(ExecState& state, JSDataCue& thisObject, ThrowScope& throwScope) |
| 245 | { |
| 246 | UNUSED_PARAM(throwScope); |
| 247 | UNUSED_PARAM(state); |
| 248 | auto& impl = thisObject.wrapped(); |
| 249 | JSValue result = toJS<IDLArrayBuffer>(state, *thisObject.globalObject(), throwScope, impl.data()); |
| 250 | return result; |
| 251 | } |
| 252 | |
| 253 | EncodedJSValue jsDataCueData(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 254 | { |
| 255 | return IDLAttribute<JSDataCue>::get<jsDataCueDataGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "data" ); |
| 256 | } |
| 257 | |
| 258 | static inline bool setJSDataCueDataSetter(ExecState& state, JSDataCue& thisObject, JSValue value, ThrowScope& throwScope) |
| 259 | { |
| 260 | UNUSED_PARAM(throwScope); |
| 261 | auto& impl = thisObject.wrapped(); |
| 262 | auto nativeValue = convert<IDLArrayBuffer>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "DataCue" , "data" , "ArrayBuffer" ); }); |
| 263 | RETURN_IF_EXCEPTION(throwScope, false); |
| 264 | AttributeSetter::call(state, throwScope, [&] { |
| 265 | return impl.setData(*nativeValue); |
| 266 | }); |
| 267 | return true; |
| 268 | } |
| 269 | |
| 270 | bool setJSDataCueData(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 271 | { |
| 272 | return IDLAttribute<JSDataCue>::set<setJSDataCueDataSetter>(*state, thisValue, encodedValue, "data" ); |
| 273 | } |
| 274 | |
| 275 | static inline JSValue jsDataCueValueGetter(ExecState& state, JSDataCue& thisObject, ThrowScope& throwScope) |
| 276 | { |
| 277 | UNUSED_PARAM(throwScope); |
| 278 | UNUSED_PARAM(state); |
| 279 | auto& impl = thisObject.wrapped(); |
| 280 | JSValue result = toJS<IDLAny>(state, throwScope, impl.value(state)); |
| 281 | return result; |
| 282 | } |
| 283 | |
| 284 | EncodedJSValue jsDataCueValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 285 | { |
| 286 | return IDLAttribute<JSDataCue>::get<jsDataCueValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "value" ); |
| 287 | } |
| 288 | |
| 289 | static inline bool setJSDataCueValueSetter(ExecState& state, JSDataCue& thisObject, JSValue value, ThrowScope& throwScope) |
| 290 | { |
| 291 | UNUSED_PARAM(throwScope); |
| 292 | auto& impl = thisObject.wrapped(); |
| 293 | auto nativeValue = convert<IDLAny>(state, value); |
| 294 | RETURN_IF_EXCEPTION(throwScope, false); |
| 295 | AttributeSetter::call(state, throwScope, [&] { |
| 296 | return impl.setValue(state, WTFMove(nativeValue)); |
| 297 | }); |
| 298 | return true; |
| 299 | } |
| 300 | |
| 301 | bool setJSDataCueValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 302 | { |
| 303 | return IDLAttribute<JSDataCue>::set<setJSDataCueValueSetter>(*state, thisValue, encodedValue, "value" ); |
| 304 | } |
| 305 | |
| 306 | static inline JSValue jsDataCueTypeGetter(ExecState& state, JSDataCue& thisObject, ThrowScope& throwScope) |
| 307 | { |
| 308 | UNUSED_PARAM(throwScope); |
| 309 | UNUSED_PARAM(state); |
| 310 | auto& impl = thisObject.wrapped(); |
| 311 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.type()); |
| 312 | return result; |
| 313 | } |
| 314 | |
| 315 | EncodedJSValue jsDataCueType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 316 | { |
| 317 | return IDLAttribute<JSDataCue>::get<jsDataCueTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type" ); |
| 318 | } |
| 319 | |
| 320 | void JSDataCue::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 321 | { |
| 322 | auto* thisObject = jsCast<JSDataCue*>(cell); |
| 323 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 324 | if (thisObject->scriptExecutionContext()) |
| 325 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 326 | Base::heapSnapshot(cell, builder); |
| 327 | } |
| 328 | |
| 329 | #if ENABLE(BINDING_INTEGRITY) |
| 330 | #if PLATFORM(WIN) |
| 331 | #pragma warning(disable: 4483) |
| 332 | extern "C" { extern void (*const __identifier("??_7DataCue@WebCore@@6B@" )[])(); } |
| 333 | #else |
| 334 | extern "C" { extern void* _ZTVN7WebCore7DataCueE[]; } |
| 335 | #endif |
| 336 | #endif |
| 337 | |
| 338 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DataCue>&& impl) |
| 339 | { |
| 340 | |
| 341 | #if ENABLE(BINDING_INTEGRITY) |
| 342 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 343 | #if PLATFORM(WIN) |
| 344 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7DataCue@WebCore@@6B@" )); |
| 345 | #else |
| 346 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore7DataCueE[2]); |
| 347 | #endif |
| 348 | |
| 349 | // If this fails DataCue does not have a vtable, so you need to add the |
| 350 | // ImplementationLacksVTable attribute to the interface definition |
| 351 | static_assert(std::is_polymorphic<DataCue>::value, "DataCue is not polymorphic" ); |
| 352 | |
| 353 | // If you hit this assertion you either have a use after free bug, or |
| 354 | // DataCue has subclasses. If DataCue has subclasses that get passed |
| 355 | // to toJS() we currently require DataCue you to opt out of binding hardening |
| 356 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 357 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 358 | #endif |
| 359 | return createWrapper<DataCue>(globalObject, WTFMove(impl)); |
| 360 | } |
| 361 | |
| 362 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DataCue& impl) |
| 363 | { |
| 364 | return wrap(state, globalObject, impl); |
| 365 | } |
| 366 | |
| 367 | |
| 368 | } |
| 369 | |
| 370 | #endif // ENABLE(VIDEO_TRACK) |
| 371 | |