| /* |
| 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(MEDIA_STREAM) |
| |
| #include "JSMediaStreamTrackEvent.h" |
| |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDictionary.h" |
| #include "JSMediaStreamTrack.h" |
| #include <runtime/Error.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsMediaStreamTrackEventTrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsMediaStreamTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSMediaStreamTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSMediaStreamTrackEventPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSMediaStreamTrackEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSMediaStreamTrackEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaStreamTrackEventPrototype>(vm.heap)) JSMediaStreamTrackEventPrototype(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: |
| JSMediaStreamTrackEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSMediaStreamTrackEvent> JSMediaStreamTrackEventConstructor; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSMediaStreamTrackEventConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| auto* jsConstructor = jsCast<JSMediaStreamTrackEventConstructor*>(state->callee()); |
| ASSERT(jsConstructor); |
| |
| if (!jsConstructor->scriptExecutionContext()) |
| return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "MediaStreamTrackEvent"); |
| |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| |
| AtomicString eventType = state->uncheckedArgument(0).toString(state)->toAtomicString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| |
| MediaStreamTrackEventInit eventInit; |
| |
| JSValue initializerValue = state->argument(1); |
| if (!initializerValue.isUndefinedOrNull()) { |
| // Given the above test, this will always yield an object. |
| JSObject* initializerObject = initializerValue.toObject(state); |
| ASSERT(!throwScope.exception()); |
| |
| // Create the dictionary wrapper from the initializer object. |
| JSDictionary dictionary(state, initializerObject); |
| |
| // Attempt to fill in the EventInit. |
| if (!fillMediaStreamTrackEventInit(eventInit, dictionary)) |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| Ref<MediaStreamTrackEvent> event = MediaStreamTrackEvent::createForBindings(eventType, eventInit); |
| return JSValue::encode(createWrapper<MediaStreamTrackEvent>(jsConstructor->globalObject(), WTFMove(event))); |
| } |
| |
| bool fillMediaStreamTrackEventInit(MediaStreamTrackEventInit& eventInit, JSDictionary& dictionary) |
| { |
| if (!fillEventInit(eventInit, dictionary)) |
| return false; |
| |
| if (!dictionary.tryGetProperty("track", eventInit.track)) |
| return false; |
| return true; |
| } |
| |
| template<> JSValue JSMediaStreamTrackEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSEvent::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSMediaStreamTrackEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSMediaStreamTrackEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("MediaStreamTrackEvent"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSMediaStreamTrackEventConstructor::s_info = { "MediaStreamTrackEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMediaStreamTrackEventConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSMediaStreamTrackEventPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackEventConstructor) } }, |
| { "track", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackEventTrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| }; |
| |
| const ClassInfo JSMediaStreamTrackEventPrototype::s_info = { "MediaStreamTrackEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMediaStreamTrackEventPrototype) }; |
| |
| void JSMediaStreamTrackEventPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSMediaStreamTrackEventPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSMediaStreamTrackEvent::s_info = { "MediaStreamTrackEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMediaStreamTrackEvent) }; |
| |
| JSMediaStreamTrackEvent::JSMediaStreamTrackEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaStreamTrackEvent>&& impl) |
| : JSEvent(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSMediaStreamTrackEvent::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSMediaStreamTrackEventPrototype::create(vm, globalObject, JSMediaStreamTrackEventPrototype::createStructure(vm, globalObject, JSEvent::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSMediaStreamTrackEvent::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSMediaStreamTrackEvent>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsMediaStreamTrackEventTrack(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<JSMediaStreamTrackEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "MediaStreamTrackEvent", "track"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.track()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsMediaStreamTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSMediaStreamTrackEventPrototype* domObject = jsDynamicCast<JSMediaStreamTrackEventPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSMediaStreamTrackEvent::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSMediaStreamTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSMediaStreamTrackEventPrototype* domObject = jsDynamicCast<JSMediaStreamTrackEventPrototype*>(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); |
| } |
| |
| JSValue JSMediaStreamTrackEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSMediaStreamTrackEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| |
| } |
| |
| #endif // ENABLE(MEDIA_STREAM) |