Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM MediaTrackCapabilities.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "MediaTrackCapabilitiesBinding.h"
#include "js/Array.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/ForOfIterator.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.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::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
DoubleRange::DoubleRange()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
DoubleRange::InitIds(JSContext* cx, DoubleRangeAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->min_id.init(cx, "min") ||
!atomsCache->max_id.init(cx, "max")) {
return false;
}
return true;
}
bool
DoubleRange::Init(const char* sourceDescription, bool passedToJSImpl)
{
return true;
}
bool
DoubleRange::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
DoubleRangeAtoms* atomsCache = GetAtomCache<DoubleRangeAtoms>(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 (mMax.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mMax.InternalValue();
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->max_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mMin.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mMin.InternalValue();
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->min_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
DoubleRange::TraceDictionary(JSTracer* trc)
{
}
DoubleRange&
DoubleRange::operator=(const DoubleRange& aOther)
{
DictionaryBase::operator=(aOther);
mMax.Reset();
if (aOther.mMax.WasPassed()) {
mMax.Construct(aOther.mMax.Value());
}
mMin.Reset();
if (aOther.mMin.WasPassed()) {
mMin.Construct(aOther.mMin.Value());
}
return *this;
}
ULongRange::ULongRange()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
ULongRange::InitIds(JSContext* cx, ULongRangeAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->min_id.init(cx, "min") ||
!atomsCache->max_id.init(cx, "max")) {
return false;
}
return true;
}
bool
ULongRange::Init(const char* sourceDescription, bool passedToJSImpl)
{
return true;
}
bool
ULongRange::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
ULongRangeAtoms* atomsCache = GetAtomCache<ULongRangeAtoms>(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 (mMax.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mMax.InternalValue();
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->max_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mMin.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mMin.InternalValue();
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->min_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
ULongRange::TraceDictionary(JSTracer* trc)
{
}
ULongRange&
ULongRange::operator=(const ULongRange& aOther)
{
DictionaryBase::operator=(aOther);
mMax.Reset();
if (aOther.mMax.WasPassed()) {
mMax.Construct(aOther.mMax.Value());
}
mMin.Reset();
if (aOther.mMin.WasPassed()) {
mMin.Construct(aOther.mMin.Value());
}
return *this;
}
MediaTrackCapabilities::MediaTrackCapabilities()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
MediaTrackCapabilities::InitIds(JSContext* cx, MediaTrackCapabilitiesAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->width_id.init(cx, "width") ||
!atomsCache->noiseSuppression_id.init(cx, "noiseSuppression") ||
!atomsCache->height_id.init(cx, "height") ||
!atomsCache->groupId_id.init(cx, "groupId") ||
!atomsCache->frameRate_id.init(cx, "frameRate") ||
!atomsCache->facingMode_id.init(cx, "facingMode") ||
!atomsCache->echoCancellation_id.init(cx, "echoCancellation") ||
!atomsCache->deviceId_id.init(cx, "deviceId") ||
!atomsCache->channelCount_id.init(cx, "channelCount") ||
!atomsCache->autoGainControl_id.init(cx, "autoGainControl")) {
return false;
}
return true;
}
bool
MediaTrackCapabilities::Init(const char* sourceDescription, bool passedToJSImpl)
{
return true;
}
bool
MediaTrackCapabilities::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
MediaTrackCapabilitiesAtoms* atomsCache = GetAtomCache<MediaTrackCapabilitiesAtoms>(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 (mAutoGainControl.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<bool> const & currentValue = mAutoGainControl.InternalValue();
uint32_t length = currentValue.Length();
JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
if (!returnArray) {
return false;
}
// Scope for 'tmp'
{
JS::Rooted<JS::Value> tmp(cx);
for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
// Control block to let us common up the JS_DefineElement calls when there
// are different ways to succeed at wrapping the object.
do {
tmp.setBoolean(currentValue[sequenceIdx0]);
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
temp.setObject(*returnArray);
if (!JS_DefinePropertyById(cx, obj, atomsCache->autoGainControl_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mChannelCount.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
ULongRange const & currentValue = mChannelCount.InternalValue();
if (!currentValue.ToObjectInternal(cx, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->channelCount_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mDeviceId.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mDeviceId.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->deviceId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mEchoCancellation.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<bool> const & currentValue = mEchoCancellation.InternalValue();
uint32_t length = currentValue.Length();
JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
if (!returnArray) {
return false;
}
// Scope for 'tmp'
{
JS::Rooted<JS::Value> tmp(cx);
for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
// Control block to let us common up the JS_DefineElement calls when there
// are different ways to succeed at wrapping the object.
do {
tmp.setBoolean(currentValue[sequenceIdx0]);
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
temp.setObject(*returnArray);
if (!JS_DefinePropertyById(cx, obj, atomsCache->echoCancellation_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mFacingMode.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<nsString> const & currentValue = mFacingMode.InternalValue();
uint32_t length = currentValue.Length();
JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
if (!returnArray) {
return false;
}
// Scope for 'tmp'
{
JS::Rooted<JS::Value> tmp(cx);
for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
// Control block to let us common up the JS_DefineElement calls when there
// are different ways to succeed at wrapping the object.
do {
if (!xpc::NonVoidStringToJsval(cx, currentValue[sequenceIdx0], &tmp)) {
return false;
}
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
temp.setObject(*returnArray);
if (!JS_DefinePropertyById(cx, obj, atomsCache->facingMode_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mFrameRate.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
DoubleRange const & currentValue = mFrameRate.InternalValue();
if (!currentValue.ToObjectInternal(cx, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->frameRate_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mGroupId.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mGroupId.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->groupId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mHeight.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
ULongRange const & currentValue = mHeight.InternalValue();
if (!currentValue.ToObjectInternal(cx, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->height_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mNoiseSuppression.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<bool> const & currentValue = mNoiseSuppression.InternalValue();
uint32_t length = currentValue.Length();
JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
if (!returnArray) {
return false;
}
// Scope for 'tmp'
{
JS::Rooted<JS::Value> tmp(cx);
for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
// Control block to let us common up the JS_DefineElement calls when there
// are different ways to succeed at wrapping the object.
do {
tmp.setBoolean(currentValue[sequenceIdx0]);
break;
} while (false);
if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
JSPROP_ENUMERATE)) {
return false;
}
}
}
temp.setObject(*returnArray);
if (!JS_DefinePropertyById(cx, obj, atomsCache->noiseSuppression_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mWidth.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
ULongRange const & currentValue = mWidth.InternalValue();
if (!currentValue.ToObjectInternal(cx, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->width_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
MediaTrackCapabilities::TraceDictionary(JSTracer* trc)
{
}
MediaTrackCapabilities&
MediaTrackCapabilities::operator=(const MediaTrackCapabilities& aOther)
{
DictionaryBase::operator=(aOther);
mAutoGainControl.Reset();
if (aOther.mAutoGainControl.WasPassed()) {
mAutoGainControl.Construct(aOther.mAutoGainControl.Value());
}
mChannelCount.Reset();
if (aOther.mChannelCount.WasPassed()) {
mChannelCount.Construct(aOther.mChannelCount.Value());
}
mDeviceId.Reset();
if (aOther.mDeviceId.WasPassed()) {
mDeviceId.Construct(aOther.mDeviceId.Value());
}
mEchoCancellation.Reset();
if (aOther.mEchoCancellation.WasPassed()) {
mEchoCancellation.Construct(aOther.mEchoCancellation.Value());
}
mFacingMode.Reset();
if (aOther.mFacingMode.WasPassed()) {
mFacingMode.Construct(aOther.mFacingMode.Value());
}
mFrameRate.Reset();
if (aOther.mFrameRate.WasPassed()) {
mFrameRate.Construct(aOther.mFrameRate.Value());
}
mGroupId.Reset();
if (aOther.mGroupId.WasPassed()) {
mGroupId.Construct(aOther.mGroupId.Value());
}
mHeight.Reset();
if (aOther.mHeight.WasPassed()) {
mHeight.Construct(aOther.mHeight.Value());
}
mNoiseSuppression.Reset();
if (aOther.mNoiseSuppression.WasPassed()) {
mNoiseSuppression.Construct(aOther.mNoiseSuppression.Value());
}
mWidth.Reset();
if (aOther.mWidth.WasPassed()) {
mWidth.Construct(aOther.mWidth.Value());
}
return *this;
}
} // namespace mozilla::dom