Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4337cd6
Add SwiftFunction annotation
ailtonvivaz Jul 3, 2022
d3eb40d
Bump version to 3.2.4
ailtonvivaz Jul 3, 2022
2920bbf
Remove unused imports
ailtonvivaz Jul 3, 2022
ac02d63
Improve methods map
ailtonvivaz Jul 5, 2022
f52ab0c
Remove unnecessary print
ailtonvivaz Jul 8, 2022
b5ec8ae
Force cast match of SwiftFunction
ailtonvivaz Jul 9, 2022
ac2b51b
Update packages/pigeon/lib/pigeon_lib.dart
ailtonvivaz Jul 27, 2022
f0bbf86
Merge branch 'main' into swift-function-annotation
ailtonvivaz Jul 27, 2022
5f70ea2
Improve documentation of function to parse method with SwiftFunction
ailtonvivaz Jul 27, 2022
718c1b3
Merge branch 'main' into swift-function-annotation
ailtonvivaz Aug 24, 2022
b034144
Merge branch 'main' into swift-function-annotation
ailtonvivaz Aug 25, 2022
519ff35
Merge branch 'main' into swift-function-annotation
ailtonvivaz Aug 27, 2022
9f86539
Fix some dartdocs
ailtonvivaz Aug 31, 2022
d754a58
Merge branch 'main' into swift-function-annotation
ailtonvivaz Sep 22, 2022
d8bf6d4
Merge branch 'swift-function-annotation' of github.com:ailtonvivaz/pa…
tarrinneal Jan 17, 2023
d4175a9
gen
tarrinneal Jan 17, 2023
09ebdea
analyze
tarrinneal Jan 17, 2023
6db9d1b
Improve SwiftFunction application
ailtonvivaz Jan 18, 2023
22af130
Merge branch 'main' into swift-function-annotation
ailtonvivaz Jan 18, 2023
399e4ae
Add type annotation
ailtonvivaz Jan 18, 2023
608b5ef
format
tarrinneal Jan 18, 2023
4bc40a3
Run format
ailtonvivaz Jan 18, 2023
a8c90f0
Update macos Swift tests
ailtonvivaz Jan 18, 2023
1bdde71
Bump version to 7.0.0
ailtonvivaz Jan 18, 2023
3da3698
Merge branch 'swift-function-annotation' of github.com:ailtonvivaz/pa…
tarrinneal Jan 18, 2023
b13b7ca
revert version change
tarrinneal Jan 18, 2023
ef9b5d0
Improve some code of SwiftGenerator
ailtonvivaz Jan 18, 2023
62b3163
Merge branch 'swift-function-annotation' of github.com:ailtonvivaz/pa…
ailtonvivaz Jan 18, 2023
a44aa18
Bump version to 6.1.0
ailtonvivaz Jan 18, 2023
5aa2197
Improve echo functions for Swift
ailtonvivaz Jan 18, 2023
9176579
Match order of parameters
ailtonvivaz Jan 18, 2023
372d7b7
Documents _SwiftFunctionComponents.fromMethod and _SwiftFunctionArgument
ailtonvivaz Jan 18, 2023
e734c28
Merge branch 'main' into swift-function-annotation
ailtonvivaz Jan 24, 2023
0039165
Improve doc comments
ailtonvivaz Jan 24, 2023
651f9fa
Fix tests
ailtonvivaz Jan 24, 2023
217e4f7
Merge branch 'main' of github.com:flutter/packages into swift-functio…
tarrinneal Jan 25, 2023
245a327
Fix SwiftFunction documentation
ailtonvivaz Jan 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve documentation of function to parse method with SwiftFunction
  • Loading branch information
ailtonvivaz committed Jul 27, 2022
commit 5f70ea269aff532465e711cf75685b4d3eef3c56
8 changes: 5 additions & 3 deletions packages/pigeon/lib/swift_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ String _getCodecName(Api api) => '${api.name}Codec';
/// Returns a new [Method] using the swift function signature from [func],
/// ie the name of function e the strings between the semicolons.
/// Example:
/// f('void add(int x, int y)') -> ['add', 'x', 'y']
Method _methodWithSwiftFunction(Method func) {
/// _swiftMethod('@SwiftFunction('add(_:with:)') void add(int x, int y)')
/// will return 'void add(int _ x, int with y)'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why remap the Dart APIs to a hybrid string that will never be used (and has no meaning in either language), only to re-extract the components later, instead of doing the mapping at the point of constructing the Swift code (as is done in the ObjC generator)?

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 followed this approach to minimize the changes. But, if this is not the better way, I could change to be similar with ObjC.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think having this intermediate format will likely make it harder to understand what's happening, and there's more potential for strange side effects (e.g., some new code trying to use the methods, and it not being obvious why they don't match the original source), so I'm concerned about the maintenance impact. I would much rather this transformation happen at the usage point even if it's more code in the short term.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree. I'll work on this update.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ailtonvivaz What is the status of this update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this. Is this approach better?

/// which represents 'func add(_ x: Int32, with y: Int32) -> Void' in Swift.
Method _swiftMethod(Method func) {
if (func.swiftFunction.isEmpty) {
return func;
} else {
Expand Down Expand Up @@ -639,7 +641,7 @@ void generateSwift(SwiftOptions options, Root root, StringSink sink) {
_writeCodec(indent, api, root);
indent.addln('');

api.methods = api.methods.map(_methodWithSwiftFunction).toList();
api.methods = api.methods.map(_swiftMethod).toList();

writeApi(api, root);
}
Expand Down