Skip to content

Support @serdeEnumProxy (@serdeProxyCast) UDA#22

Merged
9il merged 2 commits intolibmir:masterfrom
WebFreak001:add-serdeEnumProxy-uda
Oct 2, 2022
Merged

Support @serdeEnumProxy (@serdeProxyCast) UDA#22
9il merged 2 commits intolibmir:masterfrom
WebFreak001:add-serdeEnumProxy-uda

Conversation

@WebFreak001
Copy link
Copy Markdown
Contributor

@WebFreak001
Copy link
Copy Markdown
Contributor Author

marking as draft to explore different PR right now

WebFreak001 added a commit to WebFreak001/mir-ion that referenced this pull request Jun 24, 2022
support e.g. deserializing int to Variant!(void, ProxiedInt)

Side-effect: this allows us to easily implement serdeProxyCast, which is
done here and supersedes the PR libmir#22
WebFreak001 added a commit to WebFreak001/mir-ion that referenced this pull request Jun 24, 2022
support e.g. deserializing int to Variant!(void, ProxiedInt)

Side-effect: this allows us to easily implement serdeProxyCast, which is
done here and supersedes the PR libmir#22
@WebFreak001 WebFreak001 force-pushed the add-serdeEnumProxy-uda branch from 173d595 to 8e3ffe5 Compare September 26, 2022 10:48
@WebFreak001 WebFreak001 marked this pull request as ready for review September 26, 2022 10:49
@WebFreak001
Copy link
Copy Markdown
Contributor Author

not sure if integration test failures are related, the code changes here are entirely compile-time opt-in by annotating enums with an UDA.

Some DMD tests need restarting because of download failure.

Comment thread source/mir/deser/package.d Outdated
value = to!T(move(temporal));
static if (hasUDA!(T, serdeProxyCast))
{
static if (__traits(compiles, ()@safe{return cast(T)move(temporal);}))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cast(T)move ( ... <- move is useless when cast. Please remove

Comment thread source/mir/ser/package.d Outdated
{
serializer.serializeWithProxy!(serdeGetProxy!V)(value);
static if (hasUDA!(V, serdeProxyCast))
serializeValue(serializer, cast(serdeGetProxy!V)value);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The cast may return by value. serializeValue may want a reference.

Comment thread source/mir/ser/package.d Outdated
static if (hasUDA!(V, serdeProxyCast))
serializeValue(serializer, cast(serdeGetProxy!V)value);
else
serializer.serializeWithProxy!(serdeGetProxy!V)(value);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

serializeWithProxy has to be updated instead with all its calls and test for them. Please add tests for those cases too.

@9il 9il merged commit 19f1222 into libmir:master Oct 2, 2022
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.

2 participants