aboutsummaryrefslogtreecommitdiff
path: root/std/std.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-13 18:15:51 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-13 18:15:51 -0700
commitb28b7f63d15ab0fdd9064c6c58e6339705edbc27 (patch)
tree8139f31b749a6838bb92d16053e371f826224d32 /std/std.zig
parentcb46d0b5b0d1d83856adab34b461049f5cfac019 (diff)
downloadzig-b28b7f63d15ab0fdd9064c6c58e6339705edbc27.tar.gz
zig-b28b7f63d15ab0fdd9064c6c58e6339705edbc27.zip
all types are now expressions
See #22
Diffstat (limited to 'std/std.zig')
-rw-r--r--std/std.zig24
1 files changed, 12 insertions, 12 deletions
diff --git a/std/std.zig b/std/std.zig
index e1b66d9cb1..667210f433 100644
--- a/std/std.zig
+++ b/std/std.zig
@@ -5,25 +5,25 @@ pub const stdout_fileno : isize = 1;
pub const stderr_fileno : isize = 2;
// TODO error handling
-pub fn os_get_random_bytes(buf: &u8, count: usize) -> isize {
+pub fn os_get_random_bytes(buf: &u8, count: usize) isize => {
getrandom(buf, count, 0)
}
// TODO error handling
// TODO handle buffering and flushing (mutex protected)
-pub fn print_str(str: []const u8) -> isize {
+pub fn print_str(str: []const u8) isize => {
fprint_str(stdout_fileno, str)
}
// TODO error handling
// TODO handle buffering and flushing (mutex protected)
-pub fn fprint_str(fd: isize, str: []const u8) -> isize {
+pub fn fprint_str(fd: isize, str: []const u8) isize => {
write(fd, str.ptr, str.len)
}
// TODO handle buffering and flushing (mutex protected)
// TODO error handling
-pub fn print_u64(x: u64) -> isize {
+pub fn print_u64(x: u64) isize => {
var buf: [max_u64_base10_digits]u8;
const len = buf_print_u64(buf, x);
return write(stdout_fileno, buf.ptr, len);
@@ -31,14 +31,14 @@ pub fn print_u64(x: u64) -> isize {
// TODO handle buffering and flushing (mutex protected)
// TODO error handling
-pub fn print_i64(x: i64) -> isize {
+pub fn print_i64(x: i64) isize => {
var buf: [max_u64_base10_digits]u8;
const len = buf_print_i64(buf, x);
return write(stdout_fileno, buf.ptr, len);
}
// TODO error handling
-pub fn readline(buf: []u8, out_len: &usize) -> bool {
+pub fn readline(buf: []u8, out_len: &usize) bool => {
const amt_read = read(stdin_fileno, buf.ptr, buf.len);
if (amt_read < 0) {
return true;
@@ -48,10 +48,10 @@ pub fn readline(buf: []u8, out_len: &usize) -> bool {
}
// TODO return ?u64 when we support returning struct byval
-pub fn parse_u64(buf: []u8, radix: u8, result: &u64) -> bool {
+pub fn parse_u64(buf: []u8, radix: u8, result: &u64) bool => {
var x : u64 = 0;
- var i : #typeof(buf.len) = 0;
+ var i : @typeof(buf.len) = 0;
while (i < buf.len) {
const c = buf[i];
const digit = char_to_digit(c);
@@ -77,7 +77,7 @@ pub fn parse_u64(buf: []u8, radix: u8, result: &u64) -> bool {
return false;
}
-fn char_to_digit(c: u8) -> u8 {
+fn char_to_digit(c: u8) u8 => {
if ('0' <= c && c <= '9') {
c - '0'
} else if ('A' <= c && c <= 'Z') {
@@ -85,13 +85,13 @@ fn char_to_digit(c: u8) -> u8 {
} else if ('a' <= c && c <= 'z') {
c - 'a' + 10
} else {
- #max_value(u8)
+ @max_value(u8)
}
}
const max_u64_base10_digits: usize = 20;
-fn buf_print_i64(out_buf: []u8, x: i64) -> usize {
+fn buf_print_i64(out_buf: []u8, x: i64) usize => {
if (x < 0) {
out_buf[0] = '-';
return 1 + buf_print_u64(out_buf[1...], ((-(x + 1)) as u64) + 1);
@@ -100,7 +100,7 @@ fn buf_print_i64(out_buf: []u8, x: i64) -> usize {
}
}
-fn buf_print_u64(out_buf: []u8, x: u64) -> usize {
+fn buf_print_u64(out_buf: []u8, x: u64) usize => {
var buf: [max_u64_base10_digits]u8;
var a = x;
var index = buf.len;