-
Notifications
You must be signed in to change notification settings - Fork 570
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
Read unknown enum tag #2934
Conversation
* 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? { |
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 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> { |
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.
This is for repeated properties?
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.
Yes, repeated MyEnum my_enums = 1
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 wanna rename it to unknownEnumValue
and unknownEnumValues
by the way.
bb2a410
to
4c401cf
Compare
@psymoon @swankjesse I did a big revamp following a pairing Jesse and I did. Please, have a look |
4c401cf
to
d8ad293
Compare
Continuing the work for #2725