-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
fa8175f
to
173d595
Compare
marking as draft to explore different PR right now |
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
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
173d595
to
8e3ffe5
Compare
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. |
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);})) |
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.
cast(T)move ( ...
<- move
is useless when cast. Please remove
source/mir/ser/package.d
Outdated
@@ -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); |
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.
The cast may return by value. serializeValue
may want a reference.
source/mir/ser/package.d
Outdated
static if (hasUDA!(V, serdeProxyCast)) | ||
serializeValue(serializer, cast(serdeGetProxy!V)value); | ||
else | ||
serializer.serializeWithProxy!(serdeGetProxy!V)(value); |
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.
serializeWithProxy
has to be updated instead with all its calls and test for them. Please add tests for those cases too.
depends on libmir/mir-algorithm#408