Merge pull request #50 from quickfur/issue49
Replace 'byte' with 'ubyte', aligns with DBus spec
This commit is contained in:
commit
f988709b7a
|
@ -450,7 +450,7 @@ unittest {
|
||||||
z = 4
|
z = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
alias V = Algebraic!(byte, short, int, long, string);
|
alias V = Algebraic!(ubyte, short, int, long, string);
|
||||||
|
|
||||||
Message msg = Message(busName("org.example.wow"), ObjectPath("/wut"), interfaceName("org.test.iface"), "meth2");
|
Message msg = Message(busName("org.example.wow"), ObjectPath("/wut"), interfaceName("org.test.iface"), "meth2");
|
||||||
V v1 = "hello from variant";
|
V v1 = "hello from variant";
|
||||||
|
|
|
@ -275,7 +275,7 @@ unittest {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct S {
|
struct S {
|
||||||
byte b;
|
ubyte b;
|
||||||
ulong ul;
|
ulong ul;
|
||||||
F f;
|
F f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,7 +222,7 @@ struct DBusAny {
|
||||||
|
|
||||||
union {
|
union {
|
||||||
///
|
///
|
||||||
byte int8;
|
ubyte uint8;
|
||||||
///
|
///
|
||||||
short int16;
|
short int16;
|
||||||
///
|
///
|
||||||
|
@ -273,8 +273,8 @@ struct DBusAny {
|
||||||
+/
|
+/
|
||||||
this(T)(T value) {
|
this(T)(T value) {
|
||||||
static if (is(T == byte) || is(T == ubyte)) {
|
static if (is(T == byte) || is(T == ubyte)) {
|
||||||
this(typeCode!byte, null, false);
|
this(typeCode!ubyte, null, false);
|
||||||
int8 = cast(byte) value;
|
uint8 = cast(ubyte) value;
|
||||||
} else static if (is(T == short)) {
|
} else static if (is(T == short)) {
|
||||||
this(typeCode!short, null, false);
|
this(typeCode!short, null, false);
|
||||||
int16 = cast(short) value;
|
int16 = cast(short) value;
|
||||||
|
@ -410,8 +410,8 @@ struct DBusAny {
|
||||||
string toString() const {
|
string toString() const {
|
||||||
string valueStr;
|
string valueStr;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case typeCode!byte:
|
case typeCode!ubyte:
|
||||||
valueStr = int8.to!string;
|
valueStr = uint8.to!string;
|
||||||
break;
|
break;
|
||||||
case typeCode!short:
|
case typeCode!short:
|
||||||
valueStr = int16.to!string;
|
valueStr = int16.to!string;
|
||||||
|
@ -712,7 +712,7 @@ unittest {
|
||||||
b.toString();
|
b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
test(cast(ubyte) 184, set!"int8"(DBusAny('y', null, false), cast(byte) 184));
|
test(cast(ubyte) 184, set!"uint8"(DBusAny('y', null, false), cast(ubyte) 184));
|
||||||
test(cast(short) 184, set!"int16"(DBusAny('n', null, false), cast(short) 184));
|
test(cast(short) 184, set!"int16"(DBusAny('n', null, false), cast(short) 184));
|
||||||
test(cast(ushort) 184, set!"uint16"(DBusAny('q', null, false), cast(ushort) 184));
|
test(cast(ushort) 184, set!"uint16"(DBusAny('q', null, false), cast(ushort) 184));
|
||||||
test(cast(int) 184, set!"int32"(DBusAny('i', null, false), cast(int) 184));
|
test(cast(int) 184, set!"int32"(DBusAny('i', null, false), cast(int) 184));
|
||||||
|
@ -726,7 +726,7 @@ unittest {
|
||||||
test(cast(ubyte[])[1, 2, 3], set!"binaryData"(DBusAny('a', ['y'], false),
|
test(cast(ubyte[])[1, 2, 3], set!"binaryData"(DBusAny('a', ['y'], false),
|
||||||
cast(ubyte[])[1, 2, 3]));
|
cast(ubyte[])[1, 2, 3]));
|
||||||
|
|
||||||
test(variant(cast(ubyte) 184), set!"int8"(DBusAny('y', null, true), cast(byte) 184));
|
test(variant(cast(ubyte) 184), set!"uint8"(DBusAny('y', null, true), cast(ubyte) 184));
|
||||||
test(variant(cast(short) 184), set!"int16"(DBusAny('n', null, true), cast(short) 184));
|
test(variant(cast(short) 184), set!"int16"(DBusAny('n', null, true), cast(short) 184));
|
||||||
test(variant(cast(ushort) 184), set!"uint16"(DBusAny('q', null, true), cast(ushort) 184));
|
test(variant(cast(ushort) 184), set!"uint16"(DBusAny('q', null, true), cast(ushort) 184));
|
||||||
test(variant(cast(int) 184), set!"int32"(DBusAny('i', null, true), cast(int) 184));
|
test(variant(cast(int) 184), set!"int32"(DBusAny('i', null, true), cast(int) 184));
|
||||||
|
|
|
@ -54,7 +54,7 @@ template allCanDBus(TS...) {
|
||||||
AliasSeq of all basic types in terms of the DBus typesystem
|
AliasSeq of all basic types in terms of the DBus typesystem
|
||||||
+/
|
+/
|
||||||
package // Don't add to the API yet, 'cause I intend to move it later
|
package // Don't add to the API yet, 'cause I intend to move it later
|
||||||
alias BasicTypes = AliasSeq!(bool, byte, short, ushort, int, uint, long, ulong,
|
alias BasicTypes = AliasSeq!(bool, ubyte, short, ushort, int, uint, long, ulong,
|
||||||
double, string, ObjectPath, InterfaceName, BusName);
|
double, string, ObjectPath, InterfaceName, BusName);
|
||||||
|
|
||||||
template basicDBus(T) {
|
template basicDBus(T) {
|
||||||
|
@ -108,7 +108,7 @@ unittest {
|
||||||
|
|
||||||
string typeSig(T)()
|
string typeSig(T)()
|
||||||
if (canDBus!T) {
|
if (canDBus!T) {
|
||||||
static if (is(T == byte)) {
|
static if (is(T == ubyte)) {
|
||||||
return "y";
|
return "y";
|
||||||
} else static if (is(T == bool)) {
|
} else static if (is(T == bool)) {
|
||||||
return "b";
|
return "b";
|
||||||
|
@ -218,13 +218,13 @@ unittest {
|
||||||
typeSig!string().assertEqual("s");
|
typeSig!string().assertEqual("s");
|
||||||
typeSig!(Variant!int)().assertEqual("v");
|
typeSig!(Variant!int)().assertEqual("v");
|
||||||
// enums
|
// enums
|
||||||
enum E : byte {
|
enum E : ubyte {
|
||||||
a,
|
a,
|
||||||
b,
|
b,
|
||||||
c
|
c
|
||||||
}
|
}
|
||||||
|
|
||||||
typeSig!E().assertEqual(typeSig!byte());
|
typeSig!E().assertEqual(typeSig!ubyte());
|
||||||
enum U : string {
|
enum U : string {
|
||||||
One = "One",
|
One = "One",
|
||||||
Two = "Two"
|
Two = "Two"
|
||||||
|
@ -262,7 +262,7 @@ unittest {
|
||||||
// arrays
|
// arrays
|
||||||
typeSig!(int[]).assertEqual("ai");
|
typeSig!(int[]).assertEqual("ai");
|
||||||
typeSig!(Variant!int[]).assertEqual("av");
|
typeSig!(Variant!int[]).assertEqual("av");
|
||||||
typeSig!(Tuple!(byte)[][]).assertEqual("aa(y)");
|
typeSig!(Tuple!(ubyte)[][]).assertEqual("aa(y)");
|
||||||
// dictionaries
|
// dictionaries
|
||||||
typeSig!(int[string]).assertEqual("a{si}");
|
typeSig!(int[string]).assertEqual("a{si}");
|
||||||
typeSig!(DictionaryEntry!(string, int)[]).assertEqual("a{si}");
|
typeSig!(DictionaryEntry!(string, int)[]).assertEqual("a{si}");
|
||||||
|
|
Loading…
Reference in a new issue