Skip to content

Commit e6ac945

Browse files
authored
Merge branch 'main' into web-remove-web-renderer-option
2 parents d59eeae + 5e90ce2 commit e6ac945

File tree

9 files changed

+54
-41
lines changed

9 files changed

+54
-41
lines changed

packages/pigeon/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 22.6.1
2+
3+
* [gobject] Moves class declarations to the header to work around a bug in some
4+
versions of glib.
5+
16
## 22.6.0
27

38
* [swift] Adds `includeErrorClass` to `SwiftOptions`.

packages/pigeon/example/app/linux/messages.g.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ pigeon_example_package_message_data_new_from_list(FlValue* values) {
118118
return pigeon_example_package_message_data_new(name, description, code, data);
119119
}
120120

121-
G_DECLARE_FINAL_TYPE(PigeonExamplePackageMessageCodec,
122-
pigeon_example_package_message_codec,
123-
PIGEON_EXAMPLE_PACKAGE, MESSAGE_CODEC,
124-
FlStandardMessageCodec)
125-
126121
struct _PigeonExamplePackageMessageCodec {
127122
FlStandardMessageCodec parent_instance;
128123
};
@@ -468,10 +463,6 @@ pigeon_example_package_example_host_api_send_message_response_new_error(
468463
return self;
469464
}
470465

