aboutsummaryrefslogtreecommitdiff
path: root/src/io.zig
blob: 549711daa16718946c01a926138ee2ae19ffc482 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const std = @import("std");

pub const IOErrors = error{
    IOError,
    NotImplemented,
};

pub const Functions = struct {
    characterInput: fn () IOErrors!i64,
    decimalInput: fn () IOErrors!i64,
    characterOutput: fn (i64) IOErrors!void,
    decimalOutput: fn (i64) IOErrors!void,
};

pub const defaultFunctions = Functions{
    .characterInput = characterInput,
    .decimalInput = decimalInput,
    .characterOutput = characterOutput,
    .decimalOutput = decimalOutput,
};

fn characterInput() IOErrors!i64 {
    // TODO
    return error.NotImplemented;
}

fn decimalInput() IOErrors!i64 {
    // TODO
    return error.NotImplemented;
}

fn characterOutput(v: i64) IOErrors!void {
    std.debug.print("{c}", .{@intCast(u8, v)});
    return;
}

fn decimalOutput(v: i64) IOErrors!void {
    std.debug.print("{d}", .{v});
    return;
}

test "all" {
    std.testing.refAllDecls(@This());
}