-
Notifications
You must be signed in to change notification settings - Fork 27
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
Added "struct syntax" to AST #1140
Conversation
pkgs/swiftgen/swift2objc/Sources/swift2objc/AST/AccessModifier.swift
Outdated
Show resolved
Hide resolved
pkgs/swiftgen/swift2objc/Sources/swift2objc/AST/AccessModifier.swift
Outdated
Show resolved
Hide resolved
pkgs/swiftgen/swift2objc/Sources/swift2objc/AST/ParameterSyntax.swift
Outdated
Show resolved
Hide resolved
pkgs/swiftgen/swift2objc/Tests/swift2objcTests/swift2objcTests.swift
Outdated
Show resolved
Hide resolved
pkgs/swiftgen/swift2objc/Sources/swift2objc/AST/StructSyntax/StructMemberSyntax.swift
Outdated
Show resolved
Hide resolved
pkgs/swiftgen/swift2objc/Sources/swift2objc/AST/TypeSyntax.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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?
pkgs/swiftgen/lib/swiftgen.dart
Outdated
// 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing newline
There was a problem hiding this comment.
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}); |
There was a problem hiding this comment.
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"
?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 interface
s 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?
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/enum_declaration.dart
Outdated
Show resolved
Hide resolved
pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/paramable.dart
Outdated
Show resolved
Hide resolved
import 'declaration.dart'; | ||
import 'referred_type.dart'; | ||
|
||
class CompoundDeclaration extends Declaration { |
There was a problem hiding this comment.
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.
Created a swift2objc "package" with AST models.
#1143