Attempt at fixing enum type lookups (anything not implicitly in scope of mixin such as built-in types)

This commit is contained in:
Tristan B. Velloza Kildaire 2023-01-06 16:38:34 +02:00
parent 2f5710fafb
commit b10c7d928d
2 changed files with 91 additions and 88 deletions

View File

@ -3,8 +3,10 @@ module libpb.deserialization;
import std.json;
import std.traits : FieldTypeTuple, FieldNameTuple;
public RecordType fromJSON(RecordType)(JSONValue jsonIn)
template T(RecordType)
{
public RecordType fromJSON(JSONValue jsonIn)
{
RecordType record;
// Alias as to only expand later when used in compile-time
@ -102,6 +104,7 @@ public RecordType fromJSON(RecordType)(JSONValue jsonIn)
}
return record;
}
}
unittest
@ -128,7 +131,7 @@ unittest
}
`);
Person person = fromJSON!(Person)(json);
Person person = T!(Person).fromJSON(json);
debug(dbg)
{

View File

@ -158,7 +158,7 @@ public class PocketBase
}
}
recordsOut ~= fromJSON!(RecordType)(returnedItem);
recordsOut ~= T!(RecordType).fromJSON(returnedItem);
}
return recordsOut;
@ -268,7 +268,7 @@ public class PocketBase
responseJSON["passwordConfirm"] = "";
}
recordOut = fromJSON!(RecordType)(responseJSON);
recordOut = T!(RecordType).fromJSON(responseJSON);
return recordOut;
}
@ -349,7 +349,7 @@ public class PocketBase
}
recordOut = fromJSON!(RecordType)(recordResponse);
recordOut = T!(RecordType).fromJSON(recordResponse);
// Store the token
token = responseJSON["token"].str();
@ -448,7 +448,7 @@ public class PocketBase
}
}
recordOut = fromJSON!(RecordType)(responseJSON);
recordOut = T!(RecordType).fromJSON(responseJSON);
return recordOut;
}
@ -553,7 +553,7 @@ public class PocketBase
}
}
recordOut = fromJSON!(RecordType)(responseJSON);
recordOut = T!(RecordType).fromJSON(responseJSON);
return recordOut;
}