Skip to content
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

Read unknown enum tag #2934

Merged
merged 1 commit into from
May 15, 2024
Merged

Read unknown enum tag #2934

merged 1 commit into from
May 15, 2024

Conversation

oldergod
Copy link
Member

@oldergod oldergod commented May 9, 2024

Continuing the work for #2725

* the method will throw an [IOException].
*/
@Throws(IOException::class)
inline fun <reified M : Message<M, B>, B : Message.Builder<M, B>, reified P : Enum<P>> Message<M, B>.unknownEnumTag(property: KProperty1<M, P?>): Int? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to do the reflection machines thing here. Create something like this:

interface UnknownEnumTagReader<M, B, P> {
  fun get(message: M): P?
}

That way we don’t have to do the KProperty reflection stuff each time we want to read a field

* found but the value attached to it isn't a varint, the method will throw an [IOException].
*/
@Throws(IOException::class)
inline fun <reified M : Message<M, B>, B : Message.Builder<M, B>, reified P : Enum<P>> Message<M, B>.unknownEnumTags(property: KProperty1<M, List<P>>): List<Int> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for repeated properties?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, repeated MyEnum my_enums = 1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanna rename it to unknownEnumValue and unknownEnumValues by the way.

@oldergod oldergod force-pushed the bquenaudon.2024-05-09.unknowntag branch 2 times, most recently from bb2a410 to 4c401cf Compare May 13, 2024 21:04
@oldergod
Copy link
Member Author

@psymoon @swankjesse I did a big revamp following a pairing Jesse and I did. Please, have a look

@oldergod oldergod force-pushed the bquenaudon.2024-05-09.unknowntag branch from 4c401cf to d8ad293 Compare May 14, 2024 13:41
@oldergod oldergod merged commit a7f930c into master May 15, 2024
11 checks passed
@oldergod oldergod deleted the bquenaudon.2024-05-09.unknowntag branch May 15, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants