Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [] and []= operators for unnamed getters and setters #293

Merged
merged 3 commits into from
Aug 28, 2024

Conversation

srujzs
Copy link
Contributor

@srujzs srujzs commented Aug 27, 2024

Closes #127

The IDL defines unnamed getters or setters which should be emitted as special variants of the index operators.

Closes dart-lang#127

The IDL defines unnamed getters or setters which should be
emitted as special variants of the index operators.
@srujzs srujzs requested a review from kevmoo August 27, 2024 22:56
@srujzs
Copy link
Contributor Author

srujzs commented Aug 27, 2024

cc @rutvik110 who was curious about generator changes. In general, changes go into translator.dart, which contain the following:

  • Intermediate representations when translating from the parsed IDL to the resulting Dart code.
  • Code to visit the parsed IDL and create IR nodes, including interfacelikes, attributes, operations, types, and more.
    -- This is where the real bulk is, especially when dealing with types.
    -- Here, we use the special field of IDL operations to give different names to some operations.
  • Code to process the resulting IR nodes and emit them as Dart code (using package:code_builder which itself is a representation of Dart code).
    -- Here, we just make sure that []= members don't contain an invalid return type when emitting them as Dart code.

The definition for the parsed IDL comes from https://github.com/w3c/webidl2.js.

@kevmoo
Copy link
Member

kevmoo commented Aug 28, 2024

Since we're using..."weird" operators, would it make sense to add a simple integration test...for just one of the types here.?

@srujzs
Copy link
Contributor Author

srujzs commented Aug 28, 2024

Since we're using..."weird" operators, would it make sense to add a simple integration test...for just one of the types here.?

Yup, I tested this locally anyways, so no reason not to add a test for it. I added a smoke test for examples of [] and []=.

@@ -51,4 +51,15 @@ void main() {
expect(div.style.textOverflow, equals('ellipsis'));
expect(div.style.getPropertyValue('text-overflow'), equals('ellipsis'));
});

test('External [] and []= operators work as expected.', () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ ❤️ ❤️ ❤️

@srujzs srujzs merged commit 3619fd8 into dart-lang:main Aug 28, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add indexing operators for getter and setter attributes
2 participants