Skip to content

Commit

Permalink
update for new compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
9il committed Aug 2, 2023
1 parent fc569f2 commit 3eaf539
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 37 deletions.
2 changes: 1 addition & 1 deletion dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description "Fast, Expressive, and Easy to use Ion, JSON, YAML, CSV, and Msgpack
authors "Ilia Ki (Asdf & Mir Ion) " "Yannick Koechlin (Asdf)"
copyright "Tamedia Digital, 2016, Symmetry Investments and Kaleidic Associates, 2020, Symmetry Investments and Ilia Ki 2021-"
license "Apache-2.0"
dependency "mir-algorithm" version=">=3.20.5"
dependency "mir-algorithm" version=">=3.21.0"
dependency "mir-cpuid" version="~>1.2.6"

configuration "library" {
Expand Down
4 changes: 3 additions & 1 deletion source/mir/csv.d
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ struct CsvReader
auto scalar = readCell();
if (scalar.error)
{
import mir.exception: toMutable;
import mir.ion.exception: IonException;
static immutable exc = new IonException("mir.csv: left double quote is missing in the first row");
throw exc;
throw exc.toMutable;

}
if (this.text.length && this.text[0] == separator)
Expand Down Expand Up @@ -680,6 +681,7 @@ Slice!(CsvAlgebraic*, 2) csvToAlgebraicMatrix(
}

///
version(mir_ion_test)
unittest
{
import mir.csv;
Expand Down
40 changes: 20 additions & 20 deletions source/mir/deser/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,20 @@ template deserializeValue(string[] symbolTable, TableKind tableKind)
import mir.conv: to;
import mir.reflection: hasField;

enum likeList = hasUDA!(__traits(getMember, T, member), serdeLikeList);
enum likeStruct = hasUDA!(__traits(getMember, T, member), serdeLikeStruct);
enum hasProxy = hasUDA!(__traits(getMember, T, member), serdeProxy);
enum likeList = hasUDA!(T, member, serdeLikeList);
enum likeStruct = hasUDA!(T, member, serdeLikeStruct);
enum hasProxy = hasUDA!(T, member, serdeProxy);

alias Member = serdeDeserializationMemberType!(T, member);

static if (hasProxy)
alias Temporal = serdeGetProxy!(__traits(getMember, value, member));
alias Temporal = serdeGetProxy!(T, member);
else
alias Temporal = Member;

enum hasScoped = hasUDA!(__traits(getMember, T, member), serdeScoped) || hasScoped!Temporal;
enum hasScoped = hasUDA!(T, member, serdeScoped) || hasScoped!Temporal;

enum hasTransform = hasUDA!(__traits(getMember, T, member), serdeTransformIn);
enum hasTransform = hasUDA!(T, member, serdeTransformIn);

static if (hasTransform)
alias transform = serdeGetTransformIn!(__traits(getMember, value, member));
Expand All @@ -214,7 +214,7 @@ template deserializeValue(string[] symbolTable, TableKind tableKind)
alias impl = deserializeValue;
}

static if (!hasUDA!(__traits(getMember, T, member), serdeAllowMultiple))
static if (!hasUDA!(T, member, serdeAllowMultiple))
if (__traits(getMember, requiredFlags, member))
return unqualException(excm!(T, member));

Expand Down Expand Up @@ -1080,7 +1080,7 @@ template deserializeValue(string[] symbolTable, TableKind tableKind)
case findKey(symbolTable, key):
}

static if(hasUDA!(__traits(getMember, T, member), serdeIgnoreIfAggregate))
static if(hasUDA!(T, member, serdeIgnoreIfAggregate))
{
alias pred = serdeGetIgnoreIfAggregate!(__traits(getMember, value, member));
if (pred(value))
Expand All @@ -1090,7 +1090,7 @@ template deserializeValue(string[] symbolTable, TableKind tableKind)
}
}

static if(hasUDA!(__traits(getMember, T, member), serdeIgnoreInIfAggregate))
static if(hasUDA!(T, member, serdeIgnoreInIfAggregate))
{
alias pred = serdeGetIgnoreInIfAggregate!(__traits(getMember, value, member));
if (pred(value))
Expand All @@ -1108,16 +1108,16 @@ template deserializeValue(string[] symbolTable, TableKind tableKind)
}
}

