DBus variant File descriptor storage more explicit

Also added constants for the stdin, stdout, stderr filenos
This commit is contained in:
Chris Josten 2021-01-22 01:27:40 +01:00
parent 95a29d0578
commit 168bc0eb81

View file

@ -177,8 +177,10 @@ InterfaceName interfaceName(string path) pure @nogc nothrow @safe {
/// Serving as a typesafe alias for a FileDescriptor. /// Serving as a typesafe alias for a FileDescriptor.
enum FileDescriptor : int { enum FileDescriptor : int {
none = -1, none = -1,
max = int.max stdin = 0,
stdout = 1,
stderr = 2
} }
/// Casts an integer to a FileDescriptor. /// Casts an integer to a FileDescriptor.
@ -266,6 +268,7 @@ struct DBusAny {
DictionaryEntry!(DBusAny, DBusAny)* entry; DictionaryEntry!(DBusAny, DBusAny)* entry;
/// ///
ubyte[] binaryData; ubyte[] binaryData;
FileDescriptor fd;
} }
/++ /++
@ -301,7 +304,7 @@ struct DBusAny {
int32 = cast(int) value; int32 = cast(int) value;
} else static if (is(T == FileDescriptor)) { } else static if (is(T == FileDescriptor)) {
this(typeCode!FileDescriptor, null, false); this(typeCode!FileDescriptor, null, false);
int32 = cast(int) value; fd = cast(FileDescriptor) value;
} else static if (is(T == uint)) { } else static if (is(T == uint)) {
this(typeCode!uint, null, false); this(typeCode!uint, null, false);
uint32 = cast(uint) value; uint32 = cast(uint) value;
@ -511,7 +514,7 @@ struct DBusAny {
typeCode!T, type)); typeCode!T, type));
static if (is(T == FileDescriptor)) { static if (is(T == FileDescriptor)) {
return fileDescriptor(int32); return cast(U) fd;
} else static if (isIntegral!T) { } else static if (isIntegral!T) {
enum memberName = (isUnsigned!T ? "uint" : "int") ~ (T.sizeof * 8).to!string; enum memberName = (isUnsigned!T ? "uint" : "int") ~ (T.sizeof * 8).to!string;
return cast(U) __traits(getMember, this, memberName); return cast(U) __traits(getMember, this, memberName);