Skip to content

Commit

Permalink
Merge pull request #37 from Zalastax/master
Browse files Browse the repository at this point in the history
Fix import mixin to resolve issue #36
  • Loading branch information
Zalastax committed Apr 2, 2015
2 parents 33b20df + e575fd2 commit 4de0fca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions source/painlessjson/painlessjson.d
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ private T defaultFromJSONImpl(T)(in JSONValue json) if (!isBuiltinType!T && !is
mixin("const JSONValue[string] jsonAA = json.object;");
foreach (name; __traits(allMembers, T))
{

static if (__traits(compiles,{mixin("import " ~ moduleName!(__traits(getMember, t, name)) ~ ";");}))
{
mixin("import " ~ moduleName!(__traits(getMember, t, name)) ~ ";");
}

static if (__traits(compiles,
mixin(
"t." ~ name ~ "= fromJSON!(" ~ fullyQualifiedName!(typeof(__traits(getMember,
Expand All @@ -328,10 +334,6 @@ private T defaultFromJSONImpl(T)(in JSONValue json) if (!isBuiltinType!T && !is
{
enum string fromName = serializationFromName!(__traits(getMember, t,
name), name);
static if (!isBuiltinType!(typeof(__traits(getMember, t, name))))
{
mixin("import " ~ moduleName!(typeof(__traits(getMember, t, name))) ~ ";");
}
mixin(
"if ( \"" ~ fromName ~ "\" in jsonAA) t." ~ name ~ "= fromJSON!(" ~ fullyQualifiedName!(
typeof(__traits(getMember, t, name))) ~ ")(jsonAA[\"" ~ fromName ~ "\"]);");
Expand Down

0 comments on commit 4de0fca

Please sign in to comment.