Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM IterableIterator.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "IterableIteratorBinding.h"
#include "MainThreadUtils.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"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
IterableKeyAndValueResult::IterableKeyAndValueResult()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
IterableKeyAndValueResult::InitIds(JSContext* cx, IterableKeyAndValueResultAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->value_id.init(cx, "value") ||
!atomsCache->done_id.init(cx, "done")) {
return false;
}
return true;
}
bool
IterableKeyAndValueResult::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mDone = false;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
/* mValue array is already empty; nothing to do */
}
mIsAnyMemberPresent = true;
return true;
}
bool
IterableKeyAndValueResult::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
IterableKeyAndValueResultAtoms* atomsCache = GetAtomCache<IterableKeyAndValueResultAtoms>(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));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
bool const & currentValue = mDone;
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->done_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);
Sequence<JS::Value> const & currentValue = mValue;
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 {
JS::ExposeValueToActiveJS(currentValue[sequenceIdx0]);
tmp.set(currentValue[sequenceIdx0]);
if (!MaybeWrapValue(cx, &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->value_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
IterableKeyAndValueResult::TraceDictionary(JSTracer* trc)
{
DoTraceSequence(trc, mValue);
}
IterableKeyOrValueResult::IterableKeyOrValueResult()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
IterableKeyOrValueResult::InitIds(JSContext* cx, IterableKeyOrValueResultAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->value_id.init(cx, "value") ||
!atomsCache->done_id.init(cx, "done")) {
return false;
}
return true;
}
bool
IterableKeyOrValueResult::Init(const char* sourceDescription, bool passedToJSImpl)
{
{
// scope for any temporaries our default value setting needs.
mDone = false;
}
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mValue = JS::UndefinedValue();
}
mIsAnyMemberPresent = true;
return true;
}
bool
IterableKeyOrValueResult::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
IterableKeyOrValueResultAtoms* atomsCache = GetAtomCache<IterableKeyOrValueResultAtoms>(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));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
bool const & currentValue = mDone;
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->done_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);
JS::Value const & currentValue = mValue;
JS::ExposeValueToActiveJS(currentValue);
temp.set(currentValue);
if (!MaybeWrapValue(cx, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->value_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
IterableKeyOrValueResult::TraceDictionary(JSTracer* trc)
{
JS::TraceRoot(trc, &mValue, "IterableKeyOrValueResult.mValue");
}
} // namespace mozilla::dom