| /* |
| 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(WEB_RTC) |
| |
| #include "JSRTCTrackEvent.h" |
| |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDictionary.h" |
| #include "JSMediaStream.h" |
| #include "JSMediaStreamTrack.h" |
| #include "JSRTCRtpReceiver.h" |
| #include "JSRTCRtpTransceiver.h" |
| #include <runtime/Error.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsRTCTrackEventReceiver(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCTrackEventTrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCTrackEventStreams(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCTrackEventTransceiver(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSRTCTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSRTCTrackEventPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSRTCTrackEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSRTCTrackEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCTrackEventPrototype>(vm.heap)) JSRTCTrackEventPrototype(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: |
| JSRTCTrackEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSRTCTrackEvent> JSRTCTrackEventConstructor; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSRTCTrackEventConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| auto* jsConstructor = jsCast<JSRTCTrackEventConstructor*>(state->callee()); |
| ASSERT(jsConstructor); |
| |
| if (!jsConstructor->scriptExecutionContext()) |
| return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "RTCTrackEvent"); |
| |
| 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()); |
| |
| RTCTrackEventInit 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 (!fillRTCTrackEventInit(eventInit, dictionary)) |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| Ref<RTCTrackEvent> event = RTCTrackEvent::createForBindings(eventType, eventInit); |
| return JSValue::encode(createWrapper<RTCTrackEvent>(jsConstructor->globalObject(), WTFMove(event))); |
| } |
| |
| bool fillRTCTrackEventInit(RTCTrackEventInit& eventInit, JSDictionary& dictionary) |
| { |
| if (!fillEventInit(eventInit, dictionary)) |
| return false; |
| |
| if (!dictionary.tryGetProperty("receiver", eventInit.receiver)) |
| return false; |
| if (!dictionary.tryGetProperty("track", eventInit.track)) |
| return false; |
| if (!dictionary.tryGetProperty("streams", eventInit.streams)) |
| return false; |
| if (!dictionary.tryGetProperty("transceiver", eventInit.transceiver)) |
| return false; |
| return true; |
| } |
| |
| template<> JSValue JSRTCTrackEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSEvent::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSRTCTrackEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSRTCTrackEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("RTCTrackEvent"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSRTCTrackEventConstructor::s_info = { "RTCTrackEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCTrackEventConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSRTCTrackEventPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCTrackEventConstructor) } }, |
| { "receiver", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventReceiver), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "track", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventTrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "streams", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventStreams), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "transceiver", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCTrackEventTransceiver), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| }; |
| |
| const ClassInfo JSRTCTrackEventPrototype::s_info = { "RTCTrackEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCTrackEventPrototype) }; |
| |
| void JSRTCTrackEventPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSRTCTrackEventPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSRTCTrackEvent::s_info = { "RTCTrackEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCTrackEvent) }; |
| |
| JSRTCTrackEvent::JSRTCTrackEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCTrackEvent>&& impl) |
| : JSEvent(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSRTCTrackEvent::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSRTCTrackEventPrototype::create(vm, globalObject, JSRTCTrackEventPrototype::createStructure(vm, globalObject, JSEvent::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSRTCTrackEvent::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSRTCTrackEvent>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsRTCTrackEventReceiver(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<JSRTCTrackEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCTrackEvent", "receiver"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.receiver()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCTrackEventTrack(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<JSRTCTrackEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCTrackEvent", "track"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.track()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCTrackEventStreams(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<JSRTCTrackEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCTrackEvent", "streams"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsArray(state, castedThis->globalObject(), impl.streams()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCTrackEventTransceiver(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<JSRTCTrackEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCTrackEvent", "transceiver"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.transceiver()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSRTCTrackEventPrototype* domObject = jsDynamicCast<JSRTCTrackEventPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSRTCTrackEvent::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSRTCTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSRTCTrackEventPrototype* domObject = jsDynamicCast<JSRTCTrackEventPrototype*>(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 JSRTCTrackEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSRTCTrackEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| |
| } |
| |
| #endif // ENABLE(WEB_RTC) |