Truly independent web browser
/*
* Copyright (c) 2026-present, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
macro_rules! define_class_ids {
($($name:ident,)*) => {
/// Every class of cell the runtime defines, which indexes each heap's table of allocators. A class derived at
/// run time has the id of the class it extends.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u16)]
pub enum ClassId {
$($name,)*
}
/// Every class id, in the order of their values.
pub const ALL_CLASS_IDS: &[ClassId] = &[$(ClassId::$name,)*];
pub const CLASS_COUNT: usize = ALL_CLASS_IDS.len();
};
}
define_class_ids! {
Executable,
PrimitiveString,
RopeString,
Substring,
InlineString,
Symbol,
BigInt,
Accessor,
Shape,
WatchpointSet,
SpecialPropertyCache,
DeclarativeEnvironmentRareData,
DescriptorArray,
DictionaryPropertyTable,
ValueStorage,
PrivateEnvironment,
Realm,
Object,
Array,
ProxyObject,
Environment,
DeclarativeEnvironment,
GlobalDeclarativeEnvironment,
FunctionEnvironment,
ModuleEnvironment,
EnvironmentShape,
FunctionObject,
NativeFunction,
RawNativeFunction,
DirectGetterFunction,
CapturingNativeFunction,
EcmascriptFunctionObject,
EcmascriptFunctionObjectWithRareData,
SharedFunctionInstanceData,
CallEnvironmentTemplate,
BoundFunction,
ArgumentsObject,
ObjectEnvironment,
GlobalEnvironment,
Script,
// Reserved for RegExpObject, whose [[RegExpMatcher]] slot IsRegExp already recognizes by its class.
RegExpObject,
ObjectPropertyIteratorCacheData,
Intrinsics,
GlobalObject,
ObjectPrototype,
ObjectConstructor,
FunctionPrototype,
FunctionConstructor,
ArrayPrototype,
ArrayConstructor,
StringObject,
StringPrototype,
StringConstructor,
NumberObject,
NumberPrototype,
NumberConstructor,
BooleanObject,
BooleanPrototype,
BooleanConstructor,
SymbolObject,
SymbolPrototype,
SymbolConstructor,
BigIntObject,
BigIntPrototype,
BigIntConstructor,
Error,
ErrorPrototype,
ErrorConstructor,
ErrorDataCell,
EvalError,
EvalErrorPrototype,
EvalErrorConstructor,
InternalError,
InternalErrorPrototype,
InternalErrorConstructor,
RangeError,
RangeErrorPrototype,
RangeErrorConstructor,
ReferenceError,
ReferenceErrorPrototype,
ReferenceErrorConstructor,
SyntaxError,
SyntaxErrorPrototype,
SyntaxErrorConstructor,
TypeError,
TypeErrorPrototype,
TypeErrorConstructor,
URIError,
URIErrorPrototype,
URIErrorConstructor,
AggregateError,
AggregateErrorPrototype,
AggregateErrorConstructor,
IteratorPrototype,
IteratorConstructor,
ArrayIteratorPrototype,
AsyncIteratorPrototype,
IteratorHelperPrototype,
MapIteratorPrototype,
RegExpStringIteratorPrototype,
SetIteratorPrototype,
StringIteratorPrototype,
AsyncFromSyncIteratorPrototype,
WrapForValidIteratorPrototype,
GeneratorPrototype,
AsyncGeneratorPrototype,
GeneratorFunctionPrototype,
GeneratorFunctionConstructor,
AsyncGeneratorFunctionPrototype,
AsyncGeneratorFunctionConstructor,
AsyncFunctionPrototype,
AsyncFunctionConstructor,
ProxyConstructor,
IteratorRecord,
Iterator,
TemplateObjectCache,
ReflectObject,
Date,
ArrayIterator,
MathObject,
JSONObject,
RawJSONObject,
StringIterator,
GlobalSymbolRegistry,
GeneratorObject,
Console,
ConsoleClient,
ConsoleObject,
ConsoleObjectPrototype,
Test262GlobalObject,
Dollar262Object,
AgentObject,
IsHTMLDDA,
ScriptObject,
ReplObject,
ReplConsoleClient,
TestRunnerGlobalObject,
HeapFunction,
JobQueues,
JobCallback,
Promise,
PromisePrototype,
PromiseConstructor,
PromiseCapability,
ResolvingFunctions,
AwaitedCompletion,
PromiseReaction,
PromiseResolvingFunction,
RemainingElements,
PromiseValueList,
PromiseResolvingElementFunction,
PromiseAllResolveElementFunction,
PromiseAllSettledResolveElementFunction,
PromiseAllSettledRejectElementFunction,
PromiseAnyRejectElementFunction,
AsyncFunctionDriverWrapper,
AsyncGenerator,
AsyncFromSyncIterator,
Map,
MapPrototype,
MapConstructor,
MapIterator,
Set,
SetPrototype,
SetConstructor,
SetIterator,
WeakMap,
WeakMapPrototype,
WeakMapConstructor,
WeakSet,
WeakSetPrototype,
WeakSetConstructor,
WeakRef,
WeakRefPrototype,
WeakRefConstructor,
FinalizationRegistry,
FinalizationRegistryPrototype,
FinalizationRegistryConstructor,
RegExpPrototype,
RegExpConstructor,
RegExpStringIterator,
ArrayBuffer,
ArrayBufferPrototype,
ArrayBufferConstructor,
SharedArrayBufferPrototype,
SharedArrayBufferConstructor,
TypedArrayBase,
TypedArrayPrototype,
TypedArrayConstructor,
Uint8Array,
Uint8ArrayPrototype,
Uint8ArrayConstructor,
Uint8ClampedArray,
Uint8ClampedArrayPrototype,
Uint8ClampedArrayConstructor,
Uint16Array,
Uint16ArrayPrototype,
Uint16ArrayConstructor,
Uint32Array,
Uint32ArrayPrototype,
Uint32ArrayConstructor,
BigUint64Array,
BigUint64ArrayPrototype,
BigUint64ArrayConstructor,
Int8Array,
Int8ArrayPrototype,
Int8ArrayConstructor,
Int16Array,
Int16ArrayPrototype,
Int16ArrayConstructor,
Int32Array,
Int32ArrayPrototype,
Int32ArrayConstructor,
BigInt64Array,
BigInt64ArrayPrototype,
BigInt64ArrayConstructor,
Float16Array,
Float16ArrayPrototype,
Float16ArrayConstructor,
Float32Array,
Float32ArrayPrototype,
Float32ArrayConstructor,
Float64Array,
Float64ArrayPrototype,
Float64ArrayConstructor,
DataView,
DataViewPrototype,
DataViewConstructor,
AtomicsObject,
IteratorHelper,
FlatMapIterator,
WindowsIterator,
DisposableResourceStack,
ConcatIterator,
ZipIterator,
DisposableStack,
DisposableStackPrototype,
DisposableStackConstructor,
AsyncDisposableStack,
AsyncDisposableStackPrototype,
AsyncDisposableStackConstructor,
SuppressedError,
SuppressedErrorPrototype,
SuppressedErrorConstructor,
NativeJavaScriptBackedFunction,
DatePrototype,
DateConstructor,
Module,
CyclicModule,
SourceTextModule,
SyntheticModule,
GraphLoadingState,
ModuleNamespaceObject,
LoadedModules,
Intl,
Locale,
LocalePrototype,
LocaleConstructor,
Collator,
CollatorPrototype,
CollatorConstructor,
CollatorCompareFunction,
ListFormat,
ListFormatPrototype,
ListFormatConstructor,
DisplayNames,
DisplayNamesPrototype,
DisplayNamesConstructor,
Segmenter,
SegmenterPrototype,
SegmenterConstructor,
Segments,
SegmentsPrototype,
SegmentIterator,
SegmentIteratorPrototype,
Duration,
DurationPrototype,
DurationConstructor,
Instant,
InstantPrototype,
InstantConstructor,
PlainTime,
PlainTimePrototype,
PlainTimeConstructor,
PlainDate,
PlainDateTime,
PlainMonthDay,
PlainYearMonth,
ZonedDateTime,
Now,
Temporal,
PlainDatePrototype,
PlainDateConstructor,
PlainDateTimePrototype,
PlainDateTimeConstructor,
PlainYearMonthPrototype,
PlainYearMonthConstructor,
PlainMonthDayPrototype,
PlainMonthDayConstructor,
ZonedDateTimePrototype,
ZonedDateTimeConstructor,
NumberFormatBase,
NumberFormat,
NumberFormatPrototype,
NumberFormatConstructor,
NumberFormatFunction,
PluralRules,
PluralRulesPrototype,
PluralRulesConstructor,
DurationFormat,
DurationFormatPrototype,
DurationFormatConstructor,
DateTimeFormat,
DateTimeFormatPrototype,
DateTimeFormatConstructor,
DateTimeFormatFunction,
RelativeTimeFormat,
RelativeTimeFormatPrototype,
RelativeTimeFormatConstructor,
// The cells an embedder defines through the host class tables of LibJS/HostObjectABI.h.
HostObject,
HostFunction,
HostArray,
HostModule,
HostConsoleClient,
// The cells that hold values of an embedder's own types, which share this id and are told apart by their class.
EmbedderCell,
}