471-
G_DECLARE_FINAL_TYPE(PigeonExamplePackageExampleHostApi,
472-
pigeon_example_package_example_host_api,
473-
PIGEON_EXAMPLE_PACKAGE, EXAMPLE_HOST_API, GObject)
474-
475466
struct _PigeonExamplePackageExampleHostApi {
476467
GObject parent_instance;
477468

packages/pigeon/example/app/linux/messages.g.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ PigeonExamplePackageCode pigeon_example_package_message_data_get_code(
9090
FlValue* pigeon_example_package_message_data_get_data(
9191
PigeonExamplePackageMessageData* object);
9292

93+
G_DECLARE_FINAL_TYPE(PigeonExamplePackageMessageCodec,
94+
pigeon_example_package_message_codec,
95+
PIGEON_EXAMPLE_PACKAGE, MESSAGE_CODEC,
96+
FlStandardMessageCodec)
97+
98+
G_DECLARE_FINAL_TYPE(PigeonExamplePackageExampleHostApi,
99+
pigeon_example_package_example_host_api,
100+
PIGEON_EXAMPLE_PACKAGE, EXAMPLE_HOST_API, GObject)
101+
93102
G_DECLARE_FINAL_TYPE(PigeonExamplePackageExampleHostApiResponseHandle,
94103
pigeon_example_package_example_host_api_response_handle,
95104
PIGEON_EXAMPLE_PACKAGE, EXAMPLE_HOST_API_RESPONSE_HANDLE,

packages/pigeon/lib/generator_tools.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import 'ast.dart';
1414
/// The current version of pigeon.
1515
///
1616
/// This must match the version in pubspec.yaml.
17-
const String pigeonVersion = '22.6.0';
17+
const String pigeonVersion = '22.6.1';
1818

1919
/// Read all the content from [stdin] to a String.
2020
String readStdin() {

packages/pigeon/lib/gobject_generator.dart

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ const DocumentCommentSpecification _docCommentSpec =
1414
/// Name for codec class.
1515
const String _codecBaseName = 'MessageCodec';
1616

17+
/// Name of the standard codec from the Flutter SDK.
18+
const String _standardCodecName = 'FlStandardMessageCodec';
19+
1720
/// Options that control how GObject code will be generated.
1821
class GObjectOptions {
1922
/// Creates a [GObjectOptions] object
@@ -282,7 +285,12 @@ class GObjectHeaderGenerator extends StructuredGenerator<GObjectOptions> {
282285
Root root,
283286
Indent indent, {
284287
required String dartPackageName,
285-
}) {}
288+
}) {
289+
final String module = _getModule(generatorOptions, dartPackageName);
290+
indent.newln();
291+
_writeDeclareFinalType(indent, module, _codecBaseName,
292+
parentClassName: _standardCodecName);
293+
}
286294

287295
@override
288296
void writeFlutterApi(
@@ -508,6 +516,9 @@ class GObjectHeaderGenerator extends StructuredGenerator<GObjectOptions> {
508516
final String methodPrefix = _getMethodPrefix(module, api.name);
509517
final String vtableName = _getVTableName(module, api.name);
510518

519+
indent.newln();
520+
_writeDeclareFinalType(indent, module, api.name);
521+
511522
final bool hasAsyncMethod =
512523
api.methods.any((Method method) => method.isAsynchronous);
513524
if (hasAsyncMethod) {
@@ -950,13 +961,9 @@ class GObjectSourceGenerator extends StructuredGenerator<GObjectOptions> {
950961

951962
final Iterable<EnumeratedType> customTypes = getEnumeratedTypes(root);
952963

953-
indent.newln();
954-
_writeDeclareFinalType(indent, module, _codecBaseName,
955-
parentClassName: 'FlStandardMessageCodec');
956-
957964
indent.newln();
958965
_writeObjectStruct(indent, module, _codecBaseName, () {},
959-
parentClassName: 'FlStandardMessageCodec');
966+
parentClassName: _standardCodecName);
960967

961968
indent.newln();
962969
_writeDefineType(indent, module, _codecBaseName,
@@ -971,7 +978,7 @@ class GObjectSourceGenerator extends StructuredGenerator<GObjectOptions> {
971978
? '$customTypeName*'
972979
: 'FlValue*';
973980
indent.writeScoped(
974-
'static gboolean ${codecMethodPrefix}_write_$snakeCustomTypeName(FlStandardMessageCodec* codec, GByteArray* buffer, $valueType value, GError** error) {',
981+
'static gboolean ${codecMethodPrefix}_write_$snakeCustomTypeName($_standardCodecName* codec, GByteArray* buffer, $valueType value, GError** error) {',
975982
'}', () {
976983
indent.writeln('uint8_t type = ${customType.enumeration};');
977984
indent.writeln('g_byte_array_append(buffer, &type, sizeof(uint8_t));');
@@ -989,7 +996,7 @@ class GObjectSourceGenerator extends StructuredGenerator<GObjectOptions> {
989996

990997
indent.newln();
991998
indent.writeScoped(
992-
'static gboolean ${codecMethodPrefix}_write_value(FlStandardMessageCodec* codec, GByteArray* buffer, FlValue* value, GError** error) {',
999+
'static gboolean ${codecMethodPrefix}_write_value($_standardCodecName* codec, GByteArray* buffer, FlValue* value, GError** error) {',
9931000
'}', () {
9941001
indent.writeScoped(
9951002
'if (fl_value_get_type(value) == FL_VALUE_TYPE_CUSTOM) {', '}', () {
@@ -1027,7 +1034,7 @@ class GObjectSourceGenerator extends StructuredGenerator<GObjectOptions> {
10271034
_snakeCaseFromCamelCase(customTypeName);
10281035
indent.newln();
10291036
indent.writeScoped(
1030-
'static FlValue* ${codecMethodPrefix}_read_$snakeCustomTypeName(FlStandardMessageCodec* codec, GBytes* buffer, size_t* offset, GError** error) {',
1037+
'static FlValue* ${codecMethodPrefix}_read_$snakeCustomTypeName($_standardCodecName* codec, GBytes* buffer, size_t* offset, GError** error) {',
10311038
'}', () {
10321039
if (customType.type == CustomTypes.customClass) {
10331040
indent.writeln(
@@ -1055,7 +1062,7 @@ class GObjectSourceGenerator extends StructuredGenerator<GObjectOptions> {
10551062

10561063
indent.newln();
10571064
indent.writeScoped(
1058-
'static FlValue* ${codecMethodPrefix}_read_value_of_type(FlStandardMessageCodec* codec, GBytes* buffer, size_t* offset, int type, GError** error) {',
1065+
'static FlValue* ${codecMethodPrefix}_read_value_of_type($_standardCodecName* codec, GBytes* buffer, size_t* offset, int type, GError** error) {',
10591066
'}', () {
10601067
indent.writeScoped('switch (type) {', '}', () {
10611068
for (final EnumeratedType customType in customTypes) {
@@ -1473,9 +1480,6 @@ class GObjectSourceGenerator extends StructuredGenerator<GObjectOptions> {
14731480
});
14741481
}
14751482

1476-
indent.newln();
1477-
_writeDeclareFinalType(indent, module, api.name);
1478-
14791483
indent.newln();
14801484
_writeObjectStruct(indent, module, api.name, () {
14811485
indent.writeln('const ${className}VTable* vtable;');

packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.cc

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,11 +2397,6 @@ core_tests_pigeon_test_test_message_new_from_list(FlValue* values) {
23972397
return core_tests_pigeon_test_test_message_new(test_list);
23982398
}
23992399

2400-
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestMessageCodec,
2401-
core_tests_pigeon_test_message_codec,
2402-
CORE_TESTS_PIGEON_TEST, MESSAGE_CODEC,
2403-
FlStandardMessageCodec)
2404-
24052400
struct _CoreTestsPigeonTestMessageCodec {
24062401
FlStandardMessageCodec parent_instance;
24072402
};
@@ -13564,10 +13559,6 @@ core_tests_pigeon_test_host_integration_core_api_call_flutter_small_api_echo_str
1356413559
return self;
1356513560
}
1356613561

13567-
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostIntegrationCoreApi,
13568-
core_tests_pigeon_test_host_integration_core_api,
13569-
CORE_TESTS_PIGEON_TEST, HOST_INTEGRATION_CORE_API, GObject)
13570-
1357113562
struct _CoreTestsPigeonTestHostIntegrationCoreApi {
1357213563
GObject parent_instance;
1357313564

@@ -32742,10 +32733,6 @@ core_tests_pigeon_test_host_trivial_api_noop_response_new_error(
3274232733
return self;
3274332734
}
3274432735

32745-
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostTrivialApi,
32746-
core_tests_pigeon_test_host_trivial_api,
32747-
CORE_TESTS_PIGEON_TEST, HOST_TRIVIAL_API, GObject)
32748-
3274932736
struct _CoreTestsPigeonTestHostTrivialApi {
3275032737
GObject parent_instance;
3275132738

@@ -33021,10 +33008,6 @@ core_tests_pigeon_test_host_small_api_void_void_response_new_error(
3302133008
return self;
3302233009
}
3302333010

33024-
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostSmallApi,
33025-
core_tests_pigeon_test_host_small_api,
33026-
CORE_TESTS_PIGEON_TEST, HOST_SMALL_API, GObject)
33027-
3302833011
struct _CoreTestsPigeonTestHostSmallApi {
3302933012
GObject parent_instance;
3303033013

packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,15 @@ CoreTestsPigeonTestTestMessage* core_tests_pigeon_test_test_message_new(
14281428
FlValue* core_tests_pigeon_test_test_message_get_test_list(
14291429
CoreTestsPigeonTestTestMessage* object);
14301430

1431+
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestMessageCodec,
1432+
core_tests_pigeon_test_message_codec,
1433+
CORE_TESTS_PIGEON_TEST, MESSAGE_CODEC,
1434+
FlStandardMessageCodec)
1435+
1436+
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostIntegrationCoreApi,
1437+
core_tests_pigeon_test_host_integration_core_api,
1438+
CORE_TESTS_PIGEON_TEST, HOST_INTEGRATION_CORE_API, GObject)
1439+
14311440
G_DECLARE_FINAL_TYPE(
14321441
CoreTestsPigeonTestHostIntegrationCoreApiResponseHandle,
14331442
core_tests_pigeon_test_host_integration_core_api_response_handle,
@@ -11869,6 +11878,10 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_async_string_finish(
1186911878
CoreTestsPigeonTestFlutterIntegrationCoreApi* api, GAsyncResult* result,
1187011879
GError** error);
1187111880

11881+
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostTrivialApi,
11882+
core_tests_pigeon_test_host_trivial_api,
11883+
CORE_TESTS_PIGEON_TEST, HOST_TRIVIAL_API, GObject)
11884+
1187211885
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostTrivialApiNoopResponse,
1187311886
core_tests_pigeon_test_host_trivial_api_noop_response,
1187411887
CORE_TESTS_PIGEON_TEST, HOST_TRIVIAL_API_NOOP_RESPONSE,
@@ -11936,6 +11949,10 @@ void core_tests_pigeon_test_host_trivial_api_set_method_handlers(
1193611949
void core_tests_pigeon_test_host_trivial_api_clear_method_handlers(
1193711950
FlBinaryMessenger* messenger, const gchar* suffix);
1193811951

11952+
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostSmallApi,
11953+
core_tests_pigeon_test_host_small_api,
11954+
CORE_TESTS_PIGEON_TEST, HOST_SMALL_API, GObject)
11955+
1193911956
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostSmallApiResponseHandle,
1194011957
core_tests_pigeon_test_host_small_api_response_handle,
1194111958
CORE_TESTS_PIGEON_TEST, HOST_SMALL_API_RESPONSE_HANDLE,

packages/pigeon/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: pigeon
22
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
33
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+pigeon%22
5-
version: 22.6.0 # This must match the version in lib/generator_tools.dart
5+
version: 22.6.1 # This must match the version in lib/generator_tools.dart
66

77
environment:
88
sdk: ^3.3.0

packages/pigeon/test/gobject_generator_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ void main() {
9595
code,
9696
contains(
9797
'static void test_package_api_init(TestPackageApi* self) {'));
98+
// See https://github.com/flutter/flutter/issues/153083. If a private type
99+
// is ever needed, this should be updated to ensure that any type declared
100+
// in the implementation file has a corresponding _IS_ call in the file.
101+
expect(code, isNot(contains('G_DECLARE_FINAL_TYPE(')));
98102
}
99103
});
100104

0 commit comments

Comments
 (0)