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

Add wrapper types for map keys and values #73

Merged
merged 11 commits into from
Jun 21, 2020

Conversation

andrewparmet
Copy link
Collaborator

@andrewparmet andrewparmet commented Jun 19, 2020

This revealed that it seems to be a cleaner interface to Wrapper.kt to expose the converter as a nullable type than to try to pass through and replace field accesses. I'll probably revisit the existing wrapper type code and see if that cleans things up a bit, since it's not pretty.

Fixes #26.

@andrewparmet andrewparmet requested a review from ogolberg June 19, 2020 15:57
@andrewparmet andrewparmet changed the title Add wrapper types for map keys Add wrapper types for map keys and values Jun 19, 2020
@@ -127,7 +127,7 @@ private constructor(
<companion()>
<if (nested)>

<nested><\\>
<nested:{n | <n>}; separator="\n"><\\>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

formatting cleanup

@@ -62,6 +62,6 @@ deserializeVar(p) ::= <%

orDefault(p) ::= <%
<if (isMessage.(p.messageType))>
?: <value.propertyType> {}
<\ >?: <value.propertyType> {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

formatting cleanup

@@ -44,7 +44,7 @@ companion object Deserializer : KtDeserializer\<<name>\> {

while (true) {
when (deserializer.readTag()) {
0 -> return <name>(key, value <orDefault(value)>)
0 -> return <name>(key, value<orDefault(value)>)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

formatting cleanup

Comment on lines -36 to +37
<deserialize:{d | <d.tag> -> <d.assignment.fieldName> = <\\>
<if ((!d.std || d.repeated || d.assignment.long))><\n><t()><endif><\\>
<deserialize:{d | <d.tag> -> <d.assignment.fieldName> =<\\>
<if ((!d.std || d.repeated || d.assignment.long))><\n><t()><else><\ ><endif><\\>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

formatting cleanup

.fold(
{ null },
{
resolveMapEntry(
Copy link
Collaborator Author

@andrewparmet andrewparmet Jun 19, 2020

Choose a reason for hiding this comment

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

Instead of duplicating this search once annotating, convert it to a message here and extract the fields for later use.

@@ -169,24 +200,40 @@ serializer.write(Tag(<tag>)).write(<box>)<\\>
<endif>
>>

deserialize(field, read, lhs, options, packed) ::= <<
Copy link
Collaborator Author

@andrewparmet andrewparmet Jun 19, 2020

Choose a reason for hiding this comment

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

This and the others in this file: removed meaningful whitespace in favor of easier-to-read branch logic, and extracted Map variants.

@andrewparmet andrewparmet merged commit 0215f0a into open-toast:master Jun 21, 2020
@andrewparmet andrewparmet deleted the map-wrap-keys branch June 21, 2020 05:42
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.

Wrapper types for map keys and values
2 participants