Also use get in array conversion

This commit is contained in:
Harry T. Vennik 2017-12-09 16:33:44 +01:00
parent 238db94916
commit 0841ac69de

View file

@ -532,32 +532,22 @@ struct DBusAny {
alias E = Unqual!(ElementType!T); alias E = Unqual!(ElementType!T);
if (typeSig == "ay") { if (typeSig == "ay") {
auto data = get!(const(ubyte)[]);
static if (is(E == ubyte) || is(E == byte)) { static if (is(E == ubyte) || is(E == byte)) {
return cast(T) binaryData.dup; return cast(T) data.dup;
} else { } else {
T ret; return cast(T) data.map!(elem => elem.to!E).array;
ret.length = binaryData.length;
foreach (i, b; binaryData)
ret[i] = b;
return ret;
} }
} else if (type == 'a' || (type == 'r' && is(E == DBusAny))) { } else if (type == 'a' || (type == 'r' && is(E == DBusAny))) {
E[] ret; return cast(T) get!(const(DBusAny)[]).map!(elem => elem.to!E).array;
ret.length = array.length;
foreach (i, elem; array)
ret[i] = elem.to!(ElementType!T);
return cast(T) ret;
} }
} else static if (isTuple!T) { } else static if (isTuple!T) {
if (type == 'r') { if (type == 'r') {
T ret; T ret;
foreach (i, T; ret.Types) foreach (i, T; ret.Types) {
ret[i] = tuple[i].to!T; ret[i] = tuple[i].to!T;
}
return ret; return ret;
} }