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

Added "struct syntax" to AST #1140

Merged

Conversation

Mohammad3id
Copy link
Contributor

@Mohammad3id Mohammad3id commented May 13, 2024

Created a swift2objc "package" with AST models.

#1143

@liamappelbe liamappelbe added lang-swift Related to Swift support swift2objc labels May 14, 2024
Copy link
Contributor

@liamappelbe liamappelbe left a comment

Choose a reason for hiding this comment

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

Looks good overall, just a few small comments.

Also, can you un-delete the changelog and readme?

// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library swiftgen;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok XD

}

class GenericType extends ReferredType {
GenericType({required super.id});
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this have a name field? Somewhere to stick the "T"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right actually I missed it.
Added :)

import 'declaration.dart';
import 'referred_type.dart';

class CompoundDeclaration extends Declaration {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a short comment to each of these classes and their fields saying what Swift language concept it represents?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will, but first I added AST models for class, struct, and protocol. I'm using abstract interfaces to declare common fields. I was extending abstract classes initially, but I felt like interfaces are more flexible.

I'm not sure if this approach has any drawbacks, so can you please check things out first in case there're any drawbacks?

Copy link
Contributor

Choose a reason for hiding this comment

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

The class modifiers seem fine to me. I don't use them very often tbh (other than abstract). Is there a reason ObjcAnnotatable is an interface but not abstract?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the main drawback is it's a bit verbose. Since the fields are abstract, you're having to redeclare them in all the child classes, with @override, so that's 3 lines per field instead of 1.

In the meeting you said you wanted to do this to avoid writing a constructor. If that's the only reason, then I'm pretty sure it would be less code overall to just write the constructor and avoid redeclaring the fields in the child classes.

import 'declaration.dart';
import 'referred_type.dart';

class CompoundDeclaration extends Declaration {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the main drawback is it's a bit verbose. Since the fields are abstract, you're having to redeclare them in all the child classes, with @override, so that's 3 lines per field instead of 1.

In the meeting you said you wanted to do this to avoid writing a constructor. If that's the only reason, then I'm pretty sure it would be less code overall to just write the constructor and avoid redeclaring the fields in the child classes.

@HosseinYousefi HosseinYousefi merged commit 0f90ac4 into dart-lang:main Jun 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-swift Related to Swift support swift2objc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants