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:
Harry T. Vennik 2017-06-04 17:43:19 +02:00
parent f477599a8f
commit a6aa85ac74

View file

@ -59,11 +59,13 @@ template canDBus(T) {
} else static if(isTuple!T) {
enum canDBus = allCanDBus!(T.Types);
} else static if(isInputRange!T) {
enum canDBus = canDBus!(ElementType!T);
static if(is(ElementType!T == DictionaryEntry!(K, V), K, V)) {
enum canDBus = basicDBus!K && canDBus!V;
} else {
enum canDBus = canDBus!(ElementType!T);
}
} else static if(isAssociativeArray!T) {
enum canDBus = canDBus!(KeyType!T) && canDBus!(ValueType!T);
} else static if(is(T == DictionaryEntry!(K, V), K, V)) {
enum canDBus = canDBus!K && canDBus!V;
enum canDBus = basicDBus!(KeyType!T) && canDBus!(ValueType!T);
} else {
enum canDBus = false;
}
@ -163,7 +165,7 @@ unittest {
typeSig!(Tuple!(byte)[][]).assertEqual("aa(y)");
// dictionaries
typeSig!(int[string]).assertEqual("a{si}");
typeSig!(DictionaryEntry!(string, int)).assertEqual("{si}");
typeSig!(DictionaryEntry!(string, int)[]).assertEqual("a{si}");
// multiple arguments
typeSigAll!(int,bool).assertEqual("ib");
// type codes