-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[pigeon] Use a const for custom type ids for gobject generated files (#156100) #9306
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
base: main
Are you sure you want to change the base?
[pigeon] Use a const for custom type ids for gobject generated files (#156100) #9306
Conversation
9ef0df9
to
b660a0c
Compare
62b41ae
to
da4196c
Compare
packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.h
Outdated
Show resolved
Hide resolved
77d7394
to
3947e4e
Compare
The FLValue headers in some places use // fl_value.h:303
FlValue* fl_value_new_custom(int type, // uses int
gconstpointer value,
GDestroyNotify destroy_notify);
// fl_standard_message_codec.h:148
gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec* codec,
GByteArray* buffer, // uses GByteArray*, which is used (subclassed) in generated files:
FlValue* value,
GError** error);
// core_tests.gen.cc:2422
static gboolean
core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_an_enum(
FlStandardMessageCodec* codec, GByteArray* buffer, FlValue* value,
GError** error) {
uint8_t type = core_tests_pigeon_test_an_enum_type_id; // appends uint8_t to buffer
g_byte_array_append(buffer, &type, sizeof(uint8_t));
return fl_standard_message_codec_write_value(codec, buffer, value, error);
} I think this might be related to #152916. Maybe it is best to leave it as is, and for this PR use |
Where is the header using
|
My mistake, it's not the FlValue header that uses uint8_t, but only the generated code using the engine header. class DartGenerator extends StructuredGenerator<InternalDartOptions> {
(...)
void writeGeneralCodec() {
(...)
indent.writeln('buffer.putUint8(4);'); That makes more sense to me now. I guess that means we can keep it like it is. |
7aca7cf
to
c78a9d9
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
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.
Pr looks good, just one question and I can lgtm
c78a9d9
to
6e4d91e
Compare
|
||
final Iterable<EnumeratedType> customTypes = | ||
getEnumeratedTypes(root, excludeSealedClasses: true); | ||
|
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.
We should output an explanatory comment (if customTypes is not empty) about what the constants are (one comment for the whole block, not one per type).
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 put a comment, but it's not exactly in gdoc style as there's no direct symbol to refer to. (as the comment concerns a block of consts.)
If you don't like it, please give me a suggestion and I'll put it in.
/**
* Custom type ID constants:
*
* Constants used to identify custom types in the codec.
* They are used in the codec to encode and decode custom types.
* They may be used in custom object creation functions to identify the type.
*/
6e4d91e
to
75a101f
Compare
…(#156100) Adds a custom type identifier to generated gobject headers for the user. Calling fl_value_new_custom_object is now possible with that constant. This fixes flutter/flutter#156100 Also updated the CONTRIBUTING.md file to include the gobject generator.
75a101f
to
70c893a
Compare
If you'd like to compare, this commit contains the changes since the last review |
Adds a custom type identifier to generated gobject headers for the user. Calling fl_value_new_custom_object is now possible with that constant.
This fixes flutter/flutter#156100
Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3