-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[pigeon] Kotlin implementation for ProxyApis #6371
Changes from all commits
7d66bf7
d64d2a2
b64d723
89d3c92
1f7d0ad
fa3c943
2665c22
cadf14c
2bf6738
6437fc9
aea71cd
0c09e91
f114c8c
d57ac0d
ff1e210
7e345ac
db2a198
a7c94e5
7af4343
a7b20a0
f2a1d5b
f76265e
b8e70f6
4f2327d
5ade010
3b3a91b
ec37d62
186fe47
894e642
118606a
4e821cb
4205418
258653b
5070f6e
06d163b
79e994b
1b9dfc1
f91a51f
84e0a0c
bdf1aae
2ff9075
b0569f5
4f47756
03d1100
c49aff2
c7e5ad0
d1883be
3025438
9af2d08
78128b8
84879d2
90f38b6
505b500
172ef36
c294d49
eaf1302
03f8a9e
6a57229
38ab4a1
78ade11
fcb3aa5
61579bc
c981d97
60be3da
0b7de44
8974f28
4ae228d
e5ad0ce
77ac326
33e3742
927aeea
ce65169
1dd1eda
bd08aa0
b2ae858
b2b82f6
4627f4a
abe2c0d
92a7370
6d5b581
770b24c
9e59393
bc60c15
cb10073
3b3284a
cae65e8
82f0cee
233acf5
e810a8f
b95997e
24daaa1
f0aa519
fed5b58
ccb1783
0a2a643
942918b
89abc69
cc55be5
41fca50
78e1e48
e844875
af2965f
25d4515
c5a083e
676eb05
f7b662a
d79c8f0
f4ac560
f70c2f1
c1f23ae
b958879
ecf079c
98d088f
923e21e
f9d5b78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ | |
|
||
import 'package:collection/collection.dart' show ListEquality; | ||
import 'package:meta/meta.dart'; | ||
|
||
import 'generator_tools.dart'; | ||
import 'kotlin_generator.dart' show KotlinProxyApiOptions; | ||
import 'pigeon_lib.dart'; | ||
|
||
typedef _ListEquals = bool Function(List<Object?>, List<Object?>); | ||
|
@@ -140,6 +142,7 @@ class AstProxyApi extends Api { | |
required this.fields, | ||
this.superClass, | ||
this.interfaces = const <TypeDeclaration>{}, | ||
this.kotlinOptions, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need Kotlin options in a class that's currently unaware of specific generators? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the generated code references the native class, each ProxyApi needs to provide the full class name with the package. I also think |
||
}); | ||
|
||
/// List of constructors inside the API. | ||
|
@@ -154,6 +157,10 @@ class AstProxyApi extends Api { | |
/// Name of the classes this class considers to be implemented. | ||
Set<TypeDeclaration> interfaces; | ||
|
||
/// Options that control how Kotlin code will be generated for a specific | ||
/// ProxyApi. | ||
final KotlinProxyApiOptions? kotlinOptions; | ||
|
||
/// Methods implemented in the host platform language. | ||
Iterable<Method> get hostMethods => methods.where( | ||
(Method method) => method.location == ApiLocation.host, | ||
|
@@ -253,7 +260,7 @@ class AstProxyApi extends Api { | |
} | ||
} | ||
|
||
/// Whether the api has a method that callbacks to Dart to add a new instance | ||
/// Whether the API has a method that callbacks to Dart to add a new instance | ||
/// to the InstanceManager. | ||
/// | ||
/// This is possible as long as no callback methods are required to | ||
|
@@ -265,6 +272,21 @@ class AstProxyApi extends Api { | |
.every((Method method) => !method.isRequired); | ||
} | ||
|
||
/// Whether the API has any message calls from Dart to host. | ||
bool hasAnyHostMessageCalls() => | ||
constructors.isNotEmpty || | ||
attachedFields.isNotEmpty || | ||
hostMethods.isNotEmpty; | ||
|
||
/// Whether the API has any message calls from host to Dart. | ||
bool hasAnyFlutterMessageCalls() => | ||
hasCallbackConstructor() || flutterMethods.isNotEmpty; | ||
|
||
/// Whether the host proxy API class will have methods that need to be | ||
/// implemented. | ||
bool hasMethodsRequiringImplementation() => | ||
hasAnyHostMessageCalls() || unattachedFields.isNotEmpty; | ||
|
||
// Recursively search for all the interfaces apis from a list of names of | ||
// interfaces. | ||
// | ||
|
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 think open classes also need methods to be marked open so this change is a no op for now.
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.
After some experimentation with a Kotlin interpreter, it looks like this doesn't apply to methods that are inherited from an interface. The
ProxyApiBaseCodec
override the interface methods from MessageCodec which seem to always be inherently open.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.
Thanks that is not a level of kotlin nuance I would have known.