mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:57:44 +00:00
LibJS: Pass Realm to define_native_{accessor,function}()
This is needed so that the allocated NativeFunction receives the correct realm, usually forwarded from the Object's initialize() function, rather than using the current realm.
This commit is contained in:
parent
7c468b5a77
commit
e3895e6c80
116 changed files with 893 additions and 890 deletions
|
@ -146,7 +146,7 @@ void CollatorConstructor::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
}
|
||||
|
||||
// 10.1.1 Intl.Collator ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.collator
|
||||
|
|
|
@ -27,8 +27,8 @@ void CollatorPrototype::initialize(Realm& realm)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Collator"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_accessor(vm.names.compare, compare_getter, {}, attr);
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_accessor(realm, vm.names.compare, compare_getter, {}, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
}
|
||||
|
||||
// 10.3.3 get Intl.Collator.prototype.compare, https://tc39.es/ecma402/#sec-intl.collator.prototype.compare
|
||||
|
|
|
@ -32,7 +32,7 @@ void DateTimeFormatConstructor::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.prototype, realm.global_object().intl_date_time_format_prototype(), 0);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ void DateTimeFormatPrototype::initialize(Realm& realm)
|
|||
// 11.3.2 Intl.DateTimeFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DateTimeFormat"), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(vm.names.format, format, nullptr, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.formatToParts, format_to_parts, 1, attr);
|
||||
define_native_function(vm.names.formatRange, format_range, 2, attr);
|
||||
define_native_function(vm.names.formatRangeToParts, format_range_to_parts, 2, attr);
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(realm, vm.names.formatToParts, format_to_parts, 1, attr);
|
||||
define_native_function(realm, vm.names.formatRange, format_range, 2, attr);
|
||||
define_native_function(realm, vm.names.formatRangeToParts, format_range_to_parts, 2, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
}
|
||||
|
||||
// 11.3.3 get Intl.DateTimeFormat.prototype.format, https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype.format
|
||||
|
|
|
@ -31,7 +31,7 @@ void DisplayNamesConstructor::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.prototype, realm.global_object().intl_display_names_prototype(), 0);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
|
||||
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ void DisplayNamesPrototype::initialize(Realm& realm)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DisplayNames"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.of, of, 1, attr);
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(realm, vm.names.of, of, 1, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
}
|
||||
|
||||
// 12.3.3 Intl.DisplayNames.prototype.of ( code ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype.of
|
||||
|
|
|
@ -30,7 +30,7 @@ void DurationFormatConstructor::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
}
|
||||
|
||||
// 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat
|
||||
|
|
|
@ -26,9 +26,9 @@ void DurationFormatPrototype::initialize(Realm& realm)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DurationFormat"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.format, format, 1, attr);
|
||||
define_native_function(vm.names.formatToParts, format_to_parts, 1, attr);
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(realm, vm.names.format, format, 1, attr);
|
||||
define_native_function(realm, vm.names.formatToParts, format_to_parts, 1, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
}
|
||||
|
||||
// 1.4.3 Intl.DurationFormat.prototype.format ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.format
|
||||
|
|
|
@ -54,8 +54,8 @@ void Intl::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.RelativeTimeFormat, realm.global_object().intl_relative_time_format_constructor(), attr);
|
||||
define_direct_property(vm.names.Segmenter, realm.global_object().intl_segmenter_constructor(), attr);
|
||||
|
||||
define_native_function(vm.names.getCanonicalLocales, get_canonical_locales, 1, attr);
|
||||
define_native_function(vm.names.supportedValuesOf, supported_values_of, 1, attr);
|
||||
define_native_function(realm, vm.names.getCanonicalLocales, get_canonical_locales, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedValuesOf, supported_values_of, 1, attr);
|
||||
}
|
||||
|
||||
// 8.3.1 Intl.getCanonicalLocales ( locales ), https://tc39.es/ecma402/#sec-intl.getcanonicallocales
|
||||
|
|
|
@ -30,7 +30,7 @@ void ListFormatConstructor::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.prototype, realm.global_object().intl_list_format_prototype(), 0);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@ void ListFormatPrototype::initialize(Realm& realm)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.ListFormat"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.format, format, 1, attr);
|
||||
define_native_function(vm.names.formatToParts, format_to_parts, 1, attr);
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(realm, vm.names.format, format, 1, attr);
|
||||
define_native_function(realm, vm.names.formatToParts, format_to_parts, 1, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
}
|
||||
|
||||
// 13.3.3 Intl.ListFormat.prototype.format ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.format
|
||||
|
|
|
@ -26,30 +26,30 @@ void LocalePrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.maximize, maximize, 0, attr);
|
||||
define_native_function(vm.names.minimize, minimize, 0, attr);
|
||||
define_native_function(vm.names.toString, to_string, 0, attr);
|
||||
define_native_function(realm, vm.names.maximize, maximize, 0, attr);
|
||||
define_native_function(realm, vm.names.minimize, minimize, 0, attr);
|
||||
define_native_function(realm, vm.names.toString, to_string, 0, attr);
|
||||
|
||||
// 14.3.2 Intl.Locale.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.Locale.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Locale"), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(vm.names.baseName, base_name, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.calendar, calendar, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.calendars, calendars, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.caseFirst, case_first, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.collation, collation, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.collations, collations, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.hourCycle, hour_cycle, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.hourCycles, hour_cycles, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.numberingSystem, numbering_system, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.numberingSystems, numbering_systems, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.numeric, numeric, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.language, language, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.script, script, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.region, region, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.timeZones, time_zones, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.textInfo, text_info, {}, Attribute::Configurable);
|
||||
define_native_accessor(vm.names.weekInfo, week_info, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.baseName, base_name, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.calendar, calendar, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.calendars, calendars, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.caseFirst, case_first, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.collation, collation, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.collations, collations, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.hourCycle, hour_cycle, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.hourCycles, hour_cycles, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.numberingSystem, numbering_system, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.numberingSystems, numbering_systems, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.numeric, numeric, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.language, language, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.script, script, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.region, region, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.timeZones, time_zones, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.textInfo, text_info, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.weekInfo, week_info, {}, Attribute::Configurable);
|
||||
}
|
||||
|
||||
// 14.3.3 Intl.Locale.prototype.maximize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.maximize
|
||||
|
|
|
@ -29,7 +29,7 @@ void NumberFormatConstructor::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.prototype, realm.global_object().intl_number_format_prototype(), 0);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ void NumberFormatPrototype::initialize(Realm& realm)
|
|||
// 15.3.2 Intl.NumberFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.numberformat.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.NumberFormat"), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(vm.names.format, format, nullptr, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.formatToParts, format_to_parts, 1, attr);
|
||||
define_native_function(vm.names.formatRange, format_range, 2, attr);
|
||||
define_native_function(vm.names.formatRangeToParts, format_range_to_parts, 2, attr);
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(realm, vm.names.formatToParts, format_to_parts, 1, attr);
|
||||
define_native_function(realm, vm.names.formatRange, format_range, 2, attr);
|
||||
define_native_function(realm, vm.names.formatRangeToParts, format_range_to_parts, 2, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
}
|
||||
|
||||
// 15.3.3 get Intl.NumberFormat.prototype.format, https://tc39.es/ecma402/#sec-intl.numberformat.prototype.format
|
||||
|
|
|
@ -32,7 +32,7 @@ void PluralRulesConstructor::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
}
|
||||
|
||||
// 16.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules
|
||||
|
|
|
@ -28,9 +28,9 @@ void PluralRulesPrototype::initialize(Realm& realm)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.PluralRules"sv), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.select, select, 1, attr);
|
||||
define_native_function(vm.names.selectRange, select_range, 2, attr);
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(realm, vm.names.select, select, 1, attr);
|
||||
define_native_function(realm, vm.names.selectRange, select_range, 2, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
}
|
||||
|
||||
// 16.3.3 Intl.PluralRules.prototype.select ( value ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.select
|
||||
|
|
|
@ -35,7 +35,7 @@ void RelativeTimeFormatConstructor::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
}
|
||||
|
||||
// 17.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat
|
||||
|
|
|
@ -26,9 +26,9 @@ void RelativeTimeFormatPrototype::initialize(Realm& realm)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.RelativeTimeFormat"sv), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.format, format, 2, attr);
|
||||
define_native_function(vm.names.formatToParts, format_to_parts, 2, attr);
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(realm, vm.names.format, format, 2, attr);
|
||||
define_native_function(realm, vm.names.formatToParts, format_to_parts, 2, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
}
|
||||
|
||||
// 17.3.3 Intl.RelativeTimeFormat.prototype.format ( value, unit ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.format
|
||||
|
|
|
@ -28,7 +28,7 @@ void SegmentIteratorPrototype::initialize(Realm& realm)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Segmenter String Iterator"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.next, next, 0, attr);
|
||||
define_native_function(realm, vm.names.next, next, 0, attr);
|
||||
}
|
||||
|
||||
// 18.6.2.1 %SegmentIteratorPrototype%.next ( ), https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.next
|
||||
|
|
|
@ -31,7 +31,7 @@ void SegmenterConstructor::initialize(Realm& realm)
|
|||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
}
|
||||
|
||||
// 18.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter
|
||||
|
|
|
@ -27,8 +27,8 @@ void SegmenterPrototype::initialize(Realm& realm)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Segmenter"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(vm.names.segment, segment, 1, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
define_native_function(realm, vm.names.segment, segment, 1, attr);
|
||||
}
|
||||
|
||||
// 18.3.4 Intl.Segmenter.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.segmenter.prototype.resolvedoptions
|
||||
|
|
|
@ -24,8 +24,8 @@ void SegmentsPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(*vm.well_known_symbol_iterator(), symbol_iterator, 0, attr);
|
||||
define_native_function(vm.names.containing, containing, 1, attr);
|
||||
define_native_function(realm, *vm.well_known_symbol_iterator(), symbol_iterator, 0, attr);
|
||||
define_native_function(realm, vm.names.containing, containing, 1, attr);
|
||||
}
|
||||
|
||||
// 18.5.2.1 %SegmentsPrototype%.containing ( index ), https://tc39.es/ecma402/#sec-%segmentsprototype%.containing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue