Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM ShadowRealmGlobalScope.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "MainThreadUtils.h"
#include "ShadowRealmGlobalScopeBinding.h"
#include "WrapperFactory.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/DOMJSClass.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/ShadowRealmGlobalScope.h"
namespace mozilla::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
namespace ShadowRealmGlobalScope_Binding {
static void
_finalize(JS::GCContext* gcx, JSObject* obj)
{
mozilla::dom::ShadowRealmGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ShadowRealmGlobalScope>(obj);
if (self) {
JS::SetReservedSlot(obj, DOM_OBJECT_SLOT, JS::UndefinedValue());
ClearWrapper(self, self, obj);
mozilla::dom::FinalizeGlobal(gcx, obj);
if (size_t mallocBytes = BindingJSObjectMallocBytes(self)) {
JS::RemoveAssociatedMemory(obj, mallocBytes,
JS::MemoryUse::DOMBinding);
}
AddForDeferredFinalization<mozilla::dom::ShadowRealmGlobalScope>(self);
}
}
static size_t
_objectMoved(JSObject* obj, JSObject* old)
{
mozilla::dom::ShadowRealmGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ShadowRealmGlobalScope>(obj);
if (self) {
UpdateWrapper(self, self, obj, old);
}
return 0;
}
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
{
"ShadowRealmGlobalScopePrototype",
JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
JS_NULL_CLASS_OPS,
JS_NULL_CLASS_SPEC,
JS_NULL_CLASS_EXT,
JS_NULL_OBJECT_OPS
},
eGlobalInterfacePrototype,
prototypes::id::ShadowRealmGlobalScope,
PrototypeTraits<prototypes::id::ShadowRealmGlobalScope>::Depth,
&sEmptyNativePropertyHooks,
JS::GetRealmObjectPrototype
};
static const JSClassOps sClassOps = {
nullptr, /* addProperty */
nullptr, /* delProperty */
nullptr, /* enumerate */
mozilla::dom::EnumerateGlobal, /* newEnumerate */
mozilla::dom::ResolveGlobal, /* resolve */
mozilla::dom::MayResolveGlobal, /* mayResolve */
_finalize, /* finalize */
nullptr, /* call */
nullptr, /* construct */
JS_GlobalObjectTraceHook, /* trace */
};
static const js::ClassExtension sClassExtension = {
_objectMoved /* objectMovedOp */
};
static const DOMJSClass sClass = {
{ "ShadowRealmGlobalScope",
JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS),
&sClassOps,
JS_NULL_CLASS_SPEC,
&sClassExtension,
JS_NULL_OBJECT_OPS
},
{ prototypes::id::ShadowRealmGlobalScope, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
std::is_base_of_v<nsISupports, mozilla::dom::ShadowRealmGlobalScope>,
&sEmptyNativePropertyHooks,
FindAssociatedGlobalForNative<mozilla::dom::ShadowRealmGlobalScope>::Get,
JS::GetRealmObjectPrototypeHandle,
GetCCParticipant<mozilla::dom::ShadowRealmGlobalScope>::Get(),
nullptr,
nullptr
};
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
"Must have the right minimal number of reserved slots.");
static_assert(JSCLASS_GLOBAL_APPLICATION_SLOTS >= 1,
"Must have enough reserved slots.");
bool
Wrap(JSContext* aCx, mozilla::dom::ShadowRealmGlobalScope* aObject, nsWrapperCache* aCache, JS::RealmOptions& aOptions, JSPrincipals* aPrincipal, JS::MutableHandle<JSObject*> aReflector)
{
static_assert(std::is_same_v<decltype(aObject), mozilla::dom::ShadowRealmGlobalScope*>);
MOZ_ASSERT(ToSupportsIsCorrect(aObject));
MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
"nsISupports must be on our primary inheritance chain");
if (!CreateGlobal<mozilla::dom::ShadowRealmGlobalScope, JS::GetRealmObjectPrototypeHandle>(aCx,
aObject,
aCache,
sClass.ToJSClass(),
aOptions,
aPrincipal,
aReflector)) {
aCache->ReleaseWrapper(aObject);
aCache->ClearWrapper();
return false;
}
// aReflector is a new global, so has a new realm. Enter it
// before doing anything with it.
JSAutoRealm ar(aCx, aReflector);
if (!DefineProperties(aCx, aReflector, nullptr, nullptr)) {
aCache->ReleaseWrapper(aObject);
aCache->ClearWrapper();
return false;
}
return true;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
{
JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ShadowRealmGlobalScope);
JS::Heap<JSObject*>* interfaceCache = nullptr;
JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
if (!parentProto) {
return;
}
dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
&sPrototypeClass, protoCache,
nullptr, nullptr, 0, false, Span<const LegacyFactoryFunction, 0>{},
interfaceCache,
nullptr,
nullptr,
"ShadowRealmGlobalScope", aDefineOnGlobal,
nullptr,
true,
nullptr);
}
} // namespace ShadowRealmGlobalScope_Binding
} // namespace mozilla::dom