Truly independent web browser
/*
* Copyright (c) 2026-present, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
use ak::Utf16FlyString;
use crate::runtime::property_key::{PropertyKey, StringMayBeNumber};
/// Defines CommonPropertyNames with one key per name. A name is its own string unless it is followed by `= "string"`,
/// for the strings that are not valid identifiers as they are.
macro_rules! define_common_property_names {
(@string $name:ident) => {
stringify!($name)
};
(@string $name:ident $string:literal) => {
$string
};
($($name:ident $(= $string:literal)?,)*) => {
/// The property names the runtime uses, interned once per VM.
#[allow(non_snake_case)]
pub struct CommonPropertyNames {
$(pub $name: PropertyKey,)*
}
impl CommonPropertyNames {
pub fn new() -> Self {
Self {
$($name: common_property_name(define_common_property_names!(@string $name $($string)?)),)*
}
}
}
};
}
fn common_property_name(name: &str) -> PropertyKey {
PropertyKey::from_fly_string(Utf16FlyString::from_utf8(name), StringMayBeNumber::No)
}
impl Default for CommonPropertyNames {
fn default() -> Self {
Self::new()
}
}
define_common_property_names! {
and_ = "and",
catch_ = "catch",
delete_ = "delete",
for_ = "for",
or_ = "or",
register_ = "register",
return_ = "return",
throw_ = "throw",
try_ = "try",
union_ = "union",
xor_ = "xor",
inputAlias = "$_",
lastMatchAlias = "$&",
lastParenAlias = "$+",
leftContextAlias = "$`",
rightContextAlias = "$'",
// ENUMERATE_STANDARD_PROPERTY_NAMES
underscore = "_",
__defineGetter__,
__defineSetter__,
__lookupGetter__,
__lookupSetter__,
__proto__,
dollar_1 = "$1",
dollar_2 = "$2",
dollar_3 = "$3",
dollar_4 = "$4",
dollar_5 = "$5",
dollar_6 = "$6",
dollar_7 = "$7",
dollar_8 = "$8",
dollar_9 = "$9",
abs,
acos,
acosh,
add,
adopt,
all,
allSettled,
alphabet,
anchor,
any,
apply,
arguments,
asin,
asinh,
asIntN,
assert,
assign,
asUintN,
at,
atan,
atan2,
atanh,
Atomics,
baseName,
big,
BigInt,
bind,
blank,
blink,
bold,
Boolean,
buffer,
byteLength,
byteOffset,
BYTES_PER_ELEMENT,
calendar,
calendarId,
calendarName,
call,
callee,
caller,
captureStackTrace,
caseFirst,
cause,
cbrt,
ceil,
charAt,
charCodeAt,
chunks,
clear,
clz32,
codePointAt,
collation,
compactDisplay,
compare,
compareExchange,
compile,
composite,
computedOffset,
concat,
configurable,
console,
construct,
constructor,
containing,
copyWithin,
cos,
cosh,
columns,
count,
countReset,
create,
currency,
currencyDisplay,
currencySign,
dateStyle,
day,
dayOfWeek,
dayOfYear,
dayPeriod,
days,
daysDisplay,
daysInMonth,
daysInWeek,
daysInYear,
debug,
decodeURI,
decodeURIComponent,
defer,
defineProperties,
defineProperty,
deleteProperty,
deref,
description,
detached,
difference,
dir,
direction,
dirxml,
disabledFeatures,
disambiguation,
disposeAsync,
disposed,
done,
dotAll,
drop,
E,
easing,
encodeURI,
encodeURIComponent,
endsWith,
entries,
enumerable,
epochMilliseconds,
epochNanoseconds,
EPSILON,
equals,
era,
eraYear,
error,
errors,
escape,
eval,
evaluate,
every,
exchange,
exec,
exp,
expm1,
f16round,
fallback,
fill,
filter,
finally,
find,
findIndex,
findLast,
findLastIndex,
firstDay,
firstDayOfWeek,
fixed,
flags,
flat,
flatMap,
floor,
fontcolor,
fontsize,
forEach,
formAssociated,
format,
formatMatcher,
formatRange,
formatRangeToParts,
formatToParts,
fractionalDigits,
fractionalSecondDigits,
freeze,
from,
fromAsync,
fromBase64,
fromCharCode,
fromCodePoint,
fromEntries,
fromEpochMilliseconds,
fromEpochNanoseconds,
fromHex,
fround,
Function,
get,
getBigInt64,
getBigUint64,
getCalendars,
getCanonicalLocales,
getCollations,
getDate,
getDay,
getFloat16,
getFloat32,
getFloat64,
getFullYear,
getHourCycles,
getHours,
getInt8,
getInt16,
getInt32,
getMilliseconds,
getMinutes,
getMonth,
getNumberingSystems,
getOrInsert,
getOrInsertComputed,
getOwnPropertyDescriptor,
getOwnPropertyDescriptors,
getOwnPropertyNames,
getOwnPropertySymbols,
getPrototypeOf,
getSeconds,
getTextInfo,
getTime,
getTimezoneOffset,
getTimeZones,
getTimeZoneTransition,
getUint8,
getUint16,
getUint32,
getUTCDate,
getUTCDay,
getUTCFullYear,
getUTCHours,
getUTCMilliseconds,
getUTCMinutes,
getUTCMonth,
getUTCSeconds,
getWeekInfo,
getYear,
global,
globalThis,
granularity,
group,
groupBy,
groupCollapsed,
groupEnd,
groups,
grow,
growable,
has,
hasIndices,
hasOwn,
hasOwnProperty,
hour,
hour12,
hourCycle,
hours,
hoursDisplay,
hoursInDay,
hypot,
id,
ignoreCase,
ignorePunctuation,
importValue,
imul,
includes,
index,
indexOf,
indices,
Infinity,
info,
inLeapYear,
input,
instant,
intersection,
Intl,
is,
isArray,
isDisjointFrom,
isError,
isExtensible,
isFinite,
isFrozen,
isInteger,
isLockFree,
isNaN,
isPrototypeOf,
isRawJSON,
isSafeInteger,
isSealed,
isSubsetOf,
isSupersetOf,
isView,
isWellFormed,
isWordLike,
italics,
join,
JSON,
keyFor,
keys,
language,
languageDisplay,
largestUnit,
lastChunkHandling,
lastIndex,
lastIndexOf,
lastMatch,
lastParen,
leftContext,
length,
link,
LN10,
LN2,
load,
locale,
localeCompare,
localeMatcher,
log,
log10,
LOG10E,
log1p,
log2,
LOG2E,
map,
Math,
max,
MAX_SAFE_INTEGER,
MAX_VALUE,
maxByteLength,
maximize,
maximumFractionDigits,
maximumSignificantDigits,
message,
microsecond,
microseconds,
microsecondsDisplay,
millisecond,
milliseconds,
millisecondsDisplay,
min,
MIN_SAFE_INTEGER,
MIN_VALUE,
minimalDays,
minimize,
minimumFractionDigits,
minimumIntegerDigits,
minimumSignificantDigits,
minute,
minutes,
minutesDisplay,
mode,
month,
monthCode,
months,
monthsDisplay,
monthsInYear,
move_ = "move",
multiline,
name,
NaN,
nanosecond,
nanoseconds,
nanosecondsDisplay,
negated,
NEGATIVE_INFINITY,
next,
nextMethod,
normalize,
notation,
notify,
Now,
now,
Number,
numberingSystem,
numeric,
observedAttributes,
of,
offset,
offsetNanoseconds,
omitPadding,
opener,
overflow,
ownKeys,
padding,
padEnd,
padStart,
parse,
parseFloat,
parseInt,
pause,
PI,
plainDateISO,
plainDateTimeISO,
plainTime,
plainTimeISO,
pluralCategories,
pop,
POSITIVE_INFINITY,
pow,
preventExtensions,
profile,
profileEnd,
promise,
propertyIsEnumerable,
prototype,
Proxy,
proxy,
push,
race,
random,
raw,
rawJSON,
read,
reason,
reduce,
reduceRight,
Reflect,
RegExp,
region,
reject,
relativeTo,
repeat,
resizable,
resize,
resolve,
resolvedOptions,
reverse,
revocable,
revoke,
rightContext,
round,
roundingIncrement,
roundingMode,
roundingPriority,
rows,
script,
seal,
second,
seconds,
secondsDisplay,
segment,
select,
selectRange,
sensitivity,
set,
setBigInt64,
setBigUint64,
setDate,
setFloat16,
setFloat32,
setFloat64,
setFromBase64,
setFromHex,
setFullYear,
setHours,
setInt8,
setInt16,
setInt32,
setMilliseconds,
setMinutes,
setMonth,
setPrototypeOf,
setSeconds,
setTime,
setUint8,
setUint16,
setUint32,
setUTCDate,
setUTCFullYear,
setUTCHours,
setUTCMilliseconds,
setUTCMinutes,
setUTCMonth,
setUTCSeconds,
setYear,
shift,
sign,
signDisplay,
sin,
since,
sinh,
size,
slice,
small,
smallestUnit,
some,
sort,
source,
splice,
sqrt,
SQRT1_2,
SQRT2,
stack,
stackTraceLimit,
startOfDay,
startsWith,
status,
sticky,
store,
strike,
String,
stringify,
style,
sub,
subarray,
substr,
substring,
subtract,
sumPrecise,
sup,
supportedLocalesOf,
supportedValuesOf,
suppressed,
Symbol,
symmetricDifference,
table,
take,
tan,
tanh,
Temporal,
test,
then,
time,
timeEnd,
timeLog,
timeStamp,
timeStyle,
timeZone,
timeZoneId,
timeZoneName,
toArray,
toBase64,
toDateString,
toExponential,
toFixed,
toGMTString,
toHex,
toInstant,
toISOString,
toJSON,
toLocaleDateString,
toLocaleLowerCase,
toLocaleString,
toLocaleTimeString,
toLocaleUpperCase,
toLowerCase,
toPlainDate,
toPlainDateTime,
toPlainMonthDay,
toPlainTime,
toPlainYearMonth,
toPrecision,
toReversed,
toSorted,
toSpliced,
toString,
total,
toTemporalInstant,
toTimeString,
toUpperCase,
toUTCString,
toWellFormed,
toZonedDateTime,
toZonedDateTimeISO,
trace,
trailingZeroDisplay,
transfer,
transferToFixedLength,
trim,
trimEnd,
trimLeft,
trimRight,
trimStart,
trunc,
type_ = "type",
undefined,
unescape,
unicode,
unicodeSets,
unit,
unitDisplay,
unregister,
unshift,
until,
usage,
use_ = "use",
useGrouping,
UTC,
Value,
value,
valueOf,
values,
variants,
wait,
waitAsync,
warn,
weekday,
weekend,
weekOfYear,
week,
weeks,
weeksDisplay,
windows,
with,
withCalendar,
withPlainTime,
withResolvers,
withTimeZone,
writable,
written,
year,
yearOfWeek,
years,
yearsDisplay,
zip,
zipKeyed,
zonedDateTimeISO,
// JS_ENUMERATE_BUILTIN_TYPES
AggregateError,
Array,
ArrayBuffer,
AsyncDisposableStack,
AsyncFunction,
AsyncGeneratorFunction,
BigIntObject,
BooleanObject,
DataView,
Date,
DisposableStack,
Error,
FinalizationRegistry,
FunctionObject,
GeneratorFunction,
Iterator,
Map,
NumberObject,
Object,
Promise,
RegExpObject,
Set,
SharedArrayBuffer,
StringObject,
SuppressedError,
SymbolObject,
WeakMap,
WeakRef,
WeakSet,
TypedArray,
EvalError,
InternalError,
RangeError,
ReferenceError,
SyntaxError,
TypeError,
URIError,
Uint8Array,
Uint8ClampedArray,
Uint16Array,
Uint32Array,
BigUint64Array,
Int8Array,
Int16Array,
Int32Array,
BigInt64Array,
Float16Array,
Float32Array,
Float64Array,
// JS_ENUMERATE_INTL_OBJECTS
Collator,
DateTimeFormat,
DisplayNames,
DurationFormat,
ListFormat,
Locale,
NumberFormat,
PluralRules,
RelativeTimeFormat,
Segmenter,
// JS_ENUMERATE_TEMPORAL_OBJECTS
Duration,
Instant,
PlainDate,
PlainDateTime,
PlainMonthDay,
PlainTime,
PlainYearMonth,
ZonedDateTime,
// JS_ENUMERATE_WELL_KNOWN_SYMBOLS
asyncDispose,
asyncIterator,
dispose,
hasInstance,
isConcatSpreadable,
iterator,
match_ = "match",
matchAll,
replace,
replaceAll,
search,
species,
split,
toPrimitive,
toStringTag,
unscopables,
}