Some dictionary related typesystem fixes
- Keys in a dictionary are required to be basic types - A DictionaryEntry on it's own cannot be sent over DBus, it has to be wrapped in an array to form a dictionary. So, canDBus should be false for DictionaryEntry, but true for an array of DictionaryEntry.
This commit is contained in:
parent
f477599a8f
commit
a6aa85ac74
|
@ -59,11 +59,13 @@ template canDBus(T) {
|
||||||
} else static if(isTuple!T) {
|
} else static if(isTuple!T) {
|
||||||
enum canDBus = allCanDBus!(T.Types);
|
enum canDBus = allCanDBus!(T.Types);
|
||||||
} else static if(isInputRange!T) {
|
} else static if(isInputRange!T) {
|
||||||
|
static if(is(ElementType!T == DictionaryEntry!(K, V), K, V)) {
|
||||||
|
enum canDBus = basicDBus!K && canDBus!V;
|
||||||
|
} else {
|
||||||
enum canDBus = canDBus!(ElementType!T);
|
enum canDBus = canDBus!(ElementType!T);
|
||||||
|
}
|
||||||
} else static if(isAssociativeArray!T) {
|
} else static if(isAssociativeArray!T) {
|
||||||
enum canDBus = canDBus!(KeyType!T) && canDBus!(ValueType!T);
|
enum canDBus = basicDBus!(KeyType!T) && canDBus!(ValueType!T);
|
||||||
} else static if(is(T == DictionaryEntry!(K, V), K, V)) {
|
|
||||||
enum canDBus = canDBus!K && canDBus!V;
|
|
||||||
} else {
|
} else {
|
||||||
enum canDBus = false;
|
enum canDBus = false;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +165,7 @@ unittest {
|
||||||
typeSig!(Tuple!(byte)[][]).assertEqual("aa(y)");
|
typeSig!(Tuple!(byte)[][]).assertEqual("aa(y)");
|
||||||
// dictionaries
|
// dictionaries
|
||||||
typeSig!(int[string]).assertEqual("a{si}");
|
typeSig!(int[string]).assertEqual("a{si}");
|
||||||
typeSig!(DictionaryEntry!(string, int)).assertEqual("{si}");
|
typeSig!(DictionaryEntry!(string, int)[]).assertEqual("a{si}");
|
||||||
// multiple arguments
|
// multiple arguments
|
||||||
typeSigAll!(int,bool).assertEqual("ib");
|
typeSigAll!(int,bool).assertEqual("ib");
|
||||||
// type codes
|
// type codes
|
||||||
|
|
Loading…
Reference in a new issue