aboutsummaryrefslogtreecommitdiff
path: root/src/io.zig
diff options
context:
space:
mode:
authorJulien Dessaux2022-06-12 21:47:52 +0200
committerJulien Dessaux2022-06-12 21:47:52 +0200
commitf7a5e4f52c529a74ca0e4ec5a269c4d594990802 (patch)
treee15a2d8c22aae7efba67904048a121aa1e8cc7e3 /src/io.zig
parentImplemented basic cli (diff)
downloadzigfunge98-f7a5e4f52c529a74ca0e4ec5a269c4d594990802.tar.gz
zigfunge98-f7a5e4f52c529a74ca0e4ec5a269c4d594990802.tar.bz2
zigfunge98-f7a5e4f52c529a74ca0e4ec5a269c4d594990802.zip
Refactored io functions handling
Diffstat (limited to '')
-rw-r--r--src/io.zig44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/io.zig b/src/io.zig
new file mode 100644
index 0000000..549711d
--- /dev/null
+++ b/src/io.zig
@@ -0,0 +1,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());
+}