aboutsummaryrefslogtreecommitdiff
path: root/std/os
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-12-03 20:43:56 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-12-03 20:43:56 -0500
commit0ad1239522c70418990dc7b9da4e128da7cdd1d5 (patch)
tree3a434788633db0a3d6e30f779fc1239a7513205a /std/os
parent137c8f5e8a6023db24f90555e968b592a4b843e4 (diff)
downloadzig-0ad1239522c70418990dc7b9da4e128da7cdd1d5.tar.gz
zig-0ad1239522c70418990dc7b9da4e128da7cdd1d5.zip
rework enums and unions and their relationship to each other
* @enumTagName renamed to @tagName and it works on enums and union-enums * Remove the EnumTag type. Now there is only enum and union, and the tag type of a union is always an enum. * unions support specifying the tag enum type, and they support inferring an enum tag type. * Enums no longer support field types but they do support setting the tag values. Likewise union-enums when inferring an enum tag type support setting the tag values. * It is now an error for enums and unions to have 0 fields. * switch statements support union-enums closes #618
Diffstat (limited to 'std/os')
-rw-r--r--std/os/child_process.zig10
-rw-r--r--std/os/path.zig2
2 files changed, 6 insertions, 6 deletions
diff --git a/std/os/child_process.zig b/std/os/child_process.zig
index 005d9772e4..3a4c9410c5 100644
--- a/std/os/child_process.zig
+++ b/std/os/child_process.zig
@@ -58,7 +58,7 @@ pub const ChildProcess = struct {
err_pipe: if (is_windows) void else [2]i32,
llnode: if (is_windows) void else LinkedList(&ChildProcess).Node,
- pub const Term = enum {
+ pub const Term = union(enum) {
Exited: i32,
Signal: i32,
Stopped: i32,
@@ -281,13 +281,13 @@ pub const ChildProcess = struct {
fn statusToTerm(status: i32) -> Term {
return if (posix.WIFEXITED(status)) {
- Term.Exited { posix.WEXITSTATUS(status) }
+ Term { .Exited = posix.WEXITSTATUS(status) }
} else if (posix.WIFSIGNALED(status)) {
- Term.Signal { posix.WTERMSIG(status) }
+ Term { .Signal = posix.WTERMSIG(status) }
} else if (posix.WIFSTOPPED(status)) {
- Term.Stopped { posix.WSTOPSIG(status) }
+ Term { .Stopped = posix.WSTOPSIG(status) }
} else {
- Term.Unknown { status }
+ Term { .Unknown = status }
};
}
diff --git a/std/os/path.zig b/std/os/path.zig
index a372b5b077..3fd7b5e2db 100644
--- a/std/os/path.zig
+++ b/std/os/path.zig
@@ -1016,7 +1016,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) -> %[]u8 {
return os.readLink(allocator, proc_path);
},
- else => @compileError("TODO implement os.path.real for " ++ @enumTagName(builtin.os)),
+ else => @compileError("TODO implement os.path.real for " ++ @tagName(builtin.os)),
}
}