Generated file

Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM RTCEncodedFrameMetadata.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "RTCEncodedFrameMetadataBinding.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/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;
RTCEncodedFrameMetadata::RTCEncodedFrameMetadata()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
RTCEncodedFrameMetadata::InitIds(JSContext* cx, RTCEncodedFrameMetadataAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->synchronizationSource_id.init(cx, "synchronizationSource") ||
!atomsCache->rtpTimestamp_id.init(cx, "rtpTimestamp") ||
!atomsCache->payloadType_id.init(cx, "payloadType") ||
!atomsCache->mimeType_id.init(cx, "mimeType") ||
!atomsCache->contributingSources_id.init(cx, "contributingSources")) {
return false;
}
return true;
}
bool
RTCEncodedFrameMetadata::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// Passing a null JSContext is OK only if we're initing from null,
// Since in that case we will not have to do any property gets
// Also evaluate isNullOrUndefined in order to avoid false-positive
// checkers by static analysis tools
MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
RTCEncodedFrameMetadataAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<RTCEncodedFrameMetadataAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
}
if (!IsConvertibleToDictionary(val)) {
return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
}
bool isNull = val.isNullOrUndefined();
// We only need these if !isNull, in which case we have |cx|.
Maybe<JS::Rooted<JSObject *> > object;
Maybe<JS::Rooted<JS::Value> > temp;
if (!isNull) {
MOZ_ASSERT(cx);
object.emplace(cx, &val.toObject());
temp.emplace(cx);
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->contributingSources_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mContributingSources.Construct();
if (temp.ref().isObject()) {
JS::ForOfIterator iter(cx);
if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
return false;
}
if (!iter.valueIsIterable()) {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'contributingSources' member of RTCEncodedFrameMetadata", "sequence");
return false;
}
Sequence<uint32_t> &arr = (mContributingSources.Value());
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
return false;
}
if (done) {
break;
}
uint32_t* slotPtr = arr.AppendElement(mozilla::fallible);
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
return false;
}
uint32_t& slot = *slotPtr;
if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp, "Element of 'contributingSources' member of RTCEncodedFrameMetadata", &slot)) {
return false;
}
}
} else {
cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'contributingSources' member of RTCEncodedFrameMetadata", "sequence");
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->mimeType_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mMimeType.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mMimeType.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->payloadType_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mPayloadType.Construct();
if (!ValueToPrimitive<uint8_t, eDefault>(cx, temp.ref(), "'payloadType' member of RTCEncodedFrameMetadata", &(mPayloadType.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->rtpTimestamp_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mRtpTimestamp.Construct();
if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), "'rtpTimestamp' member of RTCEncodedFrameMetadata", &(mRtpTimestamp.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->synchronizationSource_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mSynchronizationSource.Construct();
if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), "'synchronizationSource' member of RTCEncodedFrameMetadata", &(mSynchronizationSource.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
RTCEncodedFrameMetadata::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// We don't want to use sourceDescription for our context here;
// that's not really what it's formatted for.
BindingCallContext cx(cx_, nullptr);
return Init(cx, val, sourceDescription, passedToJSImpl);
}
bool
RTCEncodedFrameMetadata::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
RTCEncodedFrameMetadataAtoms* atomsCache = GetAtomCache<RTCEncodedFrameMetadataAtoms>(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 (mContributingSources.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Sequence<uint32_t> const & currentValue = mContributingSources.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.setNumber(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->contributingSources_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mMimeType.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mMimeType.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->mimeType_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mPayloadType.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint8_t const & currentValue = mPayloadType.InternalValue();
temp.setInt32(int32_t(currentValue));
if (!JS_DefinePropertyById(cx, obj, atomsCache->payloadType_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mRtpTimestamp.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mRtpTimestamp.InternalValue();
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->rtpTimestamp_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mSynchronizationSource.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
uint32_t const & currentValue = mSynchronizationSource.InternalValue();
temp.setNumber(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->synchronizationSource_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
RTCEncodedFrameMetadata::TraceDictionary(JSTracer* trc)
{
}
RTCEncodedFrameMetadata&
RTCEncodedFrameMetadata::operator=(const RTCEncodedFrameMetadata& aOther)
{
MaybeEmptyDictionaryBase::operator=(aOther);
mContributingSources.Reset();
if (aOther.mContributingSources.WasPassed()) {
mContributingSources.Construct(aOther.mContributingSources.Value());
}
mMimeType.Reset();
if (aOther.mMimeType.WasPassed()) {
mMimeType.Construct(aOther.mMimeType.Value());
}
mPayloadType.Reset();
if (aOther.mPayloadType.WasPassed()) {
mPayloadType.Construct(aOther.mPayloadType.Value());
}
mRtpTimestamp.Reset();
if (aOther.mRtpTimestamp.WasPassed()) {
mRtpTimestamp.Construct(aOther.mRtpTimestamp.Value());
}
mSynchronizationSource.Reset();
if (aOther.mSynchronizationSource.WasPassed()) {
mSynchronizationSource.Construct(aOther.mSynchronizationSource.Value());
}
return *this;
}
} // namespace mozilla::dom