Skip to content

[pigeon] New annotation for Swift function naming #105932

@ailtonvivaz

Description

@ailtonvivaz

Use case

PR flutter/packages#976 has added Swift support, but there is no way to control the naming of a function like there is for ObjC (the annotation @ObjCSelector).
This is important, once Swift functions could be read like a sentence, using labels parameters.

Using the same annotation makes no sense because it is a different language, as well as Swift hasn't selectors concept.

Proposal

I propose creating a new annotation for it. The behavior would be similar to @ObjCSelector.
I don't know the best naming for it. But, just for example, I am using @SwiftFunction.

This interface in Dart

@HostApi()
abstract class Api {
  @SwiftFunction('getString(for:)')
  String? getString(String key);
  @SwiftFunction('setString(_:for:)')
  void setString(String value, String key);
  @SwiftFunction('remove(key:)')
  void remove(String key);
}

would generate this protocol in Swift

protocol Api {
  func getString(for key: String) -> String?
  func setString(_ value: String, for key: String)
  func remove(key: String)
}

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions