Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM RTCIdentityAssertion.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "RTCIdentityAssertionBinding.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 "mozilla/OwningNonNull.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.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;
RTCIdentityAssertion::RTCIdentityAssertion()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
RTCIdentityAssertion::InitIds(JSContext* cx, RTCIdentityAssertionAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->name_id.init(cx, "name") ||
!atomsCache->idp_id.init(cx, "idp")) {
return false;
}
return true;
}
bool
RTCIdentityAssertion::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());
RTCIdentityAssertionAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<RTCIdentityAssertionAtoms>(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->idp_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mIdp.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mIdp.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mName.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mName.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
RTCIdentityAssertion::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
RTCIdentityAssertion::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
RTCIdentityAssertionAtoms* atomsCache = GetAtomCache<RTCIdentityAssertionAtoms>(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 (mIdp.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mIdp.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->idp_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mName.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mName.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
RTCIdentityAssertion::TraceDictionary(JSTracer* trc)
{
}
RTCIdentityAssertion&
RTCIdentityAssertion::operator=(const RTCIdentityAssertion& aOther)
{
DictionaryBase::operator=(aOther);
mIdp.Reset();
if (aOther.mIdp.WasPassed()) {
mIdp.Construct(aOther.mIdp.Value());
}
mName.Reset();
if (aOther.mName.WasPassed()) {
mName.Construct(aOther.mName.Value());
}
return *this;
}
bool
RTCIdentityAssertion::operator==(const RTCIdentityAssertion& aOther) const
{
if (mIdp != aOther.mIdp) {
return false;
}
if (mName != aOther.mName) {
return false;
}
return true;
}
} // namespace mozilla::dom