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

Support @serdeEnumProxy (@serdeProxyCast) UDA #22

Merged
merged 2 commits into from
Oct 2, 2022

Conversation

WebFreak001
Copy link
Contributor

@WebFreak001
Copy link
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
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.

value = to!T(move(temporal));
static if (hasUDA!(T, serdeProxyCast))
{
static if (__traits(compiles, ()@safe{return cast(T)move(temporal);}))
Copy link
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

@@ -107,7 +107,10 @@ void serializeValue(S, V)(scope ref S serializer, scope const V value)
{
static if (hasUDA!(V, serdeProxy))
{
serializer.serializeWithProxy!(serdeGetProxy!V)(value);
static if (hasUDA!(V, serdeProxyCast))
serializeValue(serializer, cast(serdeGetProxy!V)value);
Copy link
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.

static if (hasUDA!(V, serdeProxyCast))
serializeValue(serializer, cast(serdeGetProxy!V)value);
else
serializer.serializeWithProxy!(serdeGetProxy!V)(value);
Copy link
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