Skip to content

Commit 75a101f

Browse files
committed
[pigeon] Add documentation comments to gobject generator
Adds documentation comments to gobject generator to document the custom type id constants Moves the custom type id constants to be all in one block instead of interleaved
1 parent 2f8f578 commit 75a101f

File tree

5 files changed

+43
-29
lines changed

5 files changed

+43
-29
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ G_DEFINE_TYPE(PigeonExamplePackageMessageCodec,
128128
fl_standard_message_codec_get_type())
129129

130130
const int pigeon_example_package_code_type_id = 129;
131+
const int pigeon_example_package_message_data_type_id = 130;
131132

132133
static gboolean
133134
pigeon_example_package_message_codec_write_pigeon_example_package_code(
@@ -138,8 +139,6 @@ pigeon_example_package_message_codec_write_pigeon_example_package_code(
138139
return fl_standard_message_codec_write_value(codec, buffer, value, error);
139140
}
140141

141-
const int pigeon_example_package_message_data_type_id = 130;
142-
143142
static gboolean
144143
pigeon_example_package_message_codec_write_pigeon_example_package_message_data(
145144
FlStandardMessageCodec* codec, GByteArray* buffer,

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,14 @@ G_DECLARE_FINAL_TYPE(PigeonExamplePackageMessageCodec,
9595
PIGEON_EXAMPLE_PACKAGE, MESSAGE_CODEC,
9696
FlStandardMessageCodec)
9797

98+
/**
99+
* Custom type ID constants:
100+
*
101+
* Constants used to identify custom types in the codec.
102+
* They are used in the codec to encode and decode custom types.
103+
* They may be used in custom object creation functions to identify the type.
104+
*/
98105
extern const int pigeon_example_package_code_type_id;
99-
100106
extern const int pigeon_example_package_message_data_type_id;
101107

102108
G_DECLARE_FINAL_TYPE(PigeonExamplePackageExampleHostApi,

packages/pigeon/lib/src/gobject/gobject_generator.dart

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,22 @@ class GObjectHeaderGenerator
342342
final Iterable<EnumeratedType> customTypes =
343343
getEnumeratedTypes(root, excludeSealedClasses: true);
344344

345+
if (customTypes.isNotEmpty) {
346+
indent.newln();
347+
addDocumentationComments(
348+
indent,
349+
<String>[
350+
'Custom type ID constants:',
351+
'',
352+
'Constants used to identify custom types in the codec.',
353+
'They are used in the codec to encode and decode custom types.',
354+
'They may be used in custom object creation functions to identify the type.',
355+
],
356+
_docCommentSpec);
357+
}
358+
345359
for (final EnumeratedType customType in customTypes) {
346360
final String customTypeId = _getCustomTypeId(module, customType);
347-
indent.newln();
348361
indent.writeln('extern const int $customTypeId;');
349362
}
350363
}
@@ -1028,15 +1041,18 @@ class GObjectSourceGenerator
10281041
_writeDefineType(indent, module, _codecBaseName,
10291042
parentType: 'fl_standard_message_codec_get_type()');
10301043

1044+
indent.newln();
1045+
for (final EnumeratedType customType in customTypes) {
1046+
final String customTypeId = _getCustomTypeId(module, customType);
1047+
indent.writeln('const int $customTypeId = ${customType.enumeration};');
1048+
}
1049+
10311050
for (final EnumeratedType customType in customTypes) {
10321051
final String customTypeName = _getClassName(module, customType.name);
10331052
final String snakeCustomTypeName =
10341053
_snakeCaseFromCamelCase(customTypeName);
10351054
final String customTypeId = _getCustomTypeId(module, customType);
10361055

1037-
indent.newln();
1038-
indent.writeln('const int $customTypeId = ${customType.enumeration};');
1039-
10401056
indent.newln();
10411057
final String valueType = customType.type == CustomTypes.customClass
10421058
? '$customTypeName*'

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,6 +2418,14 @@ G_DEFINE_TYPE(CoreTestsPigeonTestMessageCodec,
24182418
fl_standard_message_codec_get_type())
24192419

24202420
const int core_tests_pigeon_test_an_enum_type_id = 129;
2421+
const int core_tests_pigeon_test_another_enum_type_id = 130;
2422+
const int core_tests_pigeon_test_unused_class_type_id = 131;
2423+
const int core_tests_pigeon_test_all_types_type_id = 132;
2424+
const int core_tests_pigeon_test_all_nullable_types_type_id = 133;
2425+
const int core_tests_pigeon_test_all_nullable_types_without_recursion_type_id =
2426+
134;
2427+
const int core_tests_pigeon_test_all_classes_wrapper_type_id = 135;
2428+
const int core_tests_pigeon_test_test_message_type_id = 136;
24212429

24222430
static gboolean
24232431
core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_an_enum(
@@ -2428,8 +2436,6 @@ core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_an_enum(
24282436
return fl_standard_message_codec_write_value(codec, buffer, value, error);
24292437
}
24302438

2431-
const int core_tests_pigeon_test_another_enum_type_id = 130;
2432-
24332439
static gboolean
24342440
core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_another_enum(
24352441
FlStandardMessageCodec* codec, GByteArray* buffer, FlValue* value,
@@ -2439,8 +2445,6 @@ core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_another_enum(
24392445
return fl_standard_message_codec_write_value(codec, buffer, value, error);
24402446
}
24412447

2442-
const int core_tests_pigeon_test_unused_class_type_id = 131;
2443-
24442448
static gboolean
24452449
core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_unused_class(
24462450
FlStandardMessageCodec* codec, GByteArray* buffer,
@@ -2452,8 +2456,6 @@ core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_unused_class(
24522456
return fl_standard_message_codec_write_value(codec, buffer, values, error);
24532457
}
24542458

2455-
const int core_tests_pigeon_test_all_types_type_id = 132;
2456-
24572459
static gboolean
24582460
core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_all_types(
24592461
FlStandardMessageCodec* codec, GByteArray* buffer,
@@ -2464,8 +2466,6 @@ core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_all_types(
24642466
return fl_standard_message_codec_write_value(codec, buffer, values, error);
24652467
}
24662468

2467-
const int core_tests_pigeon_test_all_nullable_types_type_id = 133;
2468-
24692469
static gboolean
24702470
core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_all_nullable_types(
24712471
FlStandardMessageCodec* codec, GByteArray* buffer,
@@ -2477,9 +2477,6 @@ core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_all_nullable_t
24772477
return fl_standard_message_codec_write_value(codec, buffer, values, error);
24782478
}
24792479

2480-
const int core_tests_pigeon_test_all_nullable_types_without_recursion_type_id =
2481-
134;
2482-
24832480
static gboolean
24842481
core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_all_nullable_types_without_recursion(
24852482
FlStandardMessageCodec* codec, GByteArray* buffer,
@@ -2494,8 +2491,6 @@ core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_all_nullable_t
24942491
return fl_standard_message_codec_write_value(codec, buffer, values, error);
24952492
}
24962493

2497-
const int core_tests_pigeon_test_all_classes_wrapper_type_id = 135;
2498-
24992494
static gboolean
25002495
core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_all_classes_wrapper(
25012496
FlStandardMessageCodec* codec, GByteArray* buffer,
@@ -2507,8 +2502,6 @@ core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_all_classes_wr
25072502
return fl_standard_message_codec_write_value(codec, buffer, values, error);
25082503
}
25092504

2510-
const int core_tests_pigeon_test_test_message_type_id = 136;
2511-
25122505
static gboolean
25132506
core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_test_message(
25142507
FlStandardMessageCodec* codec, GByteArray* buffer,

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,21 +1433,21 @@ G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestMessageCodec,
14331433
CORE_TESTS_PIGEON_TEST, MESSAGE_CODEC,
14341434
FlStandardMessageCodec)
14351435

1436+
/**
1437+
* Custom type ID constants:
1438+
*
1439+
* Constants used to identify custom types in the codec.
1440+
* They are used in the codec to encode and decode custom types.
1441+
* They may be used in custom object creation functions to identify the type.
1442+
*/
14361443
extern const int core_tests_pigeon_test_an_enum_type_id;
1437-
14381444
extern const int core_tests_pigeon_test_another_enum_type_id;
1439-
14401445
extern const int core_tests_pigeon_test_unused_class_type_id;
1441-
14421446
extern const int core_tests_pigeon_test_all_types_type_id;
1443-
14441447
extern const int core_tests_pigeon_test_all_nullable_types_type_id;
1445-
14461448
extern const int
14471449
core_tests_pigeon_test_all_nullable_types_without_recursion_type_id;
1448-
14491450
extern const int core_tests_pigeon_test_all_classes_wrapper_type_id;
1450-
14511451
extern const int core_tests_pigeon_test_test_message_type_id;
14521452

14531453
G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostIntegrationCoreApi,

0 commit comments

Comments
 (0)