Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM RTCRtpSources.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "RTCRtpSourcesBinding.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.h"
#include "jsapi.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SimpleGlobalObject.h"
namespace mozilla {
namespace dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
namespace binding_detail {
const nsLiteralCString EnumStrings<RTCRtpSourceEntryType>::Values[2] = {
"contributing"_ns,
"synchronization"_ns,
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, RTCRtpSourceEntryType aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<RTCRtpSourceEntryType>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<RTCRtpSourceEntryType>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<RTCRtpSourceEntryType>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
RTCRtpContributingSource::RTCRtpContributingSource()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
RTCRtpContributingSource::InitIds(JSContext* cx, RTCRtpContributingSourceAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->timestamp_id.init(cx, "timestamp") ||
!atomsCache->source_id.init(cx, "source") ||
!atomsCache->rtpTimestamp_id.init(cx, "rtpTimestamp") ||
!atomsCache->audioLevel_id.init(cx, "audioLevel")) {
return false;
}
return true;
}
bool
RTCRtpContributingSource::Init(const char* sourceDescription, bool passedToJSImpl)
{
return true;
}
bool
RTCRtpContributingSource::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
RTCRtpContributingSourceAtoms* atomsCache = GetAtomCache<RTCRtpContributingSourceAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
if (mAudioLevel.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mAudioLevel.InternalValue();
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->audioLevel_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mRtpTimestamp;
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->rtpTimestamp_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mSource;
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->source_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mTimestamp;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->timestamp_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
RTCRtpContributingSource::TraceDictionary(JSTracer* trc)
{
}
RTCRtpContributingSource&
RTCRtpContributingSource::operator=(const RTCRtpContributingSource& aOther)
{
DictionaryBase::operator=(aOther);
mAudioLevel.Reset();
if (aOther.mAudioLevel.WasPassed()) {
mAudioLevel.Construct(aOther.mAudioLevel.Value());
}
mRtpTimestamp = aOther.mRtpTimestamp;
mSource = aOther.mSource;
mTimestamp = aOther.mTimestamp;
return *this;
}
bool
RTCRtpContributingSource::operator==(const RTCRtpContributingSource& aOther) const
{
if (mAudioLevel != aOther.mAudioLevel) {
return false;
}
if (mRtpTimestamp != aOther.mRtpTimestamp) {
return false;
}
if (mSource != aOther.mSource) {
return false;
}
if (mTimestamp != aOther.mTimestamp) {
return false;
}
return true;
}
RTCRtpSynchronizationSource::RTCRtpSynchronizationSource()
: RTCRtpContributingSource(FastDictionaryInitializer())
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
RTCRtpSynchronizationSource::InitIds(JSContext* cx, RTCRtpSynchronizationSourceAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->voiceActivityFlag_id.init(cx, "voiceActivityFlag")) {
return false;
}
return true;
}
bool
RTCRtpSynchronizationSource::Init(const char* sourceDescription, bool passedToJSImpl)
{
// We init the parent's members first
if (!RTCRtpContributingSource::Init()) {
return false;
}
return true;
}
bool
RTCRtpSynchronizationSource::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
RTCRtpSynchronizationSourceAtoms* atomsCache = GetAtomCache<RTCRtpSynchronizationSourceAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
// Per spec, we define the parent's members first
if (!RTCRtpContributingSource::ToObjectInternal(cx, rval)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, &rval.toObject());
if (mVoiceActivityFlag.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Nullable<bool> const & currentValue = mVoiceActivityFlag.InternalValue();
if (currentValue.IsNull()) {
temp.setNull();
if (!JS_DefinePropertyById(cx, obj, atomsCache->voiceActivityFlag_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
}
temp.setBoolean(currentValue.Value());
if (!JS_DefinePropertyById(cx, obj, atomsCache->voiceActivityFlag_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
RTCRtpSynchronizationSource::TraceDictionary(JSTracer* trc)
{
RTCRtpContributingSource::TraceDictionary(trc);
}
RTCRtpSynchronizationSource&
RTCRtpSynchronizationSource::operator=(const RTCRtpSynchronizationSource& aOther)
{
RTCRtpContributingSource::operator=(aOther);
mVoiceActivityFlag.Reset();
if (aOther.mVoiceActivityFlag.WasPassed()) {
mVoiceActivityFlag.Construct(aOther.mVoiceActivityFlag.Value());
}
return *this;
}
bool
RTCRtpSynchronizationSource::operator==(const RTCRtpSynchronizationSource& aOther) const
{
if (mVoiceActivityFlag != aOther.mVoiceActivityFlag) {
return false;
}
return true;
}
RTCRtpSourceEntry::RTCRtpSourceEntry()
: RTCRtpSynchronizationSource(FastDictionaryInitializer())
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
RTCRtpSourceEntry::InitIds(JSContext* cx, RTCRtpSourceEntryAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->sourceType_id.init(cx, "sourceType")) {
return false;
}
return true;
}
bool
RTCRtpSourceEntry::Init(const char* sourceDescription, bool passedToJSImpl)
{
// We init the parent's members first
if (!RTCRtpSynchronizationSource::Init()) {
return false;
}
return true;
}
void
RTCRtpSourceEntry::TraceDictionary(JSTracer* trc)
{
RTCRtpSynchronizationSource::TraceDictionary(trc);
}
RTCRtpSourceEntry&
RTCRtpSourceEntry::operator=(const RTCRtpSourceEntry& aOther)
{
RTCRtpSynchronizationSource::operator=(aOther);
mSourceType = aOther.mSourceType;
return *this;
}
} // namespace dom
} // namespace mozilla