static if (!hasUDA!(__traits(getMember, T, member), serdeOptional))
static if (!hasUDA!(T, member, serdeOptional))
{
static if(hasUDA!(__traits(getMember, T, member), serdeIgnoreIfAggregate))
static if(hasUDA!(T, member, serdeIgnoreIfAggregate))
{
alias pred = serdeGetIgnoreIfAggregate!(__traits(getMember, value, member));
if (!__traits(getMember, requiredFlags, member) && !pred(value))
return unqualException(exc!(T, member));
}
else
static if(hasUDA!(__traits(getMember, T, member), serdeIgnoreInIfAggregate))
static if(hasUDA!(T, member, serdeIgnoreInIfAggregate))
{
alias pred = serdeGetIgnoreInIfAggregate!(__traits(getMember, value, member));
if (!__traits(getMember, requiredFlags, member) && !pred(value))
Expand All @@ -1144,29 +1144,29 @@ template deserializeValue(string[] symbolTable, TableKind tableKind)
{
static foreach (member; serdeFinalProxyDeserializableMembers!T)
{{
enum keys = serdeGetKeysIn!(__traits(getMember, T, member));
enum keys = serdeGetKeysIn!(T, member);
static if (keys.length)
{
static foreach (key; keys)
{
case findKey(symbolTable, key):
}
static if(hasUDA!(__traits(getMember, T, member), serdeIgnoreInIfAggregate))
static if(hasUDA!(T, member, serdeIgnoreInIfAggregate))
{
alias pred = serdeGetIgnoreInIfAggregate!(__traits(getMember, value, member));
if (pred(value))
{
static if (hasUnexpectedKeyHandler && !hasUDA!(__traits(getMember, T, member), serdeOptional))
static if (hasUnexpectedKeyHandler && !hasUDA!(T, member, serdeOptional))
__traits(getMember, requiredFlags, member) = true;
goto default;
}
}
static if(hasUDA!(__traits(getMember, T, member), serdeIgnoreIfAggregate))
static if(hasUDA!(T, member, serdeIgnoreIfAggregate))
{
alias pred = serdeGetIgnoreIfAggregate!(__traits(getMember, value, member));
if (pred(value))
{
static if (hasUnexpectedKeyHandler && !hasUDA!(__traits(getMember, T, member), serdeOptional))
static if (hasUnexpectedKeyHandler && !hasUDA!(T, member, serdeOptional))
__traits(getMember, requiredFlags, member) = true;
goto default;
}
Expand Down Expand Up @@ -1195,16 +1195,16 @@ template deserializeValue(string[] symbolTable, TableKind tableKind)
}

static foreach (member; __traits(allMembers, SerdeFlags!T))
static if (!hasUDA!(__traits(getMember, T, member), serdeOptional))
static if (!hasUDA!(T, member, serdeOptional))
{
static if(hasUDA!(__traits(getMember, T, member), serdeIgnoreIfAggregate))
static if(hasUDA!(T, member, serdeIgnoreIfAggregate))
{
alias pred = serdeGetIgnoreIfAggregate!(__traits(getMember, value, member));
if (!__traits(getMember, requiredFlags, member) && !pred(value))
return unqualException(exc!(T, member));
}
else
static if(hasUDA!(__traits(getMember, T, member), serdeIgnoreInIfAggregate))
static if(hasUDA!(T, member, serdeIgnoreInIfAggregate))
{
alias pred = serdeGetIgnoreInIfAggregate!(__traits(getMember, value, member));
if (!__traits(getMember, requiredFlags, member) && !pred(value))
Expand Down
5 changes: 3 additions & 2 deletions source/mir/deser/text/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import mir.ion.internal.data_holder;
import mir.ion.internal.stage3 : IonErrorInfo;
import mir.bignum.integer;
import std.traits : hasUDA, getUDAs;
import mir.exception: toMutable;

private mixin template Stack(T, size_t maxDepth = 1024)
{
Expand All @@ -44,7 +45,7 @@ private mixin template Stack(T, size_t maxDepth = 1024)
{
if (stackLength + 1 > maxDepth) {
version(D_Exceptions)
throw maxDepthException;
throw maxDepthException.toMutable;
else
assert(0, maxDepthReachedMsg);
}
Expand All @@ -55,7 +56,7 @@ private mixin template Stack(T, size_t maxDepth = 1024)
{
if (stackLength <= 0) {
version (D_Exceptions)
throw cannotPopNoElementsException;
throw cannotPopNoElementsException.toMutable;
else
assert(0, cannotPopNoElementsMsg);
}
Expand Down
3 changes: 2 additions & 1 deletion source/mir/ion/examples.d
Original file line number Diff line number Diff line change
Expand Up @@ -1507,13 +1507,14 @@ version(mir_ion_test) unittest
/// Series de/serialization
@safe version(mir_ion_test) unittest
{
import mir.test;
import mir.deser.text;
import mir.ser.text;
import mir.series;
auto s = ["a", "b"].series([5, 6]);
auto t = `{index:["a","b"],data:[5,6]}`;
auto r = `{index:["b","a"],data:[6,5]}`;
assert(s.serializeText == t);
s.serializeText.should == t;
assert(r.deserializeText!(typeof(s)) == s, r.deserializeText!(typeof(s)).serializeText);
}

Expand Down
3 changes: 2 additions & 1 deletion source/mir/ion/internal/data_holder.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ version(D_Exceptions)
private static void* validatePtr()(return void* ptr)
@safe pure @nogc
{
import mir.exception: toMutable;
import mir.utility: _expect;
if (_expect(ptr is null, false))
{
version(D_Exceptions)
throw memoryOverflowException;
throw memoryOverflowException.toMutable;
else
assert(0, memoryOverflowMessage);
}
Expand Down
3 changes: 2 additions & 1 deletion source/mir/ser/json.d
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,13 @@ scope:
///
void putAnnotation(scope const(char)[] annotation)
{
import mir.exception: toMutable;
if (_annotation)
{
static if (hasDIP1008)
throw new IonMirException(jsonAnnotationExceptionMsg, " The second annotation is '", annotation, "'");
else
throw jsonAnnotationException;
throw jsonAnnotationException.toMutable;
}
_annotation = true;
putKey(annotation);
Expand Down
13 changes: 7 additions & 6 deletions source/mir/ser/msgpack.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import mir.ion.exception: IonException;
import mir.serde: SerdeTarget;

version(D_Exceptions) {
import mir.exception: toMutable;
private static immutable bigIntConvException = new IonException("Overflow when converting BigInt");
private static immutable msgpackAnnotationException = new IonException("MsgPack can store exactly one annotation.");
private static immutable stringTooLargeException = new IonException("Too large of a string for MessagePack");
Expand Down Expand Up @@ -207,7 +208,7 @@ scope:
else
{
version(D_Exceptions)
throw mapTooLargeException;
throw mapTooLargeException.toMutable;
else
assert(0, "Too large of a map for MessagePack");
}
Expand All @@ -232,7 +233,7 @@ scope:
else
{
version(D_Exceptions)
throw arrayTooLargeException;
throw arrayTooLargeException.toMutable;
else
assert(0, "Too large of an array for MessagePack");
}
Expand Down Expand Up @@ -305,7 +306,7 @@ scope:
void putAnnotation(scope const(char)[] annotation)
{
if (_annotation)
throw msgpackAnnotationException;
throw msgpackAnnotationException.toMutable;
_annotation = true;
putKey(annotation);
}
Expand Down Expand Up @@ -451,7 +452,7 @@ scope:
{
auto res = cast(long)num;
if (res != num)
throw bigIntConvException;
throw bigIntConvException.toMutable;
putValue(res);
}

Expand Down Expand Up @@ -504,7 +505,7 @@ scope:
else
{
version(D_Exceptions)
throw stringTooLargeException;
throw stringTooLargeException.toMutable;
else
assert(0, "Too large of a string for MessagePack");
}
Expand Down Expand Up @@ -539,7 +540,7 @@ scope:
else
{
version(D_Exceptions)
throw blobTooLargeException;
throw blobTooLargeException.toMutable;
else
assert(0, "Too big of a blob for MessagePack");
}
Expand Down
7 changes: 4 additions & 3 deletions source/mir/ser/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import mir.reflection;
import std.meta;
import std.traits;
import mir.internal.meta: hasUDA, getUDAs;
import mir.exception: toMutable;

public import mir.serde;

Expand All @@ -25,23 +26,23 @@ version (D_Exceptions)
private noreturn serializeVoidHandler() @safe pure @nogc
{
version (D_Exceptions)
throw cannotSerializeVoid;
throw cannotSerializeVoid.toMutable;
else
assert(0, cannotSerializeVoidMsg);
}

private noreturn serializeVoidHandlerWithSerializer(S)(scope ref S serializer) @safe pure @nogc
{
version (D_Exceptions)
throw cannotSerializeVoid;
throw cannotSerializeVoid.toMutable;
else
assert(0, cannotSerializeVoidMsg);
}

private noreturn serializeVoidHandlerWithSerializerAndState(S)(scope ref S serializer, size_t state) @safe pure @nogc
{
version (D_Exceptions)
throw cannotSerializeVoid;
throw cannotSerializeVoid.toMutable;
else
assert(0, cannotSerializeVoidMsg);
}
Expand Down
3 changes: 2 additions & 1 deletion source/mir/utf.d
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ dchar decodeFront(scope ref inout(char)[] str) @safe pure @nogc @property
{
return ret;
}
throw utfException;
import mir.exception: toMutable;
throw utfException.toMutable;
}

///
Expand Down

0 comments on commit 3eaf539

Please sign in to comment.