From 6c6f9f7d25c2c4fd6af95dd2bbe91eb597fe1830 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 26 Jun 2023 15:55:35 +0100 Subject: [PATCH] Fix fmt implementation for `js` --- core/fmt/fmt_js.odin | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/core/fmt/fmt_js.odin b/core/fmt/fmt_js.odin index 5e06041f5..881cde867 100644 --- a/core/fmt/fmt_js.odin +++ b/core/fmt/fmt_js.odin @@ -11,27 +11,24 @@ foreign odin_env { } @(private="file") -write_vtable := io.Stream_VTable{ - impl_write = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - fd := u32(uintptr(s.stream_data)) +write_stream_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + if mode == .Write { + fd := u32(uintptr(stream_data)) write(fd, p) - return len(p), nil - }, + return i64(len(p)), nil + } + return 0, .Empty } @(private="file") stdout := io.Writer{ - stream = { - stream_vtable = &write_vtable, - stream_data = rawptr(uintptr(1)), - }, + procedure = write_stream_proc, + data = rawptr(uintptr(1)), } @(private="file") stderr := io.Writer{ - stream = { - stream_vtable = &write_vtable, - stream_data = rawptr(uintptr(2)), - }, + procedure = write_stream_proc, + data = rawptr(uintptr(2)), } // print formats using the default print settings and writes to stdout