Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
use hasUDA from 2.068.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
sigod committed Aug 25, 2015
1 parent dfea4ea commit 7c5a05c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions source/gcm.d
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ template isISOExtStringSerializable(T)
is(typeof(T.init.toISOExtString()) == string) && is(typeof(T.fromISOExtString("")) == T);
}

static if (__VERSION__ < 2068) {
//TODO: remove in future versions of compiler
template hasUDA(alias symbol, alias attribute)
{
import std.typetuple : staticIndexOf;

enum bool hasUDA = staticIndexOf!(attribute, __traits(getAttributes, symbol)) != -1;
}
}
else {
import std.traits : hasUDA;
}

//TODO: support classes
JSONValue convert(T)(T value)
{
Expand Down Expand Up @@ -277,10 +290,7 @@ JSONValue convert(T)(T value)
else
static assert(false, FieldN.stringof ~ " not supported");

//TODO: use hasUDA from 2.068
static if (__traits(getAttributes, __traits(getMember, value, field_name)).length > 0
&& __traits(isSame, __traits(getAttributes, __traits(getMember, value, field_name))[0], asString))
{
static if (hasUDA!(Field, asString)) {
json = JSONValue(json.toString());
}

Expand Down

0 comments on commit 7c5a05c

Please sign in to comment.