feat(macros): support symbol-named methods in #[boa(class)]#4697
feat(macros): support symbol-named methods in #[boa(class)]#4697jedel1043 merged 5 commits intoboa-dev:mainfrom
Conversation
|
cc: @jedel1043 |
Test262 conformance changes
Tested main commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4697 +/- ##
===========================================
+ Coverage 47.24% 57.28% +10.03%
===========================================
Files 476 556 +80
Lines 46892 60657 +13765
===========================================
+ Hits 22154 34745 +12591
- Misses 24738 25912 +1174 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
68e38f2 to
9c3b330
Compare
|
cc: @jedel1043 |
|
No need to CC me, just requesting a review already pings my notifications haha |
bad habit :) |
jedel1043
left a comment
There was a problem hiding this comment.
Nice work! I have a suggestion to improve the maintainability of the code.
9c3b330 to
eebc6a4
Compare
|
hey @jedel1043 could you review this !! |
eebc6a4 to
6ab1442
Compare
Summary
This PR adds support for well-known symbol-keyed methods, statics, and accessors
in the
#[boa(class)]macro. This allows builtins to declare them declarativelyinstead of manually patching prototypes after registration.
Closes: #4688
What Changed
core/macros/src/class.rsMethodNameenum (String | Symbol) replacing the rawStringname on:FunctionAccessorClassVisitorMethodName::to_key_tokens()now emits:js_string!(...)for string keysJsSymbol::iterator()(etc.) for symbol keysname_of()now:#[boa(symbol = "...")]first#[boa(rename = "...")]or default rename scheme otherwiseserialize_class_impl()now uses polymorphic key tokens for:builder.method()builder.static_method()builder.accessor()matchis handled viaIdent::new_rawsince it is a Rust keywordcore/macros/src/module.rsFunction::from_sigcallsite to wrap the name inMethodName::String(...)core/runtime/src/fetch/headers.rs#[boa(symbol = "iterator")]onJsHeaderstests/macros/tests/class.rsPairstruct with:#[boa(symbol = "toPrimitive")]#[boa(symbol = "iterator")]boa_class_symbol_methodstest covering:+p)p + 3)[...p])for...ofAccepted Symbol Names
The following well-known symbol names are supported:
asyncIteratorhasInstanceisConcatSpreadableiteratormatchmatchAllreplacesearchspeciessplittoPrimitivetoStringTagunscopablesUnknown names produce a compile-time error listing valid options.
Usage